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 EB0ADC05027 for ; Mon, 6 Feb 2023 09:32:34 +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=92Ac0wUrkcdDmk3OsgVBbDqm/wcwAvZ98r763PfIOvg=; b=GfGiv/CjZGKiJb M5b8J6JGXTNdmsCbdxPEzvkAL72w2MQjUpG0V960HaBd1/Pg61+RcwPAbhUgngi8fAblG35XQJYXH +frQ8DbWmCImI1gA62qyeU/XYgoomw+v6YncwRMndKCeUKVdLOjPEvoYW4Wm5ayfMXxx2fgNO795a zh82WAC5aVYIfkniXJfGA9l+RL5FNGJt2cpMsHdjy6u8MGPKZZ9BAKujsEsvL89EGvKlDMCyiS4iq QPCibRd8DmuBc02fCJ63yry5GObNvKISSaW6kevL02DLceFMXLr4qVnWtkdH8hiJud3cZf/YHCI9B IarlRfhqPl+P4AYHGQfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOxqY-007tdZ-A7; Mon, 06 Feb 2023 09:31:34 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pOxqP-007tZA-Og for linux-arm-kernel@lists.infradead.org; Mon, 06 Feb 2023 09:31:31 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2748EB80DFA; Mon, 6 Feb 2023 09:31:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0912C433EF; Mon, 6 Feb 2023 09:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675675882; bh=IbbdJxwExq/xgTnQ3QxlRR4vh7AQ7SmhFQ+DR+Lfkr4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=l4sAkd10OviU9F3grPZsiDbuKk78ANHZn8ZmpfVBK0ikMJji9AdN69CPqafp3VN2T hN1OYKVDAIjkNKghPf3+slZTAvMUo5M0W3u/9h+ylr6KtuYY/G7WnUryDYXOPBCwI+ nNwWolcuaUhNe2Y/BKd2vOUCZUJnEDe+F6qk0rvCwAvVLSaopoOWiUyORbbEzt3Ziw f/sFw55ITnc3rEymlnJdvFDLYIqNGynH+X/W2POarSvTxZ30hP9ZyXlHnX7uIA68EE yuou4ZqcJ6ATDPgOSbWTEBItYQM1FRF6URqDBpjvqhcqH/Por5YgMgrlAfEJDTGMxX 2JwIh31X8N8NA== 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 1pOxqK-007wxh-Do; Mon, 06 Feb 2023 09:31:20 +0000 Date: Mon, 06 Feb 2023 09:31:20 +0000 Message-ID: <86y1pbywbb.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown , Catalin Marinas Cc: Will Deacon , Oleg Nesterov , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Shuah Khan , Alan Hayward , Luis Machado , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v4 07/21] arm64/sme: Enable host kernel to access ZT0 In-Reply-To: <20221208-arm64-sme2-v4-7-f2fa0aef982f@kernel.org> References: <20221208-arm64-sme2-v4-0-f2fa0aef982f@kernel.org> <20221208-arm64-sme2-v4-7-f2fa0aef982f@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 (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: broonie@kernel.org, catalin.marinas@arm.com, will@kernel.org, oleg@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, shuah@kernel.org, alan.hayward@arm.com, luis.machado@arm.com, szabolcs.nagy@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org 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-20230206_013126_123404_96FC6D99 X-CRM114-Status: GOOD ( 28.25 ) 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 Mon, 16 Jan 2023 16:04:42 +0000, Mark Brown wrote: > > The new register ZT0 introduced by SME2 comes with a new trap, disable it > for the host kernel so that we can implement support for it. > > Signed-off-by: Mark Brown > --- > arch/arm64/kernel/hyp-stub.S | 6 ++++++ > arch/arm64/kernel/idreg-override.c | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S > index 2ee18c860f2a..d31d1acb170d 100644 > --- a/arch/arm64/kernel/hyp-stub.S > +++ b/arch/arm64/kernel/hyp-stub.S > @@ -132,6 +132,12 @@ SYM_CODE_START_LOCAL(__finalise_el2) > orr x0, x0, SMCR_ELx_FA64_MASK > .Lskip_sme_fa64: > > + // ZT0 available? > + __check_override id_aa64smfr0 ID_AA64SMFR0_EL1_SMEver_SHIFT 4 .Linit_sme_zt0 .Lskip_sme_zt0 > +.Linit_sme_zt0: > + orr x0, x0, SMCR_ELx_EZT0_MASK > +.Lskip_sme_zt0: > + I've been looking at this in order to solve a merge conflict in next, and couldn't convince myself that the above actually works. __check_override assumes that the ID_AA64SMFR0_EL1 value is in x1, and I guess that the intent of the code is to reuse value read a few lines above. But as the comment says at the beginning of the macro, x1 will be clobbered, and the checks always fails. I presume we're just lucky that sme2_kernel_enable() does the same thing unconditionally, which probably means this was only ever tested with a VHE kernel (it'd otherwise catch fire). The easiest fix is just to reload the id register before checking it, something like the patch below, compile-tested only. M. >From a6c4aaccd33e453ffc8d8ea23a4dd4d9a263cc89 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Mon, 6 Feb 2023 09:24:40 +0000 Subject: [PATCH] arm64/sme: Fix __finalise_el2 SMEver check When checking for ID_AA64SMFR0_EL1.SMEver, __check_override assumes that the ID_AA64SMFR0_EL1 value is in x1, and the intent of the code is to reuse value read a few lines above. However, as the comment says at the beginning of the macro, x1 will be clobbered, and the checks always fails. The easiest fix is just to reload the id register before checking it. Fixes: f122576f3533 ("arm64/sme: Enable host kernel to access ZT0") Signed-off-by: Marc Zyngier --- arch/arm64/kernel/hyp-stub.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index d31d1acb170d..111ff33d93ee 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -133,6 +133,7 @@ SYM_CODE_START_LOCAL(__finalise_el2) .Lskip_sme_fa64: // ZT0 available? + mrs_s x1, SYS_ID_AA64SMFR0_EL1 __check_override id_aa64smfr0 ID_AA64SMFR0_EL1_SMEver_SHIFT 4 .Linit_sme_zt0 .Lskip_sme_zt0 .Linit_sme_zt0: orr x0, x0, SMCR_ELx_EZT0_MASK -- 2.34.1 -- 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