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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 266A0C02198 for ; Wed, 12 Feb 2025 17:11:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B615F6B0085; Wed, 12 Feb 2025 12:11:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B10F76B0088; Wed, 12 Feb 2025 12:11:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D8B16B0089; Wed, 12 Feb 2025 12:11:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 80D846B0085 for ; Wed, 12 Feb 2025 12:11:48 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 330FB823E7 for ; Wed, 12 Feb 2025 17:11:48 +0000 (UTC) X-FDA: 83111934696.23.B00419E Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf03.hostedemail.com (Postfix) with ESMTP id 7531720002 for ; Wed, 12 Feb 2025 17:11:46 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of cmarinas@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739380306; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UYT8AXeHwSuOZw0yu7hG8Ej/uv+EEusdL0gi3kC7KOg=; b=L+51CUFrEbLwxvEPzKtmkKZr5YN7zQzOkg9ZxA/MF621LmT0OGvAfYrbEOPs+e/BEKbMek 5WnwTvTe0TjwZir9z2IuHmZnV24sAlR84C7PshTQY7pMzLC4G1WW4C07v4A+AKTKxTHeqg w7VhzyrolP560O3S75vIzNL2Zo2KXEM= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of cmarinas@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739380306; a=rsa-sha256; cv=none; b=nuFrv7oeXnDCSY0Gw7AS6/Kmk5NNDNqMvV6abHyCV/KufkEoZUcLRFTO8NhJs89T347IbM jUaaYKinauoJD+l2O/r3ryDSK50tRJxOMMMJmBzBGBjIQR2Q/zywNJmTCmjC/VvVMhVeXy R807XmPySvpcyDTY4dqnxXfqGKTiXYM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 38FCFA40118; Wed, 12 Feb 2025 17:10:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46F24C4CEDF; Wed, 12 Feb 2025 17:11:40 +0000 (UTC) Date: Wed, 12 Feb 2025 17:11:37 +0000 From: Catalin Marinas To: Tong Tiangen Cc: Mark Rutland , Jonathan Cameron , Mauro Carvalho Chehab , Will Deacon , Andrew Morton , James Morse , Robin Murphy , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Michael Ellerman , Nicholas Piggin , Andrey Ryabinin , Alexander Potapenko , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Madhavan Srinivasan , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, wangkefeng.wang@huawei.com, Guohanjun Subject: Re: [PATCH v13 4/5] arm64: support copy_mc_[user]_highpage() Message-ID: References: <20241209024257.3618492-1-tongtiangen@huawei.com> <20241209024257.3618492-5-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241209024257.3618492-5-tongtiangen@huawei.com> X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 7531720002 X-Stat-Signature: y6uiyj4hfuiopk9w8x8h8djdt84tstd7 X-HE-Tag: 1739380306-953839 X-HE-Meta: U2FsdGVkX1+5Wxg64HiMMwSUhnMbSFjrIWk9z3hAy+3uEcCaI1WEqlS7tfmLU1fpPkRweimkqHGvnFQChpxInMua89xyjJD/qqVYBMFLFWbkLltieYFU9IYGUe5Fh/1oExJOQiRiJGOnSw5O1oZxvV1HcU6kASfwnEzGYced+Du5S9YD7rRUdlnr6yoBepgWyG+ajelI+i/WfsfiPhc0QOmhekq4Pzg7s/HBj2bkbiP/epDxUWTLkK8tLSrK9L5ayD5GZTe5AzvQP07qF70vdz1P6oPOpn66/IqvYQVksgGyVFR8tb04KuT6UNPnupX3LF06jVq1WZwNAa13WDVOXHx9uDQ6jWf2VExDMLSIpJDwhS/ADtqWbIe0gVBM+2cfLQBwRpPjH+5aVpxavyXM3VrR7SZuhpSCacpvYaLgWq6wFjZlXwajXt9wA0Cu0xDwqGHxmv/VmQWpqTRtDq4yYUyeIb2TIPvuy0hQuhvNboGT6fNFFLEvLXKhqAL66BXxxOzCNQsWoKI/aEd7mU2qeLmwcrlw7PXULfQnkYThkOYFrC97Op6NthggT6yxtnj+SvMRxdmgXoNdIbYMO7ATBFVI86wCjvk26v5noQtyHxc/tLk75BA3ybmS26ssOJWRbQiztZDz+nU7lG7mAYHfF126oPta+op6R4bEhg+X+z9xBVLhYuo3+Uet5CLEU2TzVsyA6T2XRAprod0tAJHfJIgBBpTyxQDD8Z2rSqwHwOLBdhHZITtclR+EkOi5s4xKJHZ/dYm4Kek2yBz/n5V4m0/JTc9aOk+/eF3WSR6mrtYq19uwITbWuEHaF55Do4PSmuVJVwzHY8fQNDRp1eelgoQXULkqGOX7r2f9+WJjE7Qv6l0FDdObVEAHGaIarO2iNEHVfc+O64azVMTW01B0MSeE4fU4EknZDCyYXG2ULSleF8yGcu31qtAXH6UBYD3Wt9JfIlKM9DCZf4w9e3g 1WYrRXbo ssFMlwVqhirANRffZGO4tm6bj8MVrwJ740QWMGGIMZFzb1sCYbm9e175SywQ5P8cTuHlGTU2WfGO3V6IHgzEPeUA+Reoq7BLvq7VntN3mCsNbWmOvhRem15C1dG9ppg+CzirpCMJr/m4JNTfBBEr/adOWFkPZWWmd2QdIVhVqku6gT9+LjxwTQUuJLylNX337PST2t74SME8TnqHgCSTRHP/0XfLCGChcSp22AJzU/trgslcit4u3IuYLvm6FYuWo0z+bxbXHdgCUygeWxgq/+ivSQLaRNSMrlgKuE/bQiZQhT3vQL/3FIkmW7L4V1JOH/sPuqvWwoIb65STNzXUzyX+qVjygshlu6sZqsXMtwJLhyrMeS+hP10SR3ydfeNqNwBQ5Mg2MrfB1bhwd2Jc432GAh+q34X/oprRrjH1cY6QnfBli10iQoa6SNltmy11X5S89lhFdqFL93kqBPw7jJb+o7YgmtMFhFOkK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Dec 09, 2024 at 10:42:56AM +0800, Tong Tiangen wrote: > Currently, many scenarios that can tolerate memory errors when copying page > have been supported in the kernel[1~5], all of which are implemented by > copy_mc_[user]_highpage(). arm64 should also support this mechanism. > > Due to mte, arm64 needs to have its own copy_mc_[user]_highpage() > architecture implementation, macros __HAVE_ARCH_COPY_MC_HIGHPAGE and > __HAVE_ARCH_COPY_MC_USER_HIGHPAGE have been added to control it. > > Add new helper copy_mc_page() which provide a page copy implementation with > hardware memory error safe. The code logic of copy_mc_page() is the same as > copy_page(), the main difference is that the ldp insn of copy_mc_page() > contains the fixup type EX_TYPE_KACCESS_ERR_ZERO_MEM_ERR, therefore, the > main logic is extracted to copy_page_template.S. In addition, the fixup of > MOPS insn is not considered at present. Could we not add the exception table entry permanently but ignore the exception table entry if it's not on the do_sea() path? That would save some code duplication. > diff --git a/arch/arm64/lib/copy_mc_page.S b/arch/arm64/lib/copy_mc_page.S > new file mode 100644 > index 000000000000..51564828c30c > --- /dev/null > +++ b/arch/arm64/lib/copy_mc_page.S > @@ -0,0 +1,37 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * Copy a page from src to dest (both are page aligned) with memory error safe > + * > + * Parameters: > + * x0 - dest > + * x1 - src > + * Returns: > + * x0 - Return 0 if copy success, or -EFAULT if anything goes wrong > + * while copying. > + */ > + .macro ldp1 reg1, reg2, ptr, val > + KERNEL_MEM_ERR(9998f, ldp \reg1, \reg2, [\ptr, \val]) > + .endm > + > +SYM_FUNC_START(__pi_copy_mc_page) > +#include "copy_page_template.S" > + > + mov x0, #0 > + ret > + > +9998: mov x0, #-EFAULT > + ret > + > +SYM_FUNC_END(__pi_copy_mc_page) > +SYM_FUNC_ALIAS(copy_mc_page, __pi_copy_mc_page) > +EXPORT_SYMBOL(copy_mc_page) [...] > diff --git a/arch/arm64/lib/copy_page_template.S b/arch/arm64/lib/copy_page_template.S > new file mode 100644 > index 000000000000..f96c7988c93d > --- /dev/null > +++ b/arch/arm64/lib/copy_page_template.S > @@ -0,0 +1,70 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (C) 2012 ARM Ltd. > + */ > + > +/* > + * Copy a page from src to dest (both are page aligned) > + * > + * Parameters: > + * x0 - dest > + * x1 - src > + */ > + > +#ifdef CONFIG_AS_HAS_MOPS > + .arch_extension mops > +alternative_if_not ARM64_HAS_MOPS > + b .Lno_mops > +alternative_else_nop_endif > + > + mov x2, #PAGE_SIZE > + cpypwn [x0]!, [x1]!, x2! > + cpymwn [x0]!, [x1]!, x2! > + cpyewn [x0]!, [x1]!, x2! > + ret > +.Lno_mops: > +#endif [...] So if we have FEAT_MOPS, the machine check won't work? Kristina is going to post MOPS support for the uaccess routines soon. You can see how they are wired up and do something similar here. But I'd prefer if we had the same code, only the exception table entry treated differently. Similarly for the MTE tag copying. -- Catalin