From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5E172342E for ; Thu, 1 Jun 2023 12:48:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07D8DC4339C; Thu, 1 Jun 2023 12:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685623726; bh=GytX/y1oWBpj3Fnw5IPVnEW36hsGqBLos/gDLfBNgPE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WWMfoVRvmQtGcdb6aSfWFhb+k3jKow/5CweUDUxQtxSLDvWt6D3jGflO2E1sPSC3r MwKi47++HBrJ9DuktNUnRCZUt5Mzj19AtsnIm/3NenJ0sTUmIh60x1hsuXueJmwsHb ZFw0PwcxQYNSvSaydkmkM/Q7oyUM2+6e8S5xZYg6aWS+kqhgrkAjKmdDupg4e+77Wc iQDmTSb2oF0r4AlMV5tlGvnDaZn22shUdhVwnCCjVPxiL33rAa0863yW43Bz4TcN2T Bf8MN61ncNeraKCcdzQIEvv2xtA7E/Fmelt3Kngnvt/4QJkc66D65QGVEp2aGNEnWD Ft/WRYnNPeddg== Received: from 90.4.23.109.rev.sfr.net ([109.23.4.90] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q4hjP-0021eM-MP; Thu, 01 Jun 2023 13:48:43 +0100 Date: Thu, 01 Jun 2023 13:48:42 +0100 Message-ID: <87bkhzpcut.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Zenghui Yu , Quentin Perret , Will Deacon , Fuad Tabba Subject: Re: [PATCH v2 05/17] arm64: Don't enable VHE for the kernel if OVERRIDE_HVHE is set In-Reply-To: References: <20230526143348.4072074-1-maz@kernel.org> <20230526143348.4072074-6-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 109.23.4.90 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, will@kernel.org, tabba@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Thu, 01 Jun 2023 08:32:40 +0100, Oliver Upton wrote: > > On Fri, May 26, 2023 at 03:33:36PM +0100, Marc Zyngier wrote: > > If the OVERRIDE_HVHE SW override is set (as a precursor of > > the KVM_HVHE capability), do not enable VHE for the kernel > > and drop to EL1 as if VHE was either disabled or unavailable. > > > > Further changes will enable VHE at EL2 only, with the kernel > > still running at EL1. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kernel/hyp-stub.S | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S > > index 9439240c3fcf..5c71e1019545 100644 > > --- a/arch/arm64/kernel/hyp-stub.S > > +++ b/arch/arm64/kernel/hyp-stub.S > > @@ -82,7 +82,15 @@ SYM_CODE_START_LOCAL(__finalise_el2) > > tbnz x1, #0, 1f > > > > // Needs to be VHE capable, obviously > > - check_override id_aa64mmfr1 ID_AA64MMFR1_EL1_VH_SHIFT 2f 1f x1 x2 > > + check_override id_aa64mmfr1 ID_AA64MMFR1_EL1_VH_SHIFT 0f 1f x1 x2 > > + > > +0: // Check whether we only want the hypervisor to run VHE, not the kernel > > + adr_l x1, arm64_sw_feature_override > > + ldr x2, [x1, FTR_OVR_VAL_OFFSET] > > + ldr x1, [x1, FTR_OVR_MASK_OFFSET] > > + and x2, x2, x1 > > nit: is applying the mask even necessary? I get it in the context of an > overlay on top of an ID register, but the software features are more of > a synthetic ID register in their own right. I guess I don't have a good reason just yet, but on the other hand it makes things predictable if the override code refuses the override for some reason other than not being VHE-capable (mask becomes 0 and val becomes 0xf). Overall, I feel that this code is too hard to follow to do anything different from the "standard" case. Thanks, M. -- Without deviation from the norm, progress is not possible.