From: Jan Beulich Date: Fri, 19 Nov 2021 08:41:41 +0000 (+0100) Subject: x86/APIC: avoid iommu_supports_x2apic() on error path X-Git-Tag: RELEASE-4.14.4~28 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=006897dd720fb723cda0926aaccd12cee91fba86;p=xen.git x86/APIC: avoid iommu_supports_x2apic() on error path The value it returns may change from true to false in case iommu_enable_x2apic() fails and, as a side effect, clears iommu_intremap (as can happen at least on AMD). Latch the return value from the first invocation to replace the second one. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné master commit: 0f50d1696b3c13cbf0b18fec817fc291d5a30a31 master date: 2021-11-04 14:44:43 +0100 --- diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index 4a2740ccea..789af8c4da 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -864,6 +864,7 @@ void x2apic_ap_setup(void) void __init x2apic_bsp_setup(void) { struct IO_APIC_route_entry **ioapic_entries = NULL; + bool iommu_x2apic; const char *orig_name; if ( !cpu_has_x2apic ) @@ -879,7 +880,8 @@ void __init x2apic_bsp_setup(void) printk("x2APIC: Already enabled by BIOS: Ignoring cmdline disable.\n"); } - if ( iommu_supports_x2apic() ) + iommu_x2apic = iommu_supports_x2apic(); + if ( iommu_x2apic ) { if ( (ioapic_entries = alloc_ioapic_entries()) == NULL ) { @@ -932,8 +934,11 @@ void __init x2apic_bsp_setup(void) printk("Switched to APIC driver %s\n", genapic.name); restore_out: - /* iommu_x2apic_enabled cannot be used here in the error case. */ - if ( iommu_supports_x2apic() ) + /* + * iommu_x2apic_enabled and iommu_supports_x2apic() cannot be used here + * in the error case. + */ + if ( iommu_x2apic ) { /* * NB: do not use raw mode when restoring entries if the iommu has