On Mon, May 12, 2025 at 09:36:51AM +0530, Sairaj Kodilkar wrote:
> From: Vasant Hegde <vasant.he...@amd.com>

A bit of history is missing here. Something like:


Before commit 8c6619f3e692 ("hw/i386/amd_iommu: Simplify non-KVM checks
on XTSup feature") amd_iommu.c used to call kvm_enable_x2apic() when
xtsup is on, to support x2apic mode.


> 
> If vCPUs > 255 then x86 common code (x86_cpus_init()) call 
> kvm_enable_x2apic().

calls

> But if vCPUs <= 255 then it won't call kvm_enable_x2apic().

it -> the common code

> Booting guest in x2apic mode, amd-iommu,xtsup=on and <= 255 vCPUs is
> broken as it fails to call kvm_enable_x2apic().

You mean
 "is now broken as kvm_enable_x2apic() is required for x2apic to work".



> Fix this by adding back kvm_enable_x2apic() call when xtsup=on.
> 
> Fixes: 8c6619f3e692 ("hw/i386/amd_iommu: Simplify non-KVM checks on XTSup 
> feature")
> Reported-by: Alejandro Jimenez <alejandro.j.jime...@oracle.com>
> Cc: Philippe Mathieu-Daudé <phi...@linaro.org>
> Cc: Joao Martins <joao.m.mart...@oracle.com>
> Signed-off-by: Vasant Hegde <vasant.he...@amd.com>
> Reviewed-by: Joao Martins <joao.m.mart...@oracle.com>
> ---
>  hw/i386/amd_iommu.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
> index df8ba5d39ada..af85706b8a0d 100644
> --- a/hw/i386/amd_iommu.c
> +++ b/hw/i386/amd_iommu.c
> @@ -1649,6 +1649,14 @@ static void amdvi_sysbus_realize(DeviceState *dev, 
> Error **errp)
>          exit(EXIT_FAILURE);
>      }
>  
> +    if (s->xtsup) {
> +        if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) {
> +            error_report("AMD IOMMU xtsup=on requires x2APIC support on "
> +                          "the KVM side");
> +            exit(EXIT_FAILURE);
> +        }
> +    }
> +
>      pci_setup_iommu(bus, &amdvi_iommu_ops, s);
>      amdvi_init(s);
>  }
> -- 
> 2.34.1


Reply via email to