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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 784DDC433F5 for ; Wed, 2 Feb 2022 11:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fsmuCP2eKpZDvQz4/BHrg4ix6dF450KVbyThjoDIeKE=; b=WyI62or+tH4iN5 iCqXgcMAnEYX2r1x6WVvaxVvc6Ei4paTuYIMGolx/Fuhqutbz9Z+E5Wtj0BPEYK2jsqHWGtA0CECp moBp0nWKL9RyKfI9KlNqS0cUQYclTr0THKxHYXbHRbwKp3k3Om9ATJ++VDWSVBcO83v2vb5vDIuRr cgL59eFFR7hhH7QVw6tplCZ/Sl2BjWZC47nHG0R77RMK9BUaHns32akwd10am0YJcvKvT5bHRTRSO VLuxF+CB+Vp4X5glkbX+s03aC5RtGxh52f7Z8Y05CR66d3QnVZJL4/cuJND8z2tfc4VocTo3byoMK Gn1SWWw1v/6cfLeWHtog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFECc-00F61t-Oc; Wed, 02 Feb 2022 11:53:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFECY-00F60x-LX for linux-arm-kernel@lists.infradead.org; Wed, 02 Feb 2022 11:53:32 +0000 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-Disposition: inline In-Reply-To: <20220128121912.509006-5-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220202_035330_775695_75C027A4 X-CRM114-Status: GOOD ( 19.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel