linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
	Greg Ungerer <gerg@linux-m68k.org>
Cc: Michael Schmitz <schmitzmic@gmail.com>, linux-m68k@lists.linux-m68k.org
Subject: [PATCH 3/7] m68k: remove the inline copy_{from,to}_user variants
Date: Fri,  9 Jul 2021 09:01:28 +0200	[thread overview]
Message-ID: <20210709070132.3387689-4-hch@lst.de> (raw)
In-Reply-To: <20210709070132.3387689-1-hch@lst.de>

Small access already use get_user/put_user so move the whole larger user
copy machinery out of line.

This saves almost 10k of .text for a defconfig build:

   text	   data	    bss	    dec	    hex	filename
4019751	1344434	 170104	5534289	 547251	vmlinux.pre
4015417	1338962	 170104	5524483	 544c03	vmlinux.post

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/m68k/include/asm/uaccess.h | 201 +-------------------------------
 arch/m68k/lib/uaccess.c         |  12 +-
 2 files changed, 10 insertions(+), 203 deletions(-)

diff --git a/arch/m68k/include/asm/uaccess.h b/arch/m68k/include/asm/uaccess.h
index 01334a9658c4..96aae4d4656b 100644
--- a/arch/m68k/include/asm/uaccess.h
+++ b/arch/m68k/include/asm/uaccess.h
@@ -181,203 +181,10 @@ asm volatile ("\n"					\
 })
 #define get_user(x, ptr) __get_user(x, ptr)
 
-unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n);
-unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned long n);
-
-#define __suffix0
-#define __suffix1 b
-#define __suffix2 w
-#define __suffix4 l
-
-#define ____constant_copy_from_user_asm(res, to, from, tmp, n1, n2, n3, s1, s2, s3)\
-	asm volatile ("\n"						\
-		"1:	"MOVES"."#s1"	(%2)+,%3\n"			\
-		"	move."#s1"	%3,(%1)+\n"			\
-		"	.ifnc	\""#s2"\",\"\"\n"			\
-		"2:	"MOVES"."#s2"	(%2)+,%3\n"			\
-		"	move."#s2"	%3,(%1)+\n"			\
-		"	.ifnc	\""#s3"\",\"\"\n"			\
-		"3:	"MOVES"."#s3"	(%2)+,%3\n"			\
-		"	move."#s3"	%3,(%1)+\n"			\
-		"	.endif\n"					\
-		"	.endif\n"					\
-		"4:\n"							\
-		"	.section __ex_table,\"a\"\n"			\
-		"	.align	4\n"					\
-		"	.long	1b,10f\n"				\
-		"	.ifnc	\""#s2"\",\"\"\n"			\
-		"	.long	2b,20f\n"				\
-		"	.ifnc	\""#s3"\",\"\"\n"			\
-		"	.long	3b,30f\n"				\
-		"	.endif\n"					\
-		"	.endif\n"					\
-		"	.previous\n"					\
-		"\n"							\
-		"	.section .fixup,\"ax\"\n"			\
-		"	.even\n"					\
-		"10:	addq.l #"#n1",%0\n"				\
-		"	.ifnc	\""#s2"\",\"\"\n"			\
-		"20:	addq.l #"#n2",%0\n"				\
-		"	.ifnc	\""#s3"\",\"\"\n"			\
-		"30:	addq.l #"#n3",%0\n"				\
-		"	.endif\n"					\
-		"	.endif\n"					\
-		"	jra	4b\n"					\
-		"	.previous\n"					\
-		: "+d" (res), "+&a" (to), "+a" (from), "=&d" (tmp)	\
-		: : "memory")
-
-#define ___constant_copy_from_user_asm(res, to, from, tmp, n1, n2, n3, s1, s2, s3)\
-	____constant_copy_from_user_asm(res, to, from, tmp, n1, n2, n3, s1, s2, s3)
-#define __constant_copy_from_user_asm(res, to, from, tmp, n1, n2, n3)	\
-	___constant_copy_from_user_asm(res, to, from, tmp, n1, n2, n3,  \
-					__suffix##n1, __suffix##n2, __suffix##n3)
-
-static __always_inline unsigned long
-__constant_copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-	unsigned long res = 0, tmp;
-
-	switch (n) {
-	case 1:
-		__constant_copy_from_user_asm(res, to, from, tmp, 1, 0, 0);
-		break;
-	case 2:
-		__constant_copy_from_user_asm(res, to, from, tmp, 2, 0, 0);
-		break;
-	case 3:
-		__constant_copy_from_user_asm(res, to, from, tmp, 2, 1, 0);
-		break;
-	case 4:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 0, 0);
-		break;
-	case 5:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 1, 0);
-		break;
-	case 6:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 2, 0);
-		break;
-	case 7:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 2, 1);
-		break;
-	case 8:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 4, 0);
-		break;
-	case 9:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 4, 1);
-		break;
-	case 10:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 4, 2);
-		break;
-	case 12:
-		__constant_copy_from_user_asm(res, to, from, tmp, 4, 4, 4);
-		break;
-	default:
-		/* we limit the inlined version to 3 moves */
-		return __generic_copy_from_user(to, from, n);
-	}
-
-	return res;
-}
-
-#define __constant_copy_to_user_asm(res, to, from, tmp, n, s1, s2, s3)	\
-	asm volatile ("\n"						\
-		"	move."#s1"	(%2)+,%3\n"			\
-		"11:	"MOVES"."#s1"	%3,(%1)+\n"			\
-		"12:	move."#s2"	(%2)+,%3\n"			\
-		"21:	"MOVES"."#s2"	%3,(%1)+\n"			\
-		"22:\n"							\
-		"	.ifnc	\""#s3"\",\"\"\n"			\
-		"	move."#s3"	(%2)+,%3\n"			\
-		"31:	"MOVES"."#s3"	%3,(%1)+\n"			\
-		"32:\n"							\
-		"	.endif\n"					\
-		"4:\n"							\
-		"\n"							\
-		"	.section __ex_table,\"a\"\n"			\
-		"	.align	4\n"					\
-		"	.long	11b,5f\n"				\
-		"	.long	12b,5f\n"				\
-		"	.long	21b,5f\n"				\
-		"	.long	22b,5f\n"				\
-		"	.ifnc	\""#s3"\",\"\"\n"			\
-		"	.long	31b,5f\n"				\
-		"	.long	32b,5f\n"				\
-		"	.endif\n"					\
-		"	.previous\n"					\
-		"\n"							\
-		"	.section .fixup,\"ax\"\n"			\
-		"	.even\n"					\
-		"5:	moveq.l	#"#n",%0\n"				\
-		"	jra	4b\n"					\
-		"	.previous\n"					\
-		: "+d" (res), "+a" (to), "+a" (from), "=&d" (tmp)	\
-		: : "memory")
-
-static __always_inline unsigned long
-__constant_copy_to_user(void __user *to, const void *from, unsigned long n)
-{
-	unsigned long res = 0, tmp;
-
-	switch (n) {
-	case 1:
-		__put_user_asm(res, *(u8 *)from, (u8 __user *)to, b, d, 1);
-		break;
-	case 2:
-		__put_user_asm(res, *(u16 *)from, (u16 __user *)to, w, r, 2);
-		break;
-	case 3:
-		__constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,);
-		break;
-	case 4:
-		__put_user_asm(res, *(u32 *)from, (u32 __user *)to, l, r, 4);
-		break;
-	case 5:
-		__constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,);
-		break;
-	case 6:
-		__constant_copy_to_user_asm(res, to, from, tmp, 6, l, w,);
-		break;
-	case 7:
-		__constant_copy_to_user_asm(res, to, from, tmp, 7, l, w, b);
-		break;
-	case 8:
-		__constant_copy_to_user_asm(res, to, from, tmp, 8, l, l,);
-		break;
-	case 9:
-		__constant_copy_to_user_asm(res, to, from, tmp, 9, l, l, b);
-		break;
-	case 10:
-		__constant_copy_to_user_asm(res, to, from, tmp, 10, l, l, w);
-		break;
-	case 12:
-		__constant_copy_to_user_asm(res, to, from, tmp, 12, l, l, l);
-		break;
-	default:
-		/* limit the inlined version to 3 moves */
-		return __generic_copy_to_user(to, from, n);
-	}
-
-	return res;
-}
-
-static inline unsigned long
-raw_copy_from_user(void *to, const void __user *from, unsigned long n)
-{
-	if (__builtin_constant_p(n))
-		return __constant_copy_from_user(to, from, n);
-	return __generic_copy_from_user(to, from, n);
-}
-
-static inline unsigned long
-raw_copy_to_user(void __user *to, const void *from, unsigned long n)
-{
-	if (__builtin_constant_p(n))
-		return __constant_copy_to_user(to, from, n);
-	return __generic_copy_to_user(to, from, n);
-}
-#define INLINE_COPY_FROM_USER
-#define INLINE_COPY_TO_USER
+unsigned long raw_copy_from_user(void *to, const void __user *from,
+		unsigned long n);
+unsigned long raw_copy_to_user(void __user *to, const void *from,
+		unsigned long n);
 
 #define user_addr_max() \
 	(uaccess_kernel() ? ~0UL : TASK_SIZE)
diff --git a/arch/m68k/lib/uaccess.c b/arch/m68k/lib/uaccess.c
index 7646e461aa62..56022d06b780 100644
--- a/arch/m68k/lib/uaccess.c
+++ b/arch/m68k/lib/uaccess.c
@@ -7,8 +7,8 @@
 #include <linux/module.h>
 #include <linux/uaccess.h>
 
-unsigned long __generic_copy_from_user(void *to, const void __user *from,
-				       unsigned long n)
+unsigned long raw_copy_from_user(void *to, const void __user *from,
+				 unsigned long n)
 {
 	unsigned long tmp, res;
 
@@ -51,10 +51,10 @@ unsigned long __generic_copy_from_user(void *to, const void __user *from,
 
 	return res;
 }
-EXPORT_SYMBOL(__generic_copy_from_user);
+EXPORT_SYMBOL(raw_copy_from_user);
 
-unsigned long __generic_copy_to_user(void __user *to, const void *from,
-				     unsigned long n)
+unsigned long raw_copy_to_user(void __user *to, const void *from,
+			       unsigned long n)
 {
 	unsigned long tmp, res;
 
@@ -95,7 +95,7 @@ unsigned long __generic_copy_to_user(void __user *to, const void *from,
 
 	return res;
 }
-EXPORT_SYMBOL(__generic_copy_to_user);
+EXPORT_SYMBOL(raw_copy_to_user);
 
 /*
  * Zero Userspace
-- 
2.30.2


  parent reply	other threads:[~2021-07-09  7:02 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09  7:01 RFC: remove set_fs for m68k Christoph Hellwig
2021-07-09  7:01 ` [PATCH 1/7] m68k: document that access_ok is broken for !CONFIG_CPU_HAS_ADDRESS_SPACES Christoph Hellwig
2021-07-09  7:01 ` [PATCH 2/7] m68k: use BUILD_BUG for passing invalid sizes to get_user/put_user Christoph Hellwig
2021-07-09  7:01 ` Christoph Hellwig [this message]
2021-07-09  7:01 ` [PATCH 4/7] m68k: remove the err argument to the get_user/put_user assembly helpers Christoph Hellwig
2021-07-09  7:01 ` [PATCH 5/7] m68k: factor the 8-byte lowlevel {get,put}_user code into helpers Christoph Hellwig
2021-07-09  7:01 ` [PATCH 6/7] m68k: provide __{get,put}_kernel_nofault Christoph Hellwig
2021-07-09  7:01 ` [PATCH 7/7] m68k: remove set_fs() Christoph Hellwig
2021-07-11  7:20 ` RFC: remove set_fs for m68k Michael Schmitz
2021-07-12  9:50   ` Christoph Hellwig
2021-07-12 10:20   ` Andreas Schwab
2021-07-12 19:12     ` Michael Schmitz
2021-07-13  5:41       ` Christoph Hellwig
2021-07-13  8:16         ` Michael Schmitz
2021-07-13  8:54           ` Christoph Hellwig
2021-07-14 19:26             ` Michael Schmitz
2021-07-14 20:03               ` Andreas Schwab
2021-07-15  5:44                 ` Michael Schmitz
2021-07-16  2:03               ` Michael Schmitz
2021-07-17  5:41                 ` Michael Schmitz
2021-07-18  1:14                   ` Michael Schmitz
2021-07-21 17:05                     ` Christoph Hellwig
2021-07-21 19:20                       ` Michael Schmitz
2021-07-23  4:00                       ` Michael Schmitz
2021-07-23  5:11                         ` Christoph Hellwig
2021-07-25  7:36                           ` Michael Schmitz
2021-07-31 19:31                             ` Michael Schmitz
2021-08-06  3:10                               ` Michael Schmitz
2021-08-11  9:12                                 ` Christoph Hellwig
2021-08-12  3:37                                   ` Michael Schmitz
2021-08-15  7:42                                 ` Christoph Hellwig
2021-08-15 19:17                                   ` Michael Schmitz
2021-08-16  6:58                                     ` Christoph Hellwig
     [not found]                                       ` <23f745f2-9086-81fb-3d9e-40ea08a1923@linux-m68k.org>
     [not found]                                         ` <20210816075155.GA29187@lst.de>
     [not found]                                           ` <d407a2a1-738b-5cd5-c2ed-b7250c5da8ec@gmail.com>
     [not found]                                             ` <83571ae-10ae-2919-cde-b6b4a5769c9@linux-m68k.org>
     [not found]                                               ` <dc594142-e459-533e-cac2-c7a213cec464@gmail.com>
     [not found]                                                 ` <f4ab2dcb-6761-c60b-54ce-35d0d017d371@gmail.com>
     [not found]                                                   ` <d772d22e-a945-3e35-80a2-f4783893bea@linux-m68k.org>
     [not found]                                                     ` <b2c55280-657b-51c2-065c-3fc93db050b9@gmail.com>
     [not found]                                                       ` <d7b8f7eb-fc18-c8d-fe3e-dcdf19d3f4b@linux-m68k.org>
     [not found]                                                         ` <755e55ba-4ce2-b4e4-a628-5abc183a557a@linux-m68k.org>
     [not found]                                                           ` <b52a10fe-3e4b-5740-d3f8-52bce3bc988@linux-m68k.org>
     [not found]                                                             ` <31f27da7-be60-8eb-9834-748b653c2246@linux-m68k.org>
2021-09-07  3:28                                                               ` Mainline kernel crashes, was " Finn Thain
2021-09-07  5:53                                                                 ` Michael Schmitz
2021-09-07 23:50                                                                   ` Finn Thain
2021-09-08  8:54                                                                     ` Michael Schmitz
2021-09-09  9:40                                                                       ` Finn Thain
2021-09-09 23:29                                                                         ` Michael Schmitz
2021-09-09 22:51                                                                       ` Finn Thain
2021-09-10  0:03                                                                         ` Michael Schmitz
2021-09-12  0:51                                                                           ` Finn Thain
2021-09-12  3:55                                                                             ` Brad Boyer
2021-09-13  1:27                                                                             ` Finn Thain
2021-09-13  3:26                                                                               ` Michael Schmitz
2021-09-13  5:22                                                                                 ` Finn Thain
2021-09-13  7:20                                                                                   ` Michael Schmitz
2021-09-14  3:13                                                                                     ` Michael Schmitz
2021-09-15  1:38                                                                                     ` Finn Thain
2021-09-15  8:37                                                                                       ` Michael Schmitz
2021-09-16  9:04                                                                                         ` Finn Thain
2021-09-16 22:28                                                                                           ` Michael Schmitz
2021-09-21 21:14                                       ` Michael Schcmitz
2021-08-22 19:33                                         ` Michael Schmitz
2021-08-23  4:04                                           ` Michael Schmitz
2021-08-23 17:59                                           ` Linus Torvalds
2021-08-23 21:31                                             ` Michael Schmitz
2021-08-23 21:49                                               ` Linus Torvalds
2021-08-24  8:08                                                 ` Andreas Schwab
2021-08-24  8:44                                                 ` Michael Schmitz
2021-08-24  8:59                                                   ` Andreas Schwab
2021-08-25  7:51                                                     ` Michael Schmitz
2021-08-25  8:44                                                       ` Andreas Schwab
2021-08-25 22:59                                                         ` Michael Schmitz
2021-08-25 23:30                                                           ` Brad Boyer
2021-08-26  7:46                                                             ` Michael Schmitz
2021-08-26  7:45                                                           ` Andreas Schwab
2021-09-14  2:43                                             ` Michael Schmitz
2021-09-14 15:54                                               ` Linus Torvalds
2021-09-14 16:28                                                 ` Al Viro
2021-09-14 16:38                                                   ` Linus Torvalds
2021-09-15  1:06                                                     ` Al Viro
2021-07-12 19:04   ` Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709070132.3387689-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=geert@linux-m68k.org \
    --cc=gerg@linux-m68k.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=schmitzmic@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).