From patchwork Mon Nov 8 07:11:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12607925 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 6B934C433F5 for ; Mon, 8 Nov 2021 07:15:05 +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 31EB3610A2 for ; Mon, 8 Nov 2021 07:15:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 31EB3610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lUbcRRuOynHJrojdrSQ923PPUq7iKk/sX8GMOczpZH0=; b=xCWhcAVjlgjBYWI6CKqcr0piPk XiWnBvce7xhNQ28K5fyk7euWVtY2CRum8gF0osjC2darc396dC4hNDynqGI2hrEkU2nvxZZeSLLT3 Nf8nQHT7QpjUZ5FSRdReP/aVxEsG41nYXjfpzOwqm746cxBy57/oLB+nUIXCjnP2WlRdnty0r42uu 6A7y4ZwSiSrc9vRzGnVrzBrly7H2eMCIcfbKldRUzVLAfrsvdGtDtw/1Kp/IWd77Om5siA9T9Ua5o P1dLdSO1iRXFyUJloiT8TuuWaPR6N0tDr/fGkrqHcNEP8YB6R6wzFnrJJf/N8FZkNuULt1IdJMV5l hAD2WT4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mjyqX-00FXXl-Du; Mon, 08 Nov 2021 07:13:37 +0000 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mjyqS-00FXWf-B8 for linux-arm-kernel@lists.infradead.org; Mon, 08 Nov 2021 07:13:35 +0000 Received: by mail-pg1-x54a.google.com with SMTP id z7-20020a63c047000000b0026b13e40309so9552513pgi.19 for ; Sun, 07 Nov 2021 23:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Ff0DQyyijjS/HbJd4Jx1dDiydS91TZk8zbynNORckFk=; b=fxuKjCaKJE0HCkTsIgy6Q50cMClMu5Iz5hF+VIdXaT069AUhAlvmRLj8uR8lJSi2qJ uLcPSvL1vTx8We6sDeUiMQzuhSoJ4Nunae/Kqf4zYR352X9r2YegxPnAt6E1fW/i7K/P 5vKk8nYxF9yqD7yIL/BzKnO80lIafwVUaHSwYWN1XGVgDofegEf9HrdrWV0e8Xr/TvvM UAZhTtRJdbN5RAtvIjuSgdb87us7Vge2OYuM4uG/UAqJICeNqfMuG0Jy5ATmq90Ff4xb 4OKCPjDBxQNF0dTaCOoHUAKslapEyStVGHJ3coxJlSAwi86tYm0eDyT4o/JIpDOmrQuS YMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Ff0DQyyijjS/HbJd4Jx1dDiydS91TZk8zbynNORckFk=; b=KugSqcSdWR0QSHH/VP5NPcAcIo2p7GWUYxyobNUwyqRQfx9vjHJT4J3UsNr9L4kMWP XPqOWDkYr+HtRga/E9Ig341e6inj91ConcFE5UzO3rwmpcYinvYiGEMxqamwMYo++Z8n SPNWChdK8FqgI+BJyx4dPa7C+JD76Y7RrmrGIhsnBT6NC0hWoidg4jZZUJE/tzamwYC8 Q2reDXD0MWXAvpH5Yyv+QvoopiwIK7VULHnz1rkcItyXGNYDZgz9i0Z5fOCQRQzhTfgn Rhehgsp87CWKuUuSpChTFw80/g8Kw1JSuZxqWXtWXUpXrEAQrIa7e5RdPWmypYsFxxP0 XpEg== X-Gm-Message-State: AOAM530AAr1Sty90yAnfvvMKPTW1HklJd2YF65nx3kkP/JYx7fLLdDhf FSpGwjx7nwsUxq3Mcm+X33I/FsL/JiI= X-Google-Smtp-Source: ABdhPJw1+vD08mBGsf/uyUXTIILriyxJEePDxoIz9F9k4SGszh+IWPgIV0nho6tzixOkntLKN1Qv5XjBjyc= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a17:902:d718:b0:13d:e2ec:1741 with SMTP id w24-20020a170902d71800b0013de2ec1741mr68261112ply.38.1636355610831; Sun, 07 Nov 2021 23:13:30 -0800 (PST) Date: Sun, 7 Nov 2021 23:11:48 -0800 In-Reply-To: <20211108071149.823570-1-reijiw@google.com> Message-Id: <20211108071149.823570-2-reijiw@google.com> Mime-Version: 1.0 References: <20211108071149.823570-1-reijiw@google.com> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog Subject: [PATCH v2 1/2] arm64: clear_page() shouldn't use DC ZVA when DCZID_EL0.DZP == 1 From: Reiji Watanabe To: Catalin Marinas , Will Deacon Cc: Marc Zyngier , Robin Murphy , Mark Rutland , Peter Collingbourne , Evgenii Stepanov , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211107_231332_410860_016B81F6 X-CRM114-Status: UNSURE ( 8.60 ) X-CRM114-Notice: Please train this message. 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 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. Fixes: f27bb139c387 ("arm64: Miscellaneous library functions") Signed-off-by: Reiji Watanabe Reviewed-by: Robin Murphy --- arch/arm64/lib/clear_page.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/lib/clear_page.S b/arch/arm64/lib/clear_page.S index b84b179edba3..ea3a6c927fe8 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 ZVA is prohibited */ and w1, w1, #0xf mov x2, #4 lsl x1, x2, x1 @@ -25,5 +26,14 @@ SYM_FUNC_START_PI(clear_page) tst x0, #(PAGE_SIZE - 1) b.ne 1b ret + +2: stp xzr, xzr, [x0] + 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 SYM_FUNC_END_PI(clear_page) EXPORT_SYMBOL(clear_page)