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 87BFCC433F5 for ; Wed, 2 Feb 2022 11:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240955AbiBBLxb (ORCPT ); Wed, 2 Feb 2022 06:53:31 -0500 Received: from foss.arm.com ([217.140.110.172]:53758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231839AbiBBLx3 (ORCPT ); Wed, 2 Feb 2022 06:53:29 -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 D2F691FB; Wed, 2 Feb 2022 03:53:28 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0FCB93F718; Wed, 2 Feb 2022 03:53:25 -0800 (PST) Date: Wed, 2 Feb 2022 11:53:35 +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 , Chase Conklin , "Russell King (Oracle)" , James Morse , Suzuki K Poulose , karl.heubaum@oracle.com, mihai.carabas@oracle.com, miguel.luis@oracle.com, kernel-team@android.com Subject: Re: [PATCH v6 04/64] KVM: arm64: nv: Allow userspace to set PSR_MODE_EL2x Message-ID: References: <20220128121912.509006-1-maz@kernel.org> <20220128121912.509006-5-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220128121912.509006-5-maz@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Marc, On Fri, Jan 28, 2022 at 12:18:12PM +0000, Marc Zyngier wrote: > From: Christoffer Dall > > We were not allowing userspace to set a more privileged mode for the VCPU > than EL1, but we should allow this when nested virtualization is enabled > for the VCPU. > > Reviewed-by: Russell King (Oracle) > Signed-off-by: Christoffer Dall > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/guest.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index e116c7767730..db6209622be9 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #include > > #include "trace.h" > @@ -259,6 +260,11 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > if (vcpu_el1_is_32bit(vcpu)) > return -EINVAL; > break; > + case PSR_MODE_EL2h: > + case PSR_MODE_EL2t: > + if (vcpu_el1_is_32bit(vcpu) || !vcpu_has_nv(vcpu)) I'm a bit confused about the vcpu_el1_is_32bit() check. The function tests that HCR_EL2.RW is not set. HCR_EL2.RW is cleared when the KVM_ARM_VCPU_EL1_32BIT feature is preset for the VCPU. But the EL2 and the 32BIT features are incompatible (kvm_reset_vcpu() returns an error when both are set). Wouldn't checking only !vcpu_has_nv() be enough here? Thanks, Alex > + return -EINVAL; > + break; > default: > err = -EINVAL; > goto out; > -- > 2.30.2 >