Skip to content

Commit

Permalink
x86/APIC: avoid iommu_supports_x2apic() on error path
Browse files Browse the repository at this point in the history
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 <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
  • Loading branch information
jbeulich committed Nov 4, 2021
1 parent 46c4061 commit 0f50d16
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions xen/arch/x86/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,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 )
Expand All @@ -880,7 +881,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 )
{
Expand Down Expand Up @@ -933,8 +935,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
Expand Down

0 comments on commit 0f50d16

Please sign in to comment.