WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2/5] x86: increase MAX_LOCAL_APIC

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/5] x86: increase MAX_LOCAL_APIC
From: "Jan Beulich" <JBeulich@xxxxxxxxxx>
Date: Wed, 15 Dec 2010 11:17:36 +0000
Cc: Yinghai Lu <yinghai@xxxxxxxxxx>
Delivery-date: Wed, 15 Dec 2010 03:19:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
x86: increase MAX_LOCAL_APIC

otherwise apicid_to_node[MAX_LOCAL_APIC] will be overrun if apicid > 255.

found xen numa dump, some cpus are pointing to wrong node... (cpu 80 to cpu 159)

(XEN) 'u' pressed -> dumping numa info (now-0x19EE:42622FD3)
...
...
(XEN) CPU80 -> NODE1
(XEN) CPU81 -> NODE4
(XEN) CPU82 -> NODE4
(XEN) CPU83 -> NODE1
(XEN) CPU84 -> NODE4
(XEN) CPU85 -> NODE0
(XEN) CPU86 -> NODE0
(XEN) CPU87 -> NODE0
(XEN) CPU88 -> NODE0
(XEN) CPU89 -> NODE0
(XEN) CPU90 -> NODE5
(XEN) CPU91 -> NODE5
(XEN) CPU92 -> NODE1
(XEN) CPU93 -> NODE1
(XEN) CPU94 -> NODE5
(XEN) CPU95 -> NODE5
(XEN) CPU96 -> NODE5
(XEN) CPU97 -> NODE5
(XEN) CPU98 -> NODE5
(XEN) CPU99 -> NODE5
(XEN) CPU100 -> NODE6
(XEN) CPU101 -> NODE6
(XEN) CPU102 -> NODE6
(XEN) CPU103 -> NODE6
(XEN) CPU104 -> NODE6
(XEN) CPU105 -> NODE6
(XEN) CPU106 -> NODE6
(XEN) CPU107 -> NODE6
(XEN) CPU108 -> NODE6
(XEN) CPU109 -> NODE6
(XEN) CPU110 -> NODE7
(XEN) CPU111 -> NODE7
(XEN) CPU112 -> NODE7
(XEN) CPU113 -> NODE7
(XEN) CPU114 -> NODE7
(XEN) CPU115 -> NODE7
(XEN) CPU116 -> NODE7
(XEN) CPU117 -> NODE7
(XEN) CPU118 -> NODE7
(XEN) CPU119 -> NODE7
(XEN) CPU120 -> NODE0
(XEN) CPU121 -> NODE4
(XEN) CPU122 -> NODE4
(XEN) CPU123 -> NODE0
(XEN) CPU124 -> NODE4
(XEN) CPU125 -> NODE0
(XEN) CPU126 -> NODE0
(XEN) CPU127 -> NODE0
(XEN) CPU128 -> NODE0
(XEN) CPU129 -> NODE0
(XEN) CPU130 -> NODE5
(XEN) CPU131 -> NODE5
(XEN) CPU132 -> NODE0
(XEN) CPU133 -> NODE0
(XEN) CPU134 -> NODE5
(XEN) CPU135 -> NODE5
(XEN) CPU136 -> NODE5
(XEN) CPU137 -> NODE5
(XEN) CPU138 -> NODE5
(XEN) CPU139 -> NODE5
(XEN) CPU140 -> NODE6
(XEN) CPU141 -> NODE6
(XEN) CPU142 -> NODE6
(XEN) CPU143 -> NODE6
(XEN) CPU144 -> NODE6
(XEN) CPU145 -> NODE6
(XEN) CPU146 -> NODE6
(XEN) CPU147 -> NODE6
(XEN) CPU148 -> NODE6
(XEN) CPU149 -> NODE6
(XEN) CPU150 -> NODE7
(XEN) CPU151 -> NODE7
(XEN) CPU152 -> NODE7
(XEN) CPU153 -> NODE7
(XEN) CPU154 -> NODE7
(XEN) CPU155 -> NODE7
(XEN) CPU156 -> NODE7
(XEN) CPU157 -> NODE7
(XEN) CPU158 -> NODE7
(XEN) CPU159 -> NODE7

after patch, the mapping get right.

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

Make this and also MAX_MADT_ENTRIES losely depend on NR_CPUS. Tie
MAX_APICS to MAX_LOCAL_APIC. Fix initializer of x86_acpiid_to_apicid[]
to match the array member type of u32, as well as all checks in
readers of this array and x86_cpu_to_apicid[].

While the adjustment to xen_vcpu_physid_to_x86_{acpi,apic}id() is not
backward compatible, I think it should still be done this way as the
former reserving of values beyond 0xff should never have been part of
the interface. If considered impossible, a second best solution would
appear to be to make the macros depend on __XEN_INTERFACE_VERSION__.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

--- 2010-11-09.orig/xen/arch/x86/acpi/boot.c
+++ 2010-11-09/xen/arch/x86/acpi/boot.c
@@ -82,7 +82,7 @@ u8 acpi_enable_value, acpi_disable_value
 #endif
 
 u32 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
-    {[0 ... MAX_MADT_ENTRIES - 1] = 0xff };
+    {[0 ... MAX_MADT_ENTRIES - 1] = BAD_APICID };
 EXPORT_SYMBOL(x86_acpiid_to_apicid);
 
 /* --------------------------------------------------------------------------
@@ -534,6 +534,7 @@ static int __init acpi_parse_madt_lapic_
 
        mp_register_lapic_address(acpi_lapic_addr);
 
+       BUILD_BUG_ON(MAX_APICS != MAX_LOCAL_APIC);
        count = acpi_table_parse_madt(ACPI_MADT_LAPIC, acpi_parse_lapic,
                                      MAX_APICS);
        x2count = acpi_table_parse_madt(ACPI_MADT_X2APIC, acpi_parse_x2apic,
@@ -1000,12 +1001,12 @@ unsigned int acpi_get_processor_id(unsig
 {
        unsigned int acpiid, apicid;
 
-       if ((apicid = x86_cpu_to_apicid[cpu]) == 0xff)
-               return 0xff;
+       if ((apicid = x86_cpu_to_apicid[cpu]) == BAD_APICID)
+               return INVALID_ACPIID;
 
        for (acpiid = 0; acpiid < ARRAY_SIZE(x86_acpiid_to_apicid); acpiid++)
                if (x86_acpiid_to_apicid[acpiid] == apicid)
                        return acpiid;
 
-       return 0xff;
+       return INVALID_ACPIID;
 }
--- 2010-11-09.orig/xen/arch/x86/acpi/cpu_idle.c
+++ 2010-11-09/xen/arch/x86/acpi/cpu_idle.c
@@ -868,7 +868,7 @@ int get_cpu_id(u8 acpi_id)
     u32 apic_id;
 
     apic_id = x86_acpiid_to_apicid[acpi_id];
-    if ( apic_id == 0xff )
+    if ( apic_id == BAD_APICID )
         return -1;
 
     for ( i = 0; i < NR_CPUS; i++ )
--- 2010-11-09.orig/xen/arch/x86/smpboot.c
+++ 2010-11-09/xen/arch/x86/smpboot.c
@@ -67,7 +67,8 @@ EXPORT_SYMBOL(cpu_online_map);
 
 struct cpuinfo_x86 cpu_data[NR_CPUS];
 
-u32 x86_cpu_to_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = -1U };
+u32 x86_cpu_to_apicid[NR_CPUS] __read_mostly =
+       { [0 ... NR_CPUS-1] = BAD_APICID };
 
 static void map_cpu_to_logical_apicid(void);
 
@@ -890,7 +891,7 @@ int cpu_add(uint32_t apic_id, uint32_t a
         return -EBUSY;
 
     /* Detect if the cpu has been added before */
-    if ( x86_acpiid_to_apicid[acpi_id] != 0xff )
+    if ( x86_acpiid_to_apicid[acpi_id] != BAD_APICID )
     {
         cpu = (x86_acpiid_to_apicid[acpi_id] != apic_id)
             ? -EINVAL : -EEXIST;
@@ -914,7 +915,7 @@ int cpu_add(uint32_t apic_id, uint32_t a
         {
             dprintk(XENLOG_WARNING,
                     "Setup node failed for pxm %x\n", pxm);
-            x86_acpiid_to_apicid[acpi_id] = 0xff;
+            x86_acpiid_to_apicid[acpi_id] = BAD_APICID;
             mp_unregister_lapic(apic_id, cpu);
             cpu = node;
             goto out;
--- 2010-11-09.orig/xen/include/asm-x86/acpi.h
+++ 2010-11-09/xen/include/asm-x86/acpi.h
@@ -150,9 +150,11 @@ struct acpi_sleep_info {
 
 #endif /* CONFIG_ACPI_SLEEP */
 
-#define MAX_MADT_ENTRIES       256
+#define MAX_MADT_ENTRIES       MAX(256, 2 * NR_CPUS)
 extern u32 x86_acpiid_to_apicid[];
-#define MAX_LOCAL_APIC 256
+#define MAX_LOCAL_APIC         MAX(256, 4 * NR_CPUS)
+
+#define INVALID_ACPIID         (-1U)
 
 extern u32 pmtmr_ioport;
 
--- 2010-11-09.orig/xen/include/asm-x86/numa.h
+++ 2010-11-09/xen/include/asm-x86/numa.h
@@ -37,7 +37,7 @@ extern int setup_node(int pxm);
 extern void srat_detect_node(int cpu);
 
 extern void setup_node_bootmem(int nodeid, u64 start, u64 end);
-extern unsigned char apicid_to_node[256];
+extern unsigned char apicid_to_node[];
 #ifdef CONFIG_NUMA
 extern void __init init_cpu_to_node(void);
 
--- 2010-11-09.orig/xen/include/public/vcpu.h
+++ 2010-11-09/xen/include/public/vcpu.h
@@ -187,8 +187,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_register_vc
 /* 
  * Get the physical ID information for a pinned vcpu's underlying physical
  * processor.  The physical ID informmation is architecture-specific.
- * On x86: id[31:0]=apic_id, id[63:32]=acpi_id, and all values 0xff and
- *         greater are reserved.
+ * On x86: id[31:0]=apic_id, id[63:32]=acpi_id.
  * This command returns -EINVAL if it is not a valid operation for this VCPU.
  */
 #define VCPUOP_get_physid           12 /* arg == vcpu_get_physid_t */
@@ -197,10 +196,8 @@ struct vcpu_get_physid {
 };
 typedef struct vcpu_get_physid vcpu_get_physid_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_get_physid_t);
-#define xen_vcpu_physid_to_x86_apicid(physid) \
-    ((((uint32_t)(physid)) >= 0xff) ? 0xff : ((uint8_t)(physid)))
-#define xen_vcpu_physid_to_x86_acpiid(physid) \
-    ((((uint32_t)((physid)>>32)) >= 0xff) ? 0xff : ((uint8_t)((physid)>>32)))
+#define xen_vcpu_physid_to_x86_apicid(physid) ((uint32_t)(physid))
+#define xen_vcpu_physid_to_x86_acpiid(physid) ((uint32_t)((physid) >> 32))
 
 /* 
  * Register a memory location to get a secondary copy of the vcpu time


Attachment: x86-max-local-apic.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/5] x86: increase MAX_LOCAL_APIC, Jan Beulich <=