[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/apic: Get rid of get_physical_broadcast()



commit 944fdddbfd38e9d6379c129327a84662233e6e68
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Aug 28 20:20:35 2025 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Sep 1 19:54:21 2025 +0100

    x86/apic: Get rid of get_physical_broadcast()
    
    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()
    only apply to 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.057209154@xxxxxxxxxxxxx
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 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 e3a2b84f1a..70636b0bb5 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 d8eda6df6d..d228549536 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 1816e1c0b9..42a9b653d3 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, "
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.