mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
acpi: use build_append_int_noprefix() API to compose SRAT table
Drop usage of packed structures and explicit endian conversions when building SRAT tables for arm/x86 and use endian agnostic build_append_int_noprefix() API to build it. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Message-Id: <20210924122802.1455362-18-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
255bf20f2e
commit
e5b6d55a6e
6 changed files with 80 additions and 106 deletions
|
@ -474,11 +474,13 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|||
vms->oem_table_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* ACPI spec, Revision 5.1
|
||||
* 5.2.16 System Resource Affinity Table (SRAT)
|
||||
*/
|
||||
static void
|
||||
build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
||||
{
|
||||
AcpiSratProcessorGiccAffinity *core;
|
||||
AcpiSratMemoryAffinity *numamem;
|
||||
int i;
|
||||
uint64_t mem_base;
|
||||
MachineClass *mc = MACHINE_GET_CLASS(vms);
|
||||
|
@ -492,19 +494,23 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|||
build_append_int_noprefix(table_data, 0, 8); /* Reserved */
|
||||
|
||||
for (i = 0; i < cpu_list->len; ++i) {
|
||||
core = acpi_data_push(table_data, sizeof(*core));
|
||||
core->type = ACPI_SRAT_PROCESSOR_GICC;
|
||||
core->length = sizeof(*core);
|
||||
core->proximity = cpu_to_le32(cpu_list->cpus[i].props.node_id);
|
||||
core->acpi_processor_uid = cpu_to_le32(i);
|
||||
core->flags = cpu_to_le32(1);
|
||||
uint32_t nodeid = cpu_list->cpus[i].props.node_id;
|
||||
/*
|
||||
* 5.2.16.4 GICC Affinity Structure
|
||||
*/
|
||||
build_append_int_noprefix(table_data, 3, 1); /* Type */
|
||||
build_append_int_noprefix(table_data, 18, 1); /* Length */
|
||||
build_append_int_noprefix(table_data, nodeid, 4); /* Proximity Domain */
|
||||
build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */
|
||||
/* Flags, Table 5-76 */
|
||||
build_append_int_noprefix(table_data, 1 /* Enabled */, 4);
|
||||
build_append_int_noprefix(table_data, 0, 4); /* Clock Domain */
|
||||
}
|
||||
|
||||
mem_base = vms->memmap[VIRT_MEM].base;
|
||||
for (i = 0; i < ms->numa_state->num_nodes; ++i) {
|
||||
if (ms->numa_state->nodes[i].node_mem > 0) {
|
||||
numamem = acpi_data_push(table_data, sizeof(*numamem));
|
||||
build_srat_memory(numamem, mem_base,
|
||||
build_srat_memory(table_data, mem_base,
|
||||
ms->numa_state->nodes[i].node_mem, i,
|
||||
MEM_AFFINITY_ENABLED);
|
||||
mem_base += ms->numa_state->nodes[i].node_mem;
|
||||
|
@ -516,8 +522,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|||
}
|
||||
|
||||
if (ms->device_memory) {
|
||||
numamem = acpi_data_push(table_data, sizeof *numamem);
|
||||
build_srat_memory(numamem, ms->device_memory->base,
|
||||
build_srat_memory(table_data, ms->device_memory->base,
|
||||
memory_region_size(&ms->device_memory->mr),
|
||||
ms->numa_state->num_nodes - 1,
|
||||
MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue