From: Marc Zyngier <marc.zyngier@arm.com>
To: Peter Maydell <peter.maydell@linaro.org>,
Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Marcel Apfelbaum" <marcel.apfelbaum@zoho.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-devel@nongnu.org, qemu-arm@nongnu.org, yurovsky@gmail.com
Subject: Re: [Qemu-devel] [PULL, 22/30] hw/arm: Move virt's PSCI DT fixup code to arm/boot.c
Date: Tue, 27 Mar 2018 15:22:46 +0100 [thread overview]
Message-ID: <86605hsimh.wl-marc.zyngier@arm.com> (raw)
In-Reply-To: <20180209110314.11766-23-peter.maydell@linaro.org>
On Fri, 09 Feb 2018 11:03:06 +0000,
Peter Maydell wrote:
Hi Peter, Andrey,
>
> From: Andrey Smirnov <andrew.smirnov@gmail.com>
>
> Move virt's PSCI DT fixup code to arm/boot.c and set this fixup to
> happen automatically for every board that doesn't mark "psci-conduit"
> as disabled. This way emulated boards other than "virt" that rely on
> PSIC for SMP could benefit from that code.
>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Cc: Marcel Apfelbaum <marcel.apfelbaum@zoho.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: qemu-devel@nongnu.org
> Cc: qemu-arm@nongnu.org
> Cc: yurovsky@gmail.com
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/arm/boot.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/arm/virt.c | 61 -------------------------------------------------------
> 2 files changed, 65 insertions(+), 61 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index bb244ec359..9b174b982c 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -385,6 +385,69 @@ static void set_kernel_args_old(const struct arm_boot_info *info)
> }
> }
>
> +static void fdt_add_psci_node(void *fdt)
> +{
> + uint32_t cpu_suspend_fn;
> + uint32_t cpu_off_fn;
> + uint32_t cpu_on_fn;
> + uint32_t migrate_fn;
> + ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(0));
> + const char *psci_method;
> + int64_t psci_conduit;
> +
> + psci_conduit = object_property_get_int(OBJECT(armcpu),
> + "psci-conduit",
> + &error_abort);
> + switch (psci_conduit) {
> + case QEMU_PSCI_CONDUIT_DISABLED:
> + return;
> + case QEMU_PSCI_CONDUIT_HVC:
> + psci_method = "hvc";
> + break;
> + case QEMU_PSCI_CONDUIT_SMC:
> + psci_method = "smc";
> + break;
> + default:
> + g_assert_not_reached();
> + }
> +
> + qemu_fdt_add_subnode(fdt, "/psci");
> + if (armcpu->psci_version == 2) {
> + const char comp[] = "arm,psci-0.2\0arm,psci";
> + qemu_fdt_setprop(fdt, "/psci", "compatible", comp, sizeof(comp));
> +
> + cpu_off_fn = QEMU_PSCI_0_2_FN_CPU_OFF;
> + if (arm_feature(&armcpu->env, ARM_FEATURE_AARCH64)) {
> + cpu_suspend_fn = QEMU_PSCI_0_2_FN64_CPU_SUSPEND;
> + cpu_on_fn = QEMU_PSCI_0_2_FN64_CPU_ON;
> + migrate_fn = QEMU_PSCI_0_2_FN64_MIGRATE;
> + } else {
> + cpu_suspend_fn = QEMU_PSCI_0_2_FN_CPU_SUSPEND;
> + cpu_on_fn = QEMU_PSCI_0_2_FN_CPU_ON;
> + migrate_fn = QEMU_PSCI_0_2_FN_MIGRATE;
> + }
> + } else {
> + qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
> +
> + cpu_suspend_fn = QEMU_PSCI_0_1_FN_CPU_SUSPEND;
> + cpu_off_fn = QEMU_PSCI_0_1_FN_CPU_OFF;
> + cpu_on_fn = QEMU_PSCI_0_1_FN_CPU_ON;
> + migrate_fn = QEMU_PSCI_0_1_FN_MIGRATE;
> + }
> +
> + /* We adopt the PSCI spec's nomenclature, and use 'conduit' to refer
> + * to the instruction that should be used to invoke PSCI functions.
> + * However, the device tree binding uses 'method' instead, so that is
> + * what we should use here.
> + */
> + qemu_fdt_setprop_string(fdt, "/psci", "method", psci_method);
> +
> + qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend", cpu_suspend_fn);
> + qemu_fdt_setprop_cell(fdt, "/psci", "cpu_off", cpu_off_fn);
> + qemu_fdt_setprop_cell(fdt, "/psci", "cpu_on", cpu_on_fn);
> + qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn);
> +}
> +
> /**
> * load_dtb() - load a device tree binary image into memory
> * @addr: the address to load the image at
> @@ -541,6 +604,8 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
> }
> }
>
> + fdt_add_psci_node(fdt);
> +
This particular change broke one of my favourite use cases, which is
to feed the guest with a hand-crafted DTB, and expect QEMU to just
take it as granted, and not touch it.
I now get an error:
qemu-system-aarch64: FDT: Failed to create subnode /psci: FDT_ERR_EXISTS
The obvious workaround would be to test the presence of the /psci node
before generating it (such as done for the /chosen node, for example).
Thanks,
M.
--
Jazz is not dead, it just smell funny.
next prev parent reply other threads:[~2018-03-27 14:23 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-09 11:02 [Qemu-devel] [PULL 00/30] target-arm queue Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 01/30] target/arm: Add armv7m_nvic_set_pending_derived() Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 02/30] target/arm: Split "get pending exception info" from "acknowledge it" Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 03/30] target/arm: Add ignore_stackfaults argument to v7m_exception_taken() Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 04/30] target/arm: Make v7M exception entry stack push check MPU Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 05/30] target/arm: Make v7m_push_callee_stack() honour MPU Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 06/30] target/arm: Make exception vector loads honour the SAU Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 07/30] target/arm: Handle exceptions during exception stack pop Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 08/30] target/arm: implement SHA-512 instructions Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 09/30] target/arm: implement SHA-3 instructions Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 10/30] target/arm: implement SM3 instructions Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 11/30] target/arm: implement SM4 instructions Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 12/30] target/arm: enable user-mode SHA-3, SM3, SM4 and SHA-512 instruction support Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 13/30] sdhci: Add i.MX specific subtype of SDHCI Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 14/30] hw: i.MX: Convert i.MX6 to use TYPE_IMX_USDHC Peter Maydell
2018-02-09 11:02 ` [Qemu-devel] [PULL 15/30] i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 16/30] i.MX: Add code to emulate i.MX2 watchdog IP block Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 17/30] i.MX: Add code to emulate i.MX7 SNVS IP-block Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 18/30] i.MX: Add code to emulate GPCv2 IP block Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 19/30] i.MX: Add i.MX7 GPT variant Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 20/30] i.MX: Add implementation of i.MX7 GPR IP block Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 21/30] usb: Add basic code to emulate Chipidea USB IP Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 22/30] hw/arm: Move virt's PSCI DT fixup code to arm/boot.c Peter Maydell
2018-03-27 14:22 ` Marc Zyngier [this message]
2018-02-09 11:03 ` [Qemu-devel] [PULL 23/30] target/arm: Expand vector registers for SVE Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 24/30] target/arm: Add predicate " Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 25/30] target/arm: Add SVE to migration state Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 26/30] target/arm: Add ZCR_ELx Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 27/30] target/arm: Add SVE state to TB->FLAGS Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 28/30] target/arm/kvm: gic: Prevent creating userspace GICv3 with KVM Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 29/30] target/arm/translate.c: Fix missing 'break' for TT insns Peter Maydell
2018-02-09 11:03 ` [Qemu-devel] [PULL 30/30] hw/core/generic-loader: Allow PC to be set on command line Peter Maydell
2018-02-09 14:38 ` [Qemu-devel] [PULL 00/30] target-arm queue Peter Maydell
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=86605hsimh.wl-marc.zyngier@arm.com \
--to=marc.zyngier@arm.com \
--cc=andrew.smirnov@gmail.com \
--cc=f4bug@amsat.org \
--cc=jasowang@redhat.com \
--cc=marcel.apfelbaum@zoho.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=yurovsky@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).