[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 3/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL
From: |
Wei Yang |
Subject: |
[Qemu-devel] [RFC PATCH 3/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_X2APIC] |
Date: |
Mon, 13 May 2019 14:19:07 +0800 |
Signed-off-by: Wei Yang <address@hidden>
---
hw/acpi/cpu.c | 14 ++------------
hw/i386/acpi-build.c | 33 +++++++++++++++++++++------------
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 35e57f9824..cb5970d659 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -529,18 +529,8 @@ void build_cpus_aml(Aml *table, MachineState *machine,
CPUHotplugFeatures opts,
assert(adevc->madt_sub[ACPI_APIC_PROCESSOR]);
adevc->madt_sub[ACPI_APIC_PROCESSOR](madt_buf, &processor_id);
} else {
- AcpiMadtProcessorX2Apic *apic = acpi_data_push(madt_buf,
- sizeof *apic);
-
- apic->type = ACPI_APIC_LOCAL_X2APIC;
- apic->length = sizeof(*apic);
- apic->uid = cpu_to_le32(i);
- apic->x2apic_id = cpu_to_le32(apic_id);
- if (arch_ids->cpus[i].cpu != NULL) {
- apic->flags = cpu_to_le32(1);
- } else {
- apic->flags = cpu_to_le32(0);
- }
+ adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC](madt_buf,
+ &processor_id);
}
switch (madt_buf->data[0]) {
case ACPI_APIC_PROCESSOR: {
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index dfcdcaeaf7..4b480efff9 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -320,8 +320,28 @@ static void pc_madt_apic_entry(GArray *entry, void *opaque)
}
}
+static void pc_madt_x2apic_entry(GArray *entry, void *opaque)
+{
+ MachineState *machine = MACHINE(qdev_get_machine());
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+ const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
+ int *processor_id = opaque;
+ AcpiMadtProcessorX2Apic *apic = acpi_data_push(entry, sizeof *apic);
+
+ apic->type = ACPI_APIC_LOCAL_X2APIC;
+ apic->length = sizeof(*apic);
+ apic->uid = cpu_to_le32(*processor_id);
+ apic->x2apic_id = cpu_to_le32(apic_ids->cpus[*processor_id].arch_id);
+ if (apic_ids->cpus[*processor_id].cpu != NULL) {
+ apic->flags = cpu_to_le32(1);
+ } else {
+ apic->flags = cpu_to_le32(0);
+ }
+}
+
madt_operations i386_madt_sub = {
[ACPI_APIC_PROCESSOR] = pc_madt_apic_entry,
+ [ACPI_APIC_LOCAL_X2APIC] = pc_madt_x2apic_entry,
};
static void
@@ -349,18 +369,7 @@ build_madt(GArray *table_data, BIOSLinker *linker,
PCMachineState *pcms)
if (apic_id < 255) {
adevc->madt_sub[ACPI_APIC_PROCESSOR](table_data, &processor_id);
} else {
- AcpiMadtProcessorX2Apic *apic = acpi_data_push(table_data,
- sizeof *apic);
-
- apic->type = ACPI_APIC_LOCAL_X2APIC;
- apic->length = sizeof(*apic);
- apic->uid = cpu_to_le32(i);
- apic->x2apic_id = cpu_to_le32(apic_id);
- if (apic_ids->cpus[i].cpu != NULL) {
- apic->flags = cpu_to_le32(1);
- } else {
- apic->flags = cpu_to_le32(0);
- }
+ adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC](table_data, &processor_id);
}
if (apic_id > 254) {
x2apic_mode = true;
--
2.19.1
- [Qemu-devel] [RFC PATCH 0/9] hw/acpi: make build_madt arch agnostic, Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 1/9] hw/acpi: expand pc_madt_cpu_entry in place, Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 2/9] hw/acpi: implement madt_sub[ACPI_APIC_PROCESSOR], Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 3/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_X2APIC],
Wei Yang <=
- [Qemu-devel] [RFC PATCH 9/9] hw/acpi: implement madt_main to manipulate main madt table, Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 8/9] hw/acpi: factor build_madt with madt_input, Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 7/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_NMI], Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 4/9] hw/acpi: implement madt_sub[ACPI_APIC_IO], Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 6/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI], Wei Yang, 2019/05/13
- [Qemu-devel] [RFC PATCH 5/9] hw/acpi: implement madt_sub[ACPI_APIC_XRUPT_OVERRIDE], Wei Yang, 2019/05/13