From patchwork Mon Dec 6 00:47:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12694855 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 E5593C433F5 for ; Mon, 6 Dec 2021 00:49: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: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=+ACOxmpINlfvej7uoiZKkgIfoLXEwiRRf+qnQU3y9sA=; b=FqrOd8zdhCtpwaX8EXrFwNz8EX nhuCb9ApxkNeGaoQB9r6whCzXJDaXO59w3VV0uvuA5WCpv1MEkwPBkZ/VJskyLTQgE6CCQiiwfcMw WZCR6O4q2HxPDCDgyItDGpJQ+MJa/purU3uHuvBn+nOk8CJsEkTopPpE1ntXiaar6zoWjk+rvJzCN J3Dl7PQTjVt3aXGf1dPkYlS5selATg3MnjROSFrqw0BpLWYtF80yFopenIKJW1AKq60t1wdSc81CB J97t4P/QQ1Q+5TO7eGRzRz6C/zh4PgZAq+lzoOyG3Q0WqcjTKDaMCLVbpi5jAGNAkKFy27a3bUNBp 3i4hg5mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mu2An-002GPT-VU; Mon, 06 Dec 2021 00:48:06 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mu2Ae-002GJm-2j for linux-arm-kernel@lists.infradead.org; Mon, 06 Dec 2021 00:47:57 +0000 Received: by mail-pf1-x449.google.com with SMTP id p1-20020aa79e81000000b004a82ea1b82bso5630604pfq.1 for ; Sun, 05 Dec 2021 16:47:54 -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=KsOznll2QzSvZVqEJOjZuGFneXu3otpLJElYDfbF2qA=; b=Q3DNXFG66kWeNZGr5r6y3DR4gjO0BgHFhM/wMuHleJTtufKYo0KG8MLwZhlA6Y5q45 82ADroFr8NPUxUB9o95M/nCNc4KMPkArDPMepE0R5PDwRaFmJBmqGxtiV6EoLKNDwwR1 1iFVjFmzXiKBYvSmULNXcEBiD3Ae3cgQ/P71izYHF87t/uwSG88y36V9KCcdV/YCNoFR xInYTKCkY1OGX6/Iu4hUFcotqkY1qnoIskCTMIrliwsQ26TMkpxXZXs9+72aEwjf5gZF 5NEQummgPVytTWP2aLbW78aX1/yr/C0JNH04V1yamsxK6dkJZGMcMHxgV8Jaf+4OqDAg uvqQ== 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=KsOznll2QzSvZVqEJOjZuGFneXu3otpLJElYDfbF2qA=; b=YHUbBaRpa6lWZCsOt0GVrQbsmEgV7CjbzWRZu751rTOHvtN1349rPR0sXpkvaxrVdN vQ7c9MTvokyCk2wRO4VYf8f7cLhUz47+GmlMxeB9eiFof3vGau52QdreGFsHBEtPT06N 0U1nK7HR6hneXF9YIGmkf2NFLXbfEJSS2gQN7rnTWVPOIBm9wmVbDlph9Vbc11puFzYB T4CMqLiGhpmYMaq4OB/alnGBr2JqUlDL6+tc7cTgtRw4+CPHx19zPhYwBfx355Sf9HPu MeuCRn/CmrgapjBHdWns6Deqh7BnOrgdH9KbGHC+jIJHxkbyyAUAFhbbvqGvFNe9+A5B N3bQ== X-Gm-Message-State: AOAM5329kEdUgUtHgF+vo8URDzAgqKWW4KPvoZ2AwHqFLBz66A5AbTKK 3IWb3hI8PxyQSSPY5N4lIvMHu+62Rfo= X-Google-Smtp-Source: ABdhPJxRJYIQILux9h9zY4HEbOzawFAJiz97BcS18IjIarPPZ5F7kk3Wtri7DZoBpdx7IUQEolDjdl86zBQ= X-Received: from reiji-vws-sp.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d59]) (user=reijiw job=sendgmr) by 2002:a05:6a00:1392:b0:4ad:5688:3e7d with SMTP id t18-20020a056a00139200b004ad56883e7dmr7308835pfg.59.1638751674177; Sun, 05 Dec 2021 16:47:54 -0800 (PST) Date: Sun, 5 Dec 2021 16:47:35 -0800 In-Reply-To: <20211206004736.1520989-1-reijiw@google.com> Message-Id: <20211206004736.1520989-2-reijiw@google.com> Mime-Version: 1.0 References: <20211206004736.1520989-1-reijiw@google.com> X-Mailer: git-send-email 2.34.1.400.ga245620fadb-goog Subject: [PATCH v4 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 , guanghuifeng@linux.alibaba.com, 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-20211205_164756_152162_E7B548F5 X-CRM114-Status: UNSURE ( 7.93 ) 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 STNP 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..1fd5d790ab80 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: stnp xzr, xzr, [x0] + stnp xzr, xzr, [x0, #16] + stnp xzr, xzr, [x0, #32] + stnp 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)