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 6E8E3D12693 for ; Tue, 5 Nov 2024 11:54:53 +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:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID: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=nvZgUBwvCDRoc3HNDha08oGJoPIb5JT7Rhqf/biHZOU=; b=qqBqDd2DFvV94pxMbDzfXLXE1Q D0WU4xGW8GBs0rxIOuzFEaNSPEbqSf1WH8NWS/4LDjDIVUrS6x0r5daPmD5iB1s6OBSD955Nh6cSG LtFuSYPz9Qjh3M13aIRIjPEHQmqU7XbsnliyRA2CffHCxWQq6Om4RhXHBCXOaWoiW8qw9wK2B1Vvf exoW3Ovc6KmE+TVlkGvUxIr1V97GbR3zhk7QPsBRtupxJiFpBfmQvdGE+kgufK1TOjrC6oIE/mI9F vsqWsJyHBlI5s4i8NeDMi2JJJE65+LuJGUEloQdX3pPa8fux0YcrqlvzMEetBOwEKadzrcWiHvSBM YSDQN/3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8I8v-0000000Gv3K-3JF5; Tue, 05 Nov 2024 11:54:41 +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 1t8I7D-0000000Gur5-3v7S for linux-arm-kernel@lists.infradead.org; Tue, 05 Nov 2024 11:52:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7927F5C0FCD; Tue, 5 Nov 2024 11:52:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4A97C4CECF; Tue, 5 Nov 2024 11:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730807575; bh=em8v0oaRh7P4v6I/TNmy2zBtL3tysoM66HeSOtaMYaY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=czcfWOqlDo4VwPiI6jpv1ZhaFfPYv+DH3C+FuTUJ3fxWzz7Y3Kci0iYbMZraHIv/R NSdHVTWiCQ3kX03BBNWEaXeDXUYAudk0gTFw9TN+VMRVEBDj3LV4mJjOC2k1WxqXTg jr55DjwRZs5bcK9tQi/dy3K7p8CRPfXjEnakQtSZqLRe6Znu2rAKh9ZGs1ldlvysOf bQiBxX/s6mm2FW46gm7Ucs6/I2DQ5bkMwDduwD/pV9j3ZrczbP4UaunGc4ImiH51Sm Fe6ANgLm+KEkNfZZi2tqP9cjVVUeGTUum5mFOBwh/nS9WHm9k5wqP0knnpEBdRr1x6 UJqZIc7h/XfVw== 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 1t8I7A-009yKX-Gk; Tue, 05 Nov 2024 11:52:52 +0000 Date: Tue, 05 Nov 2024 11:52:51 +0000 Message-ID: <86fro528z0.wl-maz@kernel.org> From: Marc Zyngier To: Catalin Marinas Cc: Yicong Yang , will@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 v4 3/5] arm64: Add support for FEAT_HAFT In-Reply-To: References: <20241102104235.62560-1-yangyicong@huawei.com> <20241102104235.62560-4-yangyicong@huawei.com> <87cyjat6vs.wl-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.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, yangyicong@huawei.com, will@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 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-20241105_035256_084487_BA79C2B4 X-CRM114-Status: GOOD ( 33.44 ) 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, 05 Nov 2024 09:58:26 +0000, Catalin Marinas wrote: > > On Tue, Nov 05, 2024 at 08:35:51AM +0000, Marc Zyngier wrote: > > On Mon, 04 Nov 2024 17:28:48 +0000, > > Catalin Marinas wrote: > > > On Sat, Nov 02, 2024 at 06:42:33PM +0800, Yicong Yang wrote: > > > > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > > > > index ccbae4525891..0bc88df7cb35 100644 > > > > --- a/arch/arm64/mm/proc.S > > > > +++ b/arch/arm64/mm/proc.S > > > > @@ -498,6 +498,10 @@ alternative_else_nop_endif > > > > and x9, x9, ID_AA64MMFR1_EL1_HAFDBS_MASK > > > > cbz x9, 1f > > > > orr tcr, tcr, #TCR_HA // hardware Access flag update > > > > + > > > > +#ifdef CONFIG_ARM64_HAFT > > > > + orr tcr2, tcr2, TCR2_EL1x_HAFT > > > > +#endif /* CONFIG_ARM64_HAFT */ > > > > 1: > > > > #endif /* CONFIG_ARM64_HW_AFDBM */ > > > > msr mair_el1, mair > > > > > > If you still want #ifdefs, I'd have left it outside the HW_AFDBM. We > > > already have a dependency in the Kconfig. Anyway, I can fix this up. > > > > > > I think as an additional patch we can also remove the ID checks for the > > > tcr bit in tge HW_AFDBM case. But that's unrelated to this series. > > > > I think you want to be careful with this one. I know of at least one > > implementation that has a broken FEAT_HAFDBS implementation, that > > removes it from the ID registers, but where the control bit in TCR_ELx > > still takes effect. > > > > Please see 6df696cd9bc1 ("arm64: errata: Mitigate Ampere1 erratum > > AC03_CPU_38 at stage-2") which indicates how we actually rely on the > > check for S1 translation. > > Ah, thanks for this. So the hardware with the erratum above can still > update the pte after it has been marked invalid, hence we can't turn it > on in TCR_EL1 even if the rest of the kernel considers the feature > disabled. So yes, the HAFDBS code needs to stay as is. Indeed. Atomicity is overrated, let's go shopping. > Let's hope the hardware people learnt and we won't have similar errata > for FEAT_HAFT. If I was religious, I'd light a candle. But we've both seen enough HW to know that they *will* fsck it up. We just don't know how yet. M. -- Without deviation from the norm, progress is not possible.