From nobody Tue Nov 4 19:05:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530708711700735.145137524299; Wed, 4 Jul 2018 05:51:51 -0700 (PDT) Received: from localhost ([::1]:46918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahG5-0000PO-L3 for importer@patchew.org; Wed, 04 Jul 2018 08:51:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahDy-0007SZ-Iw for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahDx-0000UC-Qx for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55422 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahDr-0000Rw-Ut; Wed, 04 Jul 2018 08:49:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6250581A4EA9; Wed, 4 Jul 2018 12:49:27 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37D622156889; Wed, 4 Jul 2018 12:49:26 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 4 Jul 2018 14:49:18 +0200 Message-Id: <20180704124923.32483-2-drjones@redhat.com> In-Reply-To: <20180704124923.32483-1-drjones@redhat.com> References: <20180704124923.32483-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 04 Jul 2018 12:49:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 04 Jul 2018 12:49:27 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 1/6] hw/arm/virt: Add virt-3.1 machine type 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: wei@redhat.com, peter.maydell@linaro.org, eric.auger@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Andrew Jones Reviewed-by: Igor Mammedov --- hw/arm/virt.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 281ddcdf6e26..880441275031 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1757,10 +1757,7 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); =20 -#define VIRT_COMPAT_2_12 \ - HW_COMPAT_2_12 - -static void virt_3_0_instance_init(Object *obj) +static void virt_3_1_instance_init(Object *obj) { VirtMachineState *vms =3D VIRT_MACHINE(obj); VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); @@ -1830,10 +1827,24 @@ static void virt_3_0_instance_init(Object *obj) vms->irqmap =3D a15irqmap; } =20 +static void virt_machine_3_1_options(MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(3, 1) + +static void virt_3_0_instance_init(Object *obj) +{ + virt_3_1_instance_init(obj); +} + static void virt_machine_3_0_options(MachineClass *mc) { + virt_machine_3_1_options(mc); } -DEFINE_VIRT_MACHINE_AS_LATEST(3, 0) +DEFINE_VIRT_MACHINE(3, 0) + +#define VIRT_COMPAT_2_12 \ + HW_COMPAT_2_12 =20 static void virt_2_12_instance_init(Object *obj) { --=20 2.17.1 From nobody Tue Nov 4 19:05:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153070873832733.171267895814935; Wed, 4 Jul 2018 05:52:18 -0700 (PDT) Received: from localhost ([::1]:46921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahGb-0000sF-IW for importer@patchew.org; Wed, 04 Jul 2018 08:52:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahDz-0007Te-Eu for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahDy-0000Ub-IK for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56974 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahDu-0000Sn-Gc; Wed, 04 Jul 2018 08:49:30 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED1F6407563E; Wed, 4 Jul 2018 12:49:29 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96E6A2156889; Wed, 4 Jul 2018 12:49:27 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 4 Jul 2018 14:49:19 +0200 Message-Id: <20180704124923.32483-3-drjones@redhat.com> In-Reply-To: <20180704124923.32483-1-drjones@redhat.com> References: <20180704124923.32483-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 04 Jul 2018 12:49:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 04 Jul 2018 12:49:30 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 2/6] device_tree: add qemu_fdt_add_path 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: wei@redhat.com, peter.maydell@linaro.org, Peter Crosthwaite , Alexander Graf , eric.auger@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qemu_fdt_add_path works like qemu_fdt_add_subnode, except it also recursively adds any missing parent nodes. Cc: Peter Crosthwaite Cc: Alexander Graf Signed-off-by: Andrew Jones --- device_tree.c | 24 ++++++++++++++++++++++++ include/sysemu/device_tree.h | 1 + 2 files changed, 25 insertions(+) diff --git a/device_tree.c b/device_tree.c index 6d9c9726f66c..ad570a4dbe3a 100644 --- a/device_tree.c +++ b/device_tree.c @@ -520,6 +520,30 @@ int qemu_fdt_add_subnode(void *fdt, const char *name) return retval; } =20 +int qemu_fdt_add_path(void *fdt, const char *path) +{ + char *parent; + int offset; + + offset =3D fdt_path_offset(fdt, path); + if (offset < 0 && offset !=3D -FDT_ERR_NOTFOUND) { + error_report("%s Couldn't find node %s: %s", __func__, path, + fdt_strerror(offset)); + exit(1); + } + + if (offset !=3D -FDT_ERR_NOTFOUND) { + return offset; + } + + parent =3D g_strdup(path); + strrchr(parent, '/')[0] =3D '\0'; + qemu_fdt_add_path(fdt, parent); + g_free(parent); + + return qemu_fdt_add_subnode(fdt, path); +} + void qemu_fdt_dumpdtb(void *fdt, int size) { const char *dumpdtb =3D qemu_opt_get(qemu_get_machine_opts(), "dumpdtb= "); diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index c16fd69bc0b1..d62fc873a3ea 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -101,6 +101,7 @@ uint32_t qemu_fdt_get_phandle(void *fdt, const char *pa= th); uint32_t qemu_fdt_alloc_phandle(void *fdt); int qemu_fdt_nop_node(void *fdt, const char *node_path); int qemu_fdt_add_subnode(void *fdt, const char *name); +int qemu_fdt_add_path(void *fdt, const char *path); =20 #define qemu_fdt_setprop_cells(fdt, node_path, property, ...) = \ do { = \ --=20 2.17.1 From nobody Tue Nov 4 19:05:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530708909703177.0441753126537; Wed, 4 Jul 2018 05:55:09 -0700 (PDT) Received: from localhost ([::1]:46938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahJN-0003Dn-2t for importer@patchew.org; Wed, 04 Jul 2018 08:55:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahDz-0007U6-Nw for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahDy-0000Uk-K5 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40638 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahDv-0000TS-S3; Wed, 04 Jul 2018 08:49:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 57A864075740; Wed, 4 Jul 2018 12:49:31 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F2232156889; Wed, 4 Jul 2018 12:49:30 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 4 Jul 2018 14:49:20 +0200 Message-Id: <20180704124923.32483-4-drjones@redhat.com> In-Reply-To: <20180704124923.32483-1-drjones@redhat.com> References: <20180704124923.32483-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 04 Jul 2018 12:49:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 04 Jul 2018 12:49:31 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 3/6] hw/arm/virt: DT: add cpu-map 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: wei@redhat.com, peter.maydell@linaro.org, eric.auger@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Support devicetree CPU topology descriptions. Signed-off-by: Andrew Jones --- hw/arm/virt.c | 35 +++++++++++++++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 2 files changed, 36 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 880441275031..6c5fecdd61df 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -40,6 +40,7 @@ #include "hw/devices.h" #include "net/net.h" #include "sysemu/device_tree.h" +#include "sysemu/cpus.h" #include "sysemu/numa.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" @@ -302,6 +303,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) int cpu; int addr_cells =3D 1; const MachineState *ms =3D MACHINE(vms); + VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); =20 /* * From Documentation/devicetree/bindings/arm/cpus.txt @@ -358,8 +360,38 @@ static void fdt_add_cpu_nodes(const VirtMachineState *= vms) ms->possible_cpus->cpus[cs->cpu_index].props.node_id); } =20 + qemu_fdt_setprop_cell(vms->fdt, nodename, "phandle", + qemu_fdt_alloc_phandle(vms->fdt)); g_free(nodename); } + + if (!vmc->ignore_cpu_topology) { + /* From Documentation/devicetree/bindings/arm/topology.txt + */ + qemu_fdt_add_subnode(vms->fdt, "/cpus/cpu-map"); + + for (cpu =3D vms->smp_cpus - 1; cpu >=3D 0; cpu--) { + char *cpu_path =3D g_strdup_printf("/cpus/cpu@%d", cpu); + char *map_path; + + if (smp_threads > 1) { + map_path =3D g_strdup_printf( + "/cpus/cpu-map/%s%d/%s%d/%s%d", + "cluster", cpu / (smp_cores * smp_threads), + "core", (cpu / smp_threads) % smp_cores, + "thread", cpu % smp_threads); + } else { + map_path =3D g_strdup_printf( + "/cpus/cpu-map/%s%d/%s%d", + "cluster", cpu / smp_cores, + "core", cpu % smp_cores); + } + qemu_fdt_add_path(vms->fdt, map_path); + qemu_fdt_setprop_phandle(vms->fdt, map_path, "cpu", cpu_path); + g_free(map_path); + g_free(cpu_path); + } + } } =20 static void fdt_add_its_gic_node(VirtMachineState *vms) @@ -1839,7 +1871,10 @@ static void virt_3_0_instance_init(Object *obj) =20 static void virt_machine_3_0_options(MachineClass *mc) { + VirtMachineClass *vmc =3D VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_3_1_options(mc); + vmc->ignore_cpu_topology =3D true; } DEFINE_VIRT_MACHINE(3, 0) =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 9a870ccb6a57..deb8bee72cda 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -94,6 +94,7 @@ typedef struct MemMapEntry { typedef struct { MachineClass parent; bool disallow_affinity_adjustment; + bool ignore_cpu_topology; bool no_its; bool no_pmu; bool claim_edge_triggered_timers; --=20 2.17.1 From nobody Tue Nov 4 19:05:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530708924121549.1682986382083; Wed, 4 Jul 2018 05:55:24 -0700 (PDT) Received: from localhost ([::1]:46939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahJb-0003Tf-D0 for importer@patchew.org; Wed, 04 Jul 2018 08:55:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahE0-0007Vq-P8 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahDz-0000VO-Op for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40778 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahDx-0000Tm-8y; Wed, 04 Jul 2018 08:49:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0F3F401DEA8; Wed, 4 Jul 2018 12:49:32 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E5882156889; Wed, 4 Jul 2018 12:49:31 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 4 Jul 2018 14:49:21 +0200 Message-Id: <20180704124923.32483-5-drjones@redhat.com> In-Reply-To: <20180704124923.32483-1-drjones@redhat.com> References: <20180704124923.32483-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 04 Jul 2018 12:49:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 04 Jul 2018 12:49:32 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 4/6] hw/arm/virt-acpi-build: distinguish possible and present cpus 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: wei@redhat.com, peter.maydell@linaro.org, eric.auger@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When building ACPI tables regarding CPUs we should always build them for the number of possible CPUs, not the number of present CPUs. We then ensure only the present CPUs are enabled. Signed-off-by: Andrew Jones --- hw/arm/virt-acpi-build.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 6ea47e258832..1d1fc824da6f 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -49,14 +49,22 @@ #define ARM_SPI_BASE 32 #define ACPI_POWER_BUTTON_DEVICE "PWRB" =20 -static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) +static int possible_cpus(VirtMachineState *vms) +{ + return MACHINE_GET_CLASS(vms)->possible_cpu_arch_ids(MACHINE(vms))->le= n; +} + +static void acpi_dsdt_add_cpus(Aml *scope, int possible, int present) { uint16_t i; =20 - for (i =3D 0; i < smp_cpus; i++) { + for (i =3D 0; i < possible; i++) { Aml *dev =3D aml_device("C%.03X", i); aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007"))); aml_append(dev, aml_name_decl("_UID", aml_int(i))); + if (i >=3D present) { + aml_append(dev, aml_name_decl("_STA", aml_int(0))); + } aml_append(scope, dev); } } @@ -650,7 +658,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) gicd->base_address =3D cpu_to_le64(memmap[VIRT_GIC_DIST].base); gicd->version =3D vms->gic_version; =20 - for (i =3D 0; i < vms->smp_cpus; i++) { + for (i =3D 0; i < possible_cpus(vms); i++) { AcpiMadtGenericCpuInterface *gicc =3D acpi_data_push(table_data, sizeof(*gicc)); ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(i)); @@ -663,7 +671,9 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) gicc->cpu_interface_number =3D cpu_to_le32(i); gicc->arm_mpidr =3D cpu_to_le64(armcpu->mp_affinity); gicc->uid =3D cpu_to_le32(i); - gicc->flags =3D cpu_to_le32(ACPI_MADT_GICC_ENABLED); + if (i < vms->smp_cpus) { + gicc->flags =3D cpu_to_le32(ACPI_MADT_GICC_ENABLED); + } =20 if (arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { gicc->performance_interrupt =3D cpu_to_le32(PPI(VIRTUAL_PMU_IR= Q)); @@ -763,7 +773,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) * the RTC ACPI device at all when using UEFI. */ scope =3D aml_scope("\\_SB"); - acpi_dsdt_add_cpus(scope, vms->smp_cpus); + acpi_dsdt_add_cpus(scope, possible_cpus(vms), vms->smp_cpus); acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], (irqmap[VIRT_UART] + ARM_SPI_BASE)); acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]); --=20 2.17.1 From nobody Tue Nov 4 19:05:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530708718594214.54673724169356; Wed, 4 Jul 2018 05:51:58 -0700 (PDT) Received: from localhost ([::1]:46919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahGH-0000as-Oy for importer@patchew.org; Wed, 04 Jul 2018 08:51:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahE5-0007bG-0O for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahE3-0000YQ-Kp for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40784 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahDy-0000Uh-Qf; Wed, 04 Jul 2018 08:49:34 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B88E401DEA8; Wed, 4 Jul 2018 12:49:34 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id E85D52156889; Wed, 4 Jul 2018 12:49:32 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 4 Jul 2018 14:49:22 +0200 Message-Id: <20180704124923.32483-6-drjones@redhat.com> In-Reply-To: <20180704124923.32483-1-drjones@redhat.com> References: <20180704124923.32483-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 04 Jul 2018 12:49:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 04 Jul 2018 12:49:34 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 5/6] virt-acpi-build: add PPTT 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: wei@redhat.com, peter.maydell@linaro.org, "Michael S. Tsirkin" , eric.auger@redhat.com, Shannon Zhao , imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ACPI PPTT table supports topology descriptions for ACPI guests. Note, while a DT boot Linux guest with a non-flat CPU topology will see socket and core IDs being sequential integers starting from zero, e.g. with -smp 4,sockets=3D2,cores=3D2,threads=3D1 a DT boot produces cpu: 0 package_id: 0 core_id: 0 cpu: 1 package_id: 0 core_id: 1 cpu: 2 package_id: 1 core_id: 0 cpu: 3 package_id: 1 core_id: 1 an ACPI boot produces cpu: 0 package_id: 36 core_id: 0 cpu: 1 package_id: 36 core_id: 1 cpu: 2 package_id: 96 core_id: 2 cpu: 3 package_id: 96 core_id: 3 This is due to several reasons: 1) DT cpu nodes do not have an equivalent field to what the PPTT ACPI Processor ID must be, i.e. something equal to the MADT CPU UID or equal to the UID of an ACPI processor container. In both ACPI cases those are platform dependant IDs assigned by the vendor. 2) While QEMU is the vendor for a guest, if the topology specifies SMT (> 1 thread), then, with ACPI, it is impossible to assign a core-id the same value as a package-id, thus it is not possible to have package-id=3D0 and core-id=3D0. This is because package and core containers must be in the same ACPI namespace and therefore must have unique UIDs. 3) ACPI processor containers are not required for PPTT tables to be used and, due to the limitations of which IDs are selected described above in (2), they are not helpful for QEMU, so we don't build them with this patch. In the absence of them, Linux assigns its own unique IDs. The maintainers have chosen not to use counters from zero, but rather ACPI table offsets, which explains why the numbers are so much larger than with DT. 4) When there is no SMT (threads=3D1) the core IDs for ACPI boot guests match the logical CPU IDs, because these IDs must be equal to the MADT CPU UID (as no processor containers are present), and QEMU uses the logical CPU ID for these MADT IDs. Cc: Igor Mammedov Cc: Shannon Zhao Cc: "Michael S. Tsirkin" Signed-off-by: Andrew Jones --- hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 5 ++++ include/hw/acpi/aml-build.h | 2 ++ 3 files changed, 57 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 1e43cd736de9..37e8f5182ae9 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -24,6 +24,7 @@ #include "hw/acpi/aml-build.h" #include "qemu/bswap.h" #include "qemu/bitops.h" +#include "sysemu/cpus.h" #include "sysemu/numa.h" =20 static GArray *build_alloc_array(void) @@ -1679,6 +1680,55 @@ void build_slit(GArray *table_data, BIOSLinker *link= er) table_data->len - slit_start, 1, NULL, NULL); } =20 +/* + * ACPI 6.2 Processor Properties Topology Table (PPTT) + */ +static void build_cpu_hierarchy(GArray *tbl, uint32_t flags, + uint32_t parent, uint32_t id) +{ + build_append_byte(tbl, 0); /* Type 0 - processor */ + build_append_byte(tbl, 20); /* Length, no private resources */ + build_append_int_noprefix(tbl, 0, 2); /* Reserved */ + build_append_int_noprefix(tbl, flags, 4); + build_append_int_noprefix(tbl, parent, 4); + build_append_int_noprefix(tbl, id, 4); + build_append_int_noprefix(tbl, 0, 4); /* Num private resources */ +} + +void build_pptt(GArray *table_data, BIOSLinker *linker, int possible_cpus) +{ + int pptt_start =3D table_data->len; + int uid =3D 0, cpus =3D 0, socket; + + acpi_data_push(table_data, sizeof(AcpiTableHeader)); + + for (socket =3D 0; cpus < possible_cpus; socket++) { + uint32_t socket_offset =3D table_data->len - pptt_start; + int core; + + build_cpu_hierarchy(table_data, 1, 0, socket); + + for (core =3D 0; core < smp_cores; core++) { + uint32_t core_offset =3D table_data->len - pptt_start; + int thread; + + if (smp_threads > 1) { + build_cpu_hierarchy(table_data, 0, socket_offset, core); + for (thread =3D 0; thread < smp_threads; thread++) { + build_cpu_hierarchy(table_data, 2, core_offset, uid++); + } + } else { + build_cpu_hierarchy(table_data, 2, socket_offset, uid++); + } + } + cpus +=3D smp_cores * smp_threads; + } + + build_header(linker, table_data, + (void *)(table_data->data + pptt_start), "PPTT", + table_data->len - pptt_start, 1, NULL, NULL); +} + /* build rev1/rev3/rev5.1 FADT */ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, const char *oem_id, const char *oem_table_id) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 1d1fc824da6f..aa77e1f018d9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -832,6 +832,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildT= ables *tables) acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, vms); =20 + if (!vmc->ignore_cpu_topology) { + acpi_add_table(table_offsets, tables_blob); + build_pptt(tables_blob, tables->linker, possible_cpus(vms)); + } + acpi_add_table(table_offsets, tables_blob); build_gtdt(tables_blob, tables->linker, vms); =20 diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6c36903c0a5d..2b0fde6bd417 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -414,6 +414,8 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem,= uint64_t base, =20 void build_slit(GArray *table_data, BIOSLinker *linker); =20 +void build_pptt(GArray *table_data, BIOSLinker *linker, int possible_cpus); + void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, const char *oem_id, const char *oem_table_id); #endif --=20 2.17.1 From nobody Tue Nov 4 19:05:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530708891125143.97693693204565; Wed, 4 Jul 2018 05:54:51 -0700 (PDT) Received: from localhost ([::1]:46936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahJ4-0002uW-AI for importer@patchew.org; Wed, 04 Jul 2018 08:54:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fahE5-0007bx-FN for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fahE4-0000ZI-LX for qemu-devel@nongnu.org; Wed, 04 Jul 2018 08:49:41 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40644 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fahE0-0000VY-7J; Wed, 04 Jul 2018 08:49:36 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B91C74067720; Wed, 4 Jul 2018 12:49:35 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91E212156889; Wed, 4 Jul 2018 12:49:34 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 4 Jul 2018 14:49:23 +0200 Message-Id: <20180704124923.32483-7-drjones@redhat.com> In-Reply-To: <20180704124923.32483-1-drjones@redhat.com> References: <20180704124923.32483-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 04 Jul 2018 12:49:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 04 Jul 2018 12:49:35 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'drjones@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 6/6] hw/arm/virt: cpu topology: don't allow threads 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: wei@redhat.com, peter.maydell@linaro.org, eric.auger@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" None of the cpu models supported by mach-virt support threads. Furthermore when running with KVM and cpu=3Dhost, while the host processor may support threads, we don't yet support telling KVM that we want the guest to see that. So if the user tries to select more than one thread for the cpu topology, just error-out. We'll remove the restriction for KVM guests after adding support to KVM and QEMU for userspace controlled VCPU MPIDRs. Signed-off-by: Andrew Jones --- hw/arm/virt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6c5fecdd61df..8fc2751ab4bb 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1390,6 +1390,19 @@ static void machvirt_init(MachineState *machine) exit(1); } =20 + if (!vmc->ignore_cpu_topology && smp_threads > 1) { + if (kvm_enabled() && + strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("host")) =3D=3D 0)= { + error_report("mach-virt: KVM: user controlled MPIDR.MT not " + "yet supported"); + } else { + error_report("mach-virt: CPU type %s does not support SMT", + machine->cpu_type); + } + error_report("mach-virt: smp_threads cannot be > 1"); + exit(1); + } + /* If we have an EL3 boot ROM then the assumption is that it will * implement PSCI itself, so disable QEMU's internal implementation * so it doesn't get in the way. Instead of starting secondary --=20 2.17.1