From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXXXE-0004Eo-Bm for qemu-devel@nongnu.org; Fri, 26 Sep 2014 11:34:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXXXD-00034X-9N for qemu-devel@nongnu.org; Fri, 26 Sep 2014 11:34:16 -0400 Received: from mail-we0-x229.google.com ([2a00:1450:400c:c03::229]:61135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXXXD-00034F-2s for qemu-devel@nongnu.org; Fri, 26 Sep 2014 11:34:15 -0400 Received: by mail-we0-f169.google.com with SMTP id k48so9730678wev.28 for ; Fri, 26 Sep 2014 08:34:09 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <5425876D.50002@redhat.com> Date: Fri, 26 Sep 2014 17:34:05 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1410332571-10544-1-git-send-email-ard.biesheuvel@linaro.org> <1410332571-10544-6-git-send-email-ard.biesheuvel@linaro.org> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PACTH v4 5/6] target-arm: add emulation of PSCI calls for system emulation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Ard Biesheuvel Cc: Rob Herring , QEMU Developers , Christoffer Dall Il 26/09/2014 11:10, Peter Maydell ha scritto: > On 10 September 2014 08:02, Ard Biesheuvel wrote: >> From: Rob Herring >> >> 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 >> Signed-off-by: Ard Biesheuvel > >> + 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 > >