From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557728745; cv=none; d=zoho.com; s=zohoarc; b=aLRIewKlfwe0peV07hKRBhOYEdYMKfXrg/kb6ryoUidYQAk3Fe1puygP+10QOfJu4iZg9wupoQ1OH8+t848VxEnnZPFRwLANKCQKcelK9ZdPb4v73v5ObR2WGtyw6zng6v0Wn7MtJ5IDY5zs7CtsefEGRXrLqmVLzHrkL7iq/Jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557728745; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8YGVkTXAPDgMtJ+9g/jht7GhZFZGwLIT9PMSqpOr0rU=; b=TKDEbTZX+42DkCZIN+oPiNgniP6LFTOPQflbVLHnQZNjCbkP5tbm6sZl3MVg/jPbS7mp28Km9y9gbktsGzbeQjsOpgzV9NYYS1LQENTpsLl7UFDwTF5wP53tM2nZdTdsXpB4/dwdme8pbbUjI0AU47tWsj0pI+NkNw0m942TIqo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557728745538616.315857823895; Sun, 12 May 2019 23:25:45 -0700 (PDT) Received: from localhost ([127.0.0.1]:51809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4P8-0007UK-Ep for importer@patchew.org; Mon, 13 May 2019 02:25:42 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 =3D g_strdup_printf("%s." CPUHP_RES_DEVICE, res_ro= ot); Object *obj =3D object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, NULL= ); AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(obj); - AcpiDeviceIf *adev =3D ACPI_DEVICE_IF(obj); + uint32_t apic_id; =20 cpu_ctrl_dev =3D aml_device("%s", cphp_res_path); { @@ -522,8 +522,35 @@ void build_cpus_aml(Aml *table, MachineState *machine,= CPUHotplugFeatures opts, aml_append(dev, method); =20 /* build _MAT object */ - assert(adevc && adevc->madt_cpu); - adevc->madt_cpu(adev, i, arch_ids, madt_buf); + assert(adevc); + apic_id =3D arch_ids->cpus[i].arch_id; + if (apic_id < 255) { + AcpiMadtProcessorApic *apic =3D acpi_data_push(madt_buf, + sizeof *apic); + + apic->type =3D ACPI_APIC_PROCESSOR; + apic->length =3D sizeof(*apic); + apic->processor_id =3D i; + apic->local_apic_id =3D apic_id; + if (arch_ids->cpus[i].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } else { + AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(madt_buf, + sizeof *api= c); + + apic->type =3D ACPI_APIC_LOCAL_X2APIC; + apic->length =3D sizeof(*apic); + apic->uid =3D cpu_to_le32(i); + apic->x2apic_id =3D cpu_to_le32(apic_id); + if (arch_ids->cpus[i].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } switch (madt_buf->data[0]) { case ACPI_APIC_PROCESSOR: { AcpiMadtProcessorApic *apic =3D (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, voi= d *data) hc->unplug =3D piix4_device_unplug_cb; adevc->ospm_status =3D piix4_ospm_status; adevc->send_event =3D piix4_send_gpe; - adevc->madt_cpu =3D pc_madt_cpu_entry; } =20 static const TypeInfo piix4_pm_info =3D { 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 =3D cpu_to_le32(sizeof(*facs)); } =20 -void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, - const CPUArchIdList *apic_ids, GArray *entry) -{ - uint32_t apic_id =3D 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 =3D acpi_data_push(entry, sizeof *apic= ); - - apic->type =3D ACPI_APIC_PROCESSOR; - apic->length =3D sizeof(*apic); - apic->processor_id =3D uid; - apic->local_apic_id =3D apic_id; - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } - } else { - AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *ap= ic); - - apic->type =3D ACPI_APIC_LOCAL_X2APIC; - apic->length =3D sizeof(*apic); - apic->uid =3D cpu_to_le32(uid); - apic->x2apic_id =3D cpu_to_le32(apic_id); - if (apic_ids->cpus[uid].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } - } -} - static void build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) { MachineClass *mc =3D MACHINE_GET_CLASS(pcms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); int madt_start =3D table_data->len; - AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); - AcpiDeviceIf *adev =3D ACPI_DEVICE_IF(pcms->acpi_dev); bool x2apic_mode =3D false; =20 AcpiMultipleApicTable *madt; @@ -359,8 +319,35 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) madt->flags =3D cpu_to_le32(1); =20 for (i =3D 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 =3D apic_ids->cpus[i].arch_id; + if (apic_id < 255) { + AcpiMadtProcessorApic *apic =3D acpi_data_push(table_data, + sizeof *apic); + + apic->type =3D ACPI_APIC_PROCESSOR; + apic->length =3D sizeof(*apic); + apic->processor_id =3D i; + apic->local_apic_id =3D apic_id; + if (apic_ids->cpus[i].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } else { + AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(table_data, + sizeof *apic); + + apic->type =3D ACPI_APIC_LOCAL_X2APIC; + apic->length =3D sizeof(*apic); + apic->uid =3D cpu_to_le32(i); + apic->x2apic_id =3D cpu_to_le32(apic_id); + if (apic_ids->cpus[i].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } + } + if (apic_id > 254) { x2apic_mode =3D 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, voi= d *data) hc->unplug =3D ich9_pm_device_unplug_cb; adevc->ospm_status =3D ich9_pm_ospm_status; adevc->send_event =3D ich9_send_gpe; - adevc->madt_cpu =3D pc_madt_cpu_entry; } =20 static const TypeInfo ich9_lpc_info =3D { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_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, AcpiEventStatusBi= ts 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 --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557728850; cv=none; d=zoho.com; s=zohoarc; b=J8yfCXTNmHFNnkFPxKMkQIbSBIYsknnKNHvkXfUXRJBGvBXHsfY0otgPMxSvsQya7wPyj6EtI4DYGrxPRhVpOIqMID3Xg0CMDmXChXEPy8T/zzuSP/n3FqsXkIHdIagKVzO9Qcd61Y8KH/3Gxx1ySMlrLHiA7EKUjscaumjKpbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557728850; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3w1sNubkOUTe/4T51++ZjtZSTi0ipXz3++/IUdD6kZI=; b=h80sOt39UJNalOLxX2wZPJLB/P7Vh3LQ8nilXWjEppRCFzFbYk3VK98EX5AU2erSqFir/2iocLNnOm5wvowsJ9Vkypg5LqpUnQOAL0S8EtGqTH3Di15PwvSkq3/EzfvzLDWmu74zexN+vESHa/ttrSmgE4DX/cP7hqF86XSpN/0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557728850782499.0326437101155; Sun, 12 May 2019 23:27:30 -0700 (PDT) Received: from localhost ([127.0.0.1]:51843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4Qg-0000nN-Q5 for importer@patchew.org; Mon, 13 May 2019 02:27:18 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 =3D aml_int(i); GArray *madt_buf =3D g_array_new(0, 1, 1); int arch_id =3D arch_ids->cpus[i].arch_id; + int processor_id =3D i; =20 if (opts.acpi_1_compatible && arch_id < 255) { dev =3D 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 =3D arch_ids->cpus[i].arch_id; if (apic_id < 255) { - AcpiMadtProcessorApic *apic =3D acpi_data_push(madt_buf, - sizeof *apic); - - apic->type =3D ACPI_APIC_PROCESSOR; - apic->length =3D sizeof(*apic); - apic->processor_id =3D i; - apic->local_apic_id =3D apic_id; - if (arch_ids->cpus[i].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + assert(adevc->madt_sub[ACPI_APIC_PROCESSOR]); + adevc->madt_sub[ACPI_APIC_PROCESSOR](madt_buf, &processor_= id); } else { AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(madt_buf, sizeof *api= c); 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, voi= d *data) hc->unplug =3D piix4_device_unplug_cb; adevc->ospm_status =3D piix4_ospm_status; adevc->send_event =3D piix4_send_gpe; + adevc->madt_sub =3D i386_madt_sub; } =20 static const TypeInfo piix4_pm_info =3D { 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 =3D cpu_to_le32(sizeof(*facs)); } =20 +static void pc_madt_apic_entry(GArray *entry, void *opaque) +{ + MachineState *machine =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(machine); + int *processor_id =3D opaque; + AcpiMadtProcessorApic *apic =3D acpi_data_push(entry, sizeof *apic); + + apic->type =3D ACPI_APIC_PROCESSOR; + apic->length =3D sizeof(*apic); + apic->processor_id =3D *processor_id; + apic->local_apic_id =3D apic_ids->cpus[*processor_id].arch_id; + if (apic_ids->cpus[*processor_id].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } +} + +madt_operations i386_madt_sub =3D { + [ACPI_APIC_PROCESSOR] =3D pc_madt_apic_entry, +}; + static void build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) { MachineClass *mc =3D MACHINE_GET_CLASS(pcms); const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); int madt_start =3D table_data->len; + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); + bool x2apic_mode =3D false; =20 AcpiMultipleApicTable *madt; @@ -320,19 +345,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) =20 for (i =3D 0; i < apic_ids->len; i++) { uint32_t apic_id =3D apic_ids->cpus[i].arch_id; + int processor_id =3D i; if (apic_id < 255) { - AcpiMadtProcessorApic *apic =3D acpi_data_push(table_data, - sizeof *apic); - - apic->type =3D ACPI_APIC_PROCESSOR; - apic->length =3D sizeof(*apic); - apic->processor_id =3D i; - apic->local_apic_id =3D apic_id; - if (apic_ids->cpus[i].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + adevc->madt_sub[ACPI_APIC_PROCESSOR](table_data, &processor_id= ); } else { AcpiMadtProcessorX2Apic *apic =3D 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, voi= d *data) hc->unplug =3D ich9_pm_device_unplug_cb; adevc->ospm_status =3D ich9_pm_ospm_status; adevc->send_event =3D ich9_send_gpe; + adevc->madt_sub =3D i386_madt_sub; } =20 static const TypeInfo ich9_lpc_info =3D { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_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 @@ =20 #include "qom/object.h" #include "hw/boards.h" +#include "hw/acpi/acpi-defs.h" =20 /* These values are part of guest ABI, and can not be changed */ typedef enum { @@ -29,6 +30,9 @@ typedef struct AcpiDeviceIf AcpiDeviceIf; =20 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event); =20 +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, Memo= ryRegion *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; =20 /* e820 types */ #define E820_RAM 1 --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557728926; cv=none; d=zoho.com; s=zohoarc; b=D12gTeGo8g4/RzoegAd7iWZ+6wAvLyZphFH96lbXEMhPpS5+w/mmkOjYS2SOgBXQYR/i2aw84/MVQQUoBV+tpQi/mzRr8rgZtSx1gtZYNy3wsKIwdRvhtPeqiNSAr0zrONDEFR4N0zxTZebpT1O51c7hfR6x0BQWXflXrq0VFS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557728926; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QSaHGfpzsrZ/GaN1RZYw9aI1WaDzLcTXHg9FkA8dd6o=; b=GjDRcgVtgo6RcJrEFgWcmSTsCgbb1AEzD+TcaKiaZHwgb8ycAldyLVlsqgnL8J77H8fByd0BSnPMuDe59l7WIMVRzkbOdhVLUtfKGuh1P/tvhcQHGguTOFrumxl8DB19xvZA7mK9y50qjCKfjMPrUKCqmIf6Jy7N2ntPy2MR1sQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155772892659522.34464542637238; Sun, 12 May 2019 23:28:46 -0700 (PDT) Received: from localhost ([127.0.0.1]:51857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4S0-0001mc-Hb for importer@patchew.org; Mon, 13 May 2019 02:28:40 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 =3D acpi_data_push(madt_buf, - sizeof *api= c); - - apic->type =3D ACPI_APIC_LOCAL_X2APIC; - apic->length =3D sizeof(*apic); - apic->uid =3D cpu_to_le32(i); - apic->x2apic_id =3D cpu_to_le32(apic_id); - if (arch_ids->cpus[i].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D 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 *op= aque) } } =20 +static void pc_madt_x2apic_entry(GArray *entry, void *opaque) +{ + MachineState *machine =3D MACHINE(qdev_get_machine()); + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(machine); + int *processor_id =3D opaque; + AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(entry, sizeof *apic); + + apic->type =3D ACPI_APIC_LOCAL_X2APIC; + apic->length =3D sizeof(*apic); + apic->uid =3D cpu_to_le32(*processor_id); + apic->x2apic_id =3D cpu_to_le32(apic_ids->cpus[*processor_id].arch_id); + if (apic_ids->cpus[*processor_id].cpu !=3D NULL) { + apic->flags =3D cpu_to_le32(1); + } else { + apic->flags =3D cpu_to_le32(0); + } +} + madt_operations i386_madt_sub =3D { [ACPI_APIC_PROCESSOR] =3D pc_madt_apic_entry, + [ACPI_APIC_LOCAL_X2APIC] =3D pc_madt_x2apic_entry, }; =20 static void @@ -349,18 +369,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) if (apic_id < 255) { adevc->madt_sub[ACPI_APIC_PROCESSOR](table_data, &processor_id= ); } else { - AcpiMadtProcessorX2Apic *apic =3D acpi_data_push(table_data, - sizeof *apic); - - apic->type =3D ACPI_APIC_LOCAL_X2APIC; - apic->length =3D sizeof(*apic); - apic->uid =3D cpu_to_le32(i); - apic->x2apic_id =3D cpu_to_le32(apic_id); - if (apic_ids->cpus[i].cpu !=3D NULL) { - apic->flags =3D cpu_to_le32(1); - } else { - apic->flags =3D cpu_to_le32(0); - } + adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC](table_data, &processor= _id); } if (apic_id > 254) { x2apic_mode =3D true; --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557729749; cv=none; d=zoho.com; s=zohoarc; b=SRtclbMpdeR/t2TF7JFsm9N3mD03mvvmK6QqSjdJRQ9PaszRqs41nUmdboqcfNbZ+qjLsnLaQ86Uq2G56nsOXmqk/ANEbhWkwCLUd04cWdxwp42VdJzhGH6/zQMapN+54TQmiuBufmtOnQquUioEe3jTzUAc8pgOeb3wONrNbeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557729749; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KNYKENpp4v0m4RbPMAZpk4AKUjgeaL6Jud8kpykcKiY=; b=SoNXeUfYu8Z4u8JBn+LTuDiGSf8sKAJHCA0vuJU+owMMfeIfsdp2haTjVOqc52yWaJ+wTwLNEOtbRKPTxAseykEL1iPbY1RfqPJO46874QFY7JNQkvwOsCLpk3fbHdRyYu6JCcntWgQvJevuvs+woE6BMDCRTx47aL5lVasws3c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557729749443411.77908442513717; Sun, 12 May 2019 23:42:29 -0700 (PDT) Received: from localhost ([127.0.0.1]:52019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4fK-0007H8-HU for importer@patchew.org; Mon, 13 May 2019 02:42:26 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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) } } =20 +static void pc_madt_io_entry(GArray *entry, void *opaque) +{ + AcpiMadtIoApic *io_apic; + + io_apic =3D acpi_data_push(entry, sizeof *io_apic); + io_apic->type =3D ACPI_APIC_IO; + io_apic->length =3D sizeof(*io_apic); + io_apic->io_apic_id =3D ACPI_BUILD_IOAPIC_ID; + io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); + io_apic->interrupt =3D cpu_to_le32(0); +} + madt_operations i386_madt_sub =3D { [ACPI_APIC_PROCESSOR] =3D pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] =3D pc_madt_x2apic_entry, + [ACPI_APIC_IO] =3D pc_madt_io_entry, }; =20 static void @@ -355,7 +368,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMa= chineState *pcms) bool x2apic_mode =3D false; =20 AcpiMultipleApicTable *madt; - AcpiMadtIoApic *io_apic; AcpiMadtIntsrcovr *intsrcovr; int i; =20 @@ -376,12 +388,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) } } =20 - io_apic =3D acpi_data_push(table_data, sizeof *io_apic); - io_apic->type =3D ACPI_APIC_IO; - io_apic->length =3D sizeof(*io_apic); - io_apic->io_apic_id =3D ACPI_BUILD_IOAPIC_ID; - io_apic->address =3D cpu_to_le32(IO_APIC_DEFAULT_ADDRESS); - io_apic->interrupt =3D cpu_to_le32(0); + adevc->madt_sub[ACPI_APIC_IO](table_data, NULL); =20 if (pcms->apic_xrupt_override) { intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557729524; cv=none; d=zoho.com; s=zohoarc; b=a46LJutnkR3bMavmkJFzGqOyYbKSIhawGNCRhCAxL71VXxjYsSJcWv5/H/5H85qOD1Y1sYshVTfmFYtz0ss8Bcptz1XzvJtO9YLjZnyyuD2Nxwt4hXEBKphauOpsRzCBhdHw2ngOaJw+UofvrGl9nvsJetqacSe04jJ8erVySqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557729524; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=tCqoPJXz2XAn6bYJAxZhO3WTcU9T3xX3U+ETUTeZcus=; b=DKW8YeyqkxU4MXlJEwcp3Eo721SxGCLtGyc6H0mfNjcVrflbMZ33V40ftGpe/MyObj+9ndxlClBFfBP9QJU+pSFQuQTHRnM685nbmu8PHWxOGgQ4gLLtbt8VYQseupSC/Y636YZCUkaJT5/vrEDG19KS4zc+PHwsouz4efx+jF0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557729524547237.6778246465508; Sun, 12 May 2019 23:38:44 -0700 (PDT) Received: from localhost ([127.0.0.1]:51960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4bg-0004Du-Hu for importer@patchew.org; Mon, 13 May 2019 02:38:40 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 *opa= que) io_apic->interrupt =3D cpu_to_le32(0); } =20 +static void pc_madt_xrupt_override_entry(GArray *entry, void *opaque) +{ + AcpiMadtIntsrcovr *intsrcovr; + int *idx =3D opaque; + + intsrcovr =3D acpi_data_push(entry, sizeof *intsrcovr); + intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; + intsrcovr->length =3D sizeof(*intsrcovr); + intsrcovr->source =3D *idx; + if (*idx =3D=3D 0) { + intsrcovr->gsi =3D cpu_to_le32(2); + /* conforms to bus specifications */ + intsrcovr->flags =3D cpu_to_le16(0); + } else { + intsrcovr->gsi =3D cpu_to_le32(*idx); + /* active high, level triggered */ + intsrcovr->flags =3D cpu_to_le16(0xd); + } +} + madt_operations i386_madt_sub =3D { [ACPI_APIC_PROCESSOR] =3D pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] =3D pc_madt_x2apic_entry, [ACPI_APIC_IO] =3D pc_madt_io_entry, + [ACPI_APIC_XRUPT_OVERRIDE] =3D pc_madt_xrupt_override_entry, }; =20 static void @@ -368,7 +389,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMa= chineState *pcms) bool x2apic_mode =3D false; =20 AcpiMultipleApicTable *madt; - AcpiMadtIntsrcovr *intsrcovr; int i; =20 madt =3D acpi_data_push(table_data, sizeof *madt); @@ -391,12 +411,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) adevc->madt_sub[ACPI_APIC_IO](table_data, NULL); =20 if (pcms->apic_xrupt_override) { - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D 0; - intsrcovr->gsi =3D cpu_to_le32(2); - intsrcovr->flags =3D cpu_to_le16(0); /* conforms to bus specifica= tions */ + i =3D 0; + adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); } for (i =3D 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, PCM= achineState *pcms) /* No need for a INT source override structure. */ continue; } - intsrcovr =3D acpi_data_push(table_data, sizeof *intsrcovr); - intsrcovr->type =3D ACPI_APIC_XRUPT_OVERRIDE; - intsrcovr->length =3D sizeof(*intsrcovr); - intsrcovr->source =3D i; - intsrcovr->gsi =3D cpu_to_le32(i); - intsrcovr->flags =3D cpu_to_le16(0xd); /* active high, level trig= gered */ + adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); } =20 if (x2apic_mode) { --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557729642; cv=none; d=zoho.com; s=zohoarc; b=Nerm4YLwpJO3cjvOPt+DNYbFxoG2yx5xcx7rUeyRC+t0wzXEiYDGURovenoZ6VY49RQatxMiL0SP5poDCW6N0pZPtAUXwYp/Yk4pZXMTBJJchd1vERysRC6AGSpTL1OjBQdZKnVC9qvkjTxQogCz2kB5WoRy4QGc+3T6BZTAF44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557729642; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7Ood/cWrI5JqRPsrQyRgGDrdi2qHR0227zvq6G9Umxc=; b=YpF34fEOzJBNinOMJEzaUqyFjDLBjisRyfLeH+aHG2nWPs2AFk4I3k8XmoDsOyk+Dft2ZrTllUUs7pa8FiUtNDM9DqBKmj1ZI4fBDkE4RRrugkx8hOhDr7QpwlEvWh7nqdSDgGgWj/yBgTsd2kGik23XFm+4MC2K8zPiyvzeeWE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557729642921629.9486005950865; Sun, 12 May 2019 23:40:42 -0700 (PDT) Received: from localhost ([127.0.0.1]:52004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4db-0005jN-TL for importer@patchew.org; Mon, 13 May 2019 02:40:39 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 *entr= y, void *opaque) } } =20 +static void pc_madt_x2apic_nmi_entry(GArray *entry, void *opaque) +{ + AcpiMadtLocalX2ApicNmi *local_nmi; + + local_nmi =3D acpi_data_push(entry, sizeof *local_nmi); + local_nmi->type =3D ACPI_APIC_LOCAL_X2APIC_NMI; + local_nmi->length =3D sizeof(*local_nmi); + local_nmi->uid =3D 0xFFFFFFFF; /* all processors */ + local_nmi->flags =3D cpu_to_le16(0); + local_nmi->lint =3D 1; /* ACPI_LINT1 */ +} + madt_operations i386_madt_sub =3D { [ACPI_APIC_PROCESSOR] =3D pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] =3D pc_madt_x2apic_entry, [ACPI_APIC_IO] =3D pc_madt_io_entry, [ACPI_APIC_XRUPT_OVERRIDE] =3D pc_madt_xrupt_override_entry, + [ACPI_APIC_LOCAL_X2APIC_NMI] =3D pc_madt_x2apic_nmi_entry, }; =20 static void @@ -424,14 +437,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) } =20 if (x2apic_mode) { - AcpiMadtLocalX2ApicNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_X2APIC_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->uid =3D 0xFFFFFFFF; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ + adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI](table_data, NULL); } else { AcpiMadtLocalNmi *local_nmi; =20 --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557729730; cv=none; d=zoho.com; s=zohoarc; b=WTEMKQtp8WGuIP0uOC9AgwhfKnDJLDhKJeVus+UXTmoTpsUp3wHlIczPnqiJfKyhrF4QPatK4miEJvlHAV+L/x6yXFOFzB73tg1P6tGEDK3pKSfxqYoPVA6tMQyfC3kfHBCVR4YBnJ/EoaWS3S5JpG70Gq6PyHXHp9KI98QgGYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557729730; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NfRGaWb1ViUJgOPGKGbMHZmPvRfkdIGPZVHY8coNm/4=; b=maBDUDd3XJAWRBnLSVgkWM1FMDplLKOobsFcg2CFCkulQzSb1KG7b4cZ4MKJIyjNnTpZrMQr1oxDkhfsvC7bVxrs87pZHpZ6vh7YKfFdXjAeQXtwWmnwAa6yPUDGEFFItnb3Mrrkx//+WsOjA3p4fNrlfSTsMSS0+BGv56/Z0/c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557729730961448.68239279813224; Sun, 12 May 2019 23:42:10 -0700 (PDT) Received: from localhost ([127.0.0.1]:52017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4f1-0006xo-0s for importer@patchew.org; Mon, 13 May 2019 02:42:07 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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, v= oid *opaque) local_nmi->lint =3D 1; /* ACPI_LINT1 */ } =20 +static void pc_madt_nmi_entry(GArray *entry, void *opaque) +{ + AcpiMadtLocalNmi *local_nmi; + + local_nmi =3D acpi_data_push(entry, sizeof *local_nmi); + local_nmi->type =3D ACPI_APIC_LOCAL_NMI; + local_nmi->length =3D sizeof(*local_nmi); + local_nmi->processor_id =3D 0xff; /* all processors */ + local_nmi->flags =3D cpu_to_le16(0); + local_nmi->lint =3D 1; /* ACPI_LINT1 */ +} + madt_operations i386_madt_sub =3D { [ACPI_APIC_PROCESSOR] =3D pc_madt_apic_entry, [ACPI_APIC_LOCAL_X2APIC] =3D pc_madt_x2apic_entry, [ACPI_APIC_IO] =3D pc_madt_io_entry, [ACPI_APIC_XRUPT_OVERRIDE] =3D pc_madt_xrupt_override_entry, [ACPI_APIC_LOCAL_X2APIC_NMI] =3D pc_madt_x2apic_nmi_entry, + [ACPI_APIC_LOCAL_NMI] =3D pc_madt_nmi_entry, }; =20 static void @@ -439,14 +452,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) if (x2apic_mode) { adevc->madt_sub[ACPI_APIC_LOCAL_X2APIC_NMI](table_data, NULL); } else { - AcpiMadtLocalNmi *local_nmi; - - local_nmi =3D acpi_data_push(table_data, sizeof *local_nmi); - local_nmi->type =3D ACPI_APIC_LOCAL_NMI; - local_nmi->length =3D sizeof(*local_nmi); - local_nmi->processor_id =3D 0xff; /* all processors */ - local_nmi->flags =3D cpu_to_le16(0); - local_nmi->lint =3D 1; /* ACPI_LINT1 */ + adevc->madt_sub[ACPI_APIC_LOCAL_NMI](table_data, NULL); } =20 build_header(linker, table_data, --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557729522; cv=none; d=zoho.com; s=zohoarc; b=fjvbGoH/nBWXq621JFuzAWQdSZcJf4Npry/CzmaGMh3d92EvEQW0ftROHOhPtKW/A+O4AE2XKzctq98YTkvknl1wejGHsOSNmhUU/PKWQAULPvPkSCKbRuajqEAVhF7HidTDMKMKaOTUtZntIWphNImRtmgdYBO4N87VhjGKdXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557729522; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dumnOo66lpib9llY0+XcEazfkmJGPSii/W+Z5VQkR2c=; b=m8qkqKhv6A/z25PafnePZXpnIYLP6pSXK2s0q0h91E95XfIbY75woom0SrOz/wmwj6pjoxeY66zhUvdPLt99zDlNyqW3Vx3q+S1vAxsM8PxRghf5gkaKhdJm2l0x4OPWxtaN7Mffy2aWdkYlTxlqcZfOOmjmkx6D+/QFoqvnzWk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557729522681985.4567226088708; Sun, 12 May 2019 23:38:42 -0700 (PDT) Received: from localhost ([127.0.0.1]:51958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4bf-0004CK-G6 for importer@patchew.org; Mon, 13 May 2019 02:38:39 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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 *hol= e64) NULL)); } =20 +struct madt_input { + int sub_id; + void *opaque; +}; + +int xrupt_override_idx[] =3D {0, 5, 9, 10, 11}; +static struct madt_input * +acpi_get_madt_input(PCMachineState *pcms, int *processor_id) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(pcms); + const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); + int i, sub_heads =3D 0; + uint32_t apic_id; + struct madt_input *input =3D NULL; + + sub_heads =3D apic_ids->len /* PROCESSOR/X2APIC */ + + 1 /* APIC_IO */ + + ARRAY_SIZE(xrupt_override_idx) /* XRUPT_OVERRIDE */ + + 1 /* NMI/X2APIC_NMI */ + + 1; /* END MARK */ + input =3D g_new0(struct madt_input, sub_heads); + for (i =3D 0, sub_heads =3D 0; i < apic_ids->len; i++, sub_heads++) { + apic_id =3D apic_ids->cpus[i].arch_id; + if (apic_id < 255) { + input[sub_heads].sub_id =3D ACPI_APIC_PROCESSOR; + } else { + input[sub_heads].sub_id =3D ACPI_APIC_LOCAL_X2APIC; + } + input[sub_heads].opaque =3D processor_id; + } + input[sub_heads++].sub_id =3D ACPI_APIC_IO; + for (i =3D 0; i < ARRAY_SIZE(xrupt_override_idx); i++, sub_heads++) { + if (i =3D=3D 0 && !pcms->apic_xrupt_override) { + continue; + } + input[sub_heads].sub_id =3D ACPI_APIC_XRUPT_OVERRIDE; + input[sub_heads].opaque =3D &xrupt_override_idx[i]; + } + if (apic_id > 254) { + input[sub_heads++].sub_id =3D ACPI_APIC_LOCAL_X2APIC_NMI; + } else { + input[sub_heads++].sub_id =3D ACPI_APIC_LOCAL_NMI; + } + input[sub_heads].sub_id =3D 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 *opa= que) } else { apic->flags =3D cpu_to_le32(0); } + (*processor_id)++; } =20 static void pc_madt_x2apic_entry(GArray *entry, void *opaque) @@ -337,6 +386,7 @@ static void pc_madt_x2apic_entry(GArray *entry, void *o= paque) } else { apic->flags =3D cpu_to_le32(0); } + (*processor_id)++; } =20 static void pc_madt_io_entry(GArray *entry, void *opaque) @@ -405,54 +455,27 @@ madt_operations i386_madt_sub =3D { }; =20 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 =3D MACHINE_GET_CLASS(pcms); - const CPUArchIdList *apic_ids =3D mc->possible_cpu_arch_ids(MACHINE(pc= ms)); int madt_start =3D table_data->len; AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev); =20 - bool x2apic_mode =3D false; - AcpiMultipleApicTable *madt; - int i; + int i, sub_id; + void *opaque; =20 madt =3D acpi_data_push(table_data, sizeof *madt); madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); madt->flags =3D cpu_to_le32(1); =20 - for (i =3D 0; i < apic_ids->len; i++) { - uint32_t apic_id =3D apic_ids->cpus[i].arch_id; - int processor_id =3D 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 =3D 0; ; i++) { + sub_id =3D input[i].sub_id; + if (sub_id =3D=3D ACPI_APIC_RESERVED) { + break; } - if (apic_id > 254) { - x2apic_mode =3D true; - } - } - - adevc->madt_sub[ACPI_APIC_IO](table_data, NULL); - - if (pcms->apic_xrupt_override) { - i =3D 0; - adevc->madt_sub[ACPI_APIC_XRUPT_OVERRIDE](table_data, &i); - } - for (i =3D 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 =3D input[i].opaque; + adevc->madt_sub[sub_id](table_data, opaque); } =20 build_header(linker, table_data, @@ -2627,6 +2650,8 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) GArray *tables_blob =3D tables->table_data; AcpiSlicOem slic_oem =3D { .id =3D NULL, .table_id =3D NULL }; Object *vmgenid_dev; + struct madt_input *input =3D NULL; + int processor_id =3D 0; =20 acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); @@ -2671,7 +2696,9 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) aml_len +=3D tables_blob->len - fadt; =20 acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, pcms); + input =3D acpi_get_madt_input(pcms, &processor_id); + build_madt(tables_blob, tables->linker, pcms, input); + g_free(input); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { --=20 2.19.1 From nobody Mon May 6 18:54:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1557729621; cv=none; d=zoho.com; s=zohoarc; b=SRmRgogpJkgstrSRo/dPX/CCQ0WjwP3R0v1YC5ImQ+p4KNndES5fCQJ7fP7IuQK68nYdqj13jyIF0741d5No4Pq5uDv0u/j84QLZoifay6I9SG+gMxU2ZvgOBUigKQdts2KXs1kA/c7irttl0w2c7WTjnbUlYl+btJ8Zh55N8UI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557729621; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=O2w6EQFCGsHGYVb53oaz/B0bG5/xjAysObvJSA0BnUE=; b=AKZR0hUjaWL7PQrypHYKJsZoIfp2VqGXV7Je2Weu8GlfKKYd4AlpVVMKLkz66oQhsg8t8wtBiFnclGfULkzhTbkvADt5tRbZYFuDyQp0KXQDXLwSIQIkyTA8HN14mkgxzDOiPWYaJAqcyefgaMCKIPDGSXGwIjF5zrbwHTKTtlA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557729621316601.8050751805027; Sun, 12 May 2019 23:40:21 -0700 (PDT) Received: from localhost ([127.0.0.1]:51972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQ4dG-0005Q8-DM for importer@patchew.org; Mon, 13 May 2019 02:40:18 -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 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 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 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 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 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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, voi= d *data) adevc->ospm_status =3D piix4_ospm_status; adevc->send_event =3D piix4_send_gpe; adevc->madt_sub =3D i386_madt_sub; + adevc->madt_main =3D i386_madt_main; } =20 static const TypeInfo piix4_pm_info =3D { 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 =3D { [ACPI_APIC_LOCAL_NMI] =3D pc_madt_nmi_entry, }; =20 +void i386_madt_main(GArray *entry, void *opaque) +{ + AcpiMultipleApicTable *madt =3D opaque; + + madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); + madt->flags =3D 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, PCMa= chineState *pcms, void *opaque; =20 madt =3D acpi_data_push(table_data, sizeof *madt); - madt->local_apic_address =3D cpu_to_le32(APIC_DEFAULT_ADDRESS); - madt->flags =3D cpu_to_le32(1); + if (adevc->madt_main) { + adevc->madt_main(table_data, madt); + } =20 for (i =3D 0; ; i++) { sub_id =3D 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, voi= d *data) adevc->ospm_status =3D ich9_pm_ospm_status; adevc->send_event =3D ich9_send_gpe; adevc->madt_sub =3D i386_madt_sub; + adevc->madt_main =3D i386_madt_main; } =20 static const TypeInfo ich9_lpc_info =3D { diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_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, Memo= ryRegion *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); =20 /* e820 types */ #define E820_RAM 1 --=20 2.19.1