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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 584C5C433EF for ; Tue, 26 Oct 2021 12:25:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 105C660527 for ; Tue, 26 Oct 2021 12:25:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 105C660527 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pC1wCMoCfs1/22jH7OzDuqHTXYf/zDYUCza7oLLKgrE=; b=2vICsux3ENXG5o 39odrNCe4GG5wfae3zoqBQcRWAjM7iqE4uuoYqpyApPNbOaIRz/W4HafEgyvGG8F0sYt2gdeWpK4x na6XMiuCuyDER+fTsECgqRIiCnIu6LngzldtESygrcXMChd48Jk87wVpm3HxoG7ghttHTsznWp889 K3Dex75wGX0Hae7o4NwB/yytBy70O5QDyavJi/56Ady8N93T8C0br2/8U8TiPBCXLRZix/jag588m HJOhC7ORQqwvR9oYUv9dEZFKV1yWxXKqvw7eMCU39jaIFBtvLL8x5eH4rFH4vtiOw2lZobODJmHiC 1MIkjNyrfpfpRGiNdf7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfLU2-001m6Y-M5; Tue, 26 Oct 2021 12:23:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfLTy-001m6F-Ei for linux-arm-kernel@lists.infradead.org; Tue, 26 Oct 2021 12:23:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BED3D1FB; Tue, 26 Oct 2021 05:23:05 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.74.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62DEB3F73D; Tue, 26 Oct 2021 05:23:03 -0700 (PDT) Date: Tue, 26 Oct 2021 13:23:00 +0100 From: Mark Rutland To: Robin Murphy Cc: Reiji Watanabe , Catalin Marinas , Will Deacon , Marc Zyngier , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata Subject: Re: [PATCH] arm64: clear_page() shouldn't use DC ZVA when DCZID_EL0.DZP == 1 Message-ID: <20211026122300.GB34073@C02TD0UTHF1T.local> References: <20211026034844.1393437-1-reijiw@google.com> <0cd301eb-c2a4-bc90-46b8-cb4d4e25978b@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0cd301eb-c2a4-bc90-46b8-cb4d4e25978b@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211026_052310_564899_9BC06187 X-CRM114-Status: GOOD ( 19.46 ) 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 Tue, Oct 26, 2021 at 12:22:20PM +0100, Robin Murphy wrote: > On 2021-10-26 04:48, Reiji Watanabe wrote: > > Currently, clear_page() uses DC ZVA instruction unconditionally. But it > > should make sure that DCZID_EL0.DZP, which indicates whether or not use > > of DC ZVA instruction is prohibited, is zero when using the instruction. > > Use stp as memset does instead when DCZID_EL0.DZP == 1. > > > > Signed-off-by: Reiji Watanabe > > --- > > arch/arm64/lib/clear_page.S | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/arch/arm64/lib/clear_page.S b/arch/arm64/lib/clear_page.S > > index b84b179edba3..7ce1bfa4081c 100644 > > --- a/arch/arm64/lib/clear_page.S > > +++ b/arch/arm64/lib/clear_page.S > > @@ -16,6 +16,7 @@ > > */ > > SYM_FUNC_START_PI(clear_page) > > mrs x1, dczid_el0 > > + tbnz x1, #4, 2f /* Branch if DC GVA is prohibited */ DCZID_EL0.DZP (AKA DCZID_EL0[4]) says whether all of DC {ZVA,GVA,GZVA} are prohibited. This loop uses DZ ZVA, not GC GVA, so it'd be nice to s/GVA/ZVA/ here. Howver, `DC GVA` and `DC GZVA` are both used in mte_set_mem_tag_range(), which'll need a similar update... > > and w1, w1, #0xf > > mov x2, #4 > > lsl x1, x2, x1 > > @@ -25,5 +26,15 @@ SYM_FUNC_START_PI(clear_page) > > tst x0, #(PAGE_SIZE - 1) > > b.ne 1b > > ret > > + > > +2: mov x1, #(PAGE_SIZE) > > + sub x0, x0, #16 /* Pre-bias. */ > > Out of curiosity, what's this for? It's not like we need to worry about > PAGE_SIZE or page addresses being misaligned. I don't really see why we'd > need a different condition from the DC ZVA loop. I believe this was copied from arch/arm64/lib/memset.S, in the `.Lnot_short` case, where we have: | .Lnot_short: | sub dst, dst, #16/* Pre-bias. */ | sub count, count, #64 | 1: | stp A_l, A_l, [dst, #16] | stp A_l, A_l, [dst, #32] | stp A_l, A_l, [dst, #48] | stp A_l, A_l, [dst, #64]! | subs count, count, #64 | b.ge 1b > Robin. > > > +3: stp xzr, xzr, [x0, #16] > > + stp xzr, xzr, [x0, #32] > > + stp xzr, xzr, [x0, #48] > > + stp xzr, xzr, [x0, #64]! > > + subs x1, x1, #64 > > + b.gt 3b > > + ret FWIW, I'd also prefer consistency with the existing loop, i.e. 2: stp xzr, xzr, [x0, #0] stp xzr, xzr, [x0, #16] stp xzr, xzr, [x0, #32] stp xzr, xzr, [x0, #48] add x0, x0, #64 tst x0, #(PAGE_SIZE - 1) b.ne 2b ret Thanks, Mark. > > SYM_FUNC_END_PI(clear_page) > > EXPORT_SYMBOL(clear_page) > > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel