From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BC87C433EF for ; Tue, 18 Jan 2022 16:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244140AbiARQfX (ORCPT ); Tue, 18 Jan 2022 11:35:23 -0500 Received: from foss.arm.com ([217.140.110.172]:32876 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243692AbiARQfU (ORCPT ); Tue, 18 Jan 2022 11:35:20 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D7011FB; Tue, 18 Jan 2022 08:35:20 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 066513F774; Tue, 18 Jan 2022 08:35:17 -0800 (PST) Date: Tue, 18 Jan 2022 16:35:26 +0000 From: Alexandru Elisei To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Jintack Lim , Haibo Xu , Ganapatrao Kulkarni , James Morse , Suzuki K Poulose , kernel-team@android.com Subject: Re: [PATCH v5 15/69] KVM: arm64: nv: Inject HVC exceptions to the virtual EL2 Message-ID: References: <20211129200150.351436-1-maz@kernel.org> <20211129200150.351436-16-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211129200150.351436-16-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Marc, On Mon, Nov 29, 2021 at 08:00:56PM +0000, Marc Zyngier wrote: > From: Jintack Lim > > As we expect all PSCI calls from the L1 hypervisor to be performed > using SMC when nested virtualization is enabled, it is clear that > all HVC instruction from the VM (including from the virtual EL2) > are supposed to handled in the virtual EL2. > > Forward these to EL2 as required. > > Signed-off-by: Jintack Lim > [maz: add handling of HCR_EL2.HCD] > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/handle_exit.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > index 275a27368a04..1fd1c6dfd6a0 100644 > --- a/arch/arm64/kvm/handle_exit.c > +++ b/arch/arm64/kvm/handle_exit.c > @@ -16,6 +16,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -40,6 +41,16 @@ static int handle_hvc(struct kvm_vcpu *vcpu) > kvm_vcpu_hvc_get_imm(vcpu)); > vcpu->stat.hvc_exit_stat++; > > + /* Forward hvc instructions to the virtual EL2 if the guest has EL2. */ > + if (nested_virt_in_use(vcpu)) { > + if (vcpu_read_sys_reg(vcpu, HCR_EL2) & HCR_HCD) > + kvm_inject_undefined(vcpu); > + else > + kvm_inject_nested_sync(vcpu, kvm_vcpu_get_esr(vcpu)); > + > + return 1; > + } Looks good to me: Reviewed-by: Alexandru Elisei Thanks, Alex > + > ret = kvm_hvc_call_handler(vcpu); > if (ret < 0) { > vcpu_set_reg(vcpu, 0, ~0UL); > -- > 2.30.2 >