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 1DFB7D2CE08 for ; Tue, 22 Oct 2024 17:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zxbS9VBa9/6R5BPXIUukmpEdCqX6K5Km+50AH1S3GkU=; b=UeZxZHZbwRU+R2/oZ4bvpQyoAI Fk9ZTAZVTtOc1/qy2mGf7zNKUOU8lZmJxOxTBVr2ZL91c33XUiZrcTzHlapI99w2TfsdY4uZvBwmx m+A10BSOiDFZv0TxI7btIMF1ZqsuN4HhnuoxFYzfbBHlOvhFZGz8pgfCr12IjnryRoFiCbebBqEMn 7y3OdZx595Cum525G/2Mr62zauWYcn2nEzZf/RjoZwjGJDd/Iwk6c/6lqBf+1XQVlTqf9KNyPQje9 kT/mztpvruOl9RQG+1zZQf1aStR1CGiZifa4ZoCUUvO3jiEODp0J8wpA6yRW3D13uWl+hMUd8EB8c q5MQqqEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t3IVc-0000000BcQE-3TZn; Tue, 22 Oct 2024 17:17:28 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t3I9o-0000000BYZm-41fj for linux-arm-kernel@lists.infradead.org; Tue, 22 Oct 2024 16:54:58 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E69645C4C83; Tue, 22 Oct 2024 16:54:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B3F6C4CEC3; Tue, 22 Oct 2024 16:54:53 +0000 (UTC) Date: Tue, 22 Oct 2024 17:54:51 +0100 From: Catalin Marinas To: Yicong Yang Cc: will@kernel.org, maz@kernel.org, mark.rutland@arm.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, ryan.roberts@arm.com, linuxarm@huawei.com, jonathan.cameron@huawei.com, shameerali.kolothum.thodi@huawei.com, prime.zeng@hisilicon.com, xuwei5@huawei.com, wangkefeng.wang@huawei.com, yangyicong@hisilicon.com Subject: Re: [PATCH v3 2/5] arm64: setup: name 'tcr2' register Message-ID: References: <20241022092734.59984-1-yangyicong@huawei.com> <20241022092734.59984-3-yangyicong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241022092734.59984-3-yangyicong@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241022_095457_060527_E1FFF019 X-CRM114-Status: GOOD ( 19.70 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 22, 2024 at 05:27:31PM +0800, Yicong Yang wrote: > From: Yicong Yang > > TCR2_EL1 introduced some additional controls besides TCR_EL1. Currently > only PIE is supported and enabled by writing TCR2_EL1 directly if PIE > detected. > > Introduce a named register 'tcr2' just like 'tcr' we've already had. > It'll be initialized to 0 and updated if certain feature detected and > needs to be enabled. Touch the TCR2_EL1 registers at last with the > updated 'tcr2' value if FEAT_TCR2 supported by checking > ID_AA64MMFR3_EL1.TCRX. Then we can extend the support of other features > controlled by TCR2_EL1. > > Signed-off-by: Yicong Yang > --- > arch/arm64/mm/proc.S | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > index 8abdc7fed321..ccbae4525891 100644 > --- a/arch/arm64/mm/proc.S > +++ b/arch/arm64/mm/proc.S > @@ -465,10 +465,12 @@ SYM_FUNC_START(__cpu_setup) > */ > mair .req x17 > tcr .req x16 > + tcr2 .req x15 > mov_q mair, MAIR_EL1_SET > mov_q tcr, TCR_T0SZ(IDMAP_VA_BITS) | TCR_T1SZ(VA_BITS_MIN) | TCR_CACHE_FLAGS | \ > TCR_SHARED | TCR_TG_FLAGS | TCR_KASLR_FLAGS | TCR_ASID16 | \ > TCR_TBI0 | TCR_A1 | TCR_KASAN_SW_FLAGS | TCR_MTE_FLAGS > + mov tcr2, xzr > > tcr_clear_errata_bits tcr, x9, x5 > > @@ -525,11 +527,16 @@ alternative_else_nop_endif > #undef PTE_MAYBE_NG > #undef PTE_MAYBE_SHARED > > - mov x0, TCR2_EL1x_PIE > - msr REG_TCR2_EL1, x0 > + orr tcr2, tcr2, TCR2_EL1x_PIE > > .Lskip_indirection: > > + mrs_s x1, SYS_ID_AA64MMFR3_EL1 > + ubfx x1, x1, #ID_AA64MMFR3_EL1_TCRX_SHIFT, #4 > + cbz x1, 1f > + msr REG_TCR2_EL1, tcr2 > +1: It makes sense to mimic the TCR_EL1 configuration here with a single MSR at the end. I was wondering whether to simply check if the tcr2 reg (x15) is non-zero under the assumption that bits in it would only be set if the features are present (and those features imply TCRX). However, we can set RES0 bits in here even if the feature is not supported in hardware (more on the next patch). So I think this patch is ok as is. Reviewed-by: Catalin Marinas