All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: linux-arch@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Brian Cain <bcain@codeaurora.org>,
	Chris Zankel <chris@zankel.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Christoph Hellwig <hch@lst.de>, Guo Ren <guoren@kernel.org>,
	Heiko Carstens <hca@linux.ibm.com>, Helge Deller <deller@gmx.de>,
	Jeff Dike <jdike@addtoit.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Max Filippov <jcmvbkbc@gmail.com>,
	Michal Simek <monstr@monstr.eu>,
	Richard Weinberger <richard@nod.at>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org,
	linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org,
	linux-um@lists.infradead.org, linux-xtensa@linux-xtensa.org,
	uclinux-h8-devel@lists.sourceforge.jp
Subject: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
Date: Thu, 22 Jul 2021 14:48:11 +0200	[thread overview]
Message-ID: <20210722124814.778059-7-arnd@kernel.org> (raw)
In-Reply-To: <20210722124814.778059-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2


WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@kernel.org>
To: linux-arch@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Brian Cain <bcain@codeaurora.org>,
	Chris Zankel <chris@zankel.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Christoph Hellwig <hch@lst.de>, Guo Ren <guoren@kernel.org>,
	Heiko Carstens <hca@linux.ibm.com>, Helge Deller <deller@gmx.de>,
	Jeff Dike <jdike@addtoit.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Max Filippov <jcmvbkbc@gmail.com>,
	Michal Simek <monstr@monstr.eu>,
	Richard Weinberger <richard@nod.at>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org,
	linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org,
	linux-um@lists.infradead.org, linux-xtensa@linux-xtensa.org,
	uclinux-h8-devel@lists.sourceforge.jp
Subject: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
Date: Thu, 22 Jul 2021 14:48:11 +0200	[thread overview]
Message-ID: <20210722124814.778059-7-arnd@kernel.org> (raw)
In-Reply-To: <20210722124814.778059-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2


_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@kernel.org>
To: linux-arch@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Brian Cain <bcain@codeaurora.org>,
	Chris Zankel <chris@zankel.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Christoph Hellwig <hch@lst.de>, Guo Ren <guoren@kernel.org>,
	Heiko Carstens <hca@linux.ibm.com>, Helge Deller <deller@gmx.de>,
	Jeff Dike <jdike@addtoit.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Max Filippov <jcmvbkbc@gmail.com>,
	Michal Simek <monstr@monstr.eu>,
	Richard Weinberger <richard@nod.at>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org,
	linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org,
	linux-s390@vger.kernel.org, linux-snps-arc@lists.infradead.org,
	linux-um@lists.infradead.org, linux-xtensa@linux-xtensa.org,
	uclinux-h8-devel@lists.sourceforge.jp
Subject: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
Date: Thu, 22 Jul 2021 12:48:11 +0000	[thread overview]
Message-ID: <20210722124814.778059-7-arnd@kernel.org> (raw)
In-Reply-To: <20210722124814.778059-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2

WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@kernel.org>
To: linux-arch@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Anton Ivanov <anton.ivanov@cambridgegreys.com>,
	Brian Cain <bcain@codeaurora.org>,
	Chris Zankel <chris@zankel.net>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Christoph Hellwig <hch@lst.de>, Guo Ren <guoren@kernel.org>,
	Heiko Carstens <hca@linux.ibm.com>, Helge Deller <deller@gmx.de>,
	Jeff Dike <jdike@addtoit.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Max Filippov <jcmvbkbc@gmail.com>,
	Michal Simek <monstr@monstr.eu>,
	Richard Weinberger <richard@nod.at>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Vineet Gupta <vgupta@synopsys.com>,
	Yoshinori Sato <ysato@users.sourceforge.j>
Subject: [PATCH v3 6/9] microblaze: use generic strncpy/strnlen from_user
Date: Thu, 22 Jul 2021 14:48:11 +0200	[thread overview]
Message-ID: <20210722124814.778059-7-arnd@kernel.org> (raw)
In-Reply-To: <20210722124814.778059-1-arnd@kernel.org>

From: Arnd Bergmann <arnd@arndb.de>

Remove the microblaze implemenation of strncpy/strnlen and instead use
the generic versions.  The microblaze version is fairly slow because it
always does byte accesses even for aligned data, and it lacks a checks
for user_addr_max().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/microblaze/Kconfig                   |  2 +
 arch/microblaze/include/asm/uaccess.h     | 19 +----
 arch/microblaze/kernel/microblaze_ksyms.c |  3 -
 arch/microblaze/lib/uaccess_old.S         | 90 -----------------------
 4 files changed, 4 insertions(+), 110 deletions(-)

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 14a67a42fcae..10dfa7b4feff 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -21,6 +21,8 @@ config MICROBLAZE
 	select GENERIC_IRQ_SHOW
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
+	select GENERIC_STRNCPY_FROM_USER
+	select GENERIC_STRNLEN_USER
 	select HAVE_ARCH_HASH
 	select HAVE_ARCH_KGDB
 	select HAVE_ARCH_SECCOMP
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index c44b59470e45..bbe39fe00461 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -296,28 +296,13 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 /*
  * Copy a null terminated string from userspace.
  */
-extern int __strncpy_user(char *to, const char __user *from, int len);
-
-static inline long
-strncpy_from_user(char *dst, const char __user *src, long count)
-{
-	if (!access_ok(src, 1))
-		return -EFAULT;
-	return __strncpy_user(dst, src, count);
-}
+extern long strncpy_from_user(char *dst, const char __user *src, long count);
 
 /*
  * Return the size of a string (including the ending 0)
  *
  * Return 0 on exception, a value greater than N if too long
  */
-extern int __strnlen_user(const char __user *sstr, int len);
-
-static inline long strnlen_user(const char __user *src, long n)
-{
-	if (!access_ok(src, 1))
-		return 0;
-	return __strnlen_user(src, n);
-}
+extern long strnlen_user(const char __user *sstr, int len);
 
 #endif /* _ASM_MICROBLAZE_UACCESS_H */
diff --git a/arch/microblaze/kernel/microblaze_ksyms.c b/arch/microblaze/kernel/microblaze_ksyms.c
index 303aaf13573b..14e0f2100c41 100644
--- a/arch/microblaze/kernel/microblaze_ksyms.c
+++ b/arch/microblaze/kernel/microblaze_ksyms.c
@@ -25,9 +25,6 @@ EXPORT_SYMBOL(_mcount);
 /*
  * Assembly functions that may be used (directly or indirectly) by modules
  */
-EXPORT_SYMBOL(__copy_tofrom_user);
-EXPORT_SYMBOL(__strncpy_user);
-
 #ifdef CONFIG_OPT_LIB_ASM
 EXPORT_SYMBOL(memcpy);
 EXPORT_SYMBOL(memmove);
diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S
index eca290090038..dd5f3bfbc2c5 100644
--- a/arch/microblaze/lib/uaccess_old.S
+++ b/arch/microblaze/lib/uaccess_old.S
@@ -12,96 +12,6 @@
 #include <linux/linkage.h>
 #include <asm/page.h>
 
-/*
- * int __strncpy_user(char *to, char *from, int len);
- *
- * Returns:
- *  -EFAULT  for an exception
- *  len      if we hit the buffer limit
- *  bytes copied
- */
-
-	.text
-.globl __strncpy_user;
-.type  __strncpy_user, @function
-.align 4;
-__strncpy_user:
-
-	/*
-	 * r5 - to
-	 * r6 - from
-	 * r7 - len
-	 * r3 - temp count
-	 * r4 - temp val
-	 */
-	beqid	r7,3f
-	addik	r3,r7,0		/* temp_count = len */
-1:
-	lbu	r4,r6,r0
-	beqid	r4,2f
-	sb	r4,r5,r0
-
-	addik	r5,r5,1
-	addik	r6,r6,1		/* delay slot */
-
-	addik	r3,r3,-1
-	bnei	r3,1b		/* break on len */
-2:
-	rsubk	r3,r3,r7	/* temp_count = len - temp_count */
-3:
-	rtsd	r15,8
-	nop
-	.size   __strncpy_user, . - __strncpy_user
-
-	.section	.fixup, "ax"
-	.align	2
-4:
-	brid	3b
-	addik	r3,r0, -EFAULT
-
-	.section	__ex_table, "a"
-	.word	1b,4b
-
-/*
- * int __strnlen_user(char __user *str, int maxlen);
- *
- * Returns:
- *  0 on error
- *  maxlen + 1  if no NUL byte found within maxlen bytes
- *  size of the string (including NUL byte)
- */
-
-	.text
-.globl __strnlen_user;
-.type  __strnlen_user, @function
-.align 4;
-__strnlen_user:
-	beqid	r6,3f
-	addik	r3,r6,0
-1:
-	lbu	r4,r5,r0
-	beqid	r4,2f		/* break on NUL */
-	addik	r3,r3,-1	/* delay slot */
-
-	bneid	r3,1b
-	addik	r5,r5,1		/* delay slot */
-
-	addik	r3,r3,-1	/* for break on len */
-2:
-	rsubk	r3,r3,r6
-3:
-	rtsd	r15,8
-	nop
-	.size   __strnlen_user, . - __strnlen_user
-
-	.section	.fixup,"ax"
-4:
-	brid	3b
-	addk	r3,r0,r0
-
-	.section	__ex_table,"a"
-	.word	1b,4b
-
 /* Loop unrolling for __copy_tofrom_user */
 #define COPY(offset)	\
 1:	lwi	r4 , r6, 0x0000 + offset;	\
-- 
2.29.2


  parent reply	other threads:[~2021-07-22 12:49 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-22 12:48 [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup Arnd Bergmann
2021-07-22 12:48 ` Arnd Bergmann
2021-07-22 12:48 ` Arnd Bergmann
2021-07-22 12:48 ` Arnd Bergmann
2021-07-22 12:48 ` [PATCH v3 1/9] asm-generic/uaccess.h: remove __strncpy_from_user/__strnlen_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:59   ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 2/9] h8300: remove stale strncpy_from_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:59   ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:59     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 3/9] hexagon: use generic strncpy/strnlen from_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:00   ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 4/9] arc: " Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:00   ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 13:00     ` Christoph Hellwig
2021-07-22 15:34   ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 15:34     ` Vineet Gupta
2021-07-22 12:48 ` [PATCH v3 5/9] csky: " Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:01   ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 12:48 ` Arnd Bergmann [this message]
2021-07-22 12:48   ` [PATCH v3 6/9] microblaze: " Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:01   ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 13:01     ` Christoph Hellwig
2021-07-22 20:48   ` kernel test robot
2021-07-23 12:36     ` Arnd Bergmann
2021-07-23 12:36       ` Arnd Bergmann
2021-07-23 12:42       ` Christoph Hellwig
2021-07-23 12:42         ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 7/9] asm-generic: uaccess: remove inline strncpy_from_user/strnlen_user Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 13:02   ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from, len}_user declarations Arnd Bergmann
2021-07-22 13:02   ` [PATCH v3 8/9] asm-generic: remove extra strn{cpy_from,len}_user declarations Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 13:02     ` Christoph Hellwig
2021-07-22 12:48 ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` Arnd Bergmann
2021-07-22 12:48   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Arnd Bergmann
2021-07-22 13:03   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Christoph Hellwig
2021-07-22 13:03     ` Christoph Hellwig
2021-07-22 13:03     ` Christoph Hellwig
2021-07-22 13:03     ` Christoph Hellwig
2021-07-22 13:57   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 13:57     ` Johannes Berg
2021-07-22 14:01     ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 14:01       ` Arnd Bergmann
2021-07-22 20:07       ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-22 20:07         ` Heiko Carstens
2021-07-23 12:44         ` Arnd Bergmann
2021-07-23 12:44           ` Arnd Bergmann
2021-07-23 12:44           ` Arnd Bergmann
2021-07-23 12:44           ` Arnd Bergmann
2021-07-24  9:44   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Geert Uytterhoeven
2021-07-24  9:44     ` Geert Uytterhoeven
2021-07-24  9:44     ` Geert Uytterhoeven
2021-07-24  9:44     ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM, STRNLEN}_USER symbols Geert Uytterhoeven
2021-07-26  8:55   ` [PATCH v3 9/9] asm-generic: reverse GENERIC_{STRNCPY_FROM,STRNLEN}_USER symbols Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-07-26  8:55     ` Helge Deller
2021-08-14  1:04 ` [PATCH v3 0/6] asm-generic: strncpy_from_user/strnlen_user cleanup Vineet Gupta
2021-08-14 11:10   ` Arnd Bergmann

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=20210722124814.778059-7-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=arnd@arndb.de \
    --cc=bcain@codeaurora.org \
    --cc=borntraeger@de.ibm.com \
    --cc=chris@zankel.net \
    --cc=deller@gmx.de \
    --cc=gor@linux.ibm.com \
    --cc=guoren@kernel.org \
    --cc=hca@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=jcmvbkbc@gmail.com \
    --cc=jdike@addtoit.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-hexagon@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=linux-um@lists.infradead.org \
    --cc=linux-xtensa@linux-xtensa.org \
    --cc=monstr@monstr.eu \
    --cc=richard@nod.at \
    --cc=tsbogend@alpha.franken.de \
    --cc=uclinux-h8-devel@lists.sourceforge.jp \
    --cc=vgupta@synopsys.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=ysato@users.sourceforge.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.