Skip to contentSkip to conversation

vEFI SRAT support

PATCH In review Jes Sorensen 3 participants 3 messages Jun 3, 2009 – Jun 6, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vEFI SRAT support

Hi,

Here's a patch adding SRAT support to the vEFI image. It's fairly basic, simply putting all vCPUs and memory onto node zero.

The benefit of creating the SRAT, even for smaller systems is that the current Linux kernels rely on it to count possibly CPUs, and without it, they will allocate per-CPU space for 32 CPUs. It should result in slightly less kernel memory being consumed for small setups and it allows for booting guests with > 32 vCPUs (and > 64 with older kernels).

I also changed the ACPI OEM ID to say XenKVM instead of just Xen, hope thats ok. If you prefer, feel free to ignore this part. Last I added a typecase to the memcpy() #define to avoid a compiler warning.

Cheers,
Jes

Implement basic ACPI SRAT support.

This implementation simply puts all CPUs and memory onto node 0.

For Linux guests it is preffered to have an SRAT, even for small configurations as recent kernels rely on it to determine per-CPU allocations. If no SRAT is found, the kernel will allocate space for 32 CPUs. This is also required in order to boot more than 32 vCPUs with recent kernels, and more than 64 vCPUs with older kernels.

edk2-sparse/EdkXenPkg/Dxe/XenAcpi/acpi2_0.h +45 -1
diff -r eb97cb2936d6 edk2-sparse/EdkXenPkg/Dxe/XenAcpi/acpi2_0.h
@@ -54,7 +54,7 @@
     uint32_t creator_revision;
 };
 
-#define ACPI_OEM_ID             "Xen"
+#define ACPI_OEM_ID             "XenKVM"
 #define ACPI_OEM_TABLE_ID       "HVM"
 #define ACPI_OEM_REVISION       0
 
@@ -351,6 +351,7 @@
 #define ACPI_2_0_XSDT_SIGNATURE ASCII32('X','S','D','T')
 #define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A')
 #define ACPI_2_0_HPET_SIGNATURE ASCII32('H','P','E','T')
+#define ACPI_2_0_SRAT_SIGNATURE ASCII32('S','R','A','T')
 
 /*
  * Table revision numbers.
@@ -362,6 +363,49 @@
 #define ACPI_2_0_XSDT_REVISION 0x01
 #define ACPI_2_0_TCPA_REVISION 0x02
 #define ACPI_2_0_HPET_REVISION 0x01
+#define ACPI_2_0_SRAT_REVISION 0x02
+
+/*
+ * Processor Local APIC/SAPIC Affinity Structure
+ */
+struct acpi_20_srat_cpu_affinity {
+    uint8_t  type;
+    uint8_t  length;
+    uint8_t  proximity_domain_lo;
+    uint8_t  apic_id;
+    uint32_t flags;
+    uint8_t  local_sapic_eid;
+    uint8_t  proximity_domain_hi[3];
+    uint32_t reserved;
+};
+
+#define ACPI_SRAT_CPU_ENABLED 1
+
+/*
+ * Memory Affinity Structure
+ */
+struct acpi_20_srat_memory_affinity {
+    uint8_t  type;
+    uint8_t  length;
+    uint32_t proximity_domain;
+    uint16_t reserved0;
+    uint64_t base_address;
+    uint64_t base_length;
+    uint32_t reserved1;
+    uint32_t flags;
+    uint64_t reserved2;
+};
+
+#define ACPI_SRAT_MEMORY_ENABLED 1
+
+/*
+ * System Resource Affinity Table (SRAT)
+ */
+struct acpi_20_srat {
+    struct acpi_header header;
+    uint32_t reserved0;     /* Must be 1 */
+    uint64_t reserved1;
+};
 
 #pragma pack ()
 
edk2-sparse/EdkXenPkg/Dxe/XenAcpi/build.c +97 -1

122 lines not on this page · raw message

diff -r eb97cb2936d6 edk2-sparse/env.sh

#1 lore raw

Tristan,
How about the patch to upstream?
Xiantao

-----Original Message-----
From: Jes Sorensen [mailto:[email protected]]
Sent: Wednesday, June 03, 2009 11:07 PM
To: Tristan Gingold
Cc: Zhang, Xiantao; [email protected]
Subject: [patch] vEFI SRAT support

Hi,

Here's a patch adding SRAT support to the vEFI image. It's fairly basic, simply putting all vCPUs and memory onto node zero.

The benefit of creating the SRAT, even for smaller systems is that the current Linux kernels rely on it to count possibly CPUs, and without it, they will allocate per-CPU space for 32 CPUs. It should result in slightly less kernel memory being consumed for small setups and it allows for booting guests with > 32 vCPUs (and > 64 with older kernels).

I also changed the ACPI OEM ID to say XenKVM instead of just Xen, hope thats ok. If you prefer, feel free to ignore this part. Last I added a typecase to the memcpy() #define to avoid a compiler warning.

Cheers,
Jes