Skip to content

Commit

Permalink
x86/apic: Split register_apic_address()
Browse files Browse the repository at this point in the history
Split the fixmap setup out of register_lapic_address() and reuse it when
the X2APIC is disabled during setup.

This avoids registering the APIC ID (setting 'mp_lapic_addr') twice.

[ dhansen: changelog wording tweak ]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Tested-by: Juergen Gross <jgross@suse.com> # Xen PV (dom0 and unpriv. guest)
  • Loading branch information
Thomas Gleixner authored and Dave Hansen committed Aug 9, 2023
1 parent 1751ade commit 5a88f35
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions arch/x86/kernel/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1852,6 +1852,8 @@ void x2apic_setup(void)
__x2apic_enable();
}

static __init void apic_set_fixmap(void);

static __init void x2apic_disable(void)
{
u32 x2apic_id, state = x2apic_state;
Expand All @@ -1872,7 +1874,7 @@ static __init void x2apic_disable(void)
}

__x2apic_disable();
register_lapic_address(mp_lapic_addr);
apic_set_fixmap();
}

static __init void x2apic_enable(void)
Expand Down Expand Up @@ -2145,17 +2147,21 @@ void __init init_apic_mappings(void)
}
}

static __init void apic_set_fixmap(void)
{
set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
apic_mmio_base = APIC_BASE;
apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n",
apic_mmio_base, mp_lapic_addr);
apic_read_boot_cpu_id(false);
}

void __init register_lapic_address(unsigned long address)
{
mp_lapic_addr = address;

if (x2apic_mode)
return;

set_fixmap_nocache(FIX_APIC_BASE, address);
apic_mmio_base = APIC_BASE;
apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n", APIC_BASE, address);
apic_read_boot_cpu_id(false);
if (!x2apic_mode)
apic_set_fixmap();
}

/*
Expand Down

0 comments on commit 5a88f35

Please sign in to comment.