Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3697001pxb; Mon, 24 Jan 2022 15:38:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+e1bcQZJwsqC0oXQ4ZNK4dBp3YQsC+MpeANuBaSDfQZkfoU+XYgSH/9JchYXTEYmdFift X-Received: by 2002:a17:902:e810:b0:14b:2636:9ec3 with SMTP id u16-20020a170902e81000b0014b26369ec3mr13361992plg.102.1643067536236; Mon, 24 Jan 2022 15:38:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067536; cv=none; d=google.com; s=arc-20160816; b=xsiJ37qfLYDh9WjU7AdrpAEvLEmEa3GCxZUmtvXaSKJG6kiaMObRhRvnxIwUo6h9Sv rVSeeufgk1NyALlZZ8JTGP1KLNDcHmoN89y6mOqUSh3+O5wN7YT4MacDoC7lSDfDtAA5 Vfc5W4e4i51E4f7MK5C7hU0DpUApeKMk08vvE3FkCD905iJseQnLrr5dO3ZWdaAplr8s 4NQ4F4uJ/CWajzIlIxS0zspQwRDOQsOeyo9hfKZoFBTnzO741E3ZdMJmKmvLvqs8I2ba 0hQvxTNj5u69PzHnFkcDY8IPJBrDF9Q26dDsXZyCQzJ/Q7PG1AHzUEXTxbAvuMd4TeIF VUrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K8d+G35QLUpvBLXzIkQsiK/31Jkarey9Uo63Wr6jpr4=; b=bpBaJ9poOK4rFpdF3bexJ5SLH0RMv+2JkdPAZ/v4yGcTQ1ZgU0pkz6gBcQ9FYgTKXp +bwiUER4jr99gwmjAlMMBLrpSfTfGslTs5x9QRzjiLqtut0zYck8YT1vM6rinZ79XdPy zKlT0XVUd9+O93QYxR9QHM8VAuMOa0iQ5KGBvcIadj/cPB/D0YePeKsmn8ssduS1mVLy L020VBDTDshuUqbV9EAWVCVNLvn2lXYnR108BwUptIUwQE/bgA4Qep62NjAdVWi/9zMj ajcEDD872+tIjz1mFyYguuHIgxGO1hl1ntkdudLjyS86O1y2vXrYeYLKOr0B7+Bxk7IO DUHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DHUyfZ+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si658783pjx.3.2022.01.24.15.38.44; Mon, 24 Jan 2022 15:38:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DHUyfZ+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2359621AbiAXXdB (ORCPT + 99 others); Mon, 24 Jan 2022 18:33:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1837010AbiAXWli (ORCPT ); Mon, 24 Jan 2022 17:41:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19865C055A8F; Mon, 24 Jan 2022 13:04:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C9F7EB812A8; Mon, 24 Jan 2022 21:04:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA8AFC340E5; Mon, 24 Jan 2022 21:04:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058275; bh=16LNaUCzIzb/T+JoyZ/ziwN0gPqMj0yFnQdm07T7pxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHUyfZ+qAkqow1lq2bNaGIvPhQeO6kfo5wVWwoX0XQONplpRlqbhftjZAPEJlMe6d yY8bAOR45PTerA0+wEM2MZq70MW4YTubBPkCePi6IAicNMA+xfjpS3OF4lh86415nb SuFSY6nwImZPqF1oayt+YTq15n4FIqO3cqv/xObA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Reiji Watanabe , Robin Murphy , Catalin Marinas , Sasha Levin Subject: [PATCH 5.16 0237/1039] arm64: clear_page() shouldnt use DC ZVA when DCZID_EL0.DZP == 1 Date: Mon, 24 Jan 2022 19:33:46 +0100 Message-Id: <20220124184133.283001988@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Reiji Watanabe [ Upstream commit f0616abd4e67143b45b04b565839148458857347 ] 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 Link: https://lore.kernel.org/r/20211206004736.1520989-2-reijiw@google.com Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- 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 b84b179edba3a..1fd5d790ab800 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) -- 2.34.1