All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user()
@ 2020-05-31 10:47 ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-05-31 10:47 UTC (permalink / raw)
  To: linux-sh
  Cc: Rich Felker, Yoshinori Sato, Geert Uytterhoeven, Michael Karcher,
	linux-kernel, John Paul Adrian Glaubitz

Trying to build the kernel with CONFIG_INFINIBAND_USER_ACCESS enabled fails

     ERROR: "__get_user_unknown" [drivers/infiniband/core/ib_uverbs.ko] undefined!

with on SH since the kernel misses a 64-bit implementation of get_user().

Implement the missing 64-bit get_user() as __get_user_u64(), matching the
already existing __put_user_u64() which implements the 64-bit put_user().

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 arch/sh/include/asm/uaccess_32.h | 51 ++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

 Changes since v1:
 - Replace single mov instruction for exception handling
   in case of invalid load

diff --git a/arch/sh/include/asm/uaccess_32.h b/arch/sh/include/asm/uaccess_32.h
index 624cf55acc27..35f6c1e40ec3 100644
--- a/arch/sh/include/asm/uaccess_32.h
+++ b/arch/sh/include/asm/uaccess_32.h
@@ -26,6 +26,9 @@ do {								\
 	case 4:							\
 		__get_user_asm(x, ptr, retval, "l");		\
 		break;						\
+	case 8:							\
+		__get_user_u64(x, ptr, retval);			\
+		break;						\
 	default:						\
 		__get_user_unknown();				\
 		break;						\
@@ -66,6 +69,54 @@ do {							\
 
 extern void __get_user_unknown(void);
 
+#if defined(CONFIG_CPU_LITTLE_ENDIAN)
+#define __get_user_u64(x, addr, err) \
+({ \
+__asm__ __volatile__( \
+	"1:\n\t" \
+	"mov.l	%2,%R1\n\t" \
+	"mov.l	%T2,%S1\n\t" \
+	"2:\n" \
+	".section	.fixup,\"ax\"\n" \
+	"3:\n\t" \
+	"mov  #0,%R1\n\t"   \
+	"mov  #0,%S1\n\t"   \
+	"mov.l	4f, %0\n\t" \
+	"jmp	@%0\n\t" \
+	" mov	%3, %0\n\t" \
+	".balign	4\n" \
+	"4:	.long	2b\n\t" \
+	".previous\n" \
+	".section	__ex_table,\"a\"\n\t" \
+	".long	1b, 3b\n\t" \
+	".previous" \
+	:"=&r" (err), "=&r" (x) \
+	:"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
+#else
+#define __get_user_u64(x, addr, err) \
+({ \
+__asm__ __volatile__( \
+	"1:\n\t" \
+	"mov.l	%2,%S1\n\t" \
+	"mov.l	%T2,%R1\n\t" \
+	"2:\n" \
+	".section	.fixup,\"ax\"\n" \
+	"3:\n\t" \
+	"mov  #0,%S1\n\t"   \
+	"mov  #0,%R1\n\t"   \
+	"mov.l	4f, %0\n\t" \
+	"jmp	@%0\n\t" \
+	" mov	%3, %0\n\t" \
+	".balign	4\n" \
+	"4:	.long	2b\n\t" \
+	".previous\n" \
+	".section	__ex_table,\"a\"\n\t" \
+	".long	1b, 3b\n\t" \
+	".previous" \
+	:"=&r" (err), "=&r" (x) \
+	:"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
+#endif
+
 #define __put_user_size(x,ptr,size,retval)		\
 do {							\
 	retval = 0;					\
-- 
2.27.0.rc2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user()
@ 2020-05-31 10:47 ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-05-31 10:47 UTC (permalink / raw)
  To: linux-sh
  Cc: Rich Felker, Yoshinori Sato, Geert Uytterhoeven, Michael Karcher,
	linux-kernel, John Paul Adrian Glaubitz

Trying to build the kernel with CONFIG_INFINIBAND_USER_ACCESS enabled fails

     ERROR: "__get_user_unknown" [drivers/infiniband/core/ib_uverbs.ko] undefined!

with on SH since the kernel misses a 64-bit implementation of get_user().

Implement the missing 64-bit get_user() as __get_user_u64(), matching the
already existing __put_user_u64() which implements the 64-bit put_user().

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 arch/sh/include/asm/uaccess_32.h | 51 ++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

 Changes since v1:
 - Replace single mov instruction for exception handling
   in case of invalid load

diff --git a/arch/sh/include/asm/uaccess_32.h b/arch/sh/include/asm/uaccess_32.h
index 624cf55acc27..35f6c1e40ec3 100644
--- a/arch/sh/include/asm/uaccess_32.h
+++ b/arch/sh/include/asm/uaccess_32.h
@@ -26,6 +26,9 @@ do {								\
 	case 4:							\
 		__get_user_asm(x, ptr, retval, "l");		\
 		break;						\
+	case 8:							\
+		__get_user_u64(x, ptr, retval);			\
+		break;						\
 	default:						\
 		__get_user_unknown();				\
 		break;						\
@@ -66,6 +69,54 @@ do {							\
 
 extern void __get_user_unknown(void);
 
+#if defined(CONFIG_CPU_LITTLE_ENDIAN)
+#define __get_user_u64(x, addr, err) \
+({ \
+__asm__ __volatile__( \
+	"1:\n\t" \
+	"mov.l	%2,%R1\n\t" \
+	"mov.l	%T2,%S1\n\t" \
+	"2:\n" \
+	".section	.fixup,\"ax\"\n" \
+	"3:\n\t" \
+	"mov  #0,%R1\n\t"   \
+	"mov  #0,%S1\n\t"   \
+	"mov.l	4f, %0\n\t" \
+	"jmp	@%0\n\t" \
+	" mov	%3, %0\n\t" \
+	".balign	4\n" \
+	"4:	.long	2b\n\t" \
+	".previous\n" \
+	".section	__ex_table,\"a\"\n\t" \
+	".long	1b, 3b\n\t" \
+	".previous" \
+	:"=&r" (err), "=&r" (x) \
+	:"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
+#else
+#define __get_user_u64(x, addr, err) \
+({ \
+__asm__ __volatile__( \
+	"1:\n\t" \
+	"mov.l	%2,%S1\n\t" \
+	"mov.l	%T2,%R1\n\t" \
+	"2:\n" \
+	".section	.fixup,\"ax\"\n" \
+	"3:\n\t" \
+	"mov  #0,%S1\n\t"   \
+	"mov  #0,%R1\n\t"   \
+	"mov.l	4f, %0\n\t" \
+	"jmp	@%0\n\t" \
+	" mov	%3, %0\n\t" \
+	".balign	4\n" \
+	"4:	.long	2b\n\t" \
+	".previous\n" \
+	".section	__ex_table,\"a\"\n\t" \
+	".long	1b, 3b\n\t" \
+	".previous" \
+	:"=&r" (err), "=&r" (x) \
+	:"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
+#endif
+
 #define __put_user_size(x,ptr,size,retval)		\
 do {							\
 	retval = 0;					\
-- 
2.27.0.rc2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user()
  2020-05-31 10:47 ` John Paul Adrian Glaubitz
@ 2020-06-03  7:20   ` John Paul Adrian Glaubitz
  -1 siblings, 0 replies; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-06-03  7:20 UTC (permalink / raw)
  To: linux-sh
  Cc: Rich Felker, Yoshinori Sato, Geert Uytterhoeven, Michael Karcher,
	linux-kernel

Hi!

On 5/31/20 12:47 PM, John Paul Adrian Glaubitz wrote:
>  Changes since v1:
>  - Replace single mov instruction for exception handling
>    in case of invalid load

Yutaka Niibe has had a look at my patch and he says, we might have to add
an entry for the fault handling of the upper word.

Quote:

> (1) I think that there is possibility that the second access to user
> space fails (while the first access succeeds).  IIUC, it's good have
> an entry in __ex_tables for the second access too, like:
>     ".long 1b+2, 3b\n\t"
> I don't know if the expression "1b+2" is correct, my intention is
> detecting the failure in the seccond access.

Comments?

@Sato-san: Can you comment on the patch as well?

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user()
@ 2020-06-03  7:20   ` John Paul Adrian Glaubitz
  0 siblings, 0 replies; 6+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-06-03  7:20 UTC (permalink / raw)
  To: linux-sh
  Cc: Rich Felker, Yoshinori Sato, Geert Uytterhoeven, Michael Karcher,
	linux-kernel

Hi!

On 5/31/20 12:47 PM, John Paul Adrian Glaubitz wrote:
>  Changes since v1:
>  - Replace single mov instruction for exception handling
>    in case of invalid load

Yutaka Niibe has had a look at my patch and he says, we might have to add
an entry for the fault handling of the upper word.

Quote:

> (1) I think that there is possibility that the second access to user
> space fails (while the first access succeeds).  IIUC, it's good have
> an entry in __ex_tables for the second access too, like:
>     ".long 1b+2, 3b\n\t"
> I don't know if the expression "1b+2" is correct, my intention is
> detecting the failure in the seccond access.

Comments?

@Sato-san: Can you comment on the patch as well?

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user()
  2020-06-03  7:20   ` John Paul Adrian Glaubitz
@ 2020-06-03  7:35     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2020-06-03  7:35 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Linux-sh list, Rich Felker, Yoshinori Sato, Michael Karcher,
	Linux Kernel Mailing List

Hi Adrian,

On Wed, Jun 3, 2020 at 9:20 AM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
> On 5/31/20 12:47 PM, John Paul Adrian Glaubitz wrote:
> >  Changes since v1:
> >  - Replace single mov instruction for exception handling
> >    in case of invalid load
>
> Yutaka Niibe has had a look at my patch and he says, we might have to add
> an entry for the fault handling of the upper word.
>
> Quote:
>
> > (1) I think that there is possibility that the second access to user
> > space fails (while the first access succeeds).  IIUC, it's good have
> > an entry in __ex_tables for the second access too, like:
> >     ".long 1b+2, 3b\n\t"
> > I don't know if the expression "1b+2" is correct, my intention is
> > detecting the failure in the seccond access.

So just add another numeric label, like is done on m68k.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user()
@ 2020-06-03  7:35     ` Geert Uytterhoeven
  0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2020-06-03  7:35 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Linux-sh list, Rich Felker, Yoshinori Sato, Michael Karcher,
	Linux Kernel Mailing List

Hi Adrian,

On Wed, Jun 3, 2020 at 9:20 AM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
> On 5/31/20 12:47 PM, John Paul Adrian Glaubitz wrote:
> >  Changes since v1:
> >  - Replace single mov instruction for exception handling
> >    in case of invalid load
>
> Yutaka Niibe has had a look at my patch and he says, we might have to add
> an entry for the fault handling of the upper word.
>
> Quote:
>
> > (1) I think that there is possibility that the second access to user
> > space fails (while the first access succeeds).  IIUC, it's good have
> > an entry in __ex_tables for the second access too, like:
> >     ".long 1b+2, 3b\n\t"
> > I don't know if the expression "1b+2" is correct, my intention is
> > detecting the failure in the seccond access.

So just add another numeric label, like is done on m68k.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-03  7:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-31 10:47 [PATCH v2] sh: Implement __get_user_u64() required for 64-bit get_user() John Paul Adrian Glaubitz
2020-05-31 10:47 ` John Paul Adrian Glaubitz
2020-06-03  7:20 ` John Paul Adrian Glaubitz
2020-06-03  7:20   ` John Paul Adrian Glaubitz
2020-06-03  7:35   ` Geert Uytterhoeven
2020-06-03  7:35     ` Geert Uytterhoeven

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.