This is a port of Linux commit 517234446c1a ("x86/apic: Get rid of get_physical_broadcast()") to Xen. Thomas Gleixner notes:
There is no point for this function. The only case where this is used is when there is no XAPIC available, which means the broadcast address is 0xF. In Linux, users of get_physical_broadcast() have already been hidden behind CONFIG_X86_32 suggesting we can drop all of this, but that's a task for some other time. In Xen as with Linux, setup_ioapic_ids_from_mpc() and io_apic_get_unique_id() are only called in pre-xAPIC cases, so can use a broadcast ID of 0xf. The only other user is __print_IO_APIC() for diagnostics, which can simply drop the check. No functional change. Link: https://lore.kernel.org/r/20240212154639.057209...@linutronix.de Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com> --- CC: Jan Beulich <jbeul...@suse.com> CC: Roger Pau Monné <roger....@citrix.com> add/remove: 0/1 grow/shrink: 0/3 up/down: 0/-165 (-165) Function old new delta __print_IO_APIC 980 975 -5 setup_IO_APIC 3018 2992 -26 io_apic_get_unique_id 719 686 -33 get_physical_broadcast 101 - -101 --- xen/arch/x86/apic.c | 8 -------- xen/arch/x86/include/asm/apic.h | 2 -- xen/arch/x86/io_apic.c | 16 ++++++++-------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c index e3a2b84f1aae..70636b0bb585 100644 --- a/xen/arch/x86/apic.c +++ b/xen/arch/x86/apic.c @@ -133,14 +133,6 @@ static bool __read_mostly using_apic_timer; static bool __read_mostly enabled_via_apicbase; -int get_physical_broadcast(void) -{ - if (modern_apic()) - return 0xff; - else - return 0xf; -} - int get_maxlvt(void) { unsigned int v = apic_read(APIC_LVR); diff --git a/xen/arch/x86/include/asm/apic.h b/xen/arch/x86/include/asm/apic.h index d8eda6df6d86..d22854953689 100644 --- a/xen/arch/x86/include/asm/apic.h +++ b/xen/arch/x86/include/asm/apic.h @@ -153,8 +153,6 @@ static inline u32 get_apic_id(void) void apic_wait_icr_idle(void); -int get_physical_broadcast(void); - static inline void ack_APIC_irq(void) { /* Docs say use 0 for future compatibility */ diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 1816e1c0b9f4..42a9b653d397 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -1217,8 +1217,6 @@ static void /*__init*/ __print_IO_APIC(bool boot) printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.bits.ID); printk(KERN_DEBUG "....... : Delivery Type: %X\n", reg_00.bits.delivery_type); printk(KERN_DEBUG "....... : LTS : %X\n", reg_00.bits.LTS); - if (reg_00.bits.ID >= get_physical_broadcast()) - UNEXPECTED_IO_APIC(); if (reg_00.bits.__reserved_1 || reg_00.bits.__reserved_2) UNEXPECTED_IO_APIC(); @@ -1475,6 +1473,7 @@ static void __init setup_ioapic_ids_from_mpc(void) int i; unsigned char old_id; unsigned long flags; + const uint32_t broadcast_id = 0xf; /* * Don't check I/O APIC IDs for xAPIC systems. They have @@ -1504,7 +1503,7 @@ static void __init setup_ioapic_ids_from_mpc(void) old_id = mp_ioapics[apic].mpc_apicid; - if (mp_ioapics[apic].mpc_apicid >= get_physical_broadcast()) { + if (mp_ioapics[apic].mpc_apicid >= broadcast_id) { printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n", apic, mp_ioapics[apic].mpc_apicid); printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", @@ -1521,10 +1520,10 @@ static void __init setup_ioapic_ids_from_mpc(void) { printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n", apic, mp_ioapics[apic].mpc_apicid); - for (i = 0; i < get_physical_broadcast(); i++) + for (i = 0; i < broadcast_id; i++) if (!physid_isset(i, phys_id_present_map)) break; - if (i >= get_physical_broadcast()) + if (i >= broadcast_id) panic("Max APIC ID exceeded\n"); printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", i); @@ -2223,6 +2222,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id) static physid_mask_t __initdata apic_id_map = PHYSID_MASK_NONE; unsigned long flags; int i = 0; + const uint32_t broadcast_id = 0xf; /* * The P4 platform supports up to 256 APIC IDs on two separate APIC @@ -2240,7 +2240,7 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id) reg_00.raw = io_apic_read(ioapic, 0); spin_unlock_irqrestore(&ioapic_lock, flags); - if (apic_id >= get_physical_broadcast()) { + if (apic_id >= broadcast_id) { printk(KERN_WARNING "IOAPIC[%d]: Invalid apic_id %d, trying " "%d\n", ioapic, apic_id, reg_00.bits.ID); apic_id = reg_00.bits.ID; @@ -2253,12 +2253,12 @@ int __init io_apic_get_unique_id (int ioapic, int apic_id) if ( physid_isset(apic_id, apic_id_map) ) { - for (i = 0; i < get_physical_broadcast(); i++) { + for (i = 0; i < broadcast_id; i++) { if ( !physid_isset(i, apic_id_map) ) break; } - if (i == get_physical_broadcast()) + if (i == broadcast_id) panic("Max apic_id exceeded\n"); printk(KERN_WARNING "IOAPIC[%d]: apic_id %d already used, " -- 2.39.5