{"id":2229035,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229035/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-arc/patch/9fe875d2f55af59c12708336c571a46038528678.1777306795.git.chleroy@kernel.org/","project":{"id":48,"url":"http://patchwork.ozlabs.org/api/1.1/projects/48/?format=json","name":"Linux ARC development","link_name":"linux-arc","list_id":"linux-snps-arc.lists.infradead.org","list_email":"linux-snps-arc@lists.infradead.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<9fe875d2f55af59c12708336c571a46038528678.1777306795.git.chleroy@kernel.org>","date":"2026-04-27T17:13:43","name":"[RFC,v1,2/9] uaccess: Convert INLINE_COPY_{TO/FROM}_USER to kconfig and reduce ifdefery","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"34083bc2cd6496d13fb1e7a3d29ca6c667f90c8a","submitter":{"id":92089,"url":"http://patchwork.ozlabs.org/api/1.1/people/92089/?format=json","name":"Christophe Leroy (CS GROUP)","email":"chleroy@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-arc/patch/9fe875d2f55af59c12708336c571a46038528678.1777306795.git.chleroy@kernel.org/mbox/","series":[{"id":501692,"url":"http://patchwork.ozlabs.org/api/1.1/series/501692/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-arc/list/?series=501692","date":"2026-04-27T17:13:41","name":"uaccess: Convert small fixed size copy_{to/from}_user() to scoped user access","version":1,"mbox":"http://patchwork.ozlabs.org/series/501692/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229035/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229035/checks/","tags":{},"headers":{"Return-Path":"\n <linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oithFKSH;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=iZa57++f;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g49HP43Zpz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 03:17:37 +1000 (AEST)","from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHPaS-0000000HQcD-1Xtb;\n\tMon, 27 Apr 2026 17:17:36 +0000","from tor.source.kernel.org ([172.105.4.254])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHPaP-0000000HQa2-2faa;\n\tMon, 27 Apr 2026 17:17:33 +0000","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id A0A196015B;\n\tMon, 27 Apr 2026 17:17:32 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 9AEAAC2BCB5;\n\tMon, 27 Apr 2026 17:17:13 +0000 (UTC)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=7gIn2HLCDZ6TMXo2Mmy/5AWZNKt72cTcIedprlWH7Rk=; b=oithFKSH8v10QJ\n\t9DabBGOt62ynvVgTpqRFJEPdQ0WD8OrJJsGXrYMAHKINCM0yS7xZi72d4W/NDEAZqbhcW0Uibl4Qe\n\tzkDdps8HW/DK2Y38XDXXcFS11KK2oVIBlV7ZMvsYCuzAul6cBl5nuIs42m6W1w+cY5jikAFCYsOFE\n\t74lDgWn0/Mv5Vj5incdfgv8jz0gTrTv6mawim0K5HfZ+WruGLS5yQd1J4YJ2eDt/C88t+Y2n5XpCh\n\tWJo/SeS/Qi9oYPA2avWGeXOcPfq5Fnenx+KFxqBIqv+NmPTXl389fDooPZqlCphLutCLQjbaU2J62\n\tukVZY14ZWvAMl/T2ZdjQ==;","v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777310252;\n\tbh=2A3pp34TaOBrBLCc7n3D/0VUADnJLMBU+ywYlmILDq0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=iZa57++f4J+GqwvmN6cOlz8Y1H7GNDryi4ZRD+CJk+hBQU7Iobf+tE7/GXYinO2zm\n\t iEth1up0MDkLOAxzQiz5mqcfHR3P06TXmSl3XzIFaDPQuFHo3UkJmapo/kW88jy3aQ\n\t 3aznlfwGIxcYhdaW4V5tVjatVhcyAHWEKfRp+CGH8zAHmw+dzciaz6iCaNPprV57bn\n\t 8osxBss4ioepFyLm+2kR+UIAIIrgH8FbX9Dl39gcSvCHEwtnH4JUk+pOBX2jvh7BG3\n\t 7M8Bd9CW5MVAHSPSRYqg08B9eeC3kSJm80fJ6QSe91ed2+rsgDjp3uvvAKjOOY8v3a\n\t 6k1/LUiGGTPUw=="],"From":"\"Christophe Leroy (CS GROUP)\" <chleroy@kernel.org>","To":"Yury Norov <ynorov@nvidia.com>,\n\tAndrew Morton <akpm@linux-foundation.org>,\n\tLinus Torvalds <torvalds@linux-foundation.org>,\n\tDavid Laight <david.laight.linux@gmail.com>,\n\tThomas Gleixner <tglx@linutronix.de>","Cc":"\"Christophe Leroy (CS GROUP)\" <chleroy@kernel.org>,\n\tlinux-alpha@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-snps-arc@lists.infradead.org,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-mips@vger.kernel.org,\n\tlinuxppc-dev@lists.ozlabs.org,\n\tkvm@vger.kernel.org,\n\tlinux-riscv@lists.infradead.org,\n\tlinux-s390@vger.kernel.org,\n\tsparclinux@vger.kernel.org,\n\tlinux-um@lists.infradead.org,\n\tdmaengine@vger.kernel.org,\n\tlinux-efi@vger.kernel.org,\n\tlinux-fsi@lists.ozlabs.org,\n\tamd-gfx@lists.freedesktop.org,\n\tdri-devel@lists.freedesktop.org,\n\tintel-gfx@lists.freedesktop.org,\n\tlinux-wpan@vger.kernel.org,\n\tnetdev@vger.kernel.org,\n\tlinux-wireless@vger.kernel.org,\n\tlinux-spi@vger.kernel.org,\n\tlinux-media@vger.kernel.org,\n\tlinux-staging@lists.linux.dev,\n\tlinux-serial@vger.kernel.org,\n\tlinux-usb@vger.kernel.org,\n\txen-devel@lists.xenproject.org,\n\tlinux-fsdevel@vger.kernel.org,\n\tocfs2-devel@lists.linux.dev,\n\tbpf@vger.kernel.org,\n\tkasan-dev@googlegroups.com,\n\tlinux-mm@kvack.org,\n\tlinux-x25@vger.kernel.org,\n\trust-for-linux@vger.kernel.org,\n\tlinux-sound@vger.kernel.org,\n\tsound-open-firmware@alsa-project.org,\n\tlinux-csky@vger.kernel.org,\n\tlinux-hexagon@vger.kernel.org,\n\tloongarch@lists.linux.dev,\n\tlinux-m68k@lists.linux-m68k.org,\n\tlinux-openrisc@vger.kernel.org,\n\tlinux-parisc@vger.kernel.org,\n\tlinux-sh@vger.kernel.org,\n\tlinux-arch@vger.kernel.org","Subject":"[RFC PATCH v1 2/9] uaccess: Convert INLINE_COPY_{TO/FROM}_USER to\n kconfig and reduce ifdefery","Date":"Mon, 27 Apr 2026 19:13:43 +0200","Message-ID":"\n <9fe875d2f55af59c12708336c571a46038528678.1777306795.git.chleroy@kernel.org>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<cover.1777306795.git.chleroy@kernel.org>","References":"<cover.1777306795.git.chleroy@kernel.org>","MIME-Version":"1.0","X-Developer-Signature":"v=1; a=openpgp-sha256; l=18999; i=chleroy@kernel.org;\n h=from:subject:message-id; bh=2A3pp34TaOBrBLCc7n3D/0VUADnJLMBU+ywYlmILDq0=;\n b=owGbwMvMwCV2d0KB2p7V54MZT6slMWS+nxl942rk7qV/z0wpsopc/EjgrOKra6+/qq3zDzp1o\n 3Cx5MQvcR2lLAxiXAyyYoosx/9z75rR9SU1f+oufZg5rEwgQxi4OAVgIuKajAx/ndKvMf5+vP6+\n 0DUOzaI/8u977T8/tn8jYyzy8FHU4dqzDP9dp5oyP1vg/Kml4FbUFMnSvxpN1/NNNGPF159+JNd\n bVcIDAA==","X-Developer-Key":"i=chleroy@kernel.org; a=openpgp;\n fpr=10FFE6F8B390DE17ACC2632368A92FEB01B8DD78","X-BeenThere":"linux-snps-arc@lists.infradead.org","X-Mailman-Version":"2.1.34","Precedence":"list","List-Id":"Linux on Synopsys ARC Processors <linux-snps-arc.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-snps-arc>,\n <mailto:linux-snps-arc-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-snps-arc/>","List-Post":"<mailto:linux-snps-arc@lists.infradead.org>","List-Help":"<mailto:linux-snps-arc-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-snps-arc>,\n <mailto:linux-snps-arc-request@lists.infradead.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"\"linux-snps-arc\" <linux-snps-arc-bounces@lists.infradead.org>","Errors-To":"\n linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"},"content":"Among the 21 architectures supported by the kernel, 16 define both\nINLINE_COPY_TO_USER and INLINE_COPY_FROM_USER while the 5 other ones\ndon't define any of the two.\n\nTo simplify and reduce risk of mistakes, convert them to a single\nkconfig item named CONFIG_ARCH_WANTS_NOINLINE_COPY which will be\nselected by the 5 architectures that don't want inlined copy.\n\nTo minimise complication in a later patch, also remove\nifdefery and replace it with IS_ENABLED().\n\nSigned-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>\n---\n arch/alpha/Kconfig                    |  1 +\n arch/arc/include/asm/uaccess.h        |  3 ---\n arch/arm/include/asm/uaccess.h        |  2 --\n arch/arm64/include/asm/uaccess.h      |  3 ---\n arch/csky/Kconfig                     |  1 +\n arch/hexagon/include/asm/uaccess.h    |  3 ---\n arch/loongarch/include/asm/uaccess.h  |  3 ---\n arch/m68k/include/asm/uaccess.h       |  3 ---\n arch/microblaze/include/asm/uaccess.h |  2 --\n arch/mips/include/asm/uaccess.h       |  3 ---\n arch/nios2/include/asm/uaccess.h      |  2 --\n arch/openrisc/include/asm/uaccess.h   |  2 --\n arch/parisc/include/asm/uaccess.h     |  3 ---\n arch/powerpc/Kconfig                  |  1 +\n arch/riscv/Kconfig                    |  1 +\n arch/s390/include/asm/uaccess.h       |  3 ---\n arch/sh/include/asm/uaccess.h         |  2 --\n arch/sparc/include/asm/uaccess_32.h   |  3 ---\n arch/sparc/include/asm/uaccess_64.h   |  2 --\n arch/um/include/asm/uaccess.h         |  3 ---\n arch/x86/Kconfig                      |  1 +\n arch/xtensa/include/asm/uaccess.h     |  2 --\n include/asm-generic/uaccess.h         |  2 --\n include/linux/uaccess.h               | 32 ++++++++++++---------------\n lib/Kconfig                           |  3 +++\n lib/Makefile                          |  3 ++-\n lib/usercopy.c                        |  4 ----\n rust/helpers/uaccess.c                |  2 +-\n 28 files changed, 25 insertions(+), 70 deletions(-)","diff":"diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig\nindex 7b7dafe7d9df..65e533cead6b 100644\n--- a/arch/alpha/Kconfig\n+++ b/arch/alpha/Kconfig\n@@ -11,6 +11,7 @@ config ALPHA\n \tselect ARCH_NO_PREEMPT\n \tselect ARCH_NO_SG_CHAIN\n \tselect ARCH_USE_CMPXCHG_LOCKREF\n+\tselect ARCH_WANTS_NOINLINE_COPY_USER\n \tselect FORCE_PCI\n \tselect PCI_DOMAINS if PCI\n \tselect PCI_SYSCALL if PCI\ndiff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h\nindex 1e8809ea000a..e8b161b37a03 100644\n--- a/arch/arc/include/asm/uaccess.h\n+++ b/arch/arc/include/asm/uaccess.h\n@@ -628,9 +628,6 @@ static inline unsigned long __clear_user(void __user *to, unsigned long n)\n \treturn res;\n }\n \n-#define INLINE_COPY_TO_USER\n-#define INLINE_COPY_FROM_USER\n-\n #define __clear_user\t\t\t__clear_user\n \n #include <asm-generic/uaccess.h>\ndiff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h\nindex d6ae80b5df36..7280c162bb71 100644\n--- a/arch/arm/include/asm/uaccess.h\n+++ b/arch/arm/include/asm/uaccess.h\n@@ -616,8 +616,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n }\n #define __clear_user(addr, n)\t\t(memset((void __force *)addr, 0, n), 0)\n #endif\n-#define INLINE_COPY_TO_USER\n-#define INLINE_COPY_FROM_USER\n \n static inline unsigned long __must_check clear_user(void __user *to, unsigned long n)\n {\ndiff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h\nindex b0c83a08dda9..1e20ec91b56f 100644\n--- a/arch/arm64/include/asm/uaccess.h\n+++ b/arch/arm64/include/asm/uaccess.h\n@@ -456,9 +456,6 @@ do {\t\t\t\t\t\t\t\t\t\\\n \tunsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label);\t\\\n } while (0)\n \n-#define INLINE_COPY_TO_USER\n-#define INLINE_COPY_FROM_USER\n-\n extern unsigned long __must_check __arch_clear_user(void __user *to, unsigned long n);\n static inline unsigned long __must_check __clear_user(void __user *to, unsigned long n)\n {\ndiff --git a/arch/csky/Kconfig b/arch/csky/Kconfig\nindex 4331313a42ff..d010d7eb47bf 100644\n--- a/arch/csky/Kconfig\n+++ b/arch/csky/Kconfig\n@@ -40,6 +40,7 @@ config CSKY\n \tselect ARCH_NEED_CMPXCHG_1_EMU\n \tselect ARCH_WANT_FRAME_POINTERS if !CPU_CK610 && $(cc-option,-mbacktrace)\n \tselect ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT\n+\tselect ARCH_WANTS_NOINLINE_COPY_USER\n \tselect COMMON_CLK\n \tselect CLKSRC_MMIO\n \tselect CSKY_MPINTC if CPU_CK860\ndiff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h\nindex bff77efc0d9a..4bf863217636 100644\n--- a/arch/hexagon/include/asm/uaccess.h\n+++ b/arch/hexagon/include/asm/uaccess.h\n@@ -26,9 +26,6 @@ unsigned long raw_copy_from_user(void *to, const void __user *from,\n \t\t\t\t     unsigned long n);\n unsigned long raw_copy_to_user(void __user *to, const void *from,\n \t\t\t\t   unsigned long n);\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n __kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count);\n #define __clear_user(a, s) __clear_user_hexagon((a), (s))\n \ndiff --git a/arch/loongarch/include/asm/uaccess.h b/arch/loongarch/include/asm/uaccess.h\nindex 438269313e78..72a04ac88549 100644\n--- a/arch/loongarch/include/asm/uaccess.h\n+++ b/arch/loongarch/include/asm/uaccess.h\n@@ -292,9 +292,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n \treturn __copy_user((__force void *)to, from, n);\n }\n \n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n /*\n  * __clear_user: - Zero a block of memory in user space, with less checking.\n  * @addr: Destination address, in user space.\ndiff --git a/arch/m68k/include/asm/uaccess.h b/arch/m68k/include/asm/uaccess.h\nindex 64914872a5c9..20e249a6ad07 100644\n--- a/arch/m68k/include/asm/uaccess.h\n+++ b/arch/m68k/include/asm/uaccess.h\n@@ -377,9 +377,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n \t\treturn __constant_copy_to_user(to, from, n);\n \treturn __generic_copy_to_user(to, from, n);\n }\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n #define __get_kernel_nofault(dst, src, type, err_label)\t\t\t\\\n do {\t\t\t\t\t\t\t\t\t\\\n \ttype *__gk_dst = (type *)(dst);\t\t\t\t\t\\\ndiff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h\nindex 3aab2f17e046..3355f541e12a 100644\n--- a/arch/microblaze/include/asm/uaccess.h\n+++ b/arch/microblaze/include/asm/uaccess.h\n@@ -250,8 +250,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n {\n \treturn __copy_tofrom_user(to, (__force const void __user *)from, n);\n }\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n \n /*\n  * Copy a null terminated string from userspace.\ndiff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h\nindex c0cede273c7c..8714caefbac8 100644\n--- a/arch/mips/include/asm/uaccess.h\n+++ b/arch/mips/include/asm/uaccess.h\n@@ -433,9 +433,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n \treturn __cu_len_r;\n }\n \n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n extern __kernel_size_t __bzero(void __user *addr, __kernel_size_t size);\n \n /*\ndiff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h\nindex 6ccc9a232c23..46d7312a1c96 100644\n--- a/arch/nios2/include/asm/uaccess.h\n+++ b/arch/nios2/include/asm/uaccess.h\n@@ -57,8 +57,6 @@ extern unsigned long\n raw_copy_from_user(void *to, const void __user *from, unsigned long n);\n extern unsigned long\n raw_copy_to_user(void __user *to, const void *from, unsigned long n);\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n \n extern long strncpy_from_user(char *__to, const char __user *__from,\n \t\t\t      long __len);\ndiff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h\nindex d6500a374e18..c84effde867a 100644\n--- a/arch/openrisc/include/asm/uaccess.h\n+++ b/arch/openrisc/include/asm/uaccess.h\n@@ -218,8 +218,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long size)\n {\n \treturn __copy_tofrom_user((__force void *)to, from, size);\n }\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n \n extern unsigned long __clear_user(void __user *addr, unsigned long size);\n \ndiff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h\nindex 6c531d2c847e..1dd6a1dd653f 100644\n--- a/arch/parisc/include/asm/uaccess.h\n+++ b/arch/parisc/include/asm/uaccess.h\n@@ -197,7 +197,4 @@ unsigned long __must_check raw_copy_to_user(void __user *dst, const void *src,\n \t\t\t\t\t    unsigned long len);\n unsigned long __must_check raw_copy_from_user(void *dst, const void __user *src,\n \t\t\t\t\t    unsigned long len);\n-#define INLINE_COPY_TO_USER\n-#define INLINE_COPY_FROM_USER\n-\n #endif /* __PARISC_UACCESS_H */\ndiff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig\nindex e93df95b79e7..6816f402fe3d 100644\n--- a/arch/powerpc/Kconfig\n+++ b/arch/powerpc/Kconfig\n@@ -187,6 +187,7 @@ config PPC\n \tselect ARCH_WANT_LD_ORPHAN_WARN\n \tselect ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\tif PPC_RADIX_MMU\n \tselect ARCH_WANTS_MODULES_DATA_IN_VMALLOC\tif PPC_BOOK3S_32 || PPC_8xx\n+\tselect ARCH_WANTS_NOINLINE_COPY_USER\n \tselect ARCH_WEAK_RELEASE_ACQUIRE\n \tselect AUDIT_ARCH_COMPAT_GENERIC\n \tselect BINFMT_ELF\ndiff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig\nindex d235396c4514..492b920c1a51 100644\n--- a/arch/riscv/Kconfig\n+++ b/arch/riscv/Kconfig\n@@ -88,6 +88,7 @@ config RISCV\n \tselect ARCH_WANT_OPTIMIZE_DAX_VMEMMAP\n \tselect ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP\n \tselect ARCH_WANTS_NO_INSTR\n+\tselect ARCH_WANTS_NOINLINE_COPY_USER if MMU\n \tselect ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE\n \tselect ARCH_WEAK_RELEASE_ACQUIRE if ARCH_USE_QUEUED_SPINLOCKS\n \tselect BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU\ndiff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h\nindex dff035372601..2e0472c20da0 100644\n--- a/arch/s390/include/asm/uaccess.h\n+++ b/arch/s390/include/asm/uaccess.h\n@@ -30,9 +30,6 @@ void debug_user_asce(int exit);\n #define uaccess_kmsan_or_inline __always_inline\n #endif\n \n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n static uaccess_kmsan_or_inline __must_check unsigned long\n raw_copy_from_user(void *to, const void __user *from, unsigned long size)\n {\ndiff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h\nindex a79609eb14be..0cd75308e6d3 100644\n--- a/arch/sh/include/asm/uaccess.h\n+++ b/arch/sh/include/asm/uaccess.h\n@@ -95,8 +95,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n {\n \treturn __copy_user((__force void *)to, from, n);\n }\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n \n /*\n  * Clear the area and return remaining number of bytes\ndiff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h\nindex 43284b6ec46a..e01f43c6421c 100644\n--- a/arch/sparc/include/asm/uaccess_32.h\n+++ b/arch/sparc/include/asm/uaccess_32.h\n@@ -190,9 +190,6 @@ static inline unsigned long raw_copy_from_user(void *to, const void __user *from\n \treturn __copy_user((__force void __user *) to, from, n);\n }\n \n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n static inline unsigned long __clear_user(void __user *addr, unsigned long size)\n {\n \tunsigned long ret;\ndiff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h\nindex b825a5dd0210..62ee0b074fec 100644\n--- a/arch/sparc/include/asm/uaccess_64.h\n+++ b/arch/sparc/include/asm/uaccess_64.h\n@@ -231,8 +231,6 @@ unsigned long __must_check raw_copy_from_user(void *to,\n unsigned long __must_check raw_copy_to_user(void __user *to,\n \t\t\t\t\t   const void *from,\n \t\t\t\t\t   unsigned long size);\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n \n unsigned long __must_check raw_copy_in_user(void __user *to,\n \t\t\t\t\t   const void __user *from,\ndiff --git a/arch/um/include/asm/uaccess.h b/arch/um/include/asm/uaccess.h\nindex 0df9ea4abda8..1e14260c7f0f 100644\n--- a/arch/um/include/asm/uaccess.h\n+++ b/arch/um/include/asm/uaccess.h\n@@ -27,9 +27,6 @@ static inline int __access_ok(const void __user *ptr, unsigned long size);\n #define __access_ok __access_ok\n #define __clear_user __clear_user\n \n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n-\n #include <asm-generic/uaccess.h>\n \n static inline int __access_ok(const void __user *ptr, unsigned long size)\ndiff --git a/arch/x86/Kconfig b/arch/x86/Kconfig\nindex f3f7cb01d69d..c1e58d8c6864 100644\n--- a/arch/x86/Kconfig\n+++ b/arch/x86/Kconfig\n@@ -143,6 +143,7 @@ config X86\n \tselect ARCH_WANTS_CLOCKSOURCE_READ_INLINE\tif X86_64\n \tselect ARCH_WANTS_DYNAMIC_TASK_STRUCT\n \tselect ARCH_WANTS_NO_INSTR\n+\tselect ARCH_WANTS_NOINLINE_COPY_USER\n \tselect ARCH_WANT_GENERAL_HUGETLB\n \tselect ARCH_WANT_HUGE_PMD_SHARE\t\tif X86_64\n \tselect ARCH_WANT_LD_ORPHAN_WARN\ndiff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h\nindex 56aec6d504fe..f9e1623a7be9 100644\n--- a/arch/xtensa/include/asm/uaccess.h\n+++ b/arch/xtensa/include/asm/uaccess.h\n@@ -237,8 +237,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n \tprefetch(from);\n \treturn __xtensa_copy_user((__force void *)to, from, n);\n }\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n \n /*\n  * We need to return the number of bytes not cleared.  Our memset()\ndiff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h\nindex b276f783494c..fb33a71fd24e 100644\n--- a/include/asm-generic/uaccess.h\n+++ b/include/asm-generic/uaccess.h\n@@ -91,8 +91,6 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)\n \tmemcpy((void __force *)to, from, n);\n \treturn 0;\n }\n-#define INLINE_COPY_FROM_USER\n-#define INLINE_COPY_TO_USER\n #endif /* CONFIG_UACCESS_MEMCPY */\n \n /*\ndiff --git a/include/linux/uaccess.h b/include/linux/uaccess.h\nindex 56328601218c..bd1201c81d94 100644\n--- a/include/linux/uaccess.h\n+++ b/include/linux/uaccess.h\n@@ -83,8 +83,8 @@\n  * with that.  They should not be used directly; they are used to implement\n  * the 6 functions (copy_{to,from}_user(), __copy_{to,from}_user_inatomic())\n  * that are used instead.  Out of those, __... ones are inlined.  Plain\n- * copy_{to,from}_user() might or might not be inlined.  If you want them\n- * inlined, have asm/uaccess.h define INLINE_COPY_{TO,FROM}_USER.\n+ * copy_{to,from}_user() might or might not be inlined.  If you don't want them\n+ * inlined, select CONFIG_ARCH_WANTS_NOINLINE_COPY_USER.\n  *\n  * NOTE: only copy_from_user() zero-pads the destination in case of short copy.\n  * Neither __copy_from_user() nor __copy_from_user_inatomic() zero anything\n@@ -157,8 +157,8 @@ __copy_to_user(void __user *to, const void *from, unsigned long n)\n }\n \n /*\n- * Architectures that #define INLINE_COPY_TO_USER use this function\n- * directly in the normal copy_to/from_user(), the other ones go\n+ * Architectures that don't select CONFIG_ARCH_WANTS_NOINLINE_COPY_USER use\n+ * this function directly in the normal copy_to/from_user(), the other ones go\n  * through an extern _copy_to/from_user(), which expands the same code\n  * here.\n  */\n@@ -190,10 +190,9 @@ _inline_copy_from_user(void *to, const void __user *from, unsigned long n)\n \tmemset(to + (n - res), 0, res);\n \treturn res;\n }\n-#ifndef INLINE_COPY_FROM_USER\n+\n extern __must_check unsigned long\n _copy_from_user(void *, const void __user *, unsigned long);\n-#endif\n \n static inline __must_check unsigned long\n _inline_copy_to_user(void __user *to, const void *from, unsigned long n)\n@@ -207,21 +206,19 @@ _inline_copy_to_user(void __user *to, const void *from, unsigned long n)\n \t}\n \treturn n;\n }\n-#ifndef INLINE_COPY_TO_USER\n+\n extern __must_check unsigned long\n _copy_to_user(void __user *, const void *, unsigned long);\n-#endif\n \n static __always_inline unsigned long __must_check\n copy_from_user(void *to, const void __user *from, unsigned long n)\n {\n \tif (!check_copy_size(to, n, false))\n \t\treturn n;\n-#ifdef INLINE_COPY_FROM_USER\n-\treturn _inline_copy_from_user(to, from, n);\n-#else\n-\treturn _copy_from_user(to, from, n);\n-#endif\n+\tif (IS_ENABLED(ARCH_WANTS_NOINLINE_COPY_USER))\n+\t\treturn _copy_from_user(to, from, n);\n+\telse\n+\t\treturn _inline_copy_from_user(to, from, n);\n }\n \n static __always_inline unsigned long __must_check\n@@ -230,11 +227,10 @@ copy_to_user(void __user *to, const void *from, unsigned long n)\n \tif (!check_copy_size(from, n, true))\n \t\treturn n;\n \n-#ifdef INLINE_COPY_TO_USER\n-\treturn _inline_copy_to_user(to, from, n);\n-#else\n-\treturn _copy_to_user(to, from, n);\n-#endif\n+\tif (IS_ENABLED(ARCH_WANTS_NOINLINE_COPY_USER))\n+\t\treturn _copy_to_user(to, from, n);\n+\telse\n+\t\treturn _inline_copy_to_user(to, from, n);\n }\n \n #ifndef copy_mc_to_kernel\ndiff --git a/lib/Kconfig b/lib/Kconfig\nindex 00a9509636c1..a2e07d4dd2bf 100644\n--- a/lib/Kconfig\n+++ b/lib/Kconfig\n@@ -68,6 +68,9 @@ config ARCH_HAS_STRNCPY_FROM_USER\n config ARCH_HAS_STRNLEN_USER\n \tbool\n \n+config ARCH_WANTS_NOINLINE_COPY_USER\n+\tbool\n+\n config GENERIC_STRNCPY_FROM_USER\n \tdef_bool !ARCH_HAS_STRNCPY_FROM_USER\n \ndiff --git a/lib/Makefile b/lib/Makefile\nindex 7c0334d7675b..f4d577910671 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -57,9 +57,10 @@ obj-y += bcd.o sort.o parser.o debug_locks.o random32.o \\\n \t list_sort.o uuid.o iov_iter.o clz_ctz.o \\\n \t bsearch.o find_bit.o llist.o lwq.o memweight.o kfifo.o \\\n \t percpu-refcount.o rhashtable.o base64.o \\\n-\t once.o refcount.o rcuref.o usercopy.o errseq.o bucket_locks.o \\\n+\t once.o refcount.o rcuref.o errseq.o bucket_locks.o \\\n \t generic-radix-tree.o bitmap-str.o\n obj-y += usercheck.o\n+obj-$(CONFIG_ARCH_WANTS_NOINLINE_COPY_USER) += usercopy.o\n obj-y += string_helpers.o\n obj-y += hexdump.o\n obj-$(CONFIG_TEST_HEXDUMP) += test_hexdump.o\ndiff --git a/lib/usercopy.c b/lib/usercopy.c\nindex 7a93f56d81dd..d2deb4b0a3c5 100644\n--- a/lib/usercopy.c\n+++ b/lib/usercopy.c\n@@ -4,18 +4,14 @@\n \n /* out-of-line parts */\n \n-#if !defined(INLINE_COPY_FROM_USER)\n unsigned long _copy_from_user(void *to, const void __user *from, unsigned long n)\n {\n \treturn _inline_copy_from_user(to, from, n);\n }\n EXPORT_SYMBOL(_copy_from_user);\n-#endif\n \n-#if !defined(INLINE_COPY_TO_USER)\n unsigned long _copy_to_user(void __user *to, const void *from, unsigned long n)\n {\n \treturn _inline_copy_to_user(to, from, n);\n }\n EXPORT_SYMBOL(_copy_to_user);\n-#endif\ndiff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c\nindex d9625b9ee046..01de4fbbcc84 100644\n--- a/rust/helpers/uaccess.c\n+++ b/rust/helpers/uaccess.c\n@@ -14,7 +14,7 @@ rust_helper_copy_to_user(void __user *to, const void *from, unsigned long n)\n \treturn copy_to_user(to, from, n);\n }\n \n-#ifdef INLINE_COPY_FROM_USER\n+#ifndef CONFIG_ARCH_WANTS_NOINLINE_COPY_USER\n __rust_helper\n unsigned long rust_helper__copy_from_user(void *to, const void __user *from, unsigned long n)\n {\n","prefixes":["RFC","v1","2/9"]}