From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932951AbcBAOZ4 (ORCPT ); Mon, 1 Feb 2016 09:25:56 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:33550 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932634AbcBAOZy (ORCPT ); Mon, 1 Feb 2016 09:25:54 -0500 Date: Mon, 1 Feb 2016 15:26:20 +0100 From: Christoffer Dall To: Marc Zyngier Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH v2 17/21] arm64: KVM: VHE: Add alternative panic handling Message-ID: <20160201142620.GW1478@cbox> References: <1453737235-16522-1-git-send-email-marc.zyngier@arm.com> <1453737235-16522-18-git-send-email-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1453737235-16522-18-git-send-email-marc.zyngier@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2016 at 03:53:51PM +0000, Marc Zyngier wrote: > As the kernel fully runs in HYP when VHE is enabled, we can > directly branch to the kernel's panic() implementation, and > not perform an exception return. > > Add the alternative code to deal with this. > > Signed-off-by: Marc Zyngier Reviewed-by: Christoffer Dall > --- > arch/arm64/kvm/hyp/switch.c | 35 +++++++++++++++++++++++++++-------- > 1 file changed, 27 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c > index 77f7c94..0cadb7f 100644 > --- a/arch/arm64/kvm/hyp/switch.c > +++ b/arch/arm64/kvm/hyp/switch.c > @@ -211,11 +211,34 @@ __alias(__guest_run) int __kvm_vcpu_run(struct kvm_vcpu *vcpu); > > static const char __hyp_panic_string[] = "HYP panic:\nPS:%08llx PC:%016llx ESR:%08llx\nFAR:%016llx HPFAR:%016llx PAR:%016llx\nVCPU:%p\n"; > > -void __hyp_text __noreturn __hyp_panic(void) > +static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par) > { > unsigned long str_va = (unsigned long)__hyp_panic_string; > - u64 spsr = read_sysreg(spsr_el2); > - u64 elr = read_sysreg(elr_el2); > + > + __hyp_do_panic(hyp_kern_va(str_va), > + spsr, elr, > + read_sysreg(esr_el2), read_sysreg_el2(far), > + read_sysreg(hpfar_el2), par, > + (void *)read_sysreg(tpidr_el2)); > +} > + > +static void __hyp_text __hyp_call_panic_vhe(u64 spsr, u64 elr, u64 par) > +{ > + panic(__hyp_panic_string, > + spsr, elr, > + read_sysreg_el2(esr), read_sysreg_el2(far), > + read_sysreg(hpfar_el2), par, > + (void *)read_sysreg(tpidr_el2)); > +} > + > +static hyp_alternate_select(__hyp_call_panic, > + __hyp_call_panic_nvhe, __hyp_call_panic_vhe, > + ARM64_HAS_VIRT_HOST_EXTN); > + > +void __hyp_text __noreturn __hyp_panic(void) > +{ > + u64 spsr = read_sysreg_el2(spsr); > + u64 elr = read_sysreg_el2(elr); > u64 par = read_sysreg(par_el1); > > if (read_sysreg(vttbr_el2)) { > @@ -230,11 +253,7 @@ void __hyp_text __noreturn __hyp_panic(void) > } > > /* Call panic for real */ > - __hyp_do_panic(hyp_kern_va(str_va), > - spsr, elr, > - read_sysreg(esr_el2), read_sysreg(far_el2), > - read_sysreg(hpfar_el2), par, > - (void *)read_sysreg(tpidr_el2)); > + __hyp_call_panic()(spsr, elr, par); > > unreachable(); > } > -- > 2.1.4 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: christoffer.dall@linaro.org (Christoffer Dall) Date: Mon, 1 Feb 2016 15:26:20 +0100 Subject: [PATCH v2 17/21] arm64: KVM: VHE: Add alternative panic handling In-Reply-To: <1453737235-16522-18-git-send-email-marc.zyngier@arm.com> References: <1453737235-16522-1-git-send-email-marc.zyngier@arm.com> <1453737235-16522-18-git-send-email-marc.zyngier@arm.com> Message-ID: <20160201142620.GW1478@cbox> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Jan 25, 2016 at 03:53:51PM +0000, Marc Zyngier wrote: > As the kernel fully runs in HYP when VHE is enabled, we can > directly branch to the kernel's panic() implementation, and > not perform an exception return. > > Add the alternative code to deal with this. > > Signed-off-by: Marc Zyngier Reviewed-by: Christoffer Dall > --- > arch/arm64/kvm/hyp/switch.c | 35 +++++++++++++++++++++++++++-------- > 1 file changed, 27 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c > index 77f7c94..0cadb7f 100644 > --- a/arch/arm64/kvm/hyp/switch.c > +++ b/arch/arm64/kvm/hyp/switch.c > @@ -211,11 +211,34 @@ __alias(__guest_run) int __kvm_vcpu_run(struct kvm_vcpu *vcpu); > > static const char __hyp_panic_string[] = "HYP panic:\nPS:%08llx PC:%016llx ESR:%08llx\nFAR:%016llx HPFAR:%016llx PAR:%016llx\nVCPU:%p\n"; > > -void __hyp_text __noreturn __hyp_panic(void) > +static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par) > { > unsigned long str_va = (unsigned long)__hyp_panic_string; > - u64 spsr = read_sysreg(spsr_el2); > - u64 elr = read_sysreg(elr_el2); > + > + __hyp_do_panic(hyp_kern_va(str_va), > + spsr, elr, > + read_sysreg(esr_el2), read_sysreg_el2(far), > + read_sysreg(hpfar_el2), par, > + (void *)read_sysreg(tpidr_el2)); > +} > + > +static void __hyp_text __hyp_call_panic_vhe(u64 spsr, u64 elr, u64 par) > +{ > + panic(__hyp_panic_string, > + spsr, elr, > + read_sysreg_el2(esr), read_sysreg_el2(far), > + read_sysreg(hpfar_el2), par, > + (void *)read_sysreg(tpidr_el2)); > +} > + > +static hyp_alternate_select(__hyp_call_panic, > + __hyp_call_panic_nvhe, __hyp_call_panic_vhe, > + ARM64_HAS_VIRT_HOST_EXTN); > + > +void __hyp_text __noreturn __hyp_panic(void) > +{ > + u64 spsr = read_sysreg_el2(spsr); > + u64 elr = read_sysreg_el2(elr); > u64 par = read_sysreg(par_el1); > > if (read_sysreg(vttbr_el2)) { > @@ -230,11 +253,7 @@ void __hyp_text __noreturn __hyp_panic(void) > } > > /* Call panic for real */ > - __hyp_do_panic(hyp_kern_va(str_va), > - spsr, elr, > - read_sysreg(esr_el2), read_sysreg(far_el2), > - read_sysreg(hpfar_el2), par, > - (void *)read_sysreg(tpidr_el2)); > + __hyp_call_panic()(spsr, elr, par); > > unreachable(); > } > -- > 2.1.4 >