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

[Xen-devel] [RFC Patch v4 5/8] Tool/ACPI: DSDT extension to support more vcpus



From: Lan Tianyu <tianyu.lan@xxxxxxxxx>

This patch is to change DSDT table for processor object to support 4096 vcpus
accroding to ACPI spec 8.4 Declaring Processors.

This patch contains the two changes:
1. Declare processors whose local APIC is declared as a x2apic via the ASL
   Device statement
2. Bump up the size of CPU ID used to compose processor name to 12 bits. Thus
   the processors number limitation imposed here is 4096.

Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx>
Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
---
 tools/libacpi/libacpi.h |  6 ++++++
 tools/libacpi/mk_dsdt.c | 40 +++++++++++++++++++++++++++++++++-------
 2 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h
index b89fdb5..7db4d92 100644
--- a/tools/libacpi/libacpi.h
+++ b/tools/libacpi/libacpi.h
@@ -24,6 +24,12 @@
 #include <stdint.h>  /* uintXX_t */
 
 #define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
+/*
+ * For x86, APIC ID is twice the vcpu id. In MADT, only APICs with
+ * APIC ID <= 254 can be declared as local APIC. Otherwise, APICs with
+ * APIC ID > 254 should be declared as local x2APIC.
+ */
+#define MADT_MAX_LOCAL_APIC 128U
 
 #define ACPI_HAS_COM1              (1<<0)
 #define ACPI_HAS_COM2              (1<<1)
diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c
index 2daf32c..27e5d1b 100644
--- a/tools/libacpi/mk_dsdt.c
+++ b/tools/libacpi/mk_dsdt.c
@@ -20,10 +20,13 @@
 #if defined(CONFIG_X86)
 #include <xen/arch-x86/xen.h>
 #include <xen/hvm/hvm_info_table.h>
+#include "libacpi.h"
 #elif defined(CONFIG_ARM_64)
 #include <xen/arch-arm.h>
 #endif
 
+#define CPU_NAME_FMT      "P%.03X"
+
 static unsigned int indent_level;
 static bool debug = false;
 
@@ -194,12 +197,35 @@ int main(int argc, char **argv)
 #endif
 
     /* Define processor objects and control methods. */
-    for ( cpu = 0; cpu < max_cpus; cpu++)
+    for ( cpu = 0; cpu < max_cpus; cpu++ )
     {
-        push_block("Processor", "PR%02X, %d, 0x0000b010, 0x06", cpu, cpu);
 
-        stmt("Name", "_HID, \"ACPI0007\"");
+#ifdef CONFIG_X86
+        /*
+         * According to the Processor Local x2APIC Structure of ACPI SPEC
+         * Revision 5.0, "OSPM associates the X2APIC Structure with a
+         * processor object declared in the namespace using the Device
+         * statement, when the _UID child object of the processor device
+         * evaluates to a numeric value, by matching the numeric value with
+         * this field".
+         *
+         * Anyhow, a numeric value is assigned to _UID object here. Thus,
+         * for each x2apic structure in MADT, instead of declaring the
+         * corresponding processor via the ASL Processor statement, declare
+         * it via the ASL Device statement.
+         *
+         * Note that If CPU ID is equal or greater than MADT_MAX_LOCAL_APIC,
+         * the lapic of this CPU should be enumerated as a local x2apic
+         * structure.
+         */
+        if ( cpu >= MADT_MAX_LOCAL_APIC )
+            push_block("Device", CPU_NAME_FMT, cpu);
+        else
+#endif
+            push_block("Processor", CPU_NAME_FMT ", %d,0x0000b010, 0x06",
+                       cpu, cpu);
 
+        stmt("Name", "_HID, \"ACPI0007\"");
         stmt("Name", "_UID, %d", cpu);
 #ifdef CONFIG_ARM_64
         pop_block();
@@ -268,15 +294,15 @@ int main(int argc, char **argv)
         /* Extract current CPU's status: 0=offline; 1=online. */
         stmt("And", "Local1, 1, Local2");
         /* Check if status is up-to-date in the relevant MADT LAPIC entry... */
-        push_block("If", "LNotEqual(Local2, \\_SB.PR%02X.FLG)", cpu);
+        push_block("If", "LNotEqual(Local2, \\_SB." CPU_NAME_FMT ".FLG)", cpu);
         /* ...If not, update it and the MADT checksum, and notify OSPM. */
-        stmt("Store", "Local2, \\_SB.PR%02X.FLG", cpu);
+        stmt("Store", "Local2, \\_SB." CPU_NAME_FMT ".FLG", cpu);
         push_block("If", "LEqual(Local2, 1)");
-        stmt("Notify", "PR%02X, 1", cpu); /* Notify: Device Check */
+        stmt("Notify", CPU_NAME_FMT ", 1", cpu); /* Notify: Device Check */
         stmt("Subtract", "\\_SB.MSU, 1, \\_SB.MSU"); /* Adjust MADT csum */
         pop_block();
         push_block("Else", NULL);
-        stmt("Notify", "PR%02X, 3", cpu); /* Notify: Eject Request */
+        stmt("Notify", CPU_NAME_FMT ", 3", cpu); /* Notify: Eject Request */
         stmt("Add", "\\_SB.MSU, 1, \\_SB.MSU"); /* Adjust MADT csum */
         pop_block();
         pop_block();
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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