[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v4 5/5] hw/arm/virt-acpi-build: Generate SRAT table
From: |
Shannon Zhao |
Subject: |
[Qemu-arm] [PATCH v4 5/5] hw/arm/virt-acpi-build: Generate SRAT table |
Date: |
Sat, 23 Jan 2016 19:36:46 +0800 |
From: Shannon Zhao <address@hidden>
To support NUMA, it needs to generate SRAT ACPI table.
Signed-off-by: Shannon Zhao <address@hidden>
---
CC: Igor Mammedov <address@hidden>
---
hw/arm/virt-acpi-build.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 87fbe7c..8438028 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -42,6 +42,7 @@
#include "hw/acpi/aml-build.h"
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
+#include "sysemu/numa.h"
#define ARM_SPI_BASE 32
#define ACPI_POWER_BUTTON_DEVICE "PWRB"
@@ -412,6 +413,58 @@ build_spcr(GArray *table_data, GArray *linker,
VirtGuestInfo *guest_info)
}
static void
+build_srat(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
+{
+ AcpiSystemResourceAffinityTable *srat;
+ AcpiSratProcessorGiccAffinity *core;
+ AcpiSratMemoryAffinity *numamem;
+ int i, j, srat_start;
+ uint64_t mem_len, mem_base;
+ uint32_t *cpu_node = g_malloc0(guest_info->smp_cpus * sizeof *cpu_node);
+
+ for (i = 0; i < guest_info->smp_cpus; i++) {
+ for (j = 0; j < nb_numa_nodes; j++) {
+ if (test_bit(i, numa_info[j].node_cpu)) {
+ cpu_node[i] = j;
+ break;
+ }
+ }
+ }
+
+ srat_start = table_data->len;
+ srat = acpi_data_push(table_data, sizeof *srat);
+ srat->reserved1 = cpu_to_le32(1);
+
+ for (i = 0; i < guest_info->smp_cpus; ++i) {
+ core = acpi_data_push(table_data, sizeof *core);
+ core->type = ACPI_SRAT_PROCESSOR_GICC;
+ core->length = sizeof(*core);
+ core->proximity = cpu_node[i];
+ core->acpi_processor_uid = i;
+ core->flags = cpu_to_le32(1);
+ }
+ g_free(cpu_node);
+
+ mem_base = guest_info->memmap[VIRT_MEM].base;
+ for (i = 0; i < nb_numa_nodes; ++i) {
+ mem_len = numa_info[i].node_mem;
+ numamem = acpi_data_push(table_data, sizeof *numamem);
+ numamem->type = ACPI_SRAT_MEMORY;
+ numamem->length = sizeof(*numamem);
+ memset(numamem->proximity, 0, 4);
+ numamem->proximity[0] = i;
+ numamem->flags = cpu_to_le32(1);
+ numamem->base_addr = cpu_to_le64(mem_base);
+ numamem->range_length = cpu_to_le64(mem_len);
+ mem_base += mem_len;
+ }
+
+ build_header(linker, table_data,
+ (void *)(table_data->data + srat_start), "SRAT",
+ table_data->len - srat_start, 3, NULL);
+}
+
+static void
build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
AcpiTableMcfg *mcfg;
@@ -641,6 +694,11 @@ void virt_acpi_build(VirtGuestInfo *guest_info,
AcpiBuildTables *tables)
acpi_add_table(table_offsets, tables_blob);
build_spcr(tables_blob, tables->linker, guest_info);
+ if (nb_numa_nodes > 0) {
+ acpi_add_table(table_offsets, tables_blob);
+ build_srat(tables_blob, tables->linker, guest_info);
+ }
+
/* RSDT is pointed to by RSDP */
rsdt = tables_blob->len;
build_rsdt(tables_blob, tables->linker, table_offsets);
--
2.0.4
- [Qemu-arm] [PATCH v4 0/5] ARM: Add NUMA support for machine virt, Shannon Zhao, 2016/01/23
- [Qemu-arm] [PATCH v4 1/5] ARM: Virt: Add /distance-map node for NUMA, Shannon Zhao, 2016/01/23
- [Qemu-arm] [PATCH v4 4/5] include/hw/acpi/acpi-defs: Add GICC Affinity Structure, Shannon Zhao, 2016/01/23
- [Qemu-arm] [PATCH v4 2/5] ARM: Virt: Set numa-node-id for CPUs, Shannon Zhao, 2016/01/23
- [Qemu-arm] [PATCH v4 5/5] hw/arm/virt-acpi-build: Generate SRAT table,
Shannon Zhao <=
- [Qemu-arm] [PATCH v4 3/5] ARM: Add numa-node-id for /memory node, Shannon Zhao, 2016/01/23
- Re: [Qemu-arm] [PATCH v4 0/5] ARM: Add NUMA support for machine virt, Ashok Kumar, 2016/01/29