From: Fabiano Rosas <farosas@suse.de>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Tyrone Ting" <kfting@nuvoton.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Joel Stanley" <joel@jms.id.au>,
"Alistair Francis" <alistair@alistair23.me>,
"Anton Johansson" <anjo@rev.ng>,
"Andrey Smirnov" <andrew.smirnov@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Hao Wu" <wuhaotsh@google.com>, "Cédric Le Goater" <clg@kaod.org>,
"Jean-Christophe Dubois" <jcd@tribudubois.net>,
"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Andrew Jeffery" <andrew@codeconstruct.com.au>,
"Rob Herring" <robh@kernel.org>,
qemu-arm@nongnu.org,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH 14/33] hw/cpu/arm: Handle 'has_el2/3' properties once in MPCore parent
Date: Fri, 12 Jan 2024 18:33:13 -0300 [thread overview]
Message-ID: <87y1cudyp2.fsf@suse.de> (raw)
In-Reply-To: <20231212162935.42910-15-philmd@linaro.org>
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Move the 'has_el2' and 'has_el3' properties to the abstract
> QOM parent.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/hw/cpu/cortex_mpcore.h | 5 +++++
> hw/arm/exynos4210.c | 10 ++++++++--
> hw/arm/vexpress.c | 6 ++++++
> hw/arm/xilinx_zynq.c | 6 ++++++
> hw/cpu/a15mpcore.c | 18 ++++++------------
> hw/cpu/a9mpcore.c | 5 +----
> hw/cpu/cortex_mpcore.c | 3 +++
> 7 files changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/include/hw/cpu/cortex_mpcore.h b/include/hw/cpu/cortex_mpcore.h
> index 0e7cca9e93..387552468c 100644
> --- a/include/hw/cpu/cortex_mpcore.h
> +++ b/include/hw/cpu/cortex_mpcore.h
> @@ -30,6 +30,8 @@
> * QEMU interface:
> * + QOM property "num-cores" which set the number of cores present in
> * the cluster.
> + * + QOM properties "cpu-has-el3", "cpu-has-el2" which set whether the CPUs
> + * have the exception level features present.
> */
> #define TYPE_CORTEX_MPCORE_PRIV "cortex_mpcore_priv"
> OBJECT_DECLARE_TYPE(CortexMPPrivState, CortexMPPrivClass, CORTEX_MPCORE_PRIV)
> @@ -53,6 +55,9 @@ struct CortexMPPrivState {
>
> /* Properties */
> uint32_t num_cores;
> +
> + bool cpu_has_el3;
> + bool cpu_has_el2;
> };
>
> #define TYPE_A9MPCORE_PRIV "a9mpcore_priv"
> diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
> index ea1364499d..7386a8fe57 100644
> --- a/hw/arm/exynos4210.c
> +++ b/hw/arm/exynos4210.c
> @@ -548,7 +548,7 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
> Exynos4210State *s = EXYNOS4210_SOC(socdev);
> MemoryRegion *system_mem = get_system_memory();
> SysBusDevice *busdev;
> - DeviceState *dev, *uart[4], *pl330[3];
> + DeviceState *dev, *mpdev, *uart[4], *pl330[3];
> int i, n;
>
> for (n = 0; n < EXYNOS4210_NCPUS; n++) {
> @@ -582,7 +582,13 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)
> }
>
> /* Private memory region and Internal GIC */
> - qdev_prop_set_uint32(DEVICE(&s->a9mpcore), "num-cores", EXYNOS4210_NCPUS);
> + mpdev = DEVICE(&s->a9mpcore);
> + qdev_prop_set_uint32(mpdev, "num-cores", EXYNOS4210_NCPUS);
> + /*
> + * By default A9 CPUs have EL3 enabled. This board does not currently
> + * support EL3 so the CPU EL3 property is disabled before realization.
> + */
> + qdev_prop_set_bit(mpdev, "cpu-has-el3", false);
> busdev = SYS_BUS_DEVICE(&s->a9mpcore);
> sysbus_realize(busdev, &error_fatal);
> sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR);
> diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
> index a320d1c181..294b6f15f2 100644
> --- a/hw/arm/vexpress.c
> +++ b/hw/arm/vexpress.c
> @@ -239,6 +239,12 @@ static void init_cpus(MachineState *ms, const char *cpu_type,
> * wires itself up to the CPU's generic_timer gpio out lines.
> */
> dev = qdev_new(privdev);
> + if (!secure) {
> + qdev_prop_set_bit(dev, "cpu-has-el3", false);
> + }
> + if (!virt) {
> + qdev_prop_set_bit(dev, "cpu-has-el2", false);
> + }
> qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
> busdev = SYS_BUS_DEVICE(dev);
> sysbus_realize_and_unref(busdev, &error_fatal);
> diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
> index fc9c927d09..28430dcfba 100644
> --- a/hw/arm/xilinx_zynq.c
> +++ b/hw/arm/xilinx_zynq.c
> @@ -240,6 +240,12 @@ static void zynq_init(MachineState *machine)
>
> dev = qdev_new(TYPE_A9MPCORE_PRIV);
> qdev_prop_set_uint32(dev, "num-cpu", 1);
> + /*
> + * By default A9 CPUs have EL3 enabled. This board does not
> + * currently support EL3 so the CPU EL3 property is disabled before
> + * realization.
> + */
> + qdev_prop_set_bit(dev, "cpu-has-el3", false);
> busdev = SYS_BUS_DEVICE(dev);
> sysbus_realize_and_unref(busdev, &error_fatal);
> sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE);
> diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
> index 16874426e1..a16544fdde 100644
> --- a/hw/cpu/a15mpcore.c
> +++ b/hw/cpu/a15mpcore.c
> @@ -52,9 +52,6 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
> SysBusDevice *gicsbd;
> Error *local_err = NULL;
> int i;
> - bool has_el3;
> - bool has_el2 = false;
> - Object *cpuobj;
>
> cc->parent_realize(dev, &local_err);
> if (local_err) {
> @@ -70,14 +67,11 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
> /* Make the GIC's TZ support match the CPUs. We assume that
> * either all the CPUs have TZ, or none do.
> */
> - cpuobj = OBJECT(qemu_get_cpu(0));
> - has_el3 = object_property_find(cpuobj, "has_el3") &&
> - object_property_get_bool(cpuobj, "has_el3", &error_abort);
> - qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3);
> + qdev_prop_set_bit(gicdev, "has-security-extensions",
> + c->cpu_has_el3);
> /* Similarly for virtualization support */
> - has_el2 = object_property_find(cpuobj, "has_el2") &&
> - object_property_get_bool(cpuobj, "has_el2", &error_abort);
> - qdev_prop_set_bit(gicdev, "has-virtualization-extensions", has_el2);
> + qdev_prop_set_bit(gicdev, "has-virtualization-extensions",
> + c->cpu_has_el2);
> }
>
> if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
> @@ -112,7 +106,7 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
> qdev_get_gpio_in(gicdev,
> ppibase + timer_irq[irq]));
> }
> - if (has_el2) {
> + if (c->cpu_has_el2) {
> /* Connect the GIC maintenance interrupt to PPI ID 25 */
> sysbus_connect_irq(SYS_BUS_DEVICE(gicdev), i + 4 * c->num_cores,
> qdev_get_gpio_in(gicdev, ppibase + 25));
> @@ -134,7 +128,7 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)
> sysbus_mmio_get_region(gicsbd, 0));
> memory_region_add_subregion(&c->container, 0x2000,
> sysbus_mmio_get_region(gicsbd, 1));
> - if (has_el2) {
> + if (c->cpu_has_el2) {
> memory_region_add_subregion(&c->container, 0x4000,
> sysbus_mmio_get_region(gicsbd, 2));
> memory_region_add_subregion(&c->container, 0x6000,
> diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
> index 9c138f4442..54949314f8 100644
> --- a/hw/cpu/a9mpcore.c
> +++ b/hw/cpu/a9mpcore.c
> @@ -51,7 +51,6 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)
> SysBusDevice *scubusdev, *gicbusdev, *gtimerbusdev, *mptimerbusdev,
> *wdtbusdev;
> Error *local_err = NULL;
> - bool has_el3;
> CPUState *cpu0;
> Object *cpuobj;
>
> @@ -86,9 +85,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)
> /* Make the GIC's TZ support match the CPUs. We assume that
> * either all the CPUs have TZ, or none do.
> */
> - has_el3 = object_property_find(cpuobj, "has_el3") &&
> - object_property_get_bool(cpuobj, "has_el3", &error_abort);
> - qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3);
> + qdev_prop_set_bit(gicdev, "has-security-extensions", c->cpu_has_el3);
>
> if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) {
> return;
> diff --git a/hw/cpu/cortex_mpcore.c b/hw/cpu/cortex_mpcore.c
> index d7ea633e4e..549b81f708 100644
> --- a/hw/cpu/cortex_mpcore.c
> +++ b/hw/cpu/cortex_mpcore.c
> @@ -27,6 +27,9 @@ static Property cortex_mpcore_priv_properties[] = {
> DEFINE_PROP_UINT32("num-cores", CortexMPPrivState, num_cores, 1),
> DEFINE_PROP_UINT32("num-cpu", CortexMPPrivState, num_cores, 1), /* alias */
>
> + DEFINE_PROP_BOOL("cpu-has-el3", CortexMPPrivState, cpu_has_el3, true),
> + DEFINE_PROP_BOOL("cpu-has-el2", CortexMPPrivState, cpu_has_el2, false),
Are we missing setting cpu_has_el2 somewhere else? This^ results in fewer
cpregs being registered and is what breaks migration.
You can test with:
$ (echo "migrate file:migfile"; echo "quit") | ./qemu-system-arm -M ast2600-evb -monitor stdio
$ ./scripts/analyze-migration.py -f migfile | grep array_len
Before series:
$ ./scripts/analyze-migration.py -f migfile | grep array_len
"cpreg_vmstate_array_len": "0x0000010a",
"cpreg_vmstate_array_len": "0x0000010a",
After series:
$ ./scripts/analyze-migration.py -f migfile | grep array_len
"cpreg_vmstate_array_len": "0x000000df",
"cpreg_vmstate_array_len": "0x000000df",
next prev parent reply other threads:[~2024-01-12 21:33 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 16:29 [PATCH 00/33] hw/cpu/arm: Remove one use of qemu_get_cpu() in A7/A15 MPCore priv Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 01/33] hw/arm/boot: Propagate vCPU to arm_load_dtb() Philippe Mathieu-Daudé
2024-01-02 13:51 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 02/33] hw/arm/fsl-imx6: Add a local 'gic' variable Philippe Mathieu-Daudé
2024-01-02 13:52 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 03/33] hw/arm/fsl-imx6ul: " Philippe Mathieu-Daudé
2024-01-02 13:52 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 04/33] hw/arm/fsl-imx7: " Philippe Mathieu-Daudé
2024-01-02 13:53 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 05/33] hw/cpu: Remove dead Kconfig Philippe Mathieu-Daudé
2024-01-02 13:53 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 06/33] hw/cpu/arm: Rename 'busdev' -> 'gicsbd' in a15mp_priv_realize() Philippe Mathieu-Daudé
2024-01-02 13:54 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 07/33] hw/cpu/arm: Alias 'num-cpu' property on TYPE_REALVIEW_MPCORE Philippe Mathieu-Daudé
2024-01-02 13:57 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 08/33] hw/cpu/arm: Declare CPU QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
2024-01-02 13:57 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 09/33] hw/cpu/arm: Merge {a9mpcore.h, a15mpcore.h} as cortex_mpcore.h Philippe Mathieu-Daudé
2024-01-02 14:00 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 10/33] hw/cpu/arm: Introduce abstract CORTEX_MPCORE_PRIV QOM type Philippe Mathieu-Daudé
2024-01-02 14:23 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 11/33] hw/cpu/arm: Have A9MPCORE/A15MPCORE inheritate common CORTEX_MPCORE_PRIV Philippe Mathieu-Daudé
2024-01-02 14:23 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 12/33] hw/cpu/arm: Create MPCore container in QOM parent Philippe Mathieu-Daudé
2024-01-02 14:23 ` Cédric Le Goater
2023-12-12 16:29 ` [PATCH 13/33] hw/cpu/arm: Handle 'num_cores' property once in MPCore parent Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 14/33] hw/cpu/arm: Handle 'has_el2/3' properties " Philippe Mathieu-Daudé
2024-01-12 21:33 ` Fabiano Rosas [this message]
2024-01-16 16:25 ` Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 15/33] hw/cpu/arm: Handle 'gic-irq' property " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 16/33] hw/cpu/arm: Handle GIC " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 17/33] hw/cpu/arm: Document more properties of CORTEX_MPCORE_PRIV QOM type Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 18/33] hw/cpu/arm: Replace A15MPPrivState by CortexMPPrivState Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 19/33] hw/cpu/arm: Introduce TYPE_A7MPCORE_PRIV for Cortex-A7 MPCore Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 20/33] hw/cpu/arm: Consolidate check on max GIC spi supported Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 21/33] hw/cpu/arm: Create CPUs once in MPCore parent Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 22/33] hw/arm/aspeed_ast2600: Let the A7MPcore create/wire the CPU cores Philippe Mathieu-Daudé
2024-01-02 0:11 ` Andrew Jeffery
2023-12-12 16:29 ` [PATCH 23/33] hw/arm/exynos4210: Let the A9MPcore " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 24/33] hw/arm/fsl-imx6: " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 25/33] hw/arm/fsl-imx6ul: Let the A7MPcore " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 26/33] hw/arm/fsl-imx7: " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 27/33] hw/arm/highbank: Let the A9/A15MPcore " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 28/33] hw/arm/vexpress: " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 29/33] hw/arm/xilinx_zynq: Let the A9MPcore " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 30/33] hw/arm/npcm7xx: " Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 31/33] hw/cpu/a9mpcore: Remove legacy code Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 32/33] hw/cpu/arm: Remove 'num-cpu' property alias Philippe Mathieu-Daudé
2023-12-12 16:29 ` [PATCH 33/33] hw/cpu/arm: Remove use of qemu_get_cpu() in A7/A15 realize() Philippe Mathieu-Daudé
2023-12-26 11:17 ` [PATCH 00/33] hw/cpu/arm: Remove one use of qemu_get_cpu() in A7/A15 MPCore priv Philippe Mathieu-Daudé
2024-01-02 14:55 ` Cédric Le Goater
2024-01-02 16:15 ` Philippe Mathieu-Daudé
2024-01-02 16:41 ` Cédric Le Goater
2024-01-03 9:19 ` Philippe Mathieu-Daudé
2024-01-03 19:53 ` Fabiano Rosas
2024-01-09 15:02 ` Cédric Le Goater
2024-01-09 17:40 ` Fabiano Rosas
2024-01-09 18:06 ` Cédric Le Goater
2024-01-09 20:21 ` Fabiano Rosas
2024-01-09 21:22 ` Philippe Mathieu-Daudé
2024-01-10 3:36 ` Peter Xu
2024-01-10 6:03 ` Markus Armbruster
2024-01-10 6:26 ` Peter Xu
2024-01-10 8:09 ` Markus Armbruster
2024-01-10 8:44 ` Peter Xu
2024-01-12 9:03 ` Cédric Le Goater
2024-01-10 13:19 ` Fabiano Rosas
2024-01-10 13:54 ` Markus Armbruster
2024-01-12 10:26 ` Cédric Le Goater
2024-01-12 19:54 ` Fabiano Rosas
2024-01-15 9:04 ` Cédric Le Goater
2024-01-12 8:41 ` Cédric Le Goater
2024-01-09 21:07 ` Philippe Mathieu-Daudé
2024-01-09 21:09 ` Philippe Mathieu-Daudé
2024-01-12 8:00 ` Cédric Le Goater
2024-01-12 7:29 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1cudyp2.fsf@suse.de \
--to=farosas@suse.de \
--cc=alex.bennee@linaro.org \
--cc=alistair@alistair23.me \
--cc=andrew.smirnov@gmail.com \
--cc=andrew@codeconstruct.com.au \
--cc=anjo@rev.ng \
--cc=clg@kaod.org \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=i.mitsyanko@gmail.com \
--cc=jcd@tribudubois.net \
--cc=joel@jms.id.au \
--cc=kfting@nuvoton.com \
--cc=manos.pitsidianakis@linaro.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=robh@kernel.org \
--cc=wuhaotsh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.