From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Rob Herring <rob.herring@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Christoffer Dall <christoffer.dall@linaro.org>
Subject: Re: [Qemu-devel] [PACTH v4 5/6] target-arm: add emulation of PSCI calls for system emulation
Date: Fri, 26 Sep 2014 17:34:05 +0200 [thread overview]
Message-ID: <5425876D.50002@redhat.com> (raw)
In-Reply-To: <CAFEAcA_UhVuZOjcNv6fH9sYAKz-fLtt4u7DYD8jmTbrdMZxaCw@mail.gmail.com>
Il 26/09/2014 11:10, Peter Maydell ha scritto:
> On 10 September 2014 08:02, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> From: Rob Herring <rob.herring@linaro.org>
>>
>> Add support for handling PSCI calls in system emulation. Both version
>> 0.1 and 0.2 of the PSCI spec are supported. Platforms can enable support
>> by setting the "psci-conduit" QOM property on the cpus to SMC or HVC
>> emulation and having a PSCI binding in their dtb.
>>
>> Signed-off-by: Rob Herring <rob.herring@linaro.org>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
>> + case QEMU_PSCI_0_2_FN_SYSTEM_RESET:
>> + qemu_system_reset_request();
>> + break;
>> + case QEMU_PSCI_0_2_FN_SYSTEM_OFF:
>> + qemu_system_shutdown_request();
>> + break;
>
> I just realised that this isn't quite right: PSCI
> mandates that the SYSTEM_RESET and SYSTEM_OFF
> functions never return to the caller, but the QEMU
> qemu_system_*_request() functions are just requests
> which the main loop will later handle asynchronously.
> So we should put the calling CPU into power off
> (and rely on CPU reset to power it up again if it's
> CPU 0; we don't care if we're shutting down, obviously).
>
> I propose to apply the following fixup patch to
> deal with this (since this patchset is very nearly
> ready and I know Ard's not going to be back to
> deal with it for a few weeks):
FWIW, looks good.
Thanks,
Paolo
> diff --git a/target-arm/psci.c b/target-arm/psci.c
> index 7347cbd..1cda7d3 100644
> --- a/target-arm/psci.c
> +++ b/target-arm/psci.c
> @@ -85,10 +85,15 @@ bool arm_handle_psci(CPUState *cs)
> break;
> case QEMU_PSCI_0_2_FN_SYSTEM_RESET:
> qemu_system_reset_request();
> - break;
> + /* QEMU reset and shutdown are async requests, but PSCI
> + * mandates that we never return from the reset/shutdown
> + * call, so power the CPU off now so it doesn't execute
> + * anything further.
> + */
> + goto cpu_off;
> case QEMU_PSCI_0_2_FN_SYSTEM_OFF:
> qemu_system_shutdown_request();
> - break;
> + goto cpu_off;
> case QEMU_PSCI_0_1_FN_CPU_ON:
> case QEMU_PSCI_0_2_FN_CPU_ON:
> case QEMU_PSCI_0_2_FN64_CPU_ON:
> @@ -144,11 +149,7 @@ bool arm_handle_psci(CPUState *cs)
> break;
> case QEMU_PSCI_0_1_FN_CPU_OFF:
> case QEMU_PSCI_0_2_FN_CPU_OFF:
> - cpu->powered_off = true;
> - cs->halted = 1;
> - cs->exception_index = EXCP_HLT;
> - cpu_loop_exit(cs);
> - /* notreached */
> + goto cpu_off;
> case QEMU_PSCI_0_1_FN_CPU_SUSPEND:
> case QEMU_PSCI_0_2_FN_CPU_SUSPEND:
> case QEMU_PSCI_0_2_FN64_CPU_SUSPEND:
> @@ -180,4 +181,11 @@ err:
> env->regs[0] = ret;
> }
> return true;
> +
> +cpu_off:
> + cpu->powered_off = true;
> + cs->halted = 1;
> + cs->exception_index = EXCP_HLT;
> + cpu_loop_exit(cs);
> + /* notreached */
> }
>
> thanks
> -- PMM
>
>
next prev parent reply other threads:[~2014-09-26 15:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 7:02 [Qemu-devel] [PACTH v4 0/6] ARM: add PSCI 0.2 support in TCG mode Ard Biesheuvel
2014-09-10 7:02 ` [Qemu-devel] [PACTH v4 1/6] target-arm: add powered off cpu state Ard Biesheuvel
2014-09-10 7:02 ` [Qemu-devel] [PACTH v4 2/6] target-arm: do not set do_interrupt handlers for ARM and AArch64 user modes Ard Biesheuvel
2014-09-10 7:02 ` [Qemu-devel] [PACTH v4 3/6] target-arm: add hvc and smc exception emulation handling infrastructure Ard Biesheuvel
2014-09-26 10:17 ` Peter Maydell
2014-09-10 7:02 ` [Qemu-devel] [PACTH v4 4/6] target-arm: add missing PSCI constants needed for PSCI emulation Ard Biesheuvel
2014-09-10 7:02 ` [Qemu-devel] [PACTH v4 5/6] target-arm: add emulation of PSCI calls for system emulation Ard Biesheuvel
2014-09-26 9:10 ` Peter Maydell
2014-09-26 15:34 ` Paolo Bonzini [this message]
2014-09-10 7:02 ` [Qemu-devel] [PACTH v4 6/6] arm/virt: enable PSCI emulation support " Ard Biesheuvel
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=5425876D.50002@redhat.com \
--to=pbonzini@redhat.com \
--cc=ard.biesheuvel@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rob.herring@linaro.org \
/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.