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 81554C072A2 for ; Fri, 17 Nov 2023 12:17:59 +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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pjhz21gbDTb7qs8Kw1Tqb6YTx9WMZaGQT2d+gAGY+gY=; b=VxLUF5c00MaxIC 5/MTRmas+mKbrmFNQF8AJsgvLZkWG9oP1gpWWy5tae76jzoHQZsSgjs1IgF/wQ9NtOyqFUscmo0FI igjv781VEonDYZT75TRaLalWdeWgQqtB3PVUyiR+274Os7XeTWI2Vat9Ye6rM7vQ4/MBfJYHD94Md Fn69A2i7Dqa5hfurmV9WArpX/BxnuLgeHnevtYK33PcGHNwC5P3Li9VHTdT6xJKlQ8JT1CPmDi+ig ahXZkhrFZ6ySlux8NQhIC9Jp52Qp8sPXO3UKAmC1S7IjE+1r6Pp7cgWO9ETIS76wWnRXqU6njeqCR dpj8cy2SnJmgfatgfn2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r3xmt-006Wy5-2H; Fri, 17 Nov 2023 12:17:31 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r3xmr-006Wxi-1c for linux-arm-kernel@lists.infradead.org; Fri, 17 Nov 2023 12:17:30 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 80E4961D50; Fri, 17 Nov 2023 12:17:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25798C433C8; Fri, 17 Nov 2023 12:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700223448; bh=uGv/0N97MfyoKdE5xzFfvYb927nxLnO9KiqDOTyPe9A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=i/MZ0VJb7AORj51kkZswENnpOlrphEWbqcFSYujFWQvQ33OafxZ/sBW92T9Evlr3g TDuKBwxxIKwEH8se0Hsv2zLtFVA52Jjsqg6cK9IQr3yEA2XNX4YOIlRwlwUvCt5bQ1 +yl17iaONBLngms0Jmz9pbY8mXcnSKhV9y1u+CQOKh7/QJztLJJYhmx1IzFGJQcW7A Uy7rIoaGMjh+f4IErinAmKDFnAaMbH+8a9ufwJgWuSXbSRxWeSvTAIYu3H2mi22Xgb gsvqy5AxTkDqM9eCCnmzbhsmzoVTAcMXlbWX+bTYTTk5d1QoJ4M03+X09OYFJ+RJ6T je46QQd4cLVgQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1r3xmn-00DyDc-Ix; Fri, 17 Nov 2023 12:17:25 +0000 Date: Fri, 17 Nov 2023 12:17:25 +0000 Message-ID: <86wmugzi96.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Catalin Marinas , Will Deacon , Mark Rutland , James Morse , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH 07/12] arm64: Treat HCR_EL2.E2H as RES1 when ID_AA64MMFR4_EL1.E2H0 is non-zero In-Reply-To: References: <20231113174244.3026520-1-maz@kernel.org> <20231113174244.3026520-8-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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231117_041729_645208_BC81F5D6 X-CRM114-Status: GOOD ( 27.31 ) 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 On Fri, 17 Nov 2023 00:23:13 +0000, Oliver Upton wrote: > > Hey Marc, > > On Mon, Nov 13, 2023 at 05:42:39PM +0000, Marc Zyngier wrote: > > For CPUs that have ID_AA64MMFR4_EL1.E2H0 as non-zero, it is important > > to avoid the boot path that sets HCR_EL2.E2H=0. Fortunately, we > > already have this path to cope with fruity CPUs. > > > > Tweak init_el2 to look at ID_AA64MMFR4_EL1.E2H0 first. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kernel/head.S | 25 +++++++++++++++++-------- > > 1 file changed, 17 insertions(+), 8 deletions(-) > > > > diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S > > index 7b236994f0e1..5853540f7809 100644 > > --- a/arch/arm64/kernel/head.S > > +++ b/arch/arm64/kernel/head.S > > @@ -584,25 +584,34 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL) > > mov_q x1, INIT_SCTLR_EL1_MMU_OFF > > > > /* > > - * Fruity CPUs seem to have HCR_EL2.E2H set to RES1, > > - * making it impossible to start in nVHE mode. Is that > > - * compliant with the architecture? Absolutely not! > > + * Compliant CPUs advertise their VHE-onlyness with > > + * ID_AA64MMFR4_EL1.E2H0=0b111x. HCR_EL2.E2H can be > > + * RES1 in that case. > > + * > > + * Fruity CPUs seem to have HCR_EL2.E2H set to RES1, but > > + * don't advertise it (they predate this relaxation). > > */ > > + mrs_s x0, SYS_ID_AA64MMFR4_EL1 > > + ubfx x0, x0, #ID_AA64MMFR4_EL1_E2H0_SHIFT, #ID_AA64MMFR4_EL1_E2H0_WIDTH > > + and x0, x0, #0b1110 > > + cmp x0, #0b1110 > > + b.eq 1f > > Wouldn't it be more consistent with the architectural definition of > signed feature fields to just test the sign bit in this case? > > Maybe like: > > ubfx x0, x0, #ID_AA64MMFR4_EL1_E2H0_SHIFT, #ID_AA64MMFR4_EL1_E2H0_WIDTH > tbnz x0, #3, 1f > > You'll also save 8 measly bytes of text while you're at it :) At this stage, why not try this: tbnz x0, #(ID_AA64MMFR4_EL1_E2H0_SHIFT + ID_AA64MMFR4_EL1_E2H0_WIDTH - 1), 1f and we save a total of 12 bytes! M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel