From patchwork Mon May 13 06:19:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C35E1398 for ; Mon, 13 May 2019 06:25:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CA4D201B1 for ; Mon, 13 May 2019 06:25:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E57E21FAD; Mon, 13 May 2019 06:25:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D57A0201B1 for ; Mon, 13 May 2019 06:25:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:51809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Oe-0007UK-3j for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:25:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Jy-00037V-Fj for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4Jx-0004eq-3I for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:22 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4Jw-0004ds-Qi for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:21 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:19 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:17 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:05 +0800 Message-Id: <20190513061913.9284-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 1/9] hw/acpi: expand pc_madt_cpu_entry in place X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is a preparation for MADT refactor. Signed-off-by: Wei Yang --- hw/acpi/cpu.c | 33 +++++++++++-- hw/acpi/piix4.c | 1 - hw/i386/acpi-build.c | 71 ++++++++++++---------------- hw/isa/lpc_ich9.c | 1 - include/hw/acpi/acpi_dev_interface.h | 6 --- 5 files changed, 59 insertions(+), 53 deletions(-) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 7a90c8f82d..d786df1a2c 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -329,7 +329,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, char *cphp_res_path = g_strdup_printf("%s." CPUHP_RES_DEVICE, res_root); Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, NULL); AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj); - AcpiDeviceIf *adev = ACPI_DEVICE_IF(obj); + uint32_t apic_id; cpu_ctrl_dev = aml_device("%s", cphp_res_path); { @@ -522,8 +522,35 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_append(dev, method); /* build _MAT object */ - assert(adevc && adevc->madt_cpu); - adevc->madt_cpu(adev, i, arch_ids, madt_buf); + assert(adevc); + apic_id = arch_ids->cpus[i].arch_id; + if (apic_id < 255) { + AcpiMadtProcessorApic *apic = acpi_data_push(madt_buf, + sizeof *apic); + + apic->type = ACPI_APIC_PROCESSOR; + apic->length = sizeof(*apic); + apic->processor_id = i; + apic->local_apic_id = apic_id; + if (arch_ids->cpus[i].cpu != NULL) { + apic->flags = cpu_to_le32(1); + } else { + apic->flags = cpu_to_le32(0); + } + } 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); + } + } switch (madt_buf->data[0]) { case ACPI_APIC_PROCESSOR: { AcpiMadtProcessorApic *apic = (void *)madt_buf->data; diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 9c079d6834..76fde125a3 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -722,7 +722,6 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) hc->unplug = piix4_device_unplug_cb; adevc->ospm_status = piix4_ospm_status; adevc->send_event = piix4_send_gpe; - adevc->madt_cpu = pc_madt_cpu_entry; } static const TypeInfo piix4_pm_info = { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 29980bb3f4..54b70e62ac 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -301,52 +301,12 @@ build_facs(GArray *table_data) facs->length = cpu_to_le32(sizeof(*facs)); } -void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) -{ - uint32_t apic_id = apic_ids->cpus[uid].arch_id; - - /* ACPI spec says that LAPIC entry for non present - * CPU may be omitted from MADT or it must be marked - * as disabled. However omitting non present CPU from - * MADT breaks hotplug on linux. So possible CPUs - * should be put in MADT but kept disabled. - */ - if (apic_id < 255) { - AcpiMadtProcessorApic *apic = acpi_data_push(entry, sizeof *apic); - - apic->type = ACPI_APIC_PROCESSOR; - apic->length = sizeof(*apic); - apic->processor_id = uid; - apic->local_apic_id = apic_id; - if (apic_ids->cpus[uid].cpu != NULL) { - apic->flags = cpu_to_le32(1); - } else { - apic->flags = cpu_to_le32(0); - } - } else { - AcpiMadtProcessorX2Apic *apic = acpi_data_push(entry, sizeof *apic); - - apic->type = ACPI_APIC_LOCAL_X2APIC; - apic->length = sizeof(*apic); - apic->uid = cpu_to_le32(uid); - apic->x2apic_id = cpu_to_le32(apic_id); - if (apic_ids->cpus[uid].cpu != NULL) { - apic->flags = cpu_to_le32(1); - } else { - apic->flags = cpu_to_le32(0); - } - } -} - static void build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) { MachineClass *mc = MACHINE_GET_CLASS(pcms); const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms)); int madt_start = table_data->len; - AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); - AcpiDeviceIf *adev = ACPI_DEVICE_IF(pcms->acpi_dev); bool x2apic_mode = false; AcpiMultipleApicTable *madt; @@ -359,8 +319,35 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) madt->flags = cpu_to_le32(1); for (i = 0; i < apic_ids->len; i++) { - adevc->madt_cpu(adev, i, apic_ids, table_data); - if (apic_ids->cpus[i].arch_id > 254) { + uint32_t apic_id = apic_ids->cpus[i].arch_id; + if (apic_id < 255) { + AcpiMadtProcessorApic *apic = acpi_data_push(table_data, + sizeof *apic); + + apic->type = ACPI_APIC_PROCESSOR; + apic->length = sizeof(*apic); + apic->processor_id = i; + apic->local_apic_id = apic_id; + if (apic_ids->cpus[i].cpu != NULL) { + apic->flags = cpu_to_le32(1); + } else { + apic->flags = cpu_to_le32(0); + } + } 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); + } + } + if (apic_id > 254) { x2apic_mode = true; } } diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index ac44aa53be..8e00504cd9 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -811,7 +811,6 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data) hc->unplug = ich9_pm_device_unplug_cb; adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; - adevc->madt_cpu = pc_madt_cpu_entry; } static const TypeInfo ich9_lpc_info = { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h index 43ff119179..160b785045 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -35,10 +35,6 @@ void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event); * ospm_status: returns status of ACPI device objects, reported * via _OST method if device supports it. * send_event: inject a specified event into guest - * madt_cpu: fills @entry with Interrupt Controller Structure - * for CPU indexed by @uid in @apic_ids array, - * returned structure types are: - * 0 - Local APIC, 9 - Local x2APIC, 0xB - GICC * * Interface is designed for providing unified interface * to generic ACPI functionality that could be used without @@ -52,7 +48,5 @@ typedef struct AcpiDeviceIfClass { /* */ void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); - void (*madt_cpu)(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry); } AcpiDeviceIfClass; #endif From patchwork Mon May 13 06:19:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF43C13AD for ; Mon, 13 May 2019 06:27:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B00AD223B3 for ; Mon, 13 May 2019 06:27:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A13FF26E40; Mon, 13 May 2019 06:27:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 127CB223B3 for ; Mon, 13 May 2019 06:27:00 +0000 (UTC) Received: from localhost ([127.0.0.1]:51843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4QN-0000nN-Ac for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:26:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4K0-00039N-9C for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4Jz-0004fN-1X for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:24 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4Jy-0004ds-Ps for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:22 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:20 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:06 +0800 Message-Id: <20190513061913.9284-3-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 2/9] hw/acpi: implement madt_sub[ACPI_APIC_PROCESSOR] X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wei Yang --- hw/acpi/cpu.c | 15 +++-------- hw/acpi/piix4.c | 1 + hw/i386/acpi-build.c | 39 +++++++++++++++++++--------- hw/isa/lpc_ich9.c | 1 + include/hw/acpi/acpi_dev_interface.h | 5 ++++ include/hw/i386/pc.h | 1 + 6 files changed, 38 insertions(+), 24 deletions(-) diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index d786df1a2c..35e57f9824 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -508,6 +508,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, Aml *uid = aml_int(i); GArray *madt_buf = g_array_new(0, 1, 1); int arch_id = arch_ids->cpus[i].arch_id; + int processor_id = i; if (opts.acpi_1_compatible && arch_id < 255) { dev = aml_processor(i, 0, 0, CPU_NAME_FMT, i); @@ -525,18 +526,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, assert(adevc); apic_id = arch_ids->cpus[i].arch_id; if (apic_id < 255) { - AcpiMadtProcessorApic *apic = acpi_data_push(madt_buf, - sizeof *apic); - - apic->type = ACPI_APIC_PROCESSOR; - apic->length = sizeof(*apic); - apic->processor_id = i; - apic->local_apic_id = apic_id; - if (arch_ids->cpus[i].cpu != NULL) { - apic->flags = cpu_to_le32(1); - } else { - apic->flags = cpu_to_le32(0); - } + 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); diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 76fde125a3..f4336b9238 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -722,6 +722,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) hc->unplug = piix4_device_unplug_cb; adevc->ospm_status = piix4_ospm_status; adevc->send_event = piix4_send_gpe; + adevc->madt_sub = i386_madt_sub; } static const TypeInfo piix4_pm_info = { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 54b70e62ac..dfcdcaeaf7 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -301,12 +301,37 @@ build_facs(GArray *table_data) facs->length = cpu_to_le32(sizeof(*facs)); } +static void pc_madt_apic_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; + AcpiMadtProcessorApic *apic = acpi_data_push(entry, sizeof *apic); + + apic->type = ACPI_APIC_PROCESSOR; + apic->length = sizeof(*apic); + apic->processor_id = *processor_id; + apic->local_apic_id = 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, +}; + static void build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) { MachineClass *mc = MACHINE_GET_CLASS(pcms); const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms)); int madt_start = table_data->len; + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); + bool x2apic_mode = false; AcpiMultipleApicTable *madt; @@ -320,19 +345,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) for (i = 0; i < apic_ids->len; i++) { uint32_t apic_id = apic_ids->cpus[i].arch_id; + int processor_id = i; if (apic_id < 255) { - AcpiMadtProcessorApic *apic = acpi_data_push(table_data, - sizeof *apic); - - apic->type = ACPI_APIC_PROCESSOR; - apic->length = sizeof(*apic); - apic->processor_id = i; - apic->local_apic_id = 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_PROCESSOR](table_data, &processor_id); } else { AcpiMadtProcessorX2Apic *apic = acpi_data_push(table_data, sizeof *apic); diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 8e00504cd9..efb0fd8e94 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -811,6 +811,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data) hc->unplug = ich9_pm_device_unplug_cb; adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; + adevc->madt_sub = i386_madt_sub; } static const TypeInfo ich9_lpc_info = { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h index 160b785045..3a3a12d543 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -3,6 +3,7 @@ #include "qom/object.h" #include "hw/boards.h" +#include "hw/acpi/acpi-defs.h" /* These values are part of guest ABI, and can not be changed */ typedef enum { @@ -29,6 +30,9 @@ typedef struct AcpiDeviceIf AcpiDeviceIf; void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event); +typedef void (*madt_operation)(GArray *entry, void *opaque); +typedef madt_operation madt_operations[ACPI_APIC_RESERVED]; + /** * AcpiDeviceIfClass: * @@ -48,5 +52,6 @@ typedef struct AcpiDeviceIfClass { /* */ void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); + madt_operation *madt_sub; } AcpiDeviceIfClass; #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ca65ef18af..db4ec693d3 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -281,6 +281,7 @@ void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory); /* acpi-build.c */ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry); +extern madt_operations i386_madt_sub; /* e820 types */ #define E820_RAM 1 From patchwork Mon May 13 06:19:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940357 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0AA713AD for ; Mon, 13 May 2019 06:28:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C15DF223B3 for ; Mon, 13 May 2019 06:28:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2E0D26E40; Mon, 13 May 2019 06:28:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 57761223B3 for ; Mon, 13 May 2019 06:28:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:51857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Rn-0001mc-Nk for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:28:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4K3-0003Dj-6L for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4K2-0004gh-6d for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:27 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4K1-0004ds-Uz for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:26 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:25 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:23 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:07 +0800 Message-Id: <20190513061913.9284-4-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 3/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_X2APIC] X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wei Yang --- 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; From patchwork Mon May 13 06:19:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95395924 for ; Mon, 13 May 2019 06:42:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8499022A65 for ; Mon, 13 May 2019 06:42:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75E8326E40; Mon, 13 May 2019 06:42:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 28AC722A65 for ; Mon, 13 May 2019 06:42:06 +0000 (UTC) Received: from localhost ([127.0.0.1]:52019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4ez-0007H8-F3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:42:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Zy-0002mj-6t for qemu-devel@nongnu.org; Mon, 13 May 2019 02:36:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4K5-0004mx-1y for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:30 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4K4-0004ds-QY for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:28 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:28 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:26 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:08 +0800 Message-Id: <20190513061913.9284-5-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 4/9] hw/acpi: implement madt_sub[ACPI_APIC_IO] X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wei Yang --- hw/i386/acpi-build.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4b480efff9..a661fff51d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -339,9 +339,22 @@ static void pc_madt_x2apic_entry(GArray *entry, void *opaque) } } +static void pc_madt_io_entry(GArray *entry, void *opaque) +{ + AcpiMadtIoApic *io_apic; + + io_apic = acpi_data_push(entry, sizeof *io_apic); + io_apic->type = ACPI_APIC_IO; + io_apic->length = sizeof(*io_apic); + io_apic->io_apic_id = ACPI_BUILD_IOAPIC_ID; + io_apic->address = cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); + io_apic->interrupt = cpu_to_le32(0); +} + madt_operations i386_madt_sub = { [ACPI_APIC_PROCESSOR] = pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] = pc_madt_x2apic_entry, + [ACPI_APIC_IO] = pc_madt_io_entry, }; static void @@ -355,7 +368,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) bool x2apic_mode = false; AcpiMultipleApicTable *madt; - AcpiMadtIoApic *io_apic; AcpiMadtIntsrcovr *intsrcovr; int i; @@ -376,12 +388,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) } } - io_apic = acpi_data_push(table_data, sizeof *io_apic); - io_apic->type = ACPI_APIC_IO; - io_apic->length = sizeof(*io_apic); - io_apic->io_apic_id = ACPI_BUILD_IOAPIC_ID; - io_apic->address = cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); - io_apic->interrupt = cpu_to_le32(0); + adevc->madt_sub[ACPI_APIC_IO](table_data, NULL); if (pcms->apic_xrupt_override) { intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr); From patchwork Mon May 13 06:19:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74CE815AB for ; Mon, 13 May 2019 06:38:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6826B223B3 for ; Mon, 13 May 2019 06:38:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AB3F26E4F; Mon, 13 May 2019 06:38:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A24D326E40 for ; Mon, 13 May 2019 06:38:14 +0000 (UTC) Received: from localhost ([127.0.0.1]:51960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4bF-0004Du-Uv for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:38:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Zy-0002z4-6u for qemu-devel@nongnu.org; Mon, 13 May 2019 02:36:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4K9-0004sl-1r for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:34 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4K8-0004ds-QZ for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:32 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:29 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:09 +0800 Message-Id: <20190513061913.9284-6-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 5/9] hw/acpi: implement madt_sub[ACPI_APIC_XRUPT_OVERRIDE] X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wei Yang --- hw/i386/acpi-build.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a661fff51d..f48cc5b292 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -351,10 +351,31 @@ static void pc_madt_io_entry(GArray *entry, void *opaque) io_apic->interrupt = cpu_to_le32(0); } +static void pc_madt_xrupt_override_entry(GArray *entry, void *opaque) +{ + AcpiMadtIntsrcovr *intsrcovr; + int *idx = opaque; + + intsrcovr = acpi_data_push(entry, sizeof *intsrcovr); + intsrcovr->type = ACPI_APIC_XRUPT_OVERRIDE; + intsrcovr->length = sizeof(*intsrcovr); + intsrcovr->source = *idx; + if (*idx == 0) { + intsrcovr->gsi = cpu_to_le32(2); + /* conforms to bus specifications */ + intsrcovr->flags = cpu_to_le16(0); + } else { + intsrcovr->gsi = cpu_to_le32(*idx); + /* active high, level triggered */ + intsrcovr->flags = cpu_to_le16(0xd); + } +} + madt_operations i386_madt_sub = { [ACPI_APIC_PROCESSOR] = pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] = pc_madt_x2apic_entry, [ACPI_APIC_IO] = pc_madt_io_entry, + [ACPI_APIC_XRUPT_OVERRIDE] = pc_madt_xrupt_override_entry, }; static void @@ -368,7 +389,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) bool x2apic_mode = false; AcpiMultipleApicTable *madt; - AcpiMadtIntsrcovr *intsrcovr; int i; madt = acpi_data_push(table_data, sizeof *madt); @@ -391,12 +411,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) adevc->madt_sub[ACPI_APIC_IO](table_data, NULL); if (pcms->apic_xrupt_override) { - intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type = ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length = sizeof(*intsrcovr); - intsrcovr->source = 0; - intsrcovr->gsi = cpu_to_le32(2); - intsrcovr->flags = cpu_to_le16(0); /* conforms to bus specifications */ + i = 0; + adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); } for (i = 1; i < 16; i++) { #define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) @@ -404,12 +420,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) /* No need for a INT source override structure. */ continue; } - intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type = ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length = sizeof(*intsrcovr); - intsrcovr->source = i; - intsrcovr->gsi = cpu_to_le32(i); - intsrcovr->flags = cpu_to_le16(0xd); /* active high, level triggered */ + adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); } if (x2apic_mode) { From patchwork Mon May 13 06:19:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 477AC112C for ; Mon, 13 May 2019 06:40:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39A8D1FF13 for ; Mon, 13 May 2019 06:40:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D793223B3; Mon, 13 May 2019 06:40:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3C131FF13 for ; Mon, 13 May 2019 06:40:15 +0000 (UTC) Received: from localhost ([127.0.0.1]:52004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4dD-0005jN-4C for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:40:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Zv-0002mj-RB for qemu-devel@nongnu.org; Mon, 13 May 2019 02:36:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4KB-0004tv-Ln for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:36 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4KB-0004ds-3S for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:34 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:32 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:10 +0800 Message-Id: <20190513061913.9284-7-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 6/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI] X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wei Yang --- hw/i386/acpi-build.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index f48cc5b292..bec0bed53e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -371,11 +371,24 @@ static void pc_madt_xrupt_override_entry(GArray *entry, void *opaque) } } +static void pc_madt_x2apic_nmi_entry(GArray *entry, void *opaque) +{ + AcpiMadtLocalX2ApicNmi *local_nmi; + + local_nmi = acpi_data_push(entry, sizeof *local_nmi); + local_nmi->type = ACPI_APIC_LOCAL_X2APIC_NMI; + local_nmi->length = sizeof(*local_nmi); + local_nmi->uid = 0xFFFFFFFF; /* all processors */ + local_nmi->flags = cpu_to_le16(0); + local_nmi->lint = 1; /* ACPI_LINT1 */ +} + madt_operations i386_madt_sub = { [ACPI_APIC_PROCESSOR] = pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] = pc_madt_x2apic_entry, [ACPI_APIC_IO] = pc_madt_io_entry, [ACPI_APIC_XRUPT_OVERRIDE] = pc_madt_xrupt_override_entry, + [ACPI_APIC_LOCAL_X2APIC_NMI] = pc_madt_x2apic_nmi_entry, }; static void @@ -424,14 +437,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) } if (x2apic_mode) { - AcpiMadtLocalX2ApicNmi *local_nmi; - - local_nmi = acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type = ACPI_APIC_LOCAL_X2APIC_NMI; - local_nmi->length = sizeof(*local_nmi); - local_nmi->uid = 0xFFFFFFFF; /* all processors */ - local_nmi->flags = cpu_to_le16(0); - local_nmi->lint = 1; /* ACPI_LINT1 */ + adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI](table_data, NULL); } else { AcpiMadtLocalNmi *local_nmi; From patchwork Mon May 13 06:19:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1BDE924 for ; Mon, 13 May 2019 06:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D252322A65 for ; Mon, 13 May 2019 06:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C410826E40; Mon, 13 May 2019 06:41:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D7A022A65 for ; Mon, 13 May 2019 06:41:46 +0000 (UTC) Received: from localhost ([127.0.0.1]:52017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4ef-0006xo-QZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:41:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Zu-0002mj-J4 for qemu-devel@nongnu.org; Mon, 13 May 2019 02:36:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4KG-0004vi-1r for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:41 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4KE-0004ds-Vh for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:37 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:35 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:11 +0800 Message-Id: <20190513061913.9284-8-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 7/9] hw/acpi: implement madt_sub[ACPI_APIC_LOCAL_NMI] X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wei Yang --- hw/i386/acpi-build.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index bec0bed53e..a7aeb215fc 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -383,12 +383,25 @@ static void pc_madt_x2apic_nmi_entry(GArray *entry, void *opaque) local_nmi->lint = 1; /* ACPI_LINT1 */ } +static void pc_madt_nmi_entry(GArray *entry, void *opaque) +{ + AcpiMadtLocalNmi *local_nmi; + + local_nmi = acpi_data_push(entry, sizeof *local_nmi); + local_nmi->type = ACPI_APIC_LOCAL_NMI; + local_nmi->length = sizeof(*local_nmi); + local_nmi->processor_id = 0xff; /* all processors */ + local_nmi->flags = cpu_to_le16(0); + local_nmi->lint = 1; /* ACPI_LINT1 */ +} + madt_operations i386_madt_sub = { [ACPI_APIC_PROCESSOR] = pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] = pc_madt_x2apic_entry, [ACPI_APIC_IO] = pc_madt_io_entry, [ACPI_APIC_XRUPT_OVERRIDE] = pc_madt_xrupt_override_entry, [ACPI_APIC_LOCAL_X2APIC_NMI] = pc_madt_x2apic_nmi_entry, + [ACPI_APIC_LOCAL_NMI] = pc_madt_nmi_entry, }; static void @@ -439,14 +452,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) if (x2apic_mode) { adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI](table_data, NULL); } else { - AcpiMadtLocalNmi *local_nmi; - - local_nmi = acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type = ACPI_APIC_LOCAL_NMI; - local_nmi->length = sizeof(*local_nmi); - local_nmi->processor_id = 0xff; /* all processors */ - local_nmi->flags = cpu_to_le16(0); - local_nmi->lint = 1; /* ACPI_LINT1 */ + adevc->madt_sub[ACPI_APIC_LOCAL_NMI](table_data, NULL); } build_header(linker, table_data, From patchwork Mon May 13 06:19:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 345A1924 for ; Mon, 13 May 2019 06:38:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24D4E223B3 for ; Mon, 13 May 2019 06:38:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16AAB26E51; Mon, 13 May 2019 06:38:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 288C8223B3 for ; Mon, 13 May 2019 06:38:13 +0000 (UTC) Received: from localhost ([127.0.0.1]:51958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4bE-0004CK-FC for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:38:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Zt-0002z4-RI for qemu-devel@nongnu.org; Mon, 13 May 2019 02:36:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4KG-0004w1-Q1 for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:42 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4KG-0004ds-I4 for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:40 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:40 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:38 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:12 +0800 Message-Id: <20190513061913.9284-9-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 8/9] hw/acpi: factor build_madt with madt_input X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP struct madt_input is introduced to represent one sub madt table. With help of madt_sub[] for related sub madt table, build_madt could be agnostic. Signed-off-by: Wei Yang --- hw/i386/acpi-build.c | 103 +++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 38 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a7aeb215fc..74a34e297e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -284,6 +284,54 @@ static void acpi_get_pci_holes(Range *hole, Range *hole64) NULL)); } +struct madt_input { + int sub_id; + void *opaque; +}; + +int xrupt_override_idx[] = {0, 5, 9, 10, 11}; +static struct madt_input * +acpi_get_madt_input(PCMachineState *pcms, int *processor_id) +{ + MachineClass *mc = MACHINE_GET_CLASS(pcms); + const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms)); + int i, sub_heads = 0; + uint32_t apic_id; + struct madt_input *input = NULL; + + sub_heads = apic_ids->len /* PROCESSOR/X2APIC */ + + 1 /* APIC_IO */ + + ARRAY_SIZE(xrupt_override_idx) /* XRUPT_OVERRIDE */ + + 1 /* NMI/X2APIC_NMI */ + + 1; /* END MARK */ + input = g_new0(struct madt_input, sub_heads); + for (i = 0, sub_heads = 0; i < apic_ids->len; i++, sub_heads++) { + apic_id = apic_ids->cpus[i].arch_id; + if (apic_id < 255) { + input[sub_heads].sub_id = ACPI_APIC_PROCESSOR; + } else { + input[sub_heads].sub_id = ACPI_APIC_LOCAL_X2APIC; + } + input[sub_heads].opaque = processor_id; + } + input[sub_heads++].sub_id = ACPI_APIC_IO; + for (i = 0; i < ARRAY_SIZE(xrupt_override_idx); i++, sub_heads++) { + if (i == 0 && !pcms->apic_xrupt_override) { + continue; + } + input[sub_heads].sub_id = ACPI_APIC_XRUPT_OVERRIDE; + input[sub_heads].opaque = &xrupt_override_idx[i]; + } + if (apic_id > 254) { + input[sub_heads++].sub_id = ACPI_APIC_LOCAL_X2APIC_NMI; + } else { + input[sub_heads++].sub_id = ACPI_APIC_LOCAL_NMI; + } + input[sub_heads].sub_id = ACPI_APIC_RESERVED; + + return input; +} + static void acpi_align_size(GArray *blob, unsigned align) { /* Align size to multiple of given size. This reduces the chance @@ -318,6 +366,7 @@ static void pc_madt_apic_entry(GArray *entry, void *opaque) } else { apic->flags = cpu_to_le32(0); } + (*processor_id)++; } static void pc_madt_x2apic_entry(GArray *entry, void *opaque) @@ -337,6 +386,7 @@ static void pc_madt_x2apic_entry(GArray *entry, void *opaque) } else { apic->flags = cpu_to_le32(0); } + (*processor_id)++; } static void pc_madt_io_entry(GArray *entry, void *opaque) @@ -405,54 +455,27 @@ madt_operations i386_madt_sub = { }; static void -build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) +build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms, + struct madt_input *input) { - MachineClass *mc = MACHINE_GET_CLASS(pcms); - const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms)); int madt_start = table_data->len; AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); - bool x2apic_mode = false; - AcpiMultipleApicTable *madt; - int i; + int i, sub_id; + void *opaque; madt = acpi_data_push(table_data, sizeof *madt); madt->local_apic_address = cpu_to_le32(APIC_DEFAULT_ADDRESS); madt->flags = cpu_to_le32(1); - for (i = 0; i < apic_ids->len; i++) { - uint32_t apic_id = apic_ids->cpus[i].arch_id; - int processor_id = i; - if (apic_id < 255) { - adevc->madt_sub[ACPI_APIC_PROCESSOR](table_data, &processor_id); - } else { - adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC](table_data, &processor_id); + for (i = 0; ; i++) { + sub_id = input[i].sub_id; + if (sub_id == ACPI_APIC_RESERVED) { + break; } - if (apic_id > 254) { - x2apic_mode = true; - } - } - - adevc->madt_sub[ACPI_APIC_IO](table_data, NULL); - - if (pcms->apic_xrupt_override) { - i = 0; - adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); - } - for (i = 1; i < 16; i++) { -#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11)) - if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) { - /* No need for a INT source override structure. */ - continue; - } - adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); - } - - if (x2apic_mode) { - adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI](table_data, NULL); - } else { - adevc->madt_sub[ACPI_APIC_LOCAL_NMI](table_data, NULL); + opaque = input[i].opaque; + adevc->madt_sub[sub_id](table_data, opaque); } build_header(linker, table_data, @@ -2627,6 +2650,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) GArray *tables_blob = tables->table_data; AcpiSlicOem slic_oem = { .id = NULL, .table_id = NULL }; Object *vmgenid_dev; + struct madt_input *input = NULL; + int processor_id = 0; acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); @@ -2671,7 +2696,9 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) aml_len += tables_blob->len - fadt; acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, pcms); + input = acpi_get_madt_input(pcms, &processor_id); + build_madt(tables_blob, tables->linker, pcms, input); + g_free(input); vmgenid_dev = find_vmgenid_dev(); if (vmgenid_dev) { From patchwork Mon May 13 06:19:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10940387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7836924 for ; Mon, 13 May 2019 06:39:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9AAF26419 for ; Mon, 13 May 2019 06:39:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E32426E4F; Mon, 13 May 2019 06:39:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3AC3526419 for ; Mon, 13 May 2019 06:39:57 +0000 (UTC) Received: from localhost ([127.0.0.1]:51972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4cu-0005Q8-Gv for patchwork-qemu-devel@patchwork.kernel.org; Mon, 13 May 2019 02:39:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Zs-0002mj-UF for qemu-devel@nongnu.org; Mon, 13 May 2019 02:36:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQ4KK-000509-F8 for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:46 -0400 Received: from mga07.intel.com ([134.134.136.100]:24552) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQ4KJ-0004ds-BF for qemu-devel@nongnu.org; Mon, 13 May 2019 02:20:43 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 May 2019 23:20:43 -0700 X-ExtLoop1: 1 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by orsmga003.jf.intel.com with ESMTP; 12 May 2019 23:20:41 -0700 From: Wei Yang To: qemu-devel@nongnu.org Date: Mon, 13 May 2019 14:19:13 +0800 Message-Id: <20190513061913.9284-10-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190513061913.9284-1-richardw.yang@linux.intel.com> References: <20190513061913.9284-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 Subject: [Qemu-devel] [RFC PATCH 9/9] hw/acpi: implement madt_main to manipulate main madt table X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com, Wei Yang , pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Different arch would handle the main madt table differently. Add a helper function to achieve this goal. Signed-off-by: Wei Yang --- hw/acpi/piix4.c | 1 + hw/i386/acpi-build.c | 13 +++++++++++-- hw/isa/lpc_ich9.c | 1 + include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/i386/pc.h | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index f4336b9238..d7d097daee 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -723,6 +723,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) adevc->ospm_status = piix4_ospm_status; adevc->send_event = piix4_send_gpe; adevc->madt_sub = i386_madt_sub; + adevc->madt_main = i386_madt_main; } static const TypeInfo piix4_pm_info = { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 74a34e297e..e73e9fddee 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -454,6 +454,14 @@ madt_operations i386_madt_sub = { [ACPI_APIC_LOCAL_NMI] = pc_madt_nmi_entry, }; +void i386_madt_main(GArray *entry, void *opaque) +{ + AcpiMultipleApicTable *madt = opaque; + + madt->local_apic_address = cpu_to_le32(APIC_DEFAULT_ADDRESS); + madt->flags = cpu_to_le32(1); +} + static void build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms, struct madt_input *input) @@ -466,8 +474,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms, void *opaque; madt = acpi_data_push(table_data, sizeof *madt); - madt->local_apic_address = cpu_to_le32(APIC_DEFAULT_ADDRESS); - madt->flags = cpu_to_le32(1); + if (adevc->madt_main) { + adevc->madt_main(table_data, madt); + } for (i = 0; ; i++) { sub_id = input[i].sub_id; diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index efb0fd8e94..21afd1a12d 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -812,6 +812,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data) adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; adevc->madt_sub = i386_madt_sub; + adevc->madt_main = i386_madt_main; } static const TypeInfo ich9_lpc_info = { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h index 3a3a12d543..d3b216544d 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -52,6 +52,7 @@ typedef struct AcpiDeviceIfClass { /* */ void (*ospm_status)(AcpiDeviceIf *adev, ACPIOSTInfoList ***list); void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); + madt_operation madt_main; madt_operation *madt_sub; } AcpiDeviceIfClass; #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index db4ec693d3..6b7dd060ac 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -282,6 +282,7 @@ void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory); void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry); extern madt_operations i386_madt_sub; +void i386_madt_main(GArray *entry, void *opaque); /* e820 types */ #define E820_RAM 1