All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] m68k/uaccess: Revive 64-bit get_user()
@ 2018-05-14 13:57 Geert Uytterhoeven
  2018-05-14 21:34 ` Martijn Coenen
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2018-05-14 13:57 UTC (permalink / raw)
  To: linux-m68k
  Cc: Martijn Coenen, Christoph Hellwig, linux-kernel, Geert Uytterhoeven

Revive support for 64-bit get_user(), which was disabled in commit
d94af931af42152e ("[PATCH] m68k: clean up uaccess.h") due to a "broken"
typeof in (then brand new) gcc-4.1.

  - Keep on using u64 for the temporary, as __typeof__() doesn't drop
    the const qualifier,
  - Move it into a union (like mips32 does) to get rid of the cast, as
    using get_user() to fetch a __user pointer would cause a "cast to
    pointer from integer of different size" warning otherwise.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/include/asm/uaccess_mm.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/m68k/include/asm/uaccess_mm.h b/arch/m68k/include/asm/uaccess_mm.h
index 75c172e909acdf18..c4cb889660aa0c35 100644
--- a/arch/m68k/include/asm/uaccess_mm.h
+++ b/arch/m68k/include/asm/uaccess_mm.h
@@ -141,10 +141,12 @@ asm volatile ("\n"					\
 	case 4:								\
 		__get_user_asm(__gu_err, x, ptr, u32, l, r, -EFAULT);	\
 		break;							\
-/*	case 8:	disabled because gcc-4.1 has a broken typeof		\
- 	    {								\
- 		const void *__gu_ptr = (ptr);				\
- 		u64 __gu_val;						\
+	case 8: {							\
+		const void *__gu_ptr = (ptr);				\
+		union {							\
+			u64 l;						\
+			__typeof__(*(ptr)) t;				\
+		} __gu_val;						\
 		asm volatile ("\n"					\
 			"1:	"MOVES".l	(%2)+,%1\n"		\
 			"2:	"MOVES".l	(%2),%R1\n"		\
@@ -162,13 +164,13 @@ asm volatile ("\n"					\
 			"	.long	1b,10b\n"			\
 			"	.long	2b,10b\n"			\
 			"	.previous"				\
-			: "+d" (__gu_err), "=&r" (__gu_val),		\
+			: "+d" (__gu_err), "=&r" (__gu_val.l),		\
 			  "+a" (__gu_ptr)				\
 			: "i" (-EFAULT)					\
 			: "memory");					\
-		(x) = (__force typeof(*(ptr)))__gu_val;			\
+		(x) = __gu_val.t;					\
 		break;							\
-	    }	*/							\
+	}								\
 	default:							\
 		__gu_err = __get_user_bad();				\
 		break;							\
-- 
2.7.4

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

* Re: [PATCH] m68k/uaccess: Revive 64-bit get_user()
  2018-05-14 13:57 [PATCH] m68k/uaccess: Revive 64-bit get_user() Geert Uytterhoeven
@ 2018-05-14 21:34 ` Martijn Coenen
  0 siblings, 0 replies; 2+ messages in thread
From: Martijn Coenen @ 2018-05-14 21:34 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, Christoph Hellwig, LKML

On Mon, May 14, 2018 at 3:57 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> Revive support for 64-bit get_user(), which was disabled in commit
> d94af931af42152e ("[PATCH] m68k: clean up uaccess.h") due to a "broken"
> typeof in (then brand new) gcc-4.1.
>
>   - Keep on using u64 for the temporary, as __typeof__() doesn't drop
>     the const qualifier,
>   - Move it into a union (like mips32 does) to get rid of the cast, as
>     using get_user() to fetch a __user pointer would cause a "cast to
>     pointer from integer of different size" warning otherwise.

Can't vouch for the existing asm, but the changes to it look good to
me otherwise.

>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

Acked-by: Martijn Coenen <maco@android.com>

> ---
>  arch/m68k/include/asm/uaccess_mm.h | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/arch/m68k/include/asm/uaccess_mm.h b/arch/m68k/include/asm/uaccess_mm.h
> index 75c172e909acdf18..c4cb889660aa0c35 100644
> --- a/arch/m68k/include/asm/uaccess_mm.h
> +++ b/arch/m68k/include/asm/uaccess_mm.h
> @@ -141,10 +141,12 @@ asm volatile ("\n"                                        \
>         case 4:                                                         \
>                 __get_user_asm(__gu_err, x, ptr, u32, l, r, -EFAULT);   \
>                 break;                                                  \
> -/*     case 8: disabled because gcc-4.1 has a broken typeof            \
> -           {                                                           \
> -               const void *__gu_ptr = (ptr);                           \
> -               u64 __gu_val;                                           \
> +       case 8: {                                                       \
> +               const void *__gu_ptr = (ptr);                           \
> +               union {                                                 \
> +                       u64 l;                                          \
> +                       __typeof__(*(ptr)) t;                           \
> +               } __gu_val;                                             \
>                 asm volatile ("\n"                                      \
>                         "1:     "MOVES".l       (%2)+,%1\n"             \
>                         "2:     "MOVES".l       (%2),%R1\n"             \
> @@ -162,13 +164,13 @@ asm volatile ("\n"                                        \
>                         "       .long   1b,10b\n"                       \
>                         "       .long   2b,10b\n"                       \
>                         "       .previous"                              \
> -                       : "+d" (__gu_err), "=&r" (__gu_val),            \
> +                       : "+d" (__gu_err), "=&r" (__gu_val.l),          \
>                           "+a" (__gu_ptr)                               \
>                         : "i" (-EFAULT)                                 \
>                         : "memory");                                    \
> -               (x) = (__force typeof(*(ptr)))__gu_val;                 \
> +               (x) = __gu_val.t;                                       \
>                 break;                                                  \
> -           }   */                                                      \
> +       }                                                               \
>         default:                                                        \
>                 __gu_err = __get_user_bad();                            \
>                 break;                                                  \
> --
> 2.7.4
>

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

end of thread, other threads:[~2018-05-14 21:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 13:57 [PATCH] m68k/uaccess: Revive 64-bit get_user() Geert Uytterhoeven
2018-05-14 21:34 ` Martijn Coenen

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.