uaccess: fix sparse warning on get/put_user for bitwise types
Subsystems (13)
v2 cover uaccess: fix sparse warning on get/put_user for bitwise types
changes from v1:
- xtensa and powerpc patches have been merged by maintainers, drop them
- added patches to fix put_user on a bunch of architectures
- add acks received since v1
- a bunch of whitespace tweaks
At the moment, if p and x are both tagged as bitwise types, some of get_user(x, p), put_user(x, p), __get_user(x, p), __put_user(x, p) produce a sparse warning on many architectures.
This is a false positive: *p on these architectures is loaded into long (typically using asm), then cast back to typeof(*p).
When typeof(*p) is a bitwise type (which is uncommon), such a cast needs __force, otherwise sparse produces a warning.
Some architectures already have the __force tag, add it where it's missing.
I verified that adding these __force casts does not supress any useful warnings.
Specifically, vhost wants to read/write bitwise types in userspace memory using get_user/put_user.
At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p;
__u32 x;both
put_user(x, p);
and
get_user(x, p);should be safe, but produce warnings on some architectures.
While there, I noticed that a bunch of architectures violated coding style rules within uaccess macros.
Added patches to fix them up.
I tested this on x86 only. Since it's just adding __force, should be trivially safe everywhere?
Arnd, did you merge v1 already? If yes, can you please replace with this version?
Michael S. Tsirkin (40):
x86/uaccess: fix sparse errors
alpha/uaccess: fix sparse errors
arm64/uaccess: fix sparse errors
avr32/uaccess: fix sparse errors
blackfin/uaccess: fix sparse errors
cris/uaccess: fix sparse errors
ia64/uaccess: fix sparse errors
m32r/uaccess: fix sparse errors
metag/uaccess: fix sparse errors
microblaze/uaccess: fix sparse errors
openrisc/uaccess: fix sparse errors
parisc/uaccess: fix sparse errors
sh/uaccess: fix sparse errors
sparc32/uaccess: fix sparse errors
sparc64/uaccess: fix sparse errors
m68k/uaccess: fix sparse errors
arm: fix put_user sparse errors
blackfin: fix put_user sparse errors
ia64: fix put_user sparse errors
metag: fix put_user sparse errors
sh: fix put_user sparse errors
tile: fix put_user sparse errors
tile: enable sparse checks for get/put_user
avr32: whitespace fix
arch/sparc: uaccess_32 macro whitespace fixes
arch/sparc: uaccess_64 macro whitespace fixes
blackfin: macro whitespace fixes
microblaze: whitespace fix
alpha: macro whitespace fixes
arm: macro whitespace fixes
arm64: macro whitespace fixes
avr32: macro whitespace fixes
cris: macro whitespace fixes
frv: macro whitespace fixes
m32r: macro whitespace fixes
m68k: macro whitespace fixes
parisc: macro whitespace fixes
s390: macro whitespace fixes
sh: macro whitespace fixes
xtensa: macro whitespace fixes
arch/alpha/include/asm/uaccess.h | 86 ++++---- arch/arm/include/asm/uaccess.h | 96 ++++----- arch/arm64/include/asm/uaccess.h | 4 +- arch/avr32/include/asm/uaccess.h | 24 +-- arch/blackfin/include/asm/uaccess.h | 32 +-- arch/cris/include/asm/uaccess.h | 117 +++++------ arch/frv/include/asm/segment.h | 2 +- arch/ia64/include/asm/uaccess.h | 11 +- arch/m32r/include/asm/uaccess.h | 88 ++++---- arch/m68k/include/asm/segment.h | 2 +- arch/m68k/include/asm/uaccess_mm.h | 40 ++-- arch/metag/include/asm/uaccess.h | 25 ++- arch/microblaze/include/asm/uaccess.h | 6 +- arch/openrisc/include/asm/uaccess.h | 4 +- arch/parisc/include/asm/uaccess.h | 116 +++++------ arch/s390/include/asm/uaccess.h | 4 +- arch/sh/include/asm/segment.h | 2 +- arch/sh/include/asm/uaccess.h | 4 +- arch/sh/include/asm/uaccess_64.h | 8 +- arch/sparc/include/asm/uaccess_32.h | 364 +++++++++++++++++++++------------- arch/sparc/include/asm/uaccess_64.h | 246 +++++++++++++---------- arch/tile/include/asm/uaccess.h | 6 +- arch/x86/include/asm/uaccess.h | 2 +- arch/xtensa/include/asm/uaccess.h | 90 ++++----- 24 files changed, 759 insertions(+), 620 deletions(-)
Signature · 1 line
MST
PATCH v2 1/40 x86/uaccess: fix sparse errors
virtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/x86/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/uaccess.h +1 -1
@@ -179,7 +179,7 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) asmvolatile ("call __get_user_%P3" \ :"=a" (__ret_gu),"=r" (__val_gu) \ :"0" (ptr),"i" (sizeof (*(ptr)))); \ - (x) = (__typeof__ (*(ptr ))) __val_gu; \ + (x) = (__force __typeof__(*(ptr))) __val_gu; \ __ret_gu; \ })
Signature · 1 line
MST
PATCH v2 2/40 alpha/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/alpha/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/alpha/include/asm/uaccess.h +2 -2
@@ -96,7 +96,7 @@ extern void __get_user_unknown(void);case 8 :__get_user_64 (ptr);break ; \default :__get_user_unknown ();break ; \ } \ - (x) = (__typeof__ (*(ptr ))) __gu_val; \ + (x) = (__force __typeof__(*(ptr))) __gu_val; \ __gu_err; \ })
@@ -115,7 +115,7 @@ extern void __get_user_unknown(void);default :__get_user_unknown ();break ; \ } \ } \ - (x) = (__typeof__ (*(ptr ))) __gu_val; \ + (x) = (__force __typeof__(*(ptr))) __gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 3/40 arm64/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/arm64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/uaccess.h +1 -1
@@ -147,7 +147,7 @@ do { \default : \BUILD_BUG (); \ } \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ }while (0 ) #define __get_user(x, ptr) \
Signature · 1 line
MST
PATCH v2 4/40 avr32/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/avr32/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/avr32/include/asm/uaccess.h +2 -2
@@ -191,7 +191,7 @@ extern int __put_user_bad(void);default : __gu_err =__get_user_bad ();break ; \ } \ \ - x = (typeof (*(ptr )))__gu_val; \ + x = (__force typeof(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -222,7 +222,7 @@ extern int __put_user_bad(void); }else { \ __gu_err = -EFAULT ; \ } \ - x = (typeof (*(ptr )))__gu_val; \ + x = (__force typeof(*(ptr)))__gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 6/40 cris/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/cris/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/cris/include/asm/uaccess.h +2 -2
@@ -153,7 +153,7 @@ struct __large_struct { unsigned long buf[100]; }; ({ \long __gu_err, __gu_val; \__get_user_size (__gu_val,(ptr),(size),__gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -163,7 +163,7 @@ struct __large_struct { unsigned long buf[100]; }; const __typeof__(*(ptr)) *__gu_addr = (ptr); \if (access_ok (VERIFY_READ ,__gu_addr,size)) \__get_user_size (__gu_val,__gu_addr,(size),__gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 7/40 ia64/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/ia64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/include/asm/uaccess.h +1 -1
@@ -197,7 +197,7 @@ extern void __get_user_unknown (void);case 8 :__get_user_size (__gu_val, __gu_ptr,8 , __gu_err);break ; \default :__get_user_unknown ();break ; \ } \ - (x) = (__typeof__ (*(__gu_ptr ))) __gu_val; \ + (x) = (__force __typeof__(*(__gu_ptr))) __gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 9/40 metag/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/metag/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/metag/include/asm/uaccess.h +2 -2
@@ -135,7 +135,7 @@ extern long __get_user_bad(void); ({ \long __gu_err, __gu_val; \__get_user_size (__gu_val, (ptr), (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -145,7 +145,7 @@ extern long __get_user_bad(void); const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \if (access_ok (VERIFY_READ , __gu_addr, size)) \__get_user_size (__gu_val, __gu_addr, (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 5/40 blackfin/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/blackfin/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/blackfin/include/asm/uaccess.h +1 -1
@@ -147,7 +147,7 @@ static inline int bad_user_access_length(void) } \ }else \ _err = -EFAULT ; \ - x = (typeof (*(ptr )))_val; \ + x = (__force typeof(*(ptr)))_val; \ _err; \ })
Signature · 1 line
MST
PATCH v2 8/40 m32r/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/m32r/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/m32r/include/asm/uaccess.h +2 -2
@@ -218,7 +218,7 @@ extern int fixup_exception(struct pt_regs *regs);unsigned long __gu_val; \might_fault (); \__get_user_size (__gu_val,(ptr),(size),__gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -230,7 +230,7 @@ extern int fixup_exception(struct pt_regs *regs);might_fault (); \if (access_ok (VERIFY_READ ,__gu_addr,size)) \__get_user_size (__gu_val,__gu_addr,(size),__gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 11/40 openrisc/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/openrisc/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/openrisc/include/asm/uaccess.h +2 -2
@@ -192,7 +192,7 @@ struct __large_struct { ({ \long __gu_err, __gu_val; \__get_user_size (__gu_val, (ptr), (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -202,7 +202,7 @@ struct __large_struct { const __typeof__(*(ptr)) * __gu_addr = (ptr); \if (access_ok (VERIFY_READ , __gu_addr, size)) \__get_user_size (__gu_val, __gu_addr, (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 12/40 parisc/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/parisc/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/include/asm/uaccess.h +1 -1
@@ -104,7 +104,7 @@ struct exception_data { } \ } \ \ - (x) = (__typeof__ (*(ptr ))) __gu_val; \ + (x) = (__force __typeof__(*(ptr))) __gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 13/40 sh/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/sh/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sh/include/asm/uaccess.h +2 -2
@@ -60,7 +60,7 @@ struct __large_struct { unsigned long buf[100]; }; const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \__chk_user_ptr (ptr); \__get_user_size (__gu_val, __gu_addr, (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -71,7 +71,7 @@ struct __large_struct { unsigned long buf[100]; }; const __typeof__(*(ptr)) *__gu_addr = (ptr); \if (likely (access_ok (VERIFY_READ , __gu_addr, (size)))) \__get_user_size (__gu_val, __gu_addr, (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 10/40 microblaze/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/microblaze/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/microblaze/include/asm/uaccess.h +2 -2
@@ -220,7 +220,7 @@ extern long __user_bad(void); }else { \ __gu_err = -EFAULT ; \ } \ - x = (typeof (*(ptr )))__gu_val; \ + x = (__force typeof(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -242,7 +242,7 @@ extern long __user_bad(void);default : \/* __gu_val = 0; __gu_err = -EINVAL;*/ __gu_err =__user_bad ();\ } \ - x = (__typeof__ (*(ptr ))) __gu_val; \ + x = (__force __typeof__(*(ptr))) __gu_val; \ __gu_err; \ })
Signature · 1 line
MST
PATCH v2 14/40 sparc32/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/sparc/include/asm/uaccess_32.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sparc/include/asm/uaccess_32.h +4 -4
@@ -164,7 +164,7 @@ case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ case 4: __get_user_asm(__gu_val,,addr,__gu_ret); break; \case 8 :__get_user_asm (__gu_val,d,addr,__gu_ret);break ; \default : __gu_val =0 ; __gu_ret =__get_user_bad ();break ; \ -} } else { __gu_val = 0; __gu_ret = -EFAULT; } x = (type) __gu_val; __gu_ret; }) +} } else { __gu_val = 0; __gu_ret = -EFAULT; } x = (__force type) __gu_val; __gu_ret; })#define __get_user_check_ret (x,addr,size,type,retval) ({ \ register unsigned long __gu_val __asm__ ("l1"); \
@@ -175,7 +175,7 @@ case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ case 4: __get_user_asm_ret(__gu_val,,addr,retval); break; \case 8 :__get_user_asm_ret (__gu_val,d,addr,retval);break ; \default :if (__get_user_bad ())return retval; \ -} x = (type) __gu_val; } else return retval; }) +} x = (__force type) __gu_val; } else return retval; })#define __get_user_nocheck (x,addr,size,type) ({ \ register int __gu_ret; \
@@ -186,7 +186,7 @@ case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ case 4: __get_user_asm(__gu_val,,addr,__gu_ret); break; \case 8 :__get_user_asm (__gu_val,d,addr,__gu_ret);break ; \default : __gu_val =0 ; __gu_ret =__get_user_bad ();break ; \ -} x = (type) __gu_val; __gu_ret; }) +} x = (__force type) __gu_val; __gu_ret; })#define __get_user_nocheck_ret (x,addr,size,type,retval) ({ \ register unsigned long __gu_val __asm__ ("l1"); \
@@ -196,7 +196,7 @@ case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ case 4: __get_user_asm_ret(__gu_val,,addr,retval); break; \case 8 :__get_user_asm_ret (__gu_val,d,addr,retval);break ; \default :if (__get_user_bad ())return retval; \ -} x = (type) __gu_val; }) +} x = (__force type) __gu_val; })#define __get_user_asm (x,size,addr,ret) \ __asm__ __volatile__( \
Signature · 1 line
MST
PATCH v2 15/40 sparc64/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/sparc/include/asm/uaccess_64.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/sparc/include/asm/uaccess_64.h +2 -2
@@ -145,7 +145,7 @@ case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \case 4 :__get_user_asm (__gu_val,uw,addr,__gu_ret);break ; \case 8 :__get_user_asm (__gu_val,x,addr,__gu_ret);break ; \default : __gu_val =0 ; __gu_ret =__get_user_bad ();break ; \ -} data = (type) __gu_val; __gu_ret; }) +} data = (__force type) __gu_val; __gu_ret; })#define __get_user_nocheck_ret (data,addr,size,type,retval) ({ \ register unsigned long __gu_val __asm__ ("l1"); \
@@ -155,7 +155,7 @@ case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \case 4 :__get_user_asm_ret (__gu_val,uw,addr,retval);break ; \case 8 :__get_user_asm_ret (__gu_val,x,addr,retval);break ; \default :if (__get_user_bad ())return retval; \ -} data = (type) __gu_val; }) +} data = (__force type) __gu_val; })#define __get_user_asm (x,size,addr,ret) \ __asm__ __volatile__( \
Signature · 1 line
MST
PATCH v2 16/40 m68k/uaccess: fix sparse errors
In reply to Michael S. Tsirkinvirtio wants to read bitwise types from userspace using get_user. At the moment this triggers sparse errors, since the value is passed through an integer.
Fix that up using __force.
--- arch/m68k/include/asm/uaccess_mm.h | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
arch/m68k/include/asm/uaccess_mm.h +20 -20
@@ -128,25 +128,25 @@ asm volatile ("\n" \#define put_user (x, ptr) __put_user(x, ptr) -#define __get_user_asm (res, x, ptr, type, bwl, reg, err) ({ \ - type __gu_val; \ - asm volatile ("\n" \ - "1: "MOVES"."#bwl" %2,%1\n" \ - "2:\n" \ - " .section .fixup,\"ax\"\n" \ - " .even\n" \ - "10: move.l %3,%0\n" \ - " sub.l %1,%1\n" \ - " jra 2b\n" \ - " .previous\n" \ - "\n" \ - " .section __ex_table,\"a\"\n" \ - " .align 4\n" \ - " .long 1b,10b\n" \ - " .previous" \ - : "+d" (res), "=&" #reg (__gu_val) \ - : "m" (*(ptr)), "i" (err)); \ - (x) = (typeof(*(ptr)))(unsigned long)__gu_val; \ +#define __get_user_asm (res, x, ptr, type, bwl, reg, err) ({ \ + type __gu_val; \ + asm volatile ("\n" \ + "1: "MOVES"."#bwl" %2,%1\n" \ + "2:\n" \ + " .section .fixup,\"ax\"\n" \ + " .even\n" \ + "10: move.l %3,%0\n" \ + " sub.l %1,%1\n" \ + " jra 2b\n" \ + " .previous\n" \ + "\n" \ + " .section __ex_table,\"a\"\n" \ + " .align 4\n" \ + " .long 1b,10b\n" \ + " .previous" \ + : "+d" (res), "=&" #reg (__gu_val) \ + : "m" (*(ptr)), "i" (err)); \ + (x) = (__force typeof(*(ptr)))(__force unsigned long)__gu_val; \ })#define __get_user (x, ptr) \
@@ -188,7 +188,7 @@ asm volatile ("\n" \"+a" (__gu_ptr) \ : "i" (-EFAULT) \ : "memory"); \ -(x) = (typeof(*(ptr)))__gu_val; \ +(x) = (__force typeof(*(ptr)))__gu_val; \ break; \ } */ \default : \
Signature · 1 line
MST
PATCH v2 17/40 arm: fix put_user sparse errors
In reply to Michael S. Tsirkinvirtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p; __le32 x; put_user(x, p);
is safe, but currently triggers a sparse warning.
Fix that up using __force.
Note: this does not suppress any useful sparse checks since caller assigns x to typeof(*p), which in turn forces all the necessary type checks.
--- arch/arm/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/uaccess.h +2 -2
@@ -413,14 +413,14 @@ do { \#ifndef __ARMEB__#define __put_user_asm_half (x,__pu_addr,err) \ ({ \ - unsigned long __temp = (unsigned long)(x); \ + unsigned long __temp = (__force unsigned long)(x); \ __put_user_asm_byte(__temp, __pu_addr, err); \ __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err); \ })#else #define __put_user_asm_half (x,__pu_addr,err) \ ({ \ - unsigned long __temp = (unsigned long)(x); \ + unsigned long __temp = (__force unsigned long)(x); \ __put_user_asm_byte(__temp >> 8, __pu_addr, err); \ __put_user_asm_byte(__temp, __pu_addr + 1, err); \ })
Signature · 1 line
MST
PATCH v2 18/40 blackfin: fix put_user sparse errors
In reply to Michael S. Tsirkinvirtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p; __le32 x; put_user(x, p);
is safe, but currently triggers a sparse warning.
Fix that up using __force.
Note: this does not suppress any useful sparse checks since caller assigns x to typeof(*p), which in turn forces all the necessary type checks.
--- arch/blackfin/include/asm/uaccess.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/blackfin/include/asm/uaccess.h +4 -4
@@ -89,10 +89,10 @@ struct exception_table_entry {break ; \case 8 : { \long _xl, _xh; \ - _xl = ((long *)&_x)[0 ]; \ - _xh = ((long *)&_x)[1 ]; \ - __put_user_asm(_xl, ((long __user *)_p)+0, ); \ - __put_user_asm(_xh, ((long __user *)_p)+1, ); \ + _xl = ((__force long *)&_x)[0 ]; \ + _xh = ((__force long *)&_x)[1 ]; \ + __put_user_asm(_xl, ((__force long __user *)_p)+0, );\ + __put_user_asm(_xh, ((__force long __user *)_p)+1, );\ }break ; \default : \ _err =__put_user_bad (); \
Signature · 1 line
MST
PATCH v2 19/40 ia64: fix put_user sparse errors
In reply to Michael S. Tsirkinvirtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p; __le32 x; put_user(x, p);
is safe, but currently triggers a sparse warning.
Fix that up using __force.
Note: this does not suppress any useful sparse checks since callers do a cast (__typeof__(*(ptr))) (x) which in turn forces all the necessary type checks.
--- arch/ia64/include/asm/uaccess.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/ia64/include/asm/uaccess.h +5 -4
@@ -169,10 +169,11 @@ do { \ (err) =ia64_getreg (_IA64_REG_R8); \ (val) =ia64_getreg (_IA64_REG_R9); \ } while (0) -# define __put_user_size (val, addr, n, err) \ -do { \ - __st_user("__ex_table", (unsigned long) addr, n, RELOC_TYPE, (unsigned long) (val)); \ - (err) = ia64_getreg(_IA64_REG_R8); \ +# define __put_user_size (val, addr, n, err) \ +do { \ + __st_user("__ex_table", (unsigned long) addr, n, RELOC_TYPE, \ + (__force unsigned long) (val)); \ + (err) = ia64_getreg(_IA64_REG_R8); \ } while (0)#endif /* !ASM_SUPPORTED */
Signature · 1 line
MST
PATCH v2 20/40 metag: fix put_user sparse errors
In reply to Michael S. Tsirkinvirtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p; __le32 x; put_user(x, p);
is safe, but currently triggers a sparse warning.
Fix that up using __force.
This also fixes warnings due to writing a pointer out to userland.
Note: this does not suppress any useful sparse checks since callers do a cast (__typeof__(*(ptr))) (x) which in turn forces all the necessary type checks.
--- arch/metag/include/asm/uaccess.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
arch/metag/include/asm/uaccess.h +13 -8
@@ -107,18 +107,23 @@ extern long __put_user_asm_w(unsigned int x, void __user *addr);extern long __put_user_asm_d (unsigned int x,void __user *addr);extern long __put_user_asm_l (unsigned long long x,void __user *addr); -#define __put_user_size (x, ptr, size, retval) \ -do { \ - retval = 0; \ - switch (size) { \ +#define __put_user_size (x, ptr, size, retval) \ +do { \ + retval = 0; \ + switch (size) { \ case 1: \ - retval = __put_user_asm_b((unsigned int)x, ptr); break; \ + retval = __put_user_asm_b((__force unsigned int)x, ptr);\ + break; \ case 2: \ - retval = __put_user_asm_w((unsigned int)x, ptr); break; \ + retval = __put_user_asm_w((__force unsigned int)x, ptr);\ + break; \ case 4: \ - retval = __put_user_asm_d((unsigned int)x, ptr); break; \ + retval = __put_user_asm_d((__force unsigned int)x, ptr);\ + break; \ case 8: \ - retval = __put_user_asm_l((unsigned long long)x, ptr); break; \ + retval = __put_user_asm_l((__force unsigned long long)x,\ + ptr); \ + break; \ default: \ __put_user_bad(); \ } \
Signature · 1 line
MST
PATCH v2 21/40 sh: fix put_user sparse errors
In reply to Michael S. Tsirkinvirtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p; __le32 x; put_user(x, p);
is safe, but currently triggers a sparse warning.
Fix that up using __force.
Note: this does not suppress any useful sparse checks since caller assigns x to typeof(*p), which in turn forces all the necessary type checks.
--- arch/sh/include/asm/uaccess_64.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/sh/include/asm/uaccess_64.h +4 -4
@@ -59,19 +59,19 @@ do { \switch (size) { \case 1 : \ retval =__put_user_asm_b ((void *)&x, \ - (long )ptr); \ + (__force long )ptr); \break ; \case 2 : \ retval =__put_user_asm_w ((void *)&x, \ - (long )ptr); \ + (__force long )ptr); \break ; \case 4 : \ retval =__put_user_asm_l ((void *)&x, \ - (long )ptr); \ + (__force long )ptr); \break ; \case 8 : \ retval =__put_user_asm_q ((void *)&x, \ - (long )ptr); \ + (__force long )ptr); \break ; \default : \__put_user_unknown (); \
Signature · 1 line
MST
PATCH v2 22/40 tile: fix put_user sparse errors
In reply to Michael S. Tsirkinvirtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p; __le32 x; put_user(x, p);
is safe, but currently triggers a sparse warning on tile.
The reason has to do with this code:
__typeof((x)-(x))
which seems to be a way to force check for an integer type.
Since this is part of __put_user_8 which is only ever used for unsigned and signed char types, this seems unnecessary - I also note that no other architecture has such protections.
Fix that up using __force u64 cast.
Note: this does not suppress any useful sparse checks since the original merely casted x to typeof(x-x).
Tile currently does not trigger sparse warnings when get_user causes an illegal assignment across bitwise types. This patch does not attempt to fix this.
--- arch/tile/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/tile/include/asm/uaccess.h +1 -1
@@ -246,7 +246,7 @@ extern int __get_user_bad(void)#define __put_user_4 (x, ptr, ret) __put_user_asm(sw, x, ptr, ret)#define __put_user_8 (x, ptr, ret) \ ({ \ - u64 __x = (__typeof((x)-(x)))(x); \ + u64 __x = (__force u64)(x); \ int __lo = (int) __x, __hi = (int) (__x >> 32); \ asm volatile("1: { sw %1, %2; addi %0, %1, 4 }\n" \ "2: { sw %0, %3; movei %0, 0 }\n" \
Signature · 1 line
MST
PATCH v2 23/40 tile: enable sparse checks for get/put_user
In reply to Michael S. TsirkinTile currently does not trigger sparse warnings when get_user causes an illegal assignment across bitwise types.
For example:
__le32 __user *p;__u32 x;put_user(x, p);
violates endian-ness rules, but currently does not trigger sparse warning on tile.
Fix this by adding some dead code.
--- arch/tile/include/asm/uaccess.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/tile/include/asm/uaccess.h +4 -0
@@ -218,6 +218,8 @@ extern int __get_user_bad(void)case 8 :__get_user_8 (x, ptr, __ret);break ; \default : __ret =__get_user_bad ();break ; \ } \ +if (0 ) \ + x = *(__force typeof(*ptr) *)(ptr); \ __ret; \ })
@@ -297,6 +299,8 @@ extern int __put_user_bad(void)case 8 :__put_user_8 (x, ptr, __ret);break ; \default : __ret =__put_user_bad ();break ; \ } \ +if (0 ) \ + *(__force typeof(*ptr) *)(ptr) = x; \ __ret; \ })
Signature · 1 line
MST
PATCH v2 24/40 avr32: whitespace fix
In reply to Michael S. TsirkinAlign using tabs to make code prettier.
--- arch/avr32/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/avr32/include/asm/uaccess.h +1 -1
@@ -278,7 +278,7 @@ extern int __put_user_bad(void); __pu_err); \break ; \case 8 : \ -__put_user_asm ("d" , __pu_addr, __pu_val, \ +__put_user_asm ("d" , __pu_addr, __pu_val, \ __pu_err); \break ; \default : \
Signature · 1 line
MST
PATCH v2 25/40 arch/sparc: uaccess_32 macro whitespace fixes
In reply to Michael S. TsirkinMacros within arch/sparc/include/asm/uaccess_32.h are made harder to read because they violate a bunch of coding style rules.
Fix it up.
--- arch/sparc/include/asm/uaccess_32.h | 364 ++++++++++++++++++++++-------------- 1 file changed, 226 insertions(+), 138 deletions(-)
arch/sparc/include/asm/uaccess_32.h +226 -138
@@ -37,7 +37,7 @@#define get_fs () (current->thread.current_ds)#define set_fs (val) ((current->thread.current_ds) = (val)) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)/* We have there a nice not-mapped page at PAGE_OFFSET - PAGE_SIZE, so that this test * can be fairly lightweight.
@@ -46,8 +46,8 @@*/ #define __user_ok (addr, size) ({ (void)(size); (addr) < STACK_TOP; })#define __kernel_ok (segment_eq(get_fs(), KERNEL_DS)) -#define __access_ok (addr,size) (__user_ok((addr) & get_fs().seg,(size))) -#define access_ok (type, addr, size) \ +#define __access_ok (addr, size) (__user_ok((addr) & get_fs().seg, (size))) +#define access_ok (type, addr, size) \ ({ (void)(type); __access_ok((unsigned long)(addr), size); })/*
@@ -91,158 +91,246 @@ void __ret_efault(void);* of a performance impact. Thus we have a few rather ugly macros here, * and hide all the ugliness from the user. */ -#define put_user (x,ptr) ({ \ -unsigned long __pu_addr = (unsigned long)(ptr); \ -__chk_user_ptr(ptr); \ -__put_user_check((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); }) - -#define get_user (x,ptr) ({ \ -unsigned long __gu_addr = (unsigned long)(ptr); \ -__chk_user_ptr(ptr); \ -__get_user_check((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); }) +#define put_user (x, ptr) ({ \ + unsigned long __pu_addr = (unsigned long)(ptr); \ + __chk_user_ptr(ptr); \ + __put_user_check((__typeof__(*(ptr)))(x), __pu_addr, sizeof(*(ptr))); \ +}) + +#define get_user (x, ptr) ({ \ + unsigned long __gu_addr = (unsigned long)(ptr); \ + __chk_user_ptr(ptr); \ + __get_user_check((x), __gu_addr, sizeof(*(ptr)), __typeof__(*(ptr))); \ +})/* * The "__xxx" versions do not do address space checking, useful when * doing multiple accesses to the same area (the user has to do the * checks by hand with "access_ok()") */ -#define __put_user (x,ptr) __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) -#define __get_user (x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)),__typeof__(*(ptr))) +#define __put_user (x, ptr) \ + __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) +#define __get_user (x, ptr) \ + __get_user_nocheck((x), (ptr), sizeof(*(ptr)), __typeof__(*(ptr)))struct __large_struct {unsigned long buf[100 ]; };#define __m (x) ((struct __large_struct __user *)(x)) -#define __put_user_check (x,addr,size) ({ \ -register int __pu_ret; \ -if (__access_ok(addr,size)) { \ -switch (size) { \ -case 1: __put_user_asm(x,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(x,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(x,,addr,__pu_ret); break; \ -case 8: __put_user_asm(x,d,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} } else { __pu_ret = -EFAULT; } __pu_ret; }) - -#define __put_user_nocheck (x,addr,size) ({ \ -register int __pu_ret; \ -switch (size) { \ -case 1: __put_user_asm(x,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(x,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(x,,addr,__pu_ret); break; \ -case 8: __put_user_asm(x,d,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} __pu_ret; }) - -#define __put_user_asm(x,size,addr,ret) \ +#define __put_user_check (x, addr, size) ({ \ + register int __pu_ret; \ + if (__access_ok(addr, size)) { \ + switch (size) { \ + case 1: \ + __put_user_asm(x, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(x, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(x, , addr, __pu_ret); \ + break; \ + case 8: \ + __put_user_asm(x, d, addr, __pu_ret); \ + break; \ + default: \ + __pu_ret = __put_user_bad(); \ + break; \ + } \ + } else { \ + __pu_ret = -EFAULT; \ + } \ + __pu_ret; \ +}) + +#define __put_user_nocheck (x, addr, size) ({ \ + register int __pu_ret; \ + switch (size) { \ + case 1: \ + __put_user_asm(x, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(x, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(x, , addr, __pu_ret); \ + break; \ + case 8: \ + __put_user_asm(x, d, addr, __pu_ret); \ + break; \ + default: \ + __pu_ret = __put_user_bad(); \ + break; \ + } __pu_ret; \ +}) + +#define __put_user_asm(x, size, addr, ret) \ __asm__ __volatile__( \ - "/* Put user asm, inline. */\n" \ -"1:\t" "st"#size " %1, %2\n\t" \ - "clr %0\n" \ -"2:\n\n\t" \ - ".section .fixup,#alloc,#execinstr\n\t" \ - ".align 4\n" \ -"3:\n\t" \ - "b 2b\n\t" \ - " mov %3, %0\n\t" \ - ".previous\n\n\t" \ - ".section __ex_table,#alloc\n\t" \ - ".align 4\n\t" \ - ".word 1b, 3b\n\t" \ - ".previous\n\n\t" \ - : "=&r" (ret) : "r" (x), "m" (*__m(addr)), \ - "i" (-EFAULT)) + "/* Put user asm, inline. */\n" \ + "1:\t" "st"#size " %1, %2\n\t" \ + "clr %0\n" \ + "2:\n\n\t" \ + ".section .fixup,#alloc,#execinstr\n\t" \ + ".align 4\n" \ + "3:\n\t" \ + "b 2b\n\t" \ + " mov %3, %0\n\t" \ + ".previous\n\n\t" \ + ".section __ex_table,#alloc\n\t" \ + ".align 4\n\t" \ + ".word 1b, 3b\n\t" \ + ".previous\n\n\t" \ + : "=&r" (ret) : "r" (x), "m" (*__m(addr)), \ + "i" (-EFAULT))int __put_user_bad (void ); -#define __get_user_check (x,addr,size,type) ({ \ -register int __gu_ret; \ -register unsigned long __gu_val; \ -if (__access_ok(addr,size)) { \ -switch (size) { \ -case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \ -case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ -case 4: __get_user_asm(__gu_val,,addr,__gu_ret); break; \ -case 8: __get_user_asm(__gu_val,d,addr,__gu_ret); break; \ -default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \ -} } else { __gu_val = 0; __gu_ret = -EFAULT; } x = (__force type) __gu_val; __gu_ret; }) - -#define __get_user_check_ret (x,addr,size,type,retval) ({ \ -register unsigned long __gu_val __asm__ ("l1"); \ -if (__access_ok(addr,size)) { \ -switch (size) { \ -case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \ -case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ -case 4: __get_user_asm_ret(__gu_val,,addr,retval); break; \ -case 8: __get_user_asm_ret(__gu_val,d,addr,retval); break; \ -default: if (__get_user_bad()) return retval; \ -} x = (__force type) __gu_val; } else return retval; }) - -#define __get_user_nocheck (x,addr,size,type) ({ \ -register int __gu_ret; \ -register unsigned long __gu_val; \ -switch (size) { \ -case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \ -case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ -case 4: __get_user_asm(__gu_val,,addr,__gu_ret); break; \ -case 8: __get_user_asm(__gu_val,d,addr,__gu_ret); break; \ -default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \ -} x = (__force type) __gu_val; __gu_ret; }) - -#define __get_user_nocheck_ret (x,addr,size,type,retval) ({ \ -register unsigned long __gu_val __asm__ ("l1"); \ -switch (size) { \ -case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \ -case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ -case 4: __get_user_asm_ret(__gu_val,,addr,retval); break; \ -case 8: __get_user_asm_ret(__gu_val,d,addr,retval); break; \ -default: if (__get_user_bad()) return retval; \ -} x = (__force type) __gu_val; }) - -#define __get_user_asm(x,size,addr,ret) \ +#define __get_user_check (x, addr, size, type) ({ \ + register int __gu_ret; \ + register unsigned long __gu_val; \ + if (__access_ok(addr, size)) { \ + switch (size) { \ + case 1: \ + __get_user_asm(__gu_val, ub, addr, __gu_ret); \ + break; \ + case 2: \ + __get_user_asm(__gu_val, uh, addr, __gu_ret); \ + break; \ + case 4: \ + __get_user_asm(__gu_val, , addr, __gu_ret); \ + break; \ + case 8: \ + __get_user_asm(__gu_val, d, addr, __gu_ret); \ + break; \ + default: \ + __gu_val = 0; \ + __gu_ret = __get_user_bad(); \ + break; \ + } \ + } else { \ + __gu_val = 0; \ + __gu_ret = -EFAULT; \ + } \ + x = (__force type) __gu_val; \ + __gu_ret; \ +}) + +#define __get_user_check_ret (x, addr, size, type, retval) ({ \ + register unsigned long __gu_val __asm__ ("l1"); \ + if (__access_ok(addr, size)) { \ + switch (size) { \ + case 1: \ + __get_user_asm_ret(__gu_val, ub, addr, retval); \ + break; \ + case 2: \ + __get_user_asm_ret(__gu_val, uh, addr, retval); \ + break; \ + case 4: \ + __get_user_asm_ret(__gu_val, , addr, retval); \ + break; \ + case 8: \ + __get_user_asm_ret(__gu_val, d, addr, retval); \ + break; \ + default: \ + if (__get_user_bad()) \ + return retval; \ + } \ + x = (__force type) __gu_val; \ + } else \ + return retval; \ +}) + +#define __get_user_nocheck (x, addr, size, type) ({ \ + register int __gu_ret; \ + register unsigned long __gu_val; \ + switch (size) { \ + case 1: \ + __get_user_asm(__gu_val, ub, addr, __gu_ret); \ + break; \ + case 2: \ + __get_user_asm(__gu_val, uh, addr, __gu_ret); \ + break; \ + case 4: \ + __get_user_asm(__gu_val, , addr, __gu_ret); \ + break; \ + case 8: \ + __get_user_asm(__gu_val, d, addr, __gu_ret); \ + break; \ + default: \ + __gu_val = 0; \ + __gu_ret = __get_user_bad(); \ + break; \ + } \ + x = (__force type) __gu_val; \ + __gu_ret; \ +}) + +#define __get_user_nocheck_ret (x, addr, size, type, retval) ({ \ + register unsigned long __gu_val __asm__ ("l1"); \ + switch (size) { \ + case 1: \ + __get_user_asm_ret(__gu_val, ub, addr, retval); \ + break; \ + case 2: \ + __get_user_asm_ret(__gu_val, uh, addr, retval); \ + break; \ + case 4: \ + __get_user_asm_ret(__gu_val, , addr, retval); \ + break; \ + case 8: \ + __get_user_asm_ret(__gu_val, d, addr, retval); \ + break; \ + default: \ + if (__get_user_bad()) \ + return retval; \ + } \ + x = (__force type) __gu_val; \ +}) + +#define __get_user_asm(x, size, addr, ret) \ __asm__ __volatile__( \ - "/* Get user asm, inline. */\n" \ -"1:\t" "ld"#size " %2, %1\n\t" \ - "clr %0\n" \ -"2:\n\n\t" \ - ".section .fixup,#alloc,#execinstr\n\t" \ - ".align 4\n" \ -"3:\n\t" \ - "clr %1\n\t" \ - "b 2b\n\t" \ - " mov %3, %0\n\n\t" \ - ".previous\n\t" \ - ".section __ex_table,#alloc\n\t" \ - ".align 4\n\t" \ - ".word 1b, 3b\n\n\t" \ - ".previous\n\t" \ - : "=&r" (ret), "=&r" (x) : "m" (*__m(addr)), \ - "i" (-EFAULT)) - -#define __get_user_asm_ret(x,size,addr,retval) \ + "/* Get user asm, inline. */\n" \ + "1:\t" "ld"#size " %2, %1\n\t" \ + "clr %0\n" \ + "2:\n\n\t" \ + ".section .fixup,#alloc,#execinstr\n\t" \ + ".align 4\n" \ + "3:\n\t" \ + "clr %1\n\t" \ + "b 2b\n\t" \ + " mov %3, %0\n\n\t" \ + ".previous\n\t" \ + ".section __ex_table,#alloc\n\t" \ + ".align 4\n\t" \ + ".word 1b, 3b\n\n\t" \ + ".previous\n\t" \ + : "=&r" (ret), "=&r" (x) : "m" (*__m(addr)), \ + "i" (-EFAULT)) + +#define __get_user_asm_ret(x, size, addr, retval) \ if (__builtin_constant_p(retval) && retval == -EFAULT) \ -__asm__ __volatile__( \ - "/* Get user asm ret, inline. */\n" \ -"1:\t" "ld"#size " %1, %0\n\n\t" \ - ".section __ex_table,#alloc\n\t" \ - ".align 4\n\t" \ - ".word 1b,__ret_efault\n\n\t" \ - ".previous\n\t" \ - : "=&r" (x) : "m" (*__m(addr))); \ + __asm__ __volatile__( \ + "/* Get user asm ret, inline. */\n" \ + "1:\t" "ld"#size " %1, %0\n\n\t" \ + ".section __ex_table,#alloc\n\t" \ + ".align 4\n\t" \ + ".word 1b,__ret_efault\n\n\t" \ + ".previous\n\t" \ + : "=&r" (x) : "m" (*__m(addr))); \ else \ -__asm__ __volatile__( \ - "/* Get user asm ret, inline. */\n" \ -"1:\t" "ld"#size " %1, %0\n\n\t" \ - ".section .fixup,#alloc,#execinstr\n\t" \ - ".align 4\n" \ -"3:\n\t" \ - "ret\n\t" \ - " restore %%g0, %2, %%o0\n\n\t" \ - ".previous\n\t" \ - ".section __ex_table,#alloc\n\t" \ - ".align 4\n\t" \ - ".word 1b, 3b\n\n\t" \ - ".previous\n\t" \ - : "=&r" (x) : "m" (*__m(addr)), "i" (retval)) + __asm__ __volatile__( \ + "/* Get user asm ret, inline. */\n" \ + "1:\t" "ld"#size " %1, %0\n\n\t" \ + ".section .fixup,#alloc,#execinstr\n\t" \ + ".align 4\n" \ + "3:\n\t" \ + "ret\n\t" \ + " restore %%g0, %2, %%o0\n\n\t" \ + ".previous\n\t" \ + ".section __ex_table,#alloc\n\t" \ + ".align 4\n\t" \ + ".word 1b, 3b\n\n\t" \ + ".previous\n\t" \ + : "=&r" (x) : "m" (*__m(addr)), "i" (retval))int __get_user_bad (void );
Signature · 1 line
MST
PATCH v2 26/40 arch/sparc: uaccess_64 macro whitespace fixes
In reply to Michael S. TsirkinMacros within arch/sparc/include/asm/uaccess_64.h are made harder to read because they violate a bunch of coding style rules.
Fix it up.
--- arch/sparc/include/asm/uaccess_64.h | 246 +++++++++++++++++++++--------------- 1 file changed, 142 insertions(+), 104 deletions(-)
arch/sparc/include/asm/uaccess_64.h +142 -104
@@ -41,11 +41,11 @@#define get_fs () ((mm_segment_t){(current_thread_info()->current_ds)})#define get_ds () (KERNEL_DS) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#define set_fs (val) \ do { \ - current_thread_info()->current_ds =(val).seg; \ + current_thread_info()->current_ds = (val).seg; \ __asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \ } while(0)
@@ -88,121 +88,159 @@ void __retl_efault(void);* of a performance impact. Thus we have a few rather ugly macros here, * and hide all the ugliness from the user. */ -#define put_user (x,ptr) ({ \ -unsigned long __pu_addr = (unsigned long)(ptr); \ -__chk_user_ptr(ptr); \ -__put_user_nocheck((__typeof__(*(ptr)))(x),__pu_addr,sizeof(*(ptr))); }) +#define put_user (x, ptr) ({ \ + unsigned long __pu_addr = (unsigned long)(ptr); \ + __chk_user_ptr(ptr); \ + __put_user_nocheck((__typeof__(*(ptr)))(x), __pu_addr, sizeof(*(ptr)));\ +}) -#define get_user (x,ptr) ({ \ -unsigned long __gu_addr = (unsigned long)(ptr); \ -__chk_user_ptr(ptr); \ -__get_user_nocheck((x),__gu_addr,sizeof(*(ptr)),__typeof__(*(ptr))); }) +#define get_user (x, ptr) ({ \ + unsigned long __gu_addr = (unsigned long)(ptr); \ + __chk_user_ptr(ptr); \ + __get_user_nocheck((x), __gu_addr, sizeof(*(ptr)), __typeof__(*(ptr)));\ +}) -#define __put_user (x,ptr) put_user(x,ptr) -#define __get_user (x,ptr) get_user(x,ptr) +#define __put_user (x, ptr) put_user(x, ptr) +#define __get_user (x, ptr) get_user(x, ptr)struct __large_struct {unsigned long buf[100 ]; };#define __m (x) ((struct __large_struct *)(x)) -#define __put_user_nocheck (data,addr,size) ({ \ -register int __pu_ret; \ -switch (size) { \ -case 1: __put_user_asm(data,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(data,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(data,w,addr,__pu_ret); break; \ -case 8: __put_user_asm(data,x,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} __pu_ret; }) - -#define __put_user_asm(x,size,addr,ret) \ +#define __put_user_nocheck (data, addr, size) ({ \ + register int __pu_ret; \ + switch (size) { \ + case 1: \ + __put_user_asm(data, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(data, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(data, w, addr, __pu_ret); \ + break; \ + case 8: \ + __put_user_asm(data, x, addr, __pu_ret); \ + break; \ + default: \ + __pu_ret = __put_user_bad(); \ + break; \ + } \ + __pu_ret; \ +}) + +#define __put_user_asm(x, size, addr, ret) \ __asm__ __volatile__( \ - "/* Put user asm, inline. */\n" \ -"1:\t" "st"#size "a %1, [%2] %%asi\n\t" \ - "clr %0\n" \ -"2:\n\n\t" \ - ".section .fixup,#alloc,#execinstr\n\t" \ - ".align 4\n" \ -"3:\n\t" \ - "sethi %%hi(2b), %0\n\t" \ - "jmpl %0 + %%lo(2b), %%g0\n\t" \ - " mov %3, %0\n\n\t" \ - ".previous\n\t" \ - ".section __ex_table,\"a\"\n\t" \ - ".align 4\n\t" \ - ".word 1b, 3b\n\t" \ - ".previous\n\n\t" \ - : "=r" (ret) : "r" (x), "r" (__m(addr)), \ - "i" (-EFAULT)) + "/* Put user asm, inline. */\n" \ + "1:\t" "st"#size "a %1, [%2] %%asi\n\t" \ + "clr %0\n" \ + "2:\n\n\t" \ + ".section .fixup,#alloc,#execinstr\n\t" \ + ".align 4\n" \ + "3:\n\t" \ + "sethi %%hi(2b), %0\n\t" \ + "jmpl %0 + %%lo(2b), %%g0\n\t" \ + " mov %3, %0\n\n\t" \ + ".previous\n\t" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".word 1b, 3b\n\t" \ + ".previous\n\n\t" \ + : "=r" (ret) : "r" (x), "r" (__m(addr)), \ + "i" (-EFAULT))int __put_user_bad (void ); -#define __get_user_nocheck (data,addr,size,type) ({ \ -register int __gu_ret; \ -register unsigned long __gu_val; \ -switch (size) { \ -case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \ -case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ -case 4: __get_user_asm(__gu_val,uw,addr,__gu_ret); break; \ -case 8: __get_user_asm(__gu_val,x,addr,__gu_ret); break; \ -default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \ -} data = (__force type) __gu_val; __gu_ret; }) - -#define __get_user_nocheck_ret (data,addr,size,type,retval) ({ \ -register unsigned long __gu_val __asm__ ("l1"); \ -switch (size) { \ -case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \ -case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ -case 4: __get_user_asm_ret(__gu_val,uw,addr,retval); break; \ -case 8: __get_user_asm_ret(__gu_val,x,addr,retval); break; \ -default: if (__get_user_bad()) return retval; \ -} data = (__force type) __gu_val; }) - -#define __get_user_asm(x,size,addr,ret) \ +#define __get_user_nocheck (data, addr, size, type) ({ \ + register int __gu_ret; \ + register unsigned long __gu_val; \ + switch (size) { \ + case 1: \ + __get_user_asm(__gu_val, ub, addr, __gu_ret); \ + break; \ + case 2: \ + __get_user_asm(__gu_val, uh, addr, __gu_ret); \ + break; \ + case 4: \ + __get_user_asm(__gu_val, uw, addr, __gu_ret); \ + break; \ + case 8: \ + __get_user_asm(__gu_val, x, addr, __gu_ret); \ + break; \ + default: \ + __gu_val = 0; \ + __gu_ret = __get_user_bad(); \ + break; \ + } data = (__force type) __gu_val; __gu_ret; \ +}) + +#define __get_user_nocheck_ret (data, addr, size, type, retval) ({ \ + register unsigned long __gu_val __asm__ ("l1"); \ + switch (size) { \ + case 1: \ + __get_user_asm_ret(__gu_val, ub, addr, retval); \ + break; \ + case 2: \ + __get_user_asm_ret(__gu_val, uh, addr, retval); \ + break; \ + case 4: \ + __get_user_asm_ret(__gu_val, uw, addr, retval); \ + break; \ + case 8: \ + __get_user_asm_ret(__gu_val, x, addr, retval); \ + break; \ + default: \ + if (__get_user_bad()) \ + return retval; \ + } \ + data = (__force type) __gu_val; \ +}) + +#define __get_user_asm(x, size, addr, ret) \ __asm__ __volatile__( \ - "/* Get user asm, inline. */\n" \ -"1:\t" "ld"#size "a [%2] %%asi, %1\n\t" \ - "clr %0\n" \ -"2:\n\n\t" \ - ".section .fixup,#alloc,#execinstr\n\t" \ - ".align 4\n" \ -"3:\n\t" \ - "sethi %%hi(2b), %0\n\t" \ - "clr %1\n\t" \ - "jmpl %0 + %%lo(2b), %%g0\n\t" \ - " mov %3, %0\n\n\t" \ - ".previous\n\t" \ - ".section __ex_table,\"a\"\n\t" \ - ".align 4\n\t" \ - ".word 1b, 3b\n\n\t" \ - ".previous\n\t" \ - : "=r" (ret), "=r" (x) : "r" (__m(addr)), \ - "i" (-EFAULT)) - -#define __get_user_asm_ret(x,size,addr,retval) \ + "/* Get user asm, inline. */\n" \ + "1:\t" "ld"#size "a [%2] %%asi, %1\n\t" \ + "clr %0\n" \ + "2:\n\n\t" \ + ".section .fixup,#alloc,#execinstr\n\t" \ + ".align 4\n" \ + "3:\n\t" \ + "sethi %%hi(2b), %0\n\t" \ + "clr %1\n\t" \ + "jmpl %0 + %%lo(2b), %%g0\n\t" \ + " mov %3, %0\n\n\t" \ + ".previous\n\t" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".word 1b, 3b\n\n\t" \ + ".previous\n\t" \ + : "=r" (ret), "=r" (x) : "r" (__m(addr)), \ + "i" (-EFAULT)) + +#define __get_user_asm_ret(x, size, addr, retval) \ if (__builtin_constant_p(retval) && retval == -EFAULT) \ -__asm__ __volatile__( \ - "/* Get user asm ret, inline. */\n" \ -"1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \ - ".section __ex_table,\"a\"\n\t" \ - ".align 4\n\t" \ - ".word 1b,__ret_efault\n\n\t" \ - ".previous\n\t" \ - : "=r" (x) : "r" (__m(addr))); \ + __asm__ __volatile__( \ + "/* Get user asm ret, inline. */\n" \ + "1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".word 1b,__ret_efault\n\n\t" \ + ".previous\n\t" \ + : "=r" (x) : "r" (__m(addr))); \ else \ -__asm__ __volatile__( \ - "/* Get user asm ret, inline. */\n" \ -"1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \ - ".section .fixup,#alloc,#execinstr\n\t" \ - ".align 4\n" \ -"3:\n\t" \ - "ret\n\t" \ - " restore %%g0, %2, %%o0\n\n\t" \ - ".previous\n\t" \ - ".section __ex_table,\"a\"\n\t" \ - ".align 4\n\t" \ - ".word 1b, 3b\n\n\t" \ - ".previous\n\t" \ - : "=r" (x) : "r" (__m(addr)), "i" (retval)) + __asm__ __volatile__( \ + "/* Get user asm ret, inline. */\n" \ + "1:\t" "ld"#size "a [%1] %%asi, %0\n\n\t" \ + ".section .fixup,#alloc,#execinstr\n\t" \ + ".align 4\n" \ + "3:\n\t" \ + "ret\n\t" \ + " restore %%g0, %2, %%o0\n\n\t" \ + ".previous\n\t" \ + ".section __ex_table,\"a\"\n\t" \ + ".align 4\n\t" \ + ".word 1b, 3b\n\n\t" \ + ".previous\n\t" \ + : "=r" (x) : "r" (__m(addr)), "i" (retval))int __get_user_bad (void );
Signature · 1 line
MST
PATCH v2 28/40 microblaze: whitespace fix
In reply to Michael S. TsirkinAlign using tabs to make code prettier.
--- arch/microblaze/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/microblaze/include/asm/uaccess.h +1 -1
@@ -306,7 +306,7 @@ extern long __user_bad(void);#define __put_user_check (x, ptr, size) \ ({ \ - typeof(*(ptr)) volatile __pu_val = x; \ + typeof(*(ptr)) volatile __pu_val = x; \ typeof(*(ptr)) __user *__pu_addr = (ptr); \ int __pu_err = 0; \ \
Signature · 1 line
MST
PATCH v2 29/40 alpha: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/alpha/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/alpha/include/asm/uaccess.h | 82 ++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 41 deletions(-)
arch/alpha/include/asm/uaccess.h +41 -41
@@ -27,7 +27,7 @@#define get_ds () (KERNEL_DS)#define set_fs (x) (current_thread_info()->addr_limit = (x)) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)/* * Is a address valid? This does a straightforward calculation rather
@@ -39,13 +39,13 @@* - AND "addr+size" doesn't have any high-bits set * - OR we are in kernel mode. */ -#define __access_ok (addr,size,segment) \ +#define __access_ok (addr, size, segment) \ (((segment).seg & (addr | size | (addr+size))) == 0) -#define access_ok (type,addr,size) \ +#define access_ok (type, addr, size) \ ({ \ __chk_user_ptr(addr); \ - __access_ok(((unsigned long)(addr)),(size),get_fs()); \ + __access_ok(((unsigned long)(addr)), (size), get_fs()); \ })/*
@@ -60,20 +60,20 @@* (a) re-use the arguments for side effects (sizeof/typeof is ok) * (b) require any knowledge of processes at this stage */ -#define put_user (x,ptr) \ - __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)),get_fs()) -#define get_user (x,ptr) \ - __get_user_check((x),(ptr),sizeof(*(ptr)),get_fs()) +#define put_user (x, ptr) \ + __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)), get_fs()) +#define get_user (x, ptr) \ + __get_user_check((x), (ptr), sizeof(*(ptr)), get_fs())/* * The "__xxx" versions do not do address space checking, useful when * doing multiple accesses to the same area (the programmer has to do the * checks by hand with "access_ok()") */ -#define __put_user (x,ptr) \ - __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) -#define __get_user (x,ptr) \ - __get_user_nocheck((x),(ptr),sizeof(*(ptr))) +#define __put_user (x, ptr) \ + __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) +#define __get_user (x, ptr) \ + __get_user_nocheck((x), (ptr), sizeof(*(ptr)))/* * The "lda %1, 2b-1b(%0)" bits are magic to get the assembler to
@@ -84,7 +84,7 @@extern void __get_user_unknown (void ); -#define __get_user_nocheck (x,ptr,size) \ +#define __get_user_nocheck (x, ptr, size) \ ({ \ long __gu_err = 0; \ unsigned long __gu_val; \
@@ -100,12 +100,12 @@ extern void __get_user_unknown(void); __gu_err; \ }) -#define __get_user_check (x,ptr,size,segment) \ +#define __get_user_check (x, ptr, size, segment) \ ({ \ long __gu_err = -EFAULT; \ unsigned long __gu_val = 0; \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ - if (__access_ok((unsigned long)__gu_addr,size,segment)) { \ + if (__access_ok((unsigned long)__gu_addr, size, segment)) { \ __gu_err = 0; \ switch (size) { \ case 1: __get_user_8(__gu_addr); break; \
@@ -201,31 +201,31 @@ struct __large_struct { unsigned long buf[100]; };extern void __put_user_unknown (void ); -#define __put_user_nocheck (x,ptr,size) \ +#define __put_user_nocheck (x, ptr, size) \ ({ \ long __pu_err = 0; \ __chk_user_ptr(ptr); \ switch (size) { \ - case 1: __put_user_8(x,ptr); break; \ - case 2: __put_user_16(x,ptr); break; \ - case 4: __put_user_32(x,ptr); break; \ - case 8: __put_user_64(x,ptr); break; \ + case 1: __put_user_8(x, ptr); break; \ + case 2: __put_user_16(x, ptr); break; \ + case 4: __put_user_32(x, ptr); break; \ + case 8: __put_user_64(x, ptr); break; \ default: __put_user_unknown(); break; \ } \ __pu_err; \ }) -#define __put_user_check (x,ptr,size,segment) \ +#define __put_user_check (x, ptr, size, segment) \ ({ \ long __pu_err = -EFAULT; \ __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ - if (__access_ok((unsigned long)__pu_addr,size,segment)) { \ + if (__access_ok((unsigned long)__pu_addr, size, segment)) { \ __pu_err = 0; \ switch (size) { \ - case 1: __put_user_8(x,__pu_addr); break; \ - case 2: __put_user_16(x,__pu_addr); break; \ - case 4: __put_user_32(x,__pu_addr); break; \ - case 8: __put_user_64(x,__pu_addr); break; \ + case 1: __put_user_8(x, __pu_addr); break; \ + case 2: __put_user_16(x, __pu_addr); break; \ + case 4: __put_user_32(x, __pu_addr); break; \ + case 8: __put_user_64(x, __pu_addr); break; \ default: __put_user_unknown(); break; \ } \ } \
@@ -237,7 +237,7 @@ extern void __put_user_unknown(void);* instead of writing: this is because they do not write to * any memory gcc knows about, so there are no aliasing issues */ -#define __put_user_64 (x,addr) \ +#define __put_user_64 (x, addr) \ __asm__ __volatile__("1: stq %r2,%1\n" \ "2:\n" \ ".section __ex_table,\"a\"\n" \
@@ -247,7 +247,7 @@ __asm__ __volatile__("1: stq %r2,%1\n" \ : "=r"(__pu_err) \ : "m" (__m(addr)), "rJ" (x), "0"(__pu_err)) -#define __put_user_32 (x,addr) \ +#define __put_user_32 (x, addr) \ __asm__ __volatile__("1: stl %r2,%1\n" \ "2:\n" \ ".section __ex_table,\"a\"\n" \
@@ -260,7 +260,7 @@ __asm__ __volatile__("1: stl %r2,%1\n" \#ifdef __alpha_bwx__/* Those lucky bastards with ev56 and later CPUs can do byte/word moves. */ -#define __put_user_16 (x,addr) \ +#define __put_user_16 (x, addr) \ __asm__ __volatile__("1: stw %r2,%1\n" \ "2:\n" \ ".section __ex_table,\"a\"\n" \
@@ -270,7 +270,7 @@ __asm__ __volatile__("1: stw %r2,%1\n" \ : "=r"(__pu_err) \ : "m"(__m(addr)), "rJ"(x), "0"(__pu_err)) -#define __put_user_8 (x,addr) \ +#define __put_user_8 (x, addr) \ __asm__ __volatile__("1: stb %r2,%1\n" \ "2:\n" \ ".section __ex_table,\"a\"\n" \
@@ -283,7 +283,7 @@ __asm__ __volatile__("1: stb %r2,%1\n" \/* Unfortunately, we can't get an unaligned access trap for the sub-word write, so we have to do a general unaligned operation. */ -#define __put_user_16 (x,addr) \ +#define __put_user_16 (x, addr) \ { \ long __pu_tmp1, __pu_tmp2, __pu_tmp3, __pu_tmp4; \ __asm__ __volatile__( \
@@ -308,13 +308,13 @@ __asm__ __volatile__("1: stb %r2,%1\n" \ " .long 4b - .\n" \ " lda $31, 5b-4b(%0)\n" \ ".previous" \ - : "=r"(__pu_err), "=&r"(__pu_tmp1), \ - "=&r"(__pu_tmp2), "=&r"(__pu_tmp3), \ + : "=r"(__pu_err), "=&r"(__pu_tmp1), \ + "=&r"(__pu_tmp2), "=&r"(__pu_tmp3), \ "=&r"(__pu_tmp4) \ : "r"(addr), "r"((unsigned long)(x)), "0"(__pu_err)); \ } -#define __put_user_8 (x,addr) \ +#define __put_user_8 (x, addr) \ { \ long __pu_tmp1, __pu_tmp2; \ __asm__ __volatile__( \
@@ -330,7 +330,7 @@ __asm__ __volatile__("1: stb %r2,%1\n" \ " .long 2b - .\n" \ " lda $31, 3b-2b(%0)\n" \ ".previous" \ - : "=r"(__pu_err), \ + : "=r"(__pu_err), \ "=&r"(__pu_tmp1), "=&r"(__pu_tmp2) \ : "r"((unsigned long)(x)), "r"(addr), "0"(__pu_err)); \ }
@@ -366,7 +366,7 @@ __copy_tofrom_user_nocheck(void *to, const void *from, long len) : "=r" (__cu_len), "=r" (__cu_from), "=r" (__cu_to) : __module_address(__copy_user) "0" (__cu_len), "1" (__cu_from), "2" (__cu_to) - : "$1","$2","$3","$4","$5","$28","memory"); + : "$1", "$2", "$3", "$4", "$5", "$28", "memory");return __cu_len; }
@@ -379,15 +379,15 @@ __copy_tofrom_user(void *to, const void *from, long len, const void __user *valireturn len; } -#define __copy_to_user (to,from,n) \ +#define __copy_to_user (to, from, n) \ ({ \ __chk_user_ptr(to); \ - __copy_tofrom_user_nocheck((__force void *)(to),(from),(n)); \ + __copy_tofrom_user_nocheck((__force void *)(to), (from), (n)); \ }) -#define __copy_from_user (to,from,n) \ +#define __copy_from_user (to, from, n) \ ({ \ __chk_user_ptr(from); \ - __copy_tofrom_user_nocheck((to),(__force void *)(from),(n)); \ + __copy_tofrom_user_nocheck((to), (__force void *)(from), (n)); \ })#define __copy_to_user_inatomic __copy_to_user
@@ -418,7 +418,7 @@ __clear_user(void __user *to, long len) : "=r"(__cl_len), "=r"(__cl_to) : __module_address(__do_clear_user) "0"(__cl_len), "1"(__cl_to) - : "$1","$2","$3","$4","$5","$28","memory"); + : "$1", "$2", "$3", "$4", "$5", "$28", "memory");return __cl_len; }
Signature · 1 line
MST
PATCH v2 30/40 arm: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/arm/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/arm/include/asm/uaccess.h | 92 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 46 deletions(-)
arch/arm/include/asm/uaccess.h +46 -46
@@ -73,7 +73,7 @@ static inline void set_fs(mm_segment_t fs)modify_domain (DOMAIN_KERNEL , fs ?DOMAIN_CLIENT :DOMAIN_MANAGER ); } -#define segment_eq (a,b) ((a) == (b)) +#define segment_eq (a, b) ((a) == (b))#define __addr_ok (addr) ({ \ unsigned long flag; \
@@ -84,7 +84,7 @@ static inline void set_fs(mm_segment_t fs) (flag == 0); })/* We use 33-bit arithmetic here... */ -#define __range_ok (addr,size) ({ \ +#define __range_ok (addr, size) ({ \ unsigned long flag, roksum; \ __chk_user_ptr(addr); \ __asm__("adds %1, %2, %3; sbcccs %1, %1, %0; movcc %0, #0" \
@@ -123,7 +123,7 @@ extern int __get_user_64t_4(void *);#define __GUP_CLOBBER_32t_8 "lr", "cc"#define __GUP_CLOBBER_8 "lr", "cc" -#define __get_user_x (__r2,__p,__e,__l,__s) \ +#define __get_user_x (__r2, __p, __e, __l, __s) \ __asm__ __volatile__ ( \ __asmeq("%0", "r0") __asmeq("%1", "r2") \ __asmeq("%3", "r1") \
@@ -134,7 +134,7 @@ extern int __get_user_64t_4(void *);/* narrowing a double-word get into a single 32bit word register: */ #ifdef __ARMEB__ -#define __get_user_x_32t (__r2, __p, __e, __l, __s) \ +#define __get_user_x_32t (__r2, __p, __e, __l, __s) \ __get_user_x(__r2, __p, __e, __l, 32t_8)#else #define __get_user_x_32t __get_user_x
@@ -158,7 +158,7 @@ extern int __get_user_64t_4(void *);#endif -#define __get_user_check (x,p) \ +#define __get_user_check (x, p) \ ({ \ unsigned long __limit = current_thread_info()->addr_limit - 1; \ register const typeof(*(p)) __user *__p asm("r0") = (p);\
@@ -196,10 +196,10 @@ extern int __get_user_64t_4(void *); __e; \ }) -#define get_user (x,p) \ +#define get_user (x, p) \ ({ \ might_fault(); \ - __get_user_check(x,p); \ + __get_user_check(x, p); \ })extern int __put_user_1 (void *,unsigned int );
@@ -207,7 +207,7 @@ extern int __put_user_2(void *, unsigned int);extern int __put_user_4 (void *,unsigned int );extern int __put_user_8 (void *,unsigned long long ); -#define __put_user_x (__r2,__p,__e,__l,__s) \ +#define __put_user_x (__r2, __p, __e, __l, __s) \ __asm__ __volatile__ ( \ __asmeq("%0", "r0") __asmeq("%2", "r2") \ __asmeq("%3", "r1") \
@@ -216,7 +216,7 @@ extern int __put_user_8(void *, unsigned long long); : "0" (__p), "r" (__r2), "r" (__l) \ : "ip", "lr", "cc") -#define __put_user_check (x,p) \ +#define __put_user_check (x, p) \ ({ \ unsigned long __limit = current_thread_info()->addr_limit - 1; \ const typeof(*(p)) __user *__tmp_p = (p); \
@@ -242,10 +242,10 @@ extern int __put_user_8(void *, unsigned long long); __e; \ }) -#define put_user (x,p) \ +#define put_user (x, p) \ ({ \ might_fault(); \ - __put_user_check(x,p); \ + __put_user_check(x, p); \ })#else /* CONFIG_MMU */
@@ -255,21 +255,21 @@ extern int __put_user_8(void *, unsigned long long);*/ #define USER_DS KERNEL_DS -#define segment_eq (a,b) (1) -#define __addr_ok (addr) ((void)(addr),1) -#define __range_ok (addr,size) ((void)(addr),0) +#define segment_eq (a, b) (1) +#define __addr_ok (addr) ((void)(addr), 1) +#define __range_ok (addr, size) ((void)(addr), 0)#define get_fs () (KERNEL_DS)static inline void set_fs (mm_segment_t fs) { } -#define get_user (x,p) __get_user(x,p) -#define put_user (x,p) __put_user(x,p) +#define get_user (x, p) __get_user(x, p) +#define put_user (x, p) __put_user(x, p)#endif /* CONFIG_MMU */ -#define access_ok (type,addr,size) (__range_ok(addr,size) == 0) +#define access_ok (type, addr, size) (__range_ok(addr, size) == 0)#define user_addr_max () \ (segment_eq(get_fs(), KERNEL_DS) ? ~0UL : get_fs())
@@ -283,35 +283,35 @@ static inline void set_fs(mm_segment_t fs)* error occurs, and leave it unchanged on success. Note that these * versions are void (ie, don't return a value as such). */ -#define __get_user (x,ptr) \ +#define __get_user (x, ptr) \ ({ \ long __gu_err = 0; \ - __get_user_err((x),(ptr),__gu_err); \ + __get_user_err((x), (ptr), __gu_err); \ __gu_err; \ }) -#define __get_user_error (x,ptr,err) \ +#define __get_user_error (x, ptr, err) \ ({ \ - __get_user_err((x),(ptr),err); \ + __get_user_err((x), (ptr), err); \ (void) 0; \ }) -#define __get_user_err (x,ptr,err) \ +#define __get_user_err (x, ptr, err) \ do { \ unsigned long __gu_addr = (unsigned long)(ptr); \ unsigned long __gu_val; \ __chk_user_ptr(ptr); \ might_fault(); \ switch (sizeof(*(ptr))) { \ - case 1: __get_user_asm_byte(__gu_val,__gu_addr,err); break; \ - case 2: __get_user_asm_half(__gu_val,__gu_addr,err); break; \ - case 4: __get_user_asm_word(__gu_val,__gu_addr,err); break; \ + case 1: __get_user_asm_byte(__gu_val, __gu_addr, err); break; \ + case 2: __get_user_asm_half(__gu_val, __gu_addr, err); break; \ + case 4: __get_user_asm_word(__gu_val, __gu_addr, err); break; \ default: (__gu_val) = __get_user_bad(); \ } \ (x) = (__typeof__(*(ptr)))__gu_val; \ } while (0) -#define __get_user_asm_byte (x,addr,err) \ +#define __get_user_asm_byte (x, addr, err) \ __asm__ __volatile__( \ "1: " TUSER(ldrb) " %1,[%2],#0\n" \ "2:\n" \
@@ -330,7 +330,7 @@ do { \ : "cc")#ifndef __ARMEB__ -#define __get_user_asm_half (x,__gu_addr,err) \ +#define __get_user_asm_half (x, __gu_addr, err) \ ({ \ unsigned long __b1, __b2; \ __get_user_asm_byte(__b1, __gu_addr, err); \
@@ -338,7 +338,7 @@ do { \ (x) = __b1 | (__b2 <<8 ); \ })#else -#define __get_user_asm_half (x,__gu_addr,err) \ +#define __get_user_asm_half (x, __gu_addr, err) \ ({ \ unsigned long __b1, __b2; \ __get_user_asm_byte(__b1, __gu_addr, err); \
@@ -347,7 +347,7 @@ do { \ })#endif -#define __get_user_asm_word (x,addr,err) \ +#define __get_user_asm_word (x, addr, err) \ __asm__ __volatile__( \ "1: " TUSER(ldr) " %1,[%2],#0\n" \ "2:\n" \
@@ -365,35 +365,35 @@ do { \ : "r" (addr), "i" (-EFAULT) \ : "cc") -#define __put_user (x,ptr) \ +#define __put_user (x, ptr) \ ({ \ long __pu_err = 0; \ - __put_user_err((x),(ptr),__pu_err); \ + __put_user_err((x), (ptr), __pu_err); \ __pu_err; \ }) -#define __put_user_error (x,ptr,err) \ +#define __put_user_error (x, ptr, err) \ ({ \ - __put_user_err((x),(ptr),err); \ + __put_user_err((x), (ptr), err); \ (void) 0; \ }) -#define __put_user_err (x,ptr,err) \ +#define __put_user_err (x, ptr, err) \ do { \ unsigned long __pu_addr = (unsigned long)(ptr); \ __typeof__(*(ptr)) __pu_val = (x); \ __chk_user_ptr(ptr); \ might_fault(); \ switch (sizeof(*(ptr))) { \ - case 1: __put_user_asm_byte(__pu_val,__pu_addr,err); break; \ - case 2: __put_user_asm_half(__pu_val,__pu_addr,err); break; \ - case 4: __put_user_asm_word(__pu_val,__pu_addr,err); break; \ - case 8: __put_user_asm_dword(__pu_val,__pu_addr,err); break; \ + case 1: __put_user_asm_byte(__pu_val, __pu_addr, err); break; \ + case 2: __put_user_asm_half(__pu_val, __pu_addr, err); break; \ + case 4: __put_user_asm_word(__pu_val, __pu_addr, err); break; \ + case 8: __put_user_asm_dword(__pu_val, __pu_addr, err); break; \ default: __put_user_bad(); \ } \ } while (0) -#define __put_user_asm_byte (x,__pu_addr,err) \ +#define __put_user_asm_byte (x, __pu_addr, err) \ __asm__ __volatile__( \ "1: " TUSER(strb) " %1,[%2],#0\n" \ "2:\n" \
@@ -411,14 +411,14 @@ do { \ : "cc")#ifndef __ARMEB__ -#define __put_user_asm_half (x,__pu_addr,err) \ +#define __put_user_asm_half (x, __pu_addr, err) \ ({ \ unsigned long __temp = (__force unsigned long)(x); \ __put_user_asm_byte(__temp, __pu_addr, err); \ __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err); \ })#else -#define __put_user_asm_half (x,__pu_addr,err) \ +#define __put_user_asm_half (x, __pu_addr, err) \ ({ \ unsigned long __temp = (__force unsigned long)(x); \ __put_user_asm_byte(__temp >> 8, __pu_addr, err); \
@@ -426,7 +426,7 @@ do { \ })#endif -#define __put_user_asm_word (x,__pu_addr,err) \ +#define __put_user_asm_word (x, __pu_addr, err) \ __asm__ __volatile__( \ "1: " TUSER(str) " %1,[%2],#0\n" \ "2:\n" \
@@ -451,7 +451,7 @@ do { \#define __reg_oper1 "%R2"#endif -#define __put_user_asm_dword (x,__pu_addr,err) \ +#define __put_user_asm_dword (x, __pu_addr, err) \ __asm__ __volatile__( \ ARM( "1: " TUSER(str) " " __reg_oper1 ", [%1], #4\n" ) \ ARM( "2: " TUSER(str) " " __reg_oper0 ", [%1]\n" ) \
@@ -480,9 +480,9 @@ extern unsigned long __must_check __copy_to_user_std(void __user *to, const voidextern unsigned long __must_check __clear_user (void __user *addr,unsigned long n);extern unsigned long __must_check __clear_user_std (void __user *addr,unsigned long n);#else -#define __copy_from_user (to,from,n) (memcpy(to, (void __force *)from, n), 0) -#define __copy_to_user (to,from,n) (memcpy((void __force *)to, from, n), 0) -#define __clear_user (addr,n) (memset((void __force *)addr, 0, n), 0) +#define __copy_from_user (to, from, n) (memcpy(to, (void __force *)from, n), 0) +#define __copy_to_user (to, from, n) (memcpy((void __force *)to, from, n), 0) +#define __clear_user (addr, n) (memset((void __force *)addr, 0, n), 0)#endif static inline unsigned long __must_check copy_from_user (void *to,const void __user *from,unsigned long n)
Signature · 1 line
MST
PATCH v2 31/40 arm64: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/arm64/include/asm/uaccess.h, I noticed that one macro within this header is made harder to read because it violates a coding style rule: space is missing after comma.
Fix it up.
--- arch/arm64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/uaccess.h +1 -1
@@ -63,7 +63,7 @@ static inline void set_fs(mm_segment_t fs)current_thread_info ()->addr_limit = fs; } -#define segment_eq (a,b) ((a) == (b)) +#define segment_eq (a, b) ((a) == (b))/* * Return 1 if addr < current->addr_limit, 0 otherwise.
Signature · 1 line
MST
PATCH v2 32/40 avr32: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/avr32/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/avr32/include/asm/uaccess.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
arch/avr32/include/asm/uaccess.h +9 -9
@@ -26,7 +26,7 @@ typedef struct {* For historical reasons (Data Segment Register?), these macros are misnamed. */ #define MAKE_MM_SEG (s) ((mm_segment_t) { (s) }) -#define segment_eq (a,b) ((a).is_user_space == (b).is_user_space) +#define segment_eq (a, b) ((a).is_user_space == (b).is_user_space)#define USER_ADDR_LIMIT 0x80000000
@@ -108,8 +108,8 @@ static inline __kernel_size_t __copy_from_user(void *to,* * Returns zero on success, or -EFAULT on error. */ -#define put_user (x,ptr) \ - __put_user_check((x),(ptr),sizeof(*(ptr))) +#define put_user (x, ptr) \ + __put_user_check((x), (ptr), sizeof(*(ptr)))/* * get_user: - Get a simple variable from user space.
@@ -128,8 +128,8 @@ static inline __kernel_size_t __copy_from_user(void *to,* Returns zero on success, or -EFAULT on error. * On error, the variable @x is set to zero. */ -#define get_user (x,ptr) \ - __get_user_check((x),(ptr),sizeof(*(ptr))) +#define get_user (x, ptr) \ + __get_user_check((x), (ptr), sizeof(*(ptr)))/* * __put_user: - Write a simple value into user space, with less checking.
@@ -150,8 +150,8 @@ static inline __kernel_size_t __copy_from_user(void *to,* * Returns zero on success, or -EFAULT on error. */ -#define __put_user (x,ptr) \ - __put_user_nocheck((x),(ptr),sizeof(*(ptr))) +#define __put_user (x, ptr) \ + __put_user_nocheck((x), (ptr), sizeof(*(ptr)))/* * __get_user: - Get a simple variable from user space, with less checking.
@@ -173,8 +173,8 @@ static inline __kernel_size_t __copy_from_user(void *to,* Returns zero on success, or -EFAULT on error. * On error, the variable @x is set to zero. */ -#define __get_user (x,ptr) \ - __get_user_nocheck((x),(ptr),sizeof(*(ptr))) +#define __get_user (x, ptr) \ + __get_user_nocheck((x), (ptr), sizeof(*(ptr)))extern int __get_user_bad (void );extern int __put_user_bad (void );
Signature · 1 line
MST
PATCH v2 27/40 blackfin: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/blackfin/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/blackfin/include/asm/uaccess.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
arch/blackfin/include/asm/uaccess.h +11 -11
@@ -27,7 +27,7 @@ static inline void set_fs(mm_segment_t fs)current_thread_info ()->addr_limit = fs; } -#define segment_eq (a,b) ((a) == (b)) +#define segment_eq (a, b) ((a) == (b))#define VERIFY_READ 0#define VERIFY_WRITE 1
@@ -68,11 +68,11 @@ struct exception_table_entry {* use the right size if we just have the right pointer type. */ -#define put_user (x,p) \ +#define put_user (x, p) \ ({ \ int _err = 0; \ typeof(*(p)) _x = (x); \ - typeof(*(p)) __user *_p = (p); \ + typeof(*(p)) __user *_p = (p); \ if (!access_ok(VERIFY_WRITE, _p, sizeof(*(_p)))) {\ _err = -EFAULT; \ } \
@@ -102,7 +102,7 @@ struct exception_table_entry { _err; \ }) -#define __put_user (x,p) put_user(x,p) +#define __put_user (x, p) put_user(x, p)static inline int bad_user_access_length (void ) {panic ("bad_user_access_length" );
@@ -121,10 +121,10 @@ static inline int bad_user_access_length(void)#define __ptr (x) ((unsigned long __force *)(x)) -#define __put_user_asm(x,p,bhw) \ +#define __put_user_asm(x, p, bhw) \ __asm__ (#bhw"[%1] = %0;\n\t" \ : /* no outputs */ \ - :"d" (x),"a" (__ptr(p)) : "memory") + :"d" (x), "a" (__ptr(p)) : "memory")#define get_user (x, ptr) \ ({ \
@@ -136,10 +136,10 @@ static inline int bad_user_access_length(void)BUILD_BUG_ON (ptr_size >=8 ); \switch (ptr_size) { \case 1 : \ -__get_user_asm (_val, _p,B ,(Z )); \ +__get_user_asm (_val, _p,B , (Z )); \break ; \case 2 : \ -__get_user_asm (_val, _p,W ,(Z )); \ +__get_user_asm (_val, _p,W , (Z )); \break ; \case 4 : \ __get_user_asm(_val, _p, , ); \
@@ -151,7 +151,7 @@ static inline int bad_user_access_length(void) _err; \ }) -#define __get_user (x,p) get_user(x,p) +#define __get_user (x, p) get_user(x, p)#define __get_user_bad () (bad_user_access_length(), (-EFAULT))
@@ -168,10 +168,10 @@ static inline int bad_user_access_length(void)#define __copy_to_user_inatomic __copy_to_user#define __copy_from_user_inatomic __copy_from_user -#define copy_to_user_ret (to,from,n,retval) ({ if (copy_to_user(to,from,n))\ +#define copy_to_user_ret (to, from, n, retval) ({ if (copy_to_user(to, from, n))\ return retval; }) -#define copy_from_user_ret (to,from,n,retval) ({ if (copy_from_user(to,from,n))\ +#define copy_from_user_ret (to, from, n, retval) ({ if (copy_from_user(to, from, n))\ return retval; }) static inline unsigned long __must_check
Signature · 1 line
MST
PATCH v2 34/40 frv: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/frv/include/asm/uaccess.h, I noticed that one macro within this header is made harder to read because it violates a coding style rule: space is missing after comma.
Fix it up.
--- arch/frv/include/asm/segment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/frv/include/asm/segment.h +1 -1
@@ -31,7 +31,7 @@ typedef struct {#define get_ds () (KERNEL_DS)#define get_fs () (__current_thread_info->addr_limit) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#define __kernel_ds_p () segment_eq(get_fs(), KERNEL_DS)#define get_addr_limit () (get_fs().seg)
Signature · 1 line
MST
PATCH v2 36/40 m68k: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/m68k/include/asm/uaccess.h, I noticed that one macro within this header is made harder to read because it violates a coding style rule: space is missing after comma.
Fix it up.
--- arch/m68k/include/asm/segment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/include/asm/segment.h +1 -1
@@ -58,7 +58,7 @@ static inline mm_segment_t get_ds(void)#define set_fs (x) (current_thread_info()->addr_limit = (x))#endif -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#endif /* __ASSEMBLY__ */
Signature · 1 line
MST
PATCH v2 33/40 cris: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/cris/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/cris/include/asm/uaccess.h | 113 +++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 55 deletions(-)
arch/cris/include/asm/uaccess.h +58 -55
@@ -47,12 +47,13 @@#define get_fs () (current_thread_info()->addr_limit)#define set_fs (x) (current_thread_info()->addr_limit = (x)) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#define __kernel_ok (segment_eq(get_fs(), KERNEL_DS)) -#define __user_ok (addr,size) (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size))) -#define __access_ok (addr,size) (__kernel_ok || __user_ok((addr),(size))) -#define access_ok (type,addr,size) __access_ok((unsigned long)(addr),(size)) +#define __user_ok (addr, size) \ + (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size))) +#define __access_ok (addr, size) (__kernel_ok || __user_ok((addr), (size))) +#define access_ok (type, addr, size) __access_ok((unsigned long)(addr), (size))#include <arch/uaccess.h>
@@ -92,56 +93,56 @@ struct exception_table_entry* CRIS, we can just do these as direct assignments. (Of course, the * exception handling means that it's no longer "just"...) */ -#define get_user (x,ptr) \ - __get_user_check((x),(ptr),sizeof(*(ptr))) -#define put_user (x,ptr) \ - __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) +#define get_user (x, ptr) \ + __get_user_check((x), (ptr), sizeof(*(ptr))) +#define put_user (x, ptr) \ + __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) -#define __get_user (x,ptr) \ - __get_user_nocheck((x),(ptr),sizeof(*(ptr))) -#define __put_user (x,ptr) \ - __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) +#define __get_user (x, ptr) \ + __get_user_nocheck((x), (ptr), sizeof(*(ptr))) +#define __put_user (x, ptr) \ + __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))extern long __put_user_bad (void ); -#define __put_user_size (x,ptr,size,retval) \ -do { \ - retval = 0; \ - switch (size) { \ - case 1: __put_user_asm(x,ptr,retval,"move.b"); break; \ - case 2: __put_user_asm(x,ptr,retval,"move.w"); break; \ - case 4: __put_user_asm(x,ptr,retval,"move.d"); break; \ - case 8: __put_user_asm_64(x,ptr,retval); break; \ - default: __put_user_bad(); \ - } \ +#define __put_user_size (x, ptr, size, retval) \ +do { \ + retval = 0; \ + switch (size) { \ + case 1: __put_user_asm(x, ptr, retval, "move.b"); break; \ + case 2: __put_user_asm(x, ptr, retval, "move.w"); break; \ + case 4: __put_user_asm(x, ptr, retval, "move.d"); break; \ + case 8: __put_user_asm_64(x, ptr, retval); break; \ + default: __put_user_bad(); \ + } \ } while (0) -#define __get_user_size (x,ptr,size,retval) \ -do { \ - retval = 0; \ - switch (size) { \ - case 1: __get_user_asm(x,ptr,retval,"move.b"); break; \ - case 2: __get_user_asm(x,ptr,retval,"move.w"); break; \ - case 4: __get_user_asm(x,ptr,retval,"move.d"); break; \ - case 8: __get_user_asm_64(x,ptr,retval); break; \ - default: (x) = __get_user_bad(); \ - } \ +#define __get_user_size (x, ptr, size, retval) \ +do { \ + retval = 0; \ + switch (size) { \ + case 1: __get_user_asm(x, ptr, retval, "move.b"); break; \ + case 2: __get_user_asm(x, ptr, retval, "move.w"); break; \ + case 4: __get_user_asm(x, ptr, retval, "move.d"); break; \ + case 8: __get_user_asm_64(x, ptr, retval); break; \ + default: (x) = __get_user_bad(); \ + } \ } while (0) -#define __put_user_nocheck (x,ptr,size) \ +#define __put_user_nocheck (x, ptr, size) \ ({ \ long __pu_err; \ - __put_user_size((x),(ptr),(size),__pu_err); \ + __put_user_size((x), (ptr), (size), __pu_err); \ __pu_err; \ }) -#define __put_user_check (x,ptr,size) \ -({ \ - long __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ - if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ - __put_user_size((x),__pu_addr,(size),__pu_err); \ - __pu_err; \ +#define __put_user_check (x, ptr, size) \ +({ \ + long __pu_err = -EFAULT; \ + __typeof__(*(ptr)) *__pu_addr = (ptr); \ + if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ + __put_user_size((x), __pu_addr, (size), __pu_err); \ + __pu_err; \ })struct __large_struct {unsigned long buf[100 ]; };
@@ -149,20 +150,20 @@ struct __large_struct { unsigned long buf[100]; }; -#define __get_user_nocheck (x,ptr,size) \ +#define __get_user_nocheck (x, ptr, size) \ ({ \ long __gu_err, __gu_val; \ - __get_user_size(__gu_val,(ptr),(size),__gu_err); \ + __get_user_size(__gu_val, (ptr), (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) -#define __get_user_check (x,ptr,size) \ +#define __get_user_check (x, ptr, size) \ ({ \ long __gu_err = -EFAULT, __gu_val = 0; \ const __typeof__(*(ptr)) *__gu_addr = (ptr); \ - if (access_ok(VERIFY_READ,__gu_addr,size)) \ - __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \ + if (access_ok(VERIFY_READ, __gu_addr, size)) \ + __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })
@@ -180,7 +181,7 @@ static inline unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned long n) {if (access_ok (VERIFY_WRITE , to, n)) -return __copy_user (to,from,n); +return __copy_user (to, from, n);return n; }
@@ -188,7 +189,7 @@ static inline unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n) {if (access_ok (VERIFY_READ , from, n)) -return __copy_user_zeroing (to,from,n); +return __copy_user_zeroing (to, from, n);return n; }
@@ -196,7 +197,7 @@ static inline unsigned long __generic_clear_user(void __user *to, unsigned long n) {if (access_ok (VERIFY_WRITE , to, n)) -return __do_clear_user (to,n); +return __do_clear_user (to, n);return n; }
@@ -373,29 +374,31 @@ static inline unsigned long __generic_copy_from_user_nocheck(void *to, const void __user *from, unsigned long n) { -return __copy_user_zeroing (to,from,n); +return __copy_user_zeroing (to, from, n); }static inline unsigned long __generic_copy_to_user_nocheck (void __user *to,const void *from,unsigned long n) { -return __copy_user (to,from,n); +return __copy_user (to, from, n); }static inline unsigned long __generic_clear_user_nocheck (void __user *to,unsigned long n) { -return __do_clear_user (to,n); +return __do_clear_user (to, n); }/* without checking */ -#define __copy_to_user (to,from,n) __generic_copy_to_user_nocheck((to),(from),(n)) -#define __copy_from_user (to,from,n) __generic_copy_from_user_nocheck((to),(from),(n)) +#define __copy_to_user (to, from, n) \ + __generic_copy_to_user_nocheck((to), (from), (n)) +#define __copy_from_user (to, from, n) \ + __generic_copy_from_user_nocheck((to), (from), (n))#define __copy_to_user_inatomic __copy_to_user#define __copy_from_user_inatomic __copy_from_user -#define __clear_user (to,n) __generic_clear_user_nocheck((to),(n)) +#define __clear_user (to, n) __generic_clear_user_nocheck((to), (n))#define strlen_user (str) strnlen_user((str), 0x7ffffffe)
Signature · 1 line
MST
PATCH v2 37/40 parisc: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/parisc/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/parisc/include/asm/uaccess.h | 116 +++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 58 deletions(-)
arch/parisc/include/asm/uaccess.h +58 -58
@@ -17,7 +17,7 @@#define KERNEL_DS ((mm_segment_t){0})#define USER_DS ((mm_segment_t){1}) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#define get_ds () (KERNEL_DS)#define get_fs () (current_thread_info()->addr_limit)
@@ -42,14 +42,14 @@ static inline long access_ok(int type, const void __user * addr,#if !defined(CONFIG_64BIT )#define LDD_KERNEL (ptr) BUILD_BUG()#define LDD_USER (ptr) BUILD_BUG() -#define STD_KERNEL (x, ptr) __put_kernel_asm64(x,ptr) -#define STD_USER (x, ptr) __put_user_asm64(x,ptr) +#define STD_KERNEL (x, ptr) __put_kernel_asm64(x, ptr) +#define STD_USER (x, ptr) __put_user_asm64(x, ptr)#define ASM_WORD_INSN ".word\t"#else -#define LDD_KERNEL (ptr) __get_kernel_asm("ldd",ptr) -#define LDD_USER (ptr) __get_user_asm("ldd",ptr) -#define STD_KERNEL (x, ptr) __put_kernel_asm("std",x,ptr) -#define STD_USER (x, ptr) __put_user_asm("std",x,ptr) +#define LDD_KERNEL (ptr) __get_kernel_asm("ldd", ptr) +#define LDD_USER (ptr) __get_user_asm("ldd", ptr) +#define STD_KERNEL (x, ptr) __put_kernel_asm("std", x, ptr) +#define STD_USER (x, ptr) __put_user_asm("std", x, ptr)#define ASM_WORD_INSN ".dword\t"#endif
@@ -80,68 +80,68 @@ struct exception_data {unsigned long fault_addr; }; -#define __get_user (x,ptr) \ -({ \ - register long __gu_err __asm__ ("r8") = 0; \ - register long __gu_val __asm__ ("r9") = 0; \ - \ - if (segment_eq(get_fs(),KERNEL_DS)) { \ - switch (sizeof(*(ptr))) { \ - case 1: __get_kernel_asm("ldb",ptr); break; \ - case 2: __get_kernel_asm("ldh",ptr); break; \ - case 4: __get_kernel_asm("ldw",ptr); break; \ - case 8: LDD_KERNEL(ptr); break; \ - default: BUILD_BUG(); break; \ - } \ - } \ - else { \ - switch (sizeof(*(ptr))) { \ - case 1: __get_user_asm("ldb",ptr); break; \ - case 2: __get_user_asm("ldh",ptr); break; \ - case 4: __get_user_asm("ldw",ptr); break; \ - case 8: LDD_USER(ptr); break; \ - default: BUILD_BUG(); break; \ - } \ - } \ - \ - (x) = (__force __typeof__(*(ptr))) __gu_val; \ - __gu_err; \ +#define __get_user (x, ptr) \ +({ \ + register long __gu_err __asm__ ("r8") = 0; \ + register long __gu_val __asm__ ("r9") = 0; \ + \ + if (segment_eq(get_fs(), KERNEL_DS)) { \ + switch (sizeof(*(ptr))) { \ + case 1: __get_kernel_asm("ldb", ptr); break; \ + case 2: __get_kernel_asm("ldh", ptr); break; \ + case 4: __get_kernel_asm("ldw", ptr); break; \ + case 8: LDD_KERNEL(ptr); break; \ + default: BUILD_BUG(); break; \ + } \ + } \ + else { \ + switch (sizeof(*(ptr))) { \ + case 1: __get_user_asm("ldb", ptr); break; \ + case 2: __get_user_asm("ldh", ptr); break; \ + case 4: __get_user_asm("ldw", ptr); break; \ + case 8: LDD_USER(ptr); break; \ + default: BUILD_BUG(); break; \ + } \ + } \ + \ + (x) = (__force __typeof__(*(ptr))) __gu_val; \ + __gu_err; \ }) -#define __get_kernel_asm (ldx,ptr) \ +#define __get_kernel_asm (ldx, ptr) \ __asm__("\n1:\t" ldx "\t0(%2),%0\n\t" \ ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_get_user_skip_1)\ : "=r"(__gu_val), "=r"(__gu_err) \ : "r"(ptr), "1"(__gu_err) \ : "r1"); -#define __get_user_asm (ldx,ptr) \ +#define __get_user_asm (ldx, ptr) \ __asm__("\n1:\t" ldx "\t0(%%sr3,%2),%0\n\t" \ - ASM_EXCEPTIONTABLE_ENTRY(1b,fixup_get_user_skip_1)\ + ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_get_user_skip_1)\ : "=r"(__gu_val), "=r"(__gu_err) \ : "r"(ptr), "1"(__gu_err) \ : "r1"); -#define __put_user (x,ptr) \ +#define __put_user (x, ptr) \ ({ \ register long __pu_err __asm__ ("r8") = 0; \ __typeof__(*(ptr)) __x = (__typeof__(*(ptr)))(x); \ \ - if (segment_eq(get_fs(),KERNEL_DS)) { \ + if (segment_eq(get_fs(), KERNEL_DS)) { \ switch (sizeof(*(ptr))) { \ - case 1: __put_kernel_asm("stb",__x,ptr); break; \ - case 2: __put_kernel_asm("sth",__x,ptr); break; \ - case 4: __put_kernel_asm("stw",__x,ptr); break; \ - case 8: STD_KERNEL(__x,ptr); break; \ + case 1: __put_kernel_asm("stb", __x, ptr); break; \ + case 2: __put_kernel_asm("sth", __x, ptr); break; \ + case 4: __put_kernel_asm("stw", __x, ptr); break; \ + case 8: STD_KERNEL(__x, ptr); break; \ default: BUILD_BUG(); break; \ } \ } \ else { \ switch (sizeof(*(ptr))) { \ - case 1: __put_user_asm("stb",__x,ptr); break; \ - case 2: __put_user_asm("sth",__x,ptr); break; \ - case 4: __put_user_asm("stw",__x,ptr); break; \ - case 8: STD_USER(__x,ptr); break; \ + case 1: __put_user_asm("stb", __x, ptr); break; \ + case 2: __put_user_asm("sth", __x, ptr); break; \ + case 4: __put_user_asm("stw", __x, ptr); break; \ + case 8: STD_USER(__x, ptr); break; \ default: BUILD_BUG(); break; \ } \ } \
@@ -159,18 +159,18 @@ struct exception_data {* r8/r9 are already listed as err/val. */ -#define __put_kernel_asm (stx,x,ptr) \ +#define __put_kernel_asm (stx, x, ptr) \ __asm__ __volatile__ ( \ "\n1:\t" stx "\t%2,0(%1)\n\t" \ - ASM_EXCEPTIONTABLE_ENTRY(1b,fixup_put_user_skip_1)\ + ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_put_user_skip_1)\ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err) \ : "r1") -#define __put_user_asm (stx,x,ptr) \ +#define __put_user_asm (stx, x, ptr) \ __asm__ __volatile__ ( \ "\n1:\t" stx "\t%2,0(%%sr3,%1)\n\t" \ - ASM_EXCEPTIONTABLE_ENTRY(1b,fixup_put_user_skip_1)\ + ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_put_user_skip_1)\ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err) \ : "r1")
@@ -178,23 +178,23 @@ struct exception_data {#if !defined(CONFIG_64BIT ) -#define __put_kernel_asm64 (__val,ptr) do { \ +#define __put_kernel_asm64 (__val, ptr) do { \ __asm__ __volatile__ ( \ "\n1:\tstw %2,0(%1)" \ "\n2:\tstw %R2,4(%1)\n\t" \ - ASM_EXCEPTIONTABLE_ENTRY(1b,fixup_put_user_skip_2)\ - ASM_EXCEPTIONTABLE_ENTRY(2b,fixup_put_user_skip_1)\ + ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_put_user_skip_2)\ + ASM_EXCEPTIONTABLE_ENTRY(2b, fixup_put_user_skip_1)\ : "=r"(__pu_err) \ : "r"(ptr), "r"(__val), "0"(__pu_err) \ : "r1"); \ } while (0) -#define __put_user_asm64 (__val,ptr) do { \ +#define __put_user_asm64 (__val, ptr) do { \ __asm__ __volatile__ ( \ "\n1:\tstw %2,0(%%sr3,%1)" \ "\n2:\tstw %R2,4(%%sr3,%1)\n\t" \ - ASM_EXCEPTIONTABLE_ENTRY(1b,fixup_put_user_skip_2)\ - ASM_EXCEPTIONTABLE_ENTRY(2b,fixup_put_user_skip_1)\ + ASM_EXCEPTIONTABLE_ENTRY(1b, fixup_put_user_skip_2)\ + ASM_EXCEPTIONTABLE_ENTRY(2b, fixup_put_user_skip_1)\ : "=r"(__pu_err) \ : "r"(ptr), "r"(__val), "0"(__pu_err) \ : "r1"); \
@@ -211,8 +211,8 @@ extern unsigned long lcopy_to_user(void __user *, const void *, unsigned long);extern unsigned long lcopy_from_user (void *,const void __user *,unsigned long );extern unsigned long lcopy_in_user (void __user *,const void __user *,unsigned long );extern long strncpy_from_user (char *,const char __user *,long ); -extern unsigned lclear_user (void __user *,unsigned long ); -extern long lstrnlen_user (const char __user *,long ); +extern unsigned lclear_user (void __user *,unsigned long ); +extern long lstrnlen_user (const char __user *,long );/* * Complex access routines -- macros */
Signature · 1 line
MST
PATCH v2 35/40 m32r: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/m32r/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/m32r/include/asm/uaccess.h | 84 ++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-)
arch/m32r/include/asm/uaccess.h +42 -42
@@ -54,7 +54,7 @@ static inline void set_fs(mm_segment_t s)#endif /* not CONFIG_MMU */ -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#define __addr_ok (addr) \ ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
@@ -68,7 +68,7 @@ static inline void set_fs(mm_segment_t s)* * This needs 33-bit arithmetic. We have a carry... */ -#define __range_ok (addr,size) ({ \ +#define __range_ok (addr, size) ({ \ unsigned long flag, roksum; \ __chk_user_ptr(addr); \ asm ( \
@@ -103,7 +103,7 @@ static inline void set_fs(mm_segment_t s)* this function, memory access functions may still return -EFAULT. */ #ifdef CONFIG_MMU -#define access_ok (type,addr,size) (likely(__range_ok(addr,size) == 0)) +#define access_ok (type, addr, size) (likely(__range_ok(addr, size) == 0))#else static inline int access_ok (int type,const void *addr,unsigned long size) {
@@ -167,8 +167,8 @@ extern int fixup_exception(struct pt_regs *regs);* Returns zero on success, or -EFAULT on error. * On error, the variable @x is set to zero. */ -#define get_user (x,ptr) \ - __get_user_check((x),(ptr),sizeof(*(ptr))) +#define get_user (x, ptr) \ + __get_user_check((x), (ptr), sizeof(*(ptr)))/** * put_user: - Write a simple value into user space.
@@ -186,8 +186,8 @@ extern int fixup_exception(struct pt_regs *regs);* * Returns zero on success, or -EFAULT on error. */ -#define put_user (x,ptr) \ - __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) +#define put_user (x, ptr) \ + __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))/** * __get_user: - Get a simple variable from user space, with less checking.
@@ -209,41 +209,41 @@ extern int fixup_exception(struct pt_regs *regs);* Returns zero on success, or -EFAULT on error. * On error, the variable @x is set to zero. */ -#define __get_user (x,ptr) \ - __get_user_nocheck((x),(ptr),sizeof(*(ptr))) +#define __get_user (x, ptr) \ + __get_user_nocheck((x), (ptr), sizeof(*(ptr))) -#define __get_user_nocheck (x,ptr,size) \ +#define __get_user_nocheck (x, ptr, size) \ ({ \ long __gu_err = 0; \ unsigned long __gu_val; \ might_fault(); \ - __get_user_size(__gu_val,(ptr),(size),__gu_err); \ + __get_user_size(__gu_val, (ptr), (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) -#define __get_user_check (x,ptr,size) \ +#define __get_user_check (x, ptr, size) \ ({ \ long __gu_err = -EFAULT; \ unsigned long __gu_val = 0; \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ might_fault(); \ - if (access_ok(VERIFY_READ,__gu_addr,size)) \ - __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \ + if (access_ok(VERIFY_READ, __gu_addr, size)) \ + __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })extern long __get_user_bad (void ); -#define __get_user_size (x,ptr,size,retval) \ +#define __get_user_size (x, ptr, size, retval) \ do { \ retval = 0; \ __chk_user_ptr(ptr); \ switch (size) { \ - case 1: __get_user_asm(x,ptr,retval,"ub"); break; \ - case 2: __get_user_asm(x,ptr,retval,"uh"); break; \ - case 4: __get_user_asm(x,ptr,retval,""); break; \ + case 1: __get_user_asm(x, ptr, retval, "ub"); break; \ + case 2: __get_user_asm(x, ptr, retval, "uh"); break; \ + case 4: __get_user_asm(x, ptr, retval, ""); break; \ default: (x) = __get_user_bad(); \ } \ } while (0)
@@ -288,26 +288,26 @@ do { \* * Returns zero on success, or -EFAULT on error. */ -#define __put_user (x,ptr) \ - __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) +#define __put_user (x, ptr) \ + __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) -#define __put_user_nocheck (x,ptr,size) \ +#define __put_user_nocheck (x, ptr, size) \ ({ \ long __pu_err; \ might_fault(); \ - __put_user_size((x),(ptr),(size),__pu_err); \ + __put_user_size((x), (ptr), (size), __pu_err); \ __pu_err; \ }) -#define __put_user_check (x,ptr,size) \ +#define __put_user_check (x, ptr, size) \ ({ \ long __pu_err = -EFAULT; \ __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ might_fault(); \ - if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ - __put_user_size((x),__pu_addr,(size),__pu_err); \ + if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ + __put_user_size((x), __pu_addr, (size), __pu_err); \ __pu_err; \ })
@@ -366,15 +366,15 @@ do { \extern void __put_user_bad (void ); -#define __put_user_size (x,ptr,size,retval) \ +#define __put_user_size (x, ptr, size, retval) \ do { \ retval = 0; \ __chk_user_ptr(ptr); \ switch (size) { \ - case 1: __put_user_asm(x,ptr,retval,"b"); break; \ - case 2: __put_user_asm(x,ptr,retval,"h"); break; \ - case 4: __put_user_asm(x,ptr,retval,""); break; \ - case 8: __put_user_u64((__typeof__(*ptr))(x),ptr,retval); break;\ + case 1: __put_user_asm(x, ptr, retval, "b"); break; \ + case 2: __put_user_asm(x, ptr, retval, "h"); break; \ + case 4: __put_user_asm(x, ptr, retval, ""); break; \ + case 8: __put_user_u64((__typeof__(*ptr))(x), ptr, retval); break;\ default: __put_user_bad(); \ } \ } while (0)
@@ -421,7 +421,7 @@ struct __large_struct { unsigned long buf[100]; };/* Generic arbitrary sized copy. */ /* Return the number of bytes NOT copied. */ -#define __copy_user (to,from,size) \ +#define __copy_user (to, from, size) \ do { \ unsigned long __dst, __src, __c; \ __asm__ __volatile__ ( \
@@ -478,7 +478,7 @@ do { \ : "r14", "memory"); \ } while (0) -#define __copy_user_zeroing (to,from,size) \ +#define __copy_user_zeroing (to, from, size) \ do { \ unsigned long __dst, __src, __c; \ __asm__ __volatile__ ( \
@@ -548,14 +548,14 @@ do { \static inline unsigned long __generic_copy_from_user_nocheck (void *to,const void __user *from,unsigned long n) { -__copy_user_zeroing (to,from,n); +__copy_user_zeroing (to, from, n);return n; }static inline unsigned long __generic_copy_to_user_nocheck (void __user *to,const void *from,unsigned long n) { -__copy_user (to,from,n); +__copy_user (to, from, n);return n; }
@@ -576,8 +576,8 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon* Returns number of bytes that could not be copied. * On success, this will be zero. */ -#define __copy_to_user (to,from,n) \ - __generic_copy_to_user_nocheck((to),(from),(n)) +#define __copy_to_user (to, from, n) \ + __generic_copy_to_user_nocheck((to), (from), (n))#define __copy_to_user_inatomic __copy_to_user#define __copy_from_user_inatomic __copy_from_user
@@ -595,10 +595,10 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon* Returns number of bytes that could not be copied. * On success, this will be zero. */ -#define copy_to_user (to,from,n) \ +#define copy_to_user (to, from, n) \ ({ \ might_fault(); \ - __generic_copy_to_user((to),(from),(n)); \ + __generic_copy_to_user((to), (from), (n)); \ })/**
@@ -617,8 +617,8 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon* If some data could not be copied, this function will pad the copied * data to the requested size using zero bytes. */ -#define __copy_from_user (to,from,n) \ - __generic_copy_from_user_nocheck((to),(from),(n)) +#define __copy_from_user (to, from, n) \ + __generic_copy_from_user_nocheck((to), (from), (n))/** * copy_from_user: - Copy a block of data from user space.
@@ -636,10 +636,10 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon* If some data could not be copied, this function will pad the copied * data to the requested size using zero bytes. */ -#define copy_from_user (to,from,n) \ +#define copy_from_user (to, from, n) \ ({ \ might_fault(); \ - __generic_copy_from_user((to),(from),(n)); \ + __generic_copy_from_user((to), (from), (n)); \ }) long __must_check strncpy_from_user(char *dst, const char __user *src,
Signature · 1 line
MST
PATCH v2 38/40 s390: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/s390/include/asm/uaccess.h, I noticed that a couple of macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/s390/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/include/asm/uaccess.h +2 -2
@@ -46,7 +46,7 @@__ctl_load (__pto,7 ,7 ); \ }) -#define segment_eq (a,b) ((a).ar4 == (b).ar4) +#define segment_eq (a, b) ((a).ar4 == (b).ar4)static inline int __range_ok (unsigned long addr,unsigned long size) {
@@ -147,7 +147,7 @@ unsigned long __must_check __copy_to_user(void __user *to, const void *from,"3: lhi %0,%5\n" \" jg 2b\n" \".popsection\n" \ - EX_TABLE(0b,3b) EX_TABLE(1b,3b) \ + EX_TABLE(0b, 3b) EX_TABLE(1b, 3b) \ : "=d" (__rc), "=Q" (*(to)) \: " d" (size), " Q " (*(from)), \ " d" (__reg0), " K " (-EFAULT) \
Signature · 1 line
MST
PATCH v2 39/40 sh: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/sh/include/asm/uaccess.h, I noticed that one macro within this header is made harder to read because it violates a coding style rule: space is missing after comma.
Fix it up.
--- arch/sh/include/asm/segment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/include/asm/segment.h +1 -1
@@ -23,7 +23,7 @@ typedef struct {#define USER_DS KERNEL_DS#endif -#define segment_eq (a,b) ((a).seg = (b).seg) +#define segment_eq (a, b) ((a).seg = (b).seg)#define get_ds () (KERNEL_DS)
Signature · 1 line
MST
PATCH v2 40/40 xtensa: macro whitespace fixes
In reply to Michael S. TsirkinWhile working on arch/xtensa/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.
Fix it up.
--- arch/xtensa/include/asm/uaccess.h | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-)
arch/xtensa/include/asm/uaccess.h +45 -45
@@ -182,13 +182,13 @@#define get_fs () (current->thread.current_ds)#define set_fs (val) (current->thread.current_ds = (val)) -#define segment_eq (a,b) ((a).seg == (b).seg) +#define segment_eq (a, b) ((a).seg == (b).seg)#define __kernel_ok (segment_eq(get_fs(), KERNEL_DS)) -#define __user_ok (addr,size) \ +#define __user_ok (addr, size) \ (((size) <= TASK_SIZE)&&((addr) <= TASK_SIZE-(size))) -#define __access_ok (addr,size) (__kernel_ok || __user_ok((addr),(size))) -#define access_ok (type,addr,size) __access_ok((unsigned long)(addr),(size)) +#define __access_ok (addr, size) (__kernel_ok || __user_ok((addr), (size))) +#define access_ok (type, addr, size) __access_ok((unsigned long)(addr), (size))/* * These are the main single-value transfer routines. They
@@ -204,8 +204,8 @@* (a) re-use the arguments for side effects (sizeof is ok) * (b) require any knowledge of processes at this stage */ -#define put_user (x,ptr) __put_user_check((x),(ptr),sizeof(*(ptr))) -#define get_user (x,ptr) __get_user_check((x),(ptr),sizeof(*(ptr))) +#define put_user (x, ptr) __put_user_check((x), (ptr), sizeof(*(ptr))) +#define get_user (x, ptr) __get_user_check((x), (ptr), sizeof(*(ptr)))/* * The "__xxx" versions of the user access functions are versions that
@@ -213,39 +213,39 @@* with a separate "access_ok()" call (this is used when we do multiple * accesses to the same area of user memory). */ -#define __put_user (x,ptr) __put_user_nocheck((x),(ptr),sizeof(*(ptr))) -#define __get_user (x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr))) +#define __put_user (x, ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr))) +#define __get_user (x, ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))extern long __put_user_bad (void ); -#define __put_user_nocheck (x,ptr,size) \ +#define __put_user_nocheck (x, ptr, size) \ ({ \ long __pu_err; \ - __put_user_size((x),(ptr),(size),__pu_err); \ + __put_user_size((x), (ptr), (size), __pu_err); \ __pu_err; \ }) -#define __put_user_check (x,ptr,size) \ -({ \ - long __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ - if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ - __put_user_size((x),__pu_addr,(size),__pu_err); \ - __pu_err; \ +#define __put_user_check (x, ptr, size) \ +({ \ + long __pu_err = -EFAULT; \ + __typeof__(*(ptr)) *__pu_addr = (ptr); \ + if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ + __put_user_size((x), __pu_addr, (size), __pu_err); \ + __pu_err; \ }) -#define __put_user_size (x,ptr,size,retval) \ +#define __put_user_size (x, ptr, size, retval) \ do { \ int __cb; \ retval = 0; \ switch (size) { \ - case 1: __put_user_asm(x,ptr,retval,1,"s8i",__cb); break; \ - case 2: __put_user_asm(x,ptr,retval,2,"s16i",__cb); break; \ - case 4: __put_user_asm(x,ptr,retval,4,"s32i",__cb); break; \ + case 1: __put_user_asm(x, ptr, retval, 1, "s8i", __cb); break; \ + case 2: __put_user_asm(x, ptr, retval, 2, "s16i", __cb); break; \ + case 4: __put_user_asm(x, ptr, retval, 4, "s32i", __cb); break; \ case 8: { \ __typeof__(*ptr) __v64 = x; \ - retval = __copy_to_user(ptr,&__v64,8); \ + retval = __copy_to_user(ptr, &__v64, 8); \ break; \ } \ default: __put_user_bad(); \
@@ -316,35 +316,35 @@ __asm__ __volatile__( \ :"=r" (err), "=r" (cb) \ :"r" ((int)(x)), "r" (addr), "i" (-EFAULT), "0" (err)) -#define __get_user_nocheck (x,ptr,size) \ +#define __get_user_nocheck (x, ptr, size) \ ({ \ long __gu_err, __gu_val; \ - __get_user_size(__gu_val,(ptr),(size),__gu_err); \ - (x) = (__force __typeof__(*(ptr)))__gu_val; \ + __get_user_size(__gu_val, (ptr), (size), __gu_err); \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ }) -#define __get_user_check (x,ptr,size) \ +#define __get_user_check (x, ptr, size) \ ({ \ long __gu_err = -EFAULT, __gu_val = 0; \ const __typeof__(*(ptr)) *__gu_addr = (ptr); \ - if (access_ok(VERIFY_READ,__gu_addr,size)) \ - __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \ - (x) = (__force __typeof__(*(ptr)))__gu_val; \ + if (access_ok(VERIFY_READ, __gu_addr, size)) \ + __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })extern long __get_user_bad (void ); -#define __get_user_size (x,ptr,size,retval) \ +#define __get_user_size (x, ptr, size, retval) \ do { \ int __cb; \ retval = 0; \ switch (size) { \ - case 1: __get_user_asm(x,ptr,retval,1,"l8ui",__cb); break; \ - case 2: __get_user_asm(x,ptr,retval,2,"l16ui",__cb); break; \ - case 4: __get_user_asm(x,ptr,retval,4,"l32i",__cb); break; \ - case 8: retval = __copy_from_user(&x,ptr,8); break; \ + case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb); break;\ + case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\ + case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb); break;\ + case 8: retval = __copy_from_user(&x, ptr, 8); break; \ default: (x) = __get_user_bad(); \ } \ } while (0)
@@ -390,19 +390,19 @@ __asm__ __volatile__( \*/ extern unsigned __xtensa_copy_user (void *to,const void *from,unsigned n); -#define __copy_user (to,from,size) __xtensa_copy_user(to,from,size) +#define __copy_user (to, from, size) __xtensa_copy_user(to, from, size)static inline unsigned long __generic_copy_from_user_nocheck (void *to,const void *from,unsigned long n) { -return __copy_user (to,from,n); +return __copy_user (to, from, n); }static inline unsigned long __generic_copy_to_user_nocheck (void *to,const void *from,unsigned long n) { -return __copy_user (to,from,n); +return __copy_user (to, from, n); } static inline unsigned long
@@ -410,7 +410,7 @@ __generic_copy_to_user(void *to, const void *from, unsigned long n) {prefetch (from);if (access_ok (VERIFY_WRITE , to, n)) -return __copy_user (to,from,n); +return __copy_user (to, from, n);return n; }
@@ -419,18 +419,18 @@ __generic_copy_from_user(void *to, const void *from, unsigned long n) {prefetchw (to);if (access_ok (VERIFY_READ , from, n)) -return __copy_user (to,from,n); +return __copy_user (to, from, n);else memset (to,0 , n);return n; } -#define copy_to_user (to,from,n) __generic_copy_to_user((to),(from),(n)) -#define copy_from_user (to,from,n) __generic_copy_from_user((to),(from),(n)) -#define __copy_to_user (to,from,n) \ - __generic_copy_to_user_nocheck((to),(from),(n)) -#define __copy_from_user (to,from,n) \ - __generic_copy_from_user_nocheck((to),(from),(n)) +#define copy_to_user (to, from, n) __generic_copy_to_user((to), (from), (n)) +#define copy_from_user (to, from, n) __generic_copy_from_user((to), (from), (n)) +#define __copy_to_user (to, from, n) \ + __generic_copy_to_user_nocheck((to), (from), (n)) +#define __copy_from_user (to, from, n) \ + __generic_copy_from_user_nocheck((to), (from), (n))#define __copy_to_user_inatomic __copy_to_user#define __copy_from_user_inatomic __copy_from_user
Signature · 1 line
MST
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
In reply to Michael S. TsirkinQuoted 4 lines · Michael S. Tsirkin
Macros within
arch/sparc/include/asm/uaccess_64.hare made harder to read because they violate a bunch of coding style rules.Fix it up.
As per Davem's earlier mail please prefix using sparc32/sparc64.
Quoted 22 lines
arch/sparc/include/asm/uaccess_64.h +11
-11-#define __put_user_nocheck (data,addr,size) ({ \ -register int __pu_ret; \ -switch (size) { \ -case 1: __put_user_asm(data,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(data,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(data,w,addr,__pu_ret); break; \ -case 8: __put_user_asm(data,x,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} __pu_ret; }) - -#define __put_user_asm (x,size,addr,ret) \ +#define __put_user_nocheck (data, addr, size) ({ \ + register int __pu_ret; \ + switch (size) { \ + case 1: \ + __put_user_asm(data, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(data, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(data, w, addr, __pu_ret); \
arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 129
Quoted 10 lines
arch/sparc/include/asm/uaccess_64.h +10
-0+break ; \ +case 8 : \ +__put_user_asm (data, x, addr, __pu_ret); \ +break ; \ +default : \ + __pu_ret =__put_user_bad (); \ +break ; \ + } \ + __pu_ret; \ +})
No matter what coding style says - the above is much less readable than the original version.
Quoted 57 lines
arch/sparc/include/asm/uaccess_64.h +35
-22-#define __get_user_nocheck (data,addr,size,type) ({ \ -register int __gu_ret; \ -register unsigned long __gu_val; \ -switch (size) { \ -case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \ -case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ -case 4: __get_user_asm(__gu_val,uw,addr,__gu_ret); break; \ -case 8: __get_user_asm(__gu_val,x,addr,__gu_ret); break; \ -default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \ -} data = (__force type) __gu_val; __gu_ret; }) - -#define __get_user_nocheck_ret (data,addr,size,type,retval) ({ \ -register unsigned long __gu_val __asm__ ("l1"); \ -switch (size) { \ -case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \ -case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ -case 4: __get_user_asm_ret(__gu_val,uw,addr,retval); break; \ -case 8: __get_user_asm_ret(__gu_val,x,addr,retval); break; \ -default: if (__get_user_bad()) return retval; \ -} data = (__force type) __gu_val; }) - -#define __get_user_asm (x,size,addr,ret) \ +#define __get_user_nocheck (data, addr, size, type) ({ \ + register int __gu_ret; \ + register unsigned long __gu_val; \ + switch (size) { \ + case 1: \ + __get_user_asm(__gu_val, ub, addr, __gu_ret); \ + break; \ + case 2: \ + __get_user_asm(__gu_val, uh, addr, __gu_ret); \ + break; \ + case 4: \ + __get_user_asm(__gu_val, uw, addr, __gu_ret); \ + break; \ + case 8: \ + __get_user_asm(__gu_val, x, addr, __gu_ret); \ + break; \ + default: \ + __gu_val = 0; \ + __gu_ret = __get_user_bad(); \ + break; \ + } data = (__force type) __gu_val; __gu_ret; \ +}) + +#define __get_user_nocheck_ret (data, addr, size, type, retval) ({ \ + register unsigned long __gu_val __asm__ ("l1"); \ + switch (size) { \ + case 1: \ + __get_user_asm_ret(__gu_val, ub, addr, retval); \ + break; \ + case 2: \ + __get_user_asm_ret(__gu_val, uh, addr, retval); \ + break; \ + case 4: \ + __get_user_asm_ret(__gu_val, uw, addr, retval); \ + break; \
arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 197
Quoted 10 lines
arch/sparc/include/asm/uaccess_64.h +10
-0+case 8 : \ +__get_user_asm_ret (__gu_val, x, addr, retval); \ +break ; \ +default : \ +if (__get_user_bad ()) \ +return retval; \ + } \ + data = (__force type) __gu_val; \ +}) +
Same comment for this code chunk.
Sam
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
Quoted 6 lines · Sam Ravnborg
Quoted 4 lines · Michael S. Tsirkin
Macros within
arch/sparc/include/asm/uaccess_64.hare made harder to read because they violate a bunch of coding style rules.Fix it up.
As per Davem's earlier mail please prefix using sparc32/sparc64.
I did put in uaccess_64 - insufficient?
Quoted 27 lines
Quoted 27 lines
arch/sparc/include/asm/uaccess_64.h +16
-11-#define __put_user_nocheck (data,addr,size) ({ \ -register int __pu_ret; \ -switch (size) { \ -case 1: __put_user_asm(data,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(data,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(data,w,addr,__pu_ret); break; \ -case 8: __put_user_asm(data,x,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} __pu_ret; }) - -#define __put_user_asm (x,size,addr,ret) \ +#define __put_user_nocheck (data, addr, size) ({ \ + register int __pu_ret; \ + switch (size) { \ + case 1: \ + __put_user_asm(data, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(data, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(data, w, addr, __pu_ret); \ + break; \ + case 8: \ + __put_user_asm(data, x, addr, __pu_ret); \ + break; \ + default: \
Quoted 10 lines
arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 129
Quoted 5 lines
arch/sparc/include/asm/uaccess_64.h +5
-0+ __pu_ret =__put_user_bad (); \ +break ; \ + } \ + __pu_ret; \ +})No matter what coding style says - the above is much less readable than the original version.
I guess you approve the rest of the changes then?
I get it you like it that
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break;
has the whole case on the same line?
Is that the issue?
Quoted 71 lines
Quoted 58 lines
arch/sparc/include/asm/uaccess_64.h +35
-22-#define __get_user_nocheck (data,addr,size,type) ({ \ -register int __gu_ret; \ -register unsigned long __gu_val; \ -switch (size) { \ -case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break; \ -case 2: __get_user_asm(__gu_val,uh,addr,__gu_ret); break; \ -case 4: __get_user_asm(__gu_val,uw,addr,__gu_ret); break; \ -case 8: __get_user_asm(__gu_val,x,addr,__gu_ret); break; \ -default: __gu_val = 0; __gu_ret = __get_user_bad(); break; \ -} data = (__force type) __gu_val; __gu_ret; }) - -#define __get_user_nocheck_ret (data,addr,size,type,retval) ({ \ -register unsigned long __gu_val __asm__ ("l1"); \ -switch (size) { \ -case 1: __get_user_asm_ret(__gu_val,ub,addr,retval); break; \ -case 2: __get_user_asm_ret(__gu_val,uh,addr,retval); break; \ -case 4: __get_user_asm_ret(__gu_val,uw,addr,retval); break; \ -case 8: __get_user_asm_ret(__gu_val,x,addr,retval); break; \ -default: if (__get_user_bad()) return retval; \ -} data = (__force type) __gu_val; }) - -#define __get_user_asm (x,size,addr,ret) \ +#define __get_user_nocheck (data, addr, size, type) ({ \ + register int __gu_ret; \ + register unsigned long __gu_val; \ + switch (size) { \ + case 1: \ + __get_user_asm(__gu_val, ub, addr, __gu_ret); \ + break; \ + case 2: \ + __get_user_asm(__gu_val, uh, addr, __gu_ret); \ + break; \ + case 4: \ + __get_user_asm(__gu_val, uw, addr, __gu_ret); \ + break; \ + case 8: \ + __get_user_asm(__gu_val, x, addr, __gu_ret); \ + break; \ + default: \ + __gu_val = 0; \ + __gu_ret = __get_user_bad(); \ + break; \ + } data = (__force type) __gu_val; __gu_ret; \ +}) + +#define __get_user_nocheck_ret (data, addr, size, type, retval) ({ \ + register unsigned long __gu_val __asm__ ("l1"); \ + switch (size) { \ + case 1: \ + __get_user_asm_ret(__gu_val, ub, addr, retval); \ + break; \ + case 2: \ + __get_user_asm_ret(__gu_val, uh, addr, retval); \ + break; \ + case 4: \ + __get_user_asm_ret(__gu_val, uw, addr, retval); \ + break; \arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 197
Quoted 10 lines
arch/sparc/include/asm/uaccess_64.h +10
-0+case 8 : \ +__get_user_asm_ret (__gu_val, x, addr, retval); \ +break ; \ +default : \ +if (__get_user_bad ()) \ +return retval; \ + } \ + data = (__force type) __gu_val; \ +}) +Same comment for this code chunk.
Quoted 1 line
Sam
Well I donnu. When I had to fix bugs there, it was pretty confusing to me, conding style is no a holy book but it's there for a reason.
Lack of spaces after comma makes it so much harder to count parameters.
Also:
Quoted 2 lines
arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 158
Quoted 2 lines
arch/sparc/include/asm/uaccess_64.h +0
-2-default :if (__get_user_bad ())return retval; \ -} data = (__force type) __gu_val; })
return on same line with if and code after the closing {} makes it look confusingly like the more conventional:
if (__get_user_bad())
data = (__force type) __gu_val;
Signature · 1 line
MST
Re: [PATCH v2 14/40] sparc32/uaccess: fix sparse errors
In reply to Michael S. TsirkinFrom: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 6 Jan 2015 17:44:17 +0200
Quoted 7 lines
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>
Re: [PATCH v2 15/40] sparc64/uaccess: fix sparse errors
In reply to Michael S. TsirkinFrom: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 6 Jan 2015 17:44:20 +0200
Quoted 7 lines
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>
Re: [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes
In reply to Michael S. TsirkinFrom: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 6 Jan 2015 17:44:53 +0200
Quoted 6 lines
Macros within
arch/sparc/include/asm/uaccess_32.hare made harder to read because they violate a bunch of coding style rules.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
In reply to Michael S. TsirkinFrom: "Michael S. Tsirkin" <[email protected]>
Date: Tue, 6 Jan 2015 17:44:56 +0200
Quoted 6 lines
Macros within
arch/sparc/include/asm/uaccess_64.hare made harder to read because they violate a bunch of coding style rules.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
In reply to Michael S. TsirkinQuoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · Sam Ravnborg
Quoted 4 lines · Michael S. Tsirkin
Macros within
arch/sparc/include/asm/uaccess_64.hare made harder to read because they violate a bunch of coding style rules.Fix it up.
As per Davem's earlier mail please prefix using sparc32/sparc64.
I did put in
uaccess_64- insufficient?
sparc32: bla bla
For sparc32 specific changes.
sparc64: bla bla
For sparc64 specific changes
sparc: bla bla
For general sparce changes
In this case you could have used:
sparc64: fix coding style in uaccess_64.h
Quoted 38 lines
Quoted 28 lines
Quoted 28 lines
arch/sparc/include/asm/uaccess_64.h +16
-11-#define __put_user_nocheck (data,addr,size) ({ \ -register int __pu_ret; \ -switch (size) { \ -case 1: __put_user_asm(data,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(data,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(data,w,addr,__pu_ret); break; \ -case 8: __put_user_asm(data,x,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} __pu_ret; }) - -#define __put_user_asm (x,size,addr,ret) \ +#define __put_user_nocheck (data, addr, size) ({ \ + register int __pu_ret; \ + switch (size) { \ + case 1: \ + __put_user_asm(data, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(data, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(data, w, addr, __pu_ret); \ + break; \ + case 8: \ + __put_user_asm(data, x, addr, __pu_ret); \ + break; \ + default: \Quoted 10 lines
arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 129
Quoted 5 lines
arch/sparc/include/asm/uaccess_64.h +5
-0+ __pu_ret =__put_user_bad (); \ +break ; \ + } \ + __pu_ret; \ +})No matter what coding style says - the above is much less readable than the original version.
Quoted 1 line
I guess you approve the rest of the changes then?
I did not look to carefully - but what I saw looked good.
Quoted 6 lines
I get it you like it that
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break;has the whole case on the same line?
Is that the issue?
Exactly - much easier to read this way.
That the "\" was not aligned in these parts of the code did not help either.
Sam
Arnd Bergmann
maintainerQuoted 8 lines · On Tuesday 06 January 2015 17:43:28 Michael S. Tsirkin wrote:
I tested this on x86 only. Since it's just adding
__force, should be trivially safe everywhere?Arnd, did you merge v1 already? If yes, can you please replace with this version?
I haven't merged it yet. I see that more Acks and some comments are coming in. Once those are done, could you send a pull request? It might be useful to have a branch that can be shared with architecture trees if necessary to avoid merge conflicts.
Arnd
Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
In reply to Michael S. TsirkinHi Michael,
Quoted 10 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>Acked-by Will Deacon <[email protected]>---
Did you want us to take this via the arm64 tree, or are you planning to merge it via another route?
Will
Quoted 20 lines
arch/arm64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/include/asm/uaccess.h +1
-1@@ -147,7 +147,7 @@ do { \default : \BUILD_BUG (); \ } \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ }while (0 ) #define __get_user(x, ptr) \Signature · 1 line
MST
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
In reply to Sam RavnborgQuoted 16 lines · Sam Ravnborg
Quoted 9 lines · Michael S. Tsirkin
Quoted 6 lines · Sam Ravnborg
Quoted 4 lines · Michael S. Tsirkin
Macros within
arch/sparc/include/asm/uaccess_64.hare made harder to read because they violate a bunch of coding style rules.Fix it up.
As per Davem's earlier mail please prefix using sparc32/sparc64.
I did put in
uaccess_64- insufficient?sparc32: bla bla
For sparc32 specific changes.sparc64: bla bla
For sparc64 specific changes
Quoted 6 lines
sparc: bla bla
For general sparce changesIn this case you could have used:
sparc64: fix coding style inuaccess_64.h
OK.
I see David reviewed and sent acks, so I won't bother reposting, but I'll tweak this in my tree.
Quoted 43 lines
Quoted 38 lines
Quoted 28 lines
Quoted 28 lines
arch/sparc/include/asm/uaccess_64.h +16
-11-#define __put_user_nocheck (data,addr,size) ({ \ -register int __pu_ret; \ -switch (size) { \ -case 1: __put_user_asm(data,b,addr,__pu_ret); break; \ -case 2: __put_user_asm(data,h,addr,__pu_ret); break; \ -case 4: __put_user_asm(data,w,addr,__pu_ret); break; \ -case 8: __put_user_asm(data,x,addr,__pu_ret); break; \ -default: __pu_ret = __put_user_bad(); break; \ -} __pu_ret; }) - -#define __put_user_asm (x,size,addr,ret) \ +#define __put_user_nocheck (data, addr, size) ({ \ + register int __pu_ret; \ + switch (size) { \ + case 1: \ + __put_user_asm(data, b, addr, __pu_ret); \ + break; \ + case 2: \ + __put_user_asm(data, h, addr, __pu_ret); \ + break; \ + case 4: \ + __put_user_asm(data, w, addr, __pu_ret); \ + break; \ + case 8: \ + __put_user_asm(data, x, addr, __pu_ret); \ + break; \ + default: \Quoted 10 lines
arch/sparc/include/asm/uaccess_64.h void __retl_efault(void); · line 129
Quoted 5 lines
arch/sparc/include/asm/uaccess_64.h +5
-0+ __pu_ret =__put_user_bad (); \ +break ; \ + } \ + __pu_ret; \ +})No matter what coding style says - the above is much less readable than the original version.
Quoted 1 line
I guess you approve the rest of the changes then?
I did not look to carefully - but what I saw looked good.
Quoted 2 lines
Quoted 8 lines
Quoted 4 lines
I get it you like it that
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break;has the whole case on the same line?
Is that the issue?Exactly - much easier to read this way.
That the "\" was not aligned in these parts of the code did not help either.Sam
I see David acked this already - I'll do a patch on top to tweak just these two places to your liking?
No sense making everyone re-read the whole pile of changes.
Signature · 1 line
MST
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
Quoted 5 lines
Quoted 1 line
sparc64: fix coding style in
uaccess_64.hOK.
I see David reviewed and sent acks, so I won't bother reposting, but I'll tweak this in my tree.
OK.
Quoted 11 lines
Quoted 8 lines
Quoted 4 lines
I get it you like it that
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break;has the whole case on the same line?
Is that the issue?Exactly - much easier to read this way.
That the "\" was not aligned in these parts of the code did not help either.Sam
I see David acked this already - I'll do a patch on top to tweak just these two places to your liking?
Thanks.
When you have done so please wait for David's ack before you sent then upstream. That I like it does not make it universally accepted.
Sam
Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
Quoted 14 lines · Sam Ravnborg
Quoted 5 lines
Quoted 1 line
sparc64: fix coding style in
uaccess_64.hOK.
I see David reviewed and sent acks, so I won't bother reposting, but I'll tweak this in my tree.OK.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
I get it you like it that
case 1: __get_user_asm(__gu_val,ub,addr,__gu_ret); break;has the whole case on the same line?
Is that the issue?Exactly - much easier to read this way.
That the "\" was not aligned in these parts of the code did not help either.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Sam
I see David acked this already - I'll do a patch on top to tweak just these two places to your liking?
Thanks.
OK, sent.
Mind sending acks for these and the original patches?
You can add that your ack is conditional on applying the tweak on top.
Quoted 4 lines
When you have done so please wait for David's ack before you sent then upstream. That I like it does not make it universally accepted.
Sam
Sure.
Thanks.
Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
In reply to Will DeaconQuoted 11 lines · Will Deacon
Hi Michael,
Quoted 8 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 7 lines
Quoted 2 lines
Acked-by Will Deacon <[email protected]>---
Did you want us to take this via the arm64 tree, or are you planning to merge it via another route?
Will
Up to you really: if you don't pick it up, Arnd said he'll merge through his tree.
Quoted 20 lines
Quoted 20 lines
arch/arm64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/include/asm/uaccess.h +1
-1@@ -147,7 +147,7 @@ do { \default : \BUILD_BUG (); \ } \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ }while (0 ) #define __get_user(x, ptr) \Signature · 1 line
MST
Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Will Deacon
Hi Michael,
Quoted 10 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>Acked-by Will Deacon <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Did you want us to take this via the arm64 tree, or are you planning to merge it via another route?
Will
Up to you really: if you don't pick it up, Arnd said he'll merge through his tree.
Though if you do pick it up, need to also pick up the follow-up patch - maybe my tree is easier.
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
arch/arm64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/include/asm/uaccess.h +1
-1@@ -147,7 +147,7 @@ do { \default : \BUILD_BUG (); \ } \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ }while (0 ) #define __get_user(x, ptr) \Signature · 1 line
MST
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · On Tuesday 06 January 2015 17:43:28 Michael S. Tsirkin wrote:
I tested this on x86 only. Since it's just adding
__force, should be trivially safe everywhere?
Quoted 6 lines
Quoted 3 lines
Arnd, did you merge v1 already? If yes, can you please replace with this version?
I haven't merged it yet. I see that more Acks and some comments are coming in. Once those are done, could you send a pull request?
Sure. So I'll wait some then send you a pull request and you'll merge?
Quoted 5 lines
It
might be useful to have a branch that can be shared with architecture trees if necessary to avoid merge conflicts.Arnd
In a couple of days, I'll put it on my linux-next branch and wait for a bit. That will tell us whether there are any merge conflicts.
Signature · 1 line
MSR
Re: [PATCH v2 40/40] xtensa: macro whitespace fixes
In reply to Michael S. TsirkinQuoted 10 lines · Michael S. Tsirkin
While working on
arch/xtensa/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/xtensa/include/asm/uaccess.h | 90 +++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 45 deletions(-)
Signature · 2 lines
Thanks. -- Max
Re: [PATCH v2 24/40] avr32: whitespace fix
In reply to Michael S. TsirkinQuoted 2 lines · Michael S. Tsirkin
Align using tabs to make code prettier.
It is already aligned using tabs, but there is one too much. Thanks for cleaning.
Quoted 2 lines
Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 17 lines
--- arch/avr32/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/avr32/include/asm/uaccess.h +1
-1@@ -278,7 +278,7 @@ extern int __put_user_bad(void); __pu_err); \break ; \case 8 : \ -__put_user_asm ("d" , __pu_addr, __pu_val, \ +__put_user_asm ("d" , __pu_addr, __pu_val, \ __pu_err); \break ; \default : \
Signature · 2 lines
mvh Hans-Christian Egtvedt
Re: [PATCH v2 32/40] avr32: macro whitespace fixes
In reply to Michael S. TsirkinQuoted 5 lines · Michael S. Tsirkin
While working on
arch/avr32/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.Fix it up.
Thank you (-:
Quoted 2 lines
Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 3 lines
--- arch/avr32/include/asm/uaccess.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
<snipp diff>
Signature · 2 lines
mvh Hans-Christian Egtvedt
Re: [PATCH v2 38/40] s390: macro whitespace fixes
In reply to Michael S. TsirkinQuoted 25 lines · Michael S. Tsirkin
While working on
arch/s390/include/asm/uaccess.h, I noticed that a couple of macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/s390/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/s390/include/asm/uaccess.h +1
-1@@ -46,7 +46,7 @@__ctl_load (__pto,7 ,7 ); \ }) -#define segment_eq (a,b) ((a).ar4 == (b).ar4) +#define segment_eq (a, b) ((a).ar4 == (b).ar4)static inline int __range_ok (unsigned long addr,unsigned long size) {
arch/s390/include/asm/uaccess.h unsigned long __must_check __copy_to_user(void __user *to, const void *from, · line 150
Quoted 5 lines
arch/s390/include/asm/uaccess.h +1
-1@@ -147,7 +147,7 @@ unsigned long __must_check __copy_to_user(void __user *to, const void *from,"3: lhi %0,%5\n" \" jg 2b\n" \".popsection\n" \ - EX_TABLE(0b,3b) EX_TABLE(1b,3b) \ + EX_TABLE(0b, 3b) EX_TABLE(1b, 3b) \
Most EX_TABLE() usages within s390 are without space after comma. No need to change that. Also I don't like the change of the seqment_eq() macro.
I won't apply trivial whitespace patches, since this would make 'git blame' useless and in addition invite more people to send whitespace patches.
Thanks,
Heiko
Re: [PATCH v2 38/40] s390: macro whitespace fixes
Quoted 38 lines · Heiko Carstens
Quoted 25 lines · Michael S. Tsirkin
While working on
arch/s390/include/asm/uaccess.h, I noticed that a couple of macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/s390/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/s390/include/asm/uaccess.h +1
-1@@ -46,7 +46,7 @@__ctl_load (__pto,7 ,7 ); \ }) -#define segment_eq (a,b) ((a).ar4 == (b).ar4) +#define segment_eq (a, b) ((a).ar4 == (b).ar4)static inline int __range_ok (unsigned long addr,unsigned long size) {arch/s390/include/asm/uaccess.h unsigned long __must_check __copy_to_user(void __user *to, const void *from, · line 150
Quoted 5 lines
arch/s390/include/asm/uaccess.h +1
-1@@ -147,7 +147,7 @@ unsigned long __must_check __copy_to_user(void __user *to, const void *from,"3: lhi %0,%5\n" \" jg 2b\n" \".popsection\n" \ - EX_TABLE(0b,3b) EX_TABLE(1b,3b) \ + EX_TABLE(0b, 3b) EX_TABLE(1b, 3b) \Most
EX_TABLE()usages within s390 are without space after comma. No need to change that. Also I don't like the change of theseqment_eq()macro.
I won't apply trivial whitespace patches, since this would make 'git blame' useless and in addition invite more people to send whitespace patches.
Quoted 2 lines
Thanks,
Heiko
There's always git blame -w. Anyway, I'll drop s390 patches. Fix it up yourself if you wish.
Signature · 1 line
MST
Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
In reply to Michael S. TsirkinHi Machael,
Quoted 16 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/metag/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/metag/include/asm/uaccess.h +0
-0
arch/metag/include/asm/uaccess.h extern long __get_user_bad(void); · line 138
Quoted 5 lines
arch/metag/include/asm/uaccess.h +1
-1@@ -135,7 +135,7 @@ extern long __get_user_bad(void); ({ \ long __gu_err, __gu_val; \ __get_user_size(__gu_val, (ptr), (size), __gu_err); \ - (x) = (__typeof__(*(ptr)))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \
As I mentioned before, can you please adjust the position of the \ to line up.
arch/metag/include/asm/uaccess.h extern long __get_user_bad(void); · line 148
Quoted 9 lines
arch/metag/include/asm/uaccess.h +1
-1__gu_err; \ })@@ -145,7 +145,7 @@ extern long __get_user_bad(void); const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \if (access_ok (VERIFY_READ , __gu_addr, size)) \__get_user_size (__gu_val, __gu_addr, (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \
same here (this one causes checkpatch error due to 80 column limit).
arch/metag/include/asm/uaccess.h extern long __get_user_bad(void); · line 141
Quoted 4 lines
arch/metag/include/asm/uaccess.h +0
-0__gu_err; \ })
With those changes,
Cheers
James
Re: [PATCH v2 20/40] metag: fix put_user sparse errors
In reply to Michael S. TsirkinQuoted 33 lines · Michael S. Tsirkin
virtio wants to write bitwise types to userspace using
put_user. At the moment this triggers sparse errors, since the value is passed through an integer.For example:
__le32 __user *p; __le32 x; put_user(x, p);is safe, but currently triggers a sparse warning.
Fix that up using
__force.This also fixes warnings due to writing a pointer out to userland.
Note: this does not suppress any useful sparse checks since callers do a cast (__typeof__(*(ptr))) (x) which in turn forces all the necessary type checks.
Suggested-by James Hogan <[email protected]>Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/metag/include/asm/uaccess.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)arch/metag/include/asm/uaccess.h +0
-0@@ -107,18 +107,23 @@ extern long __put_user_asm_w(unsigned int x, void __user *addr);extern long __put_user_asm_d (unsigned int x,void __user *addr);
arch/metag/include/asm/uaccess.h extern long __put_user_asm_w(unsigned int x, void __user *addr); · line 113
Quoted 10 lines
arch/metag/include/asm/uaccess.h +4
-4extern long __put_user_asm_l (unsigned long long x,void __user *addr); -#define __put_user_size (x, ptr, size, retval) \ -do { \ - retval = 0; \ - switch (size) { \ +#define __put_user_size (x, ptr, size, retval) \ +do { \ + retval = 0; \ + switch (size) { \
On the last 3 lines here you've added a tab after spaces which checkpatch complains about. With that fixed (or converted to tabs properly):
Cheers
James
Quoted 21 lines
arch/metag/include/asm/uaccess.h +9
-4case 1 : \ - retval =__put_user_asm_b ((unsigned int )x, ptr);break ; \ + retval = __put_user_asm_b((__force unsigned int)x, ptr);\ +break ; \case 2 : \ - retval =__put_user_asm_w ((unsigned int )x, ptr);break ; \ + retval = __put_user_asm_w((__force unsigned int)x, ptr);\ +break ; \case 4 : \ - retval =__put_user_asm_d ((unsigned int )x, ptr);break ; \ + retval = __put_user_asm_d((__force unsigned int)x, ptr);\ +break ; \case 8 : \ - retval =__put_user_asm_l ((unsigned long long )x, ptr);break ; \ + retval =__put_user_asm_l ((__force unsigned long long )x,\ + ptr); \ +break ; \default : \__put_user_bad (); \ } \
Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
In reply to James HoganQuoted 30 lines · James Hogan
Hi Machael,
Quoted 16 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/metag/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/metag/include/asm/uaccess.h +0
-0arch/metag/include/asm/uaccess.h extern long __get_user_bad(void); · line 138
Quoted 5 lines
arch/metag/include/asm/uaccess.h +1
-1@@ -135,7 +135,7 @@ extern long __get_user_bad(void); ({ \ long __gu_err, __gu_val; \ __get_user_size(__gu_val, (ptr), (size), __gu_err); \ - (x) = (__typeof__(*(ptr)))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \As I mentioned before, can you please adjust the position of the \ to line up.
Quoted 3 lines
arch/metag/include/asm/uaccess.h +0
-0__gu_err; \ })
Quoted 8 lines
arch/metag/include/asm/uaccess.h extern long __get_user_bad(void); · line 148
Quoted 6 lines
arch/metag/include/asm/uaccess.h +1
-1@@ -145,7 +145,7 @@ extern long __get_user_bad(void); const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \if (access_ok (VERIFY_READ , __gu_addr, size)) \__get_user_size (__gu_val, __gu_addr, (size), __gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \same here (this one causes checkpatch error due to 80 column limit).
Oops. Sorry. Will fix both. I won't repost unless there are more issues.
Quoted 6 lines
arch/metag/include/asm/uaccess.h extern long __get_user_bad(void); · line 141
Quoted 5 lines
arch/metag/include/asm/uaccess.h +0
-0__gu_err; \ })
Quoted 6 lines
With those changes,
Acked-by James Hogan <[email protected]>Cheers
James
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 36/40] m68k: macro whitespace fixes
In reply to Michael S. TsirkinQuoted 7 lines · Michael S. Tsirkin
While working on
arch/m68k/include/asm/uaccess.h, I noticed that one macro within this header is made harder to read because it violates a coding style rule: space is missing after comma.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
In reply to Michael S. TsirkinQuoted 19 lines · Michael S. Tsirkin
Quoted 18 lines · Michael S. Tsirkin
Quoted 17 lines · Will Deacon
Hi Michael,
Quoted 10 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>Acked-by Will Deacon <[email protected]>---
Did you want us to take this via the arm64 tree, or are you planning to merge it via another route?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Will
Up to you really: if you don't pick it up, Arnd said he'll merge through his tree.
Though if you do pick it up, need to also pick up the follow-up patch - maybe my tree is easier.
Ok, I'll go ack that whitespace fix for you to take then.
Will
Re: [PATCH v2 31/40] arm64: macro whitespace fixes
In reply to Michael S. TsirkinQuoted 8 lines · Michael S. Tsirkin
While working on
arch/arm64/include/asm/uaccess.h, I noticed that one macro within this header is made harder to read because it violates a coding style rule: space is missing after comma.Fix it up.
Signed-off-by Michael S. Tsirkin <[email protected]>---
Will
Quoted 20 lines
arch/arm64/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/include/asm/uaccess.h +1
-1@@ -63,7 +63,7 @@ static inline void set_fs(mm_segment_t fs)current_thread_info ()->addr_limit = fs; } -#define segment_eq (a,b) ((a) == (b)) +#define segment_eq (a, b) ((a) == (b))/* * Return 1 if addr < current->addr_limit, 0 otherwise. Signature · 1 line
MST
Re: [PATCH v2 10/40] microblaze/uaccess: fix sparse errors
In reply to Michael S. TsirkinQuoted 26 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/microblaze/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/microblaze/include/asm/uaccess.h +1
-1@@ -220,7 +220,7 @@ extern long __user_bad(void); }else { \ __gu_err = -EFAULT ; \ } \ - x = (typeof (*(ptr )))__gu_val; \ + x = (__force typeof(*(ptr)))__gu_val; \ __gu_err; \ })
arch/microblaze/include/asm/uaccess.h extern long __user_bad(void); · line 248
Quoted 8 lines
arch/microblaze/include/asm/uaccess.h +1
-1@@ -242,7 +242,7 @@ extern long __user_bad(void);default : \/* __gu_val = 0; __gu_err = -EINVAL;*/ __gu_err =__user_bad ();\ } \ - x = (__typeof__ (*(ptr ))) __gu_val; \ + x = (__force __typeof__(*(ptr))) __gu_val; \ __gu_err; \ })
Applied.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
Re: [PATCH v2 28/40] microblaze: whitespace fix
In reply to Michael S. TsirkinQuoted 13 lines · Michael S. Tsirkin
Align using tabs to make code prettier.
Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/microblaze/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/microblaze/include/asm/uaccess.h +0
-0
arch/microblaze/include/asm/uaccess.h extern long __user_bad(void); · line 312
Quoted 8 lines
arch/microblaze/include/asm/uaccess.h +1
-1@@ -306,7 +306,7 @@ extern long __user_bad(void);#define __put_user_check (x, ptr, size) \ ({ \ - typeof(*(ptr)) volatile __pu_val = x; \ + typeof(*(ptr)) volatile __pu_val = x; \ typeof(*(ptr)) __user *__pu_addr = (ptr); \ int __pu_err = 0; \ \
Applied.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
Re: [PATCH v2 16/40] m68k/uaccess: fix sparse errors
In reply to Michael S. TsirkinQuoted 7 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 06 January 2015 17:43:28 Michael S. Tsirkin wrote:
I tested this on x86 only. Since it's just adding
__force, should be trivially safe everywhere?Arnd, did you merge v1 already? If yes, can you please replace with this version?
Quoted 6 lines
I haven't merged it yet. I see that more Acks and some comments are coming in. Once those are done, could you send a pull request? It might be useful to have a branch that can be shared with architecture trees if necessary to avoid merge conflicts.
Arnd
OK, I got a bunch of acks, mostly it seems to have calmed down. Heiko Carstens (s390 maintainer) says he won't apply whitespace changes:
http://mid.gmane.org/20150107083339.GB4365@osiris
so I dropped s390 patches.
The rest is tagged:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/uaccess_for_upstream
and pushed out to linux-next.
I'll give it a couple of days there, then send a pull request - Arnd, you meant I should send it to you, right?
Signature · 1 line
MST
Re: [PATCH v2 22/40] tile: fix put_user sparse errors
In reply to Michael S. TsirkinNack for this patch as-is.
Quoted 10 lines · Michael S. Tsirkin
virtio wants to write bitwise types to userspace using
put_user. At the moment this triggers sparse errors, since the value is passed through an integer.For example:
__le32 __user *p; __le32 x; put_user(x, p);
Quoted 5 lines
is safe, but currently triggers a sparse warning on tile.
The reason has to do with this code:
__typeof((x)-(x))which seems to be a way to force check for an integer type.
No, it's purely a way to avoid
warning: cast from pointer to integer of different size
at every place we invoke put_user() with a pointer - which is in fact pretty frequent throughout the kernel. The idiom of casting to the difference of the type converts it to a type of the same size as the input (whether integral or pointer), but guaranteed to be an integral type. Then from there it's safe to cast it on to a u64 without generating a warning.
I agree that letting sparse work correctly in this case seems like an important goal. But I don't think we can tolerate adding a raft of warnings to the standard kernel build for this case, and we also can't just delete the put_user_8 case altogether, since it's used for various things even in 32-bit kernels.
I suppose we could do something like the following. It's mildly unfortunate that we'd lose out on some inlining optimization, though:
arch/tile/include/asm/uaccess.h +2 -18
@@ -244,24 +244,8 @@ extern int __get_user_bad(void)#define __put_user_1 (x, ptr, ret) __put_user_asm(sb, x, ptr, ret)#define __put_user_2 (x, ptr, ret) __put_user_asm(sh, x, ptr, ret)#define __put_user_4 (x, ptr, ret) __put_user_asm(sw, x, ptr, ret) -#define __put_user_8 (x, ptr, ret) \ - ({ \ - u64 __x = (__typeof((x)-(x)))(x); \ - int __lo = (int) __x, __hi = (int) (__x >> 32); \ - asm volatile("1: { sw %1, %2; addi %0, %1, 4 }\n" \ - "2: { sw %0, %3; movei %0, 0 }\n" \ - ".pushsection .fixup,\"ax\"\n" \ - "0: { movei %0, %4; j 9f }\n" \ - ".section __ex_table,\"a\"\n" \ - ".align 4\n" \ - ".word 1b, 0b\n" \ - ".word 2b, 0b\n" \ - ".popsection\n" \ - "9:" \ - : "=&r" (ret) \ - : "r" (ptr), "r" (__lo32(__lo, __hi)), \ - "r" (__hi32(__lo, __hi)), "i" (-EFAULT)); \ - }) +#define __put_user_8 (x, ptr, ret) \ + (ret = __copy_to_user_inatomic(ptr, &x, 8) == 0 ? 0 : -EFAULT)#endif extern int __put_user_bad (void )
Quoted 3 lines
Since this is part of
__put_user_8which is only ever used for unsigned and signed char types, this seems unnecessary - I also note that no other architecture has such protections.
Maybe because none of the other 32-bit kernel architectures provide a 64-bit inline for put_user().
Signature · 2 lines
Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
In reply to Michael S. TsirkinQuoted 24 lines · Michael S. Tsirkin
Tile currently does not trigger sparse warnings when
get_usercauses an illegal assignment across bitwise types.For example:
__le32__user*p;__u32x;put_user(x, p);violates endian-ness rules, but currently does not trigger sparse warning on tile.
Fix this by adding some dead code.
Signed-off-by Michael S. Tsirkin<[email protected]>--- arch/tile/include/asm/uaccess.h | 4 ++++ 1 file changed, 4 insertions(+)arch/tile/include/asm/uaccess.h +0
-0
arch/tile/include/asm/uaccess.h extern int __get_user_bad(void) · line 224
Quoted 7 lines
arch/tile/include/asm/uaccess.h +2
-0@@ -218,6 +218,8 @@ extern int __get_user_bad(void)case 8 :__get_user_8 (x, ptr, __ret);break ; \default : __ret =__get_user_bad ();break ; \ } \ +if (0 ) \ + x = *(__force typeof(*ptr) *)(ptr); \ __ret; \ })
The "if (0)" suggestion is cute, but pretty hacky :-)
Here's a revised change that may fix both of your sparse concerns with tile, without having to give up the optimized 64-bit get/put on tilepro. Would this fix both the issue discussed in this change, as well as the issue in the previous change (where you removed the typeof(x-x) cast)?
The key changes are to copy the x86 definition of __inttype(), and then to arrange to use an intermediate integral type that gets assigned to or from the actual typed value so as to expose any sparse issues.
If this works for you, I'm happy to queue it in the tile tree, or I can provide a proper git commit for you to include in your series, whichever works better for you.
arch/tile/include/asm/uaccess.h +20 -17
@@ -114,14 +114,14 @@ struct exception_table_entry {extern int fixup_exception (struct pt_regs *regs);/* +* This is a type: either unsigned long, if the argument fits into +* that type, or otherwise unsigned long long. +*/ +#define __inttype (x) \ + __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) + +/* * Support macros for __get_user(). -* -* Implementation note: The "case 8" logic of casting to the type of -* the result of subtracting the value from itself is basically a way -* of keeping all integer types the same, but casting any pointers to -* ptrdiff_t, i.e. also an integer type. This way there are no -* questionable casts seen by the compiler on an ILP32 platform. -* * Note that __get_user() and __put_user() assume proper alignment. */
@@ -178,7 +178,7 @@ extern int fixup_exception(struct pt_regs *regs); "9:" \ : "=r" (ret), "=r" (__a), "=&r" (__b) \ : "r" (ptr), "i" (-EFAULT)); \ - (x) = (__typeof (x))(__typeof ((x)-(x))) \ + (x) = (__typeof (x))(__inttype (x)) \ (((u64 )__hi32 (__a, __b) <<32 ) | \__lo32 (__a, __b)); \ })
@@ -210,14 +210,16 @@ extern int __get_user_bad(void)#define __get_user (x, ptr) \ ({ \ int __ret; \ + __inttype(*(ptr)) __x; \ __chk_user_ptr(ptr); \ switch (sizeof(*(ptr))) { \ - case 1: __get_user_1(x, ptr, __ret); break; \ - case 2: __get_user_2(x, ptr, __ret); break; \ - case 4: __get_user_4(x, ptr, __ret); break; \ - case 8: __get_user_8(x, ptr, __ret); break; \ + case 1: __get_user_1(__x, ptr, __ret); break; \ + case 2: __get_user_2(__x, ptr, __ret); break; \ + case 4: __get_user_4(__x, ptr, __ret); break; \ + case 8: __get_user_8(__x, ptr, __ret); break; \ default: __ret = __get_user_bad(); break; \ } \ + (x) = (typeof(x))__x; \ __ret; \ })
@@ -246,7 +248,7 @@ extern int __get_user_bad(void)#define __put_user_4 (x, ptr, ret) __put_user_asm(sw, x, ptr, ret)#define __put_user_8 (x, ptr, ret) \ ({ \ - u64 __x = (__typeof((x)-(x)))(x); \ + u64 __x = (__inttype(x))(x); \ int __lo = (int) __x, __hi = (int) (__x >> 32); \ asm volatile("1: { sw %1, %2; addi %0, %1, 4 }\n" \ "2: { sw %0, %3; movei %0, 0 }\n" \
@@ -289,12 +291,13 @@ extern int __put_user_bad(void)#define __put_user (x, ptr) \ ({ \ int __ret; \ + typeof(*(ptr)) __x = (x); \ __chk_user_ptr(ptr); \ switch (sizeof(*(ptr))) { \ - case 1: __put_user_1(x, ptr, __ret); break; \ - case 2: __put_user_2(x, ptr, __ret); break; \ - case 4: __put_user_4(x, ptr, __ret); break; \ - case 8: __put_user_8(x, ptr, __ret); break; \ + case 1: __put_user_1(__x, ptr, __ret); break; \ + case 2: __put_user_2(__x, ptr, __ret); break; \ + case 4: __put_user_4(__x, ptr, __ret); break; \ + case 8: __put_user_8(__x, ptr, __ret); break; \ default: __ret = __put_user_bad(); break; \ } \ __ret; \
Signature · 2 lines
Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Re: [PATCH v2 22/40] tile: fix put_user sparse errors
In reply to Chris MetcalfQuoted 23 lines · Chris Metcalf
Nack for this patch as-is.
Quoted 10 lines · Michael S. Tsirkin
virtio wants to write bitwise types to userspace using
put_user. At the moment this triggers sparse errors, since the value is passed through an integer.For example:
__le32 __user *p; __le32 x; put_user(x, p);Quoted 5 lines
is safe, but currently triggers a sparse warning on tile.
The reason has to do with this code:
__typeof((x)-(x))which seems to be a way to force check for an integer type.
No, it's purely a way to avoid
warning: cast from pointer to integer of different size
Quoted 8 lines
at every place we invoke
put_user()with a pointer - which is in fact pretty frequent throughout the kernel.The idiom of
casting to the difference of the type converts it to a type of the same size as the input (whether integral or pointer), but guaranteed to be an integral type. Then from there it's safe to cast it on to a u64 without generating a warning.
Thanks for the comments. OK, I see, though I wonder why didn't kbuild notify me about new warnings. Doesn't it build tile?
So if you want to merge your patch, please let me know.
But I think the fix can be much simpler: unsigned long has the same property without any of the complexity, or problems with sparse. So how about this:
--->
tile: fix put_user sparse errors
virtio wants to write bitwise types to userspace using put_user. At the moment this triggers sparse errors, since the value is passed through an integer.
For example:
__le32 __user *p;__le32 x;put_user(x, p);
is safe, but currently triggers a sparse warning on tile.
The reason has to do with this code:
__typeof((x)-(x))
which is a way to avoid cast from pointer to integer of different size warnings.
Fix that up using __force unsigned long cast instead:
this is similar to what many other architectures do.
Note: this does not suppress any useful sparse checks since the original merely casted x to typeof(x-x).
Tile currently does not trigger sparse warnings when get_user causes an illegal assignment across bitwise types. This patch does not attempt to fix this.
---->
arch/tile/include/asm/uaccess.h +1 -1
@@ -246,7 +246,7 @@ extern int __get_user_bad(void)#define __put_user_4 (x, ptr, ret) __put_user_asm(sw, x, ptr, ret)#define __put_user_8 (x, ptr, ret) \ ({ \ - u64 __x = (__typeof((x)-(x)))(x); \ + u64 __x = (u64)(__force unsigned long)(x); \ int __lo = (int) __x, __hi = (int) (__x >> 32); \ asm volatile("1: { sw %1, %2; addi %0, %1, 4 }\n" \ "2: { sw %0, %3; movei %0, 0 }\n" \
Re: [PATCH v2 22/40] tile: fix put_user sparse errors
Quoted 33 lines · Michael S. Tsirkin
Quoted 23 lines · Chris Metcalf
Nack for this patch as-is.
Quoted 10 lines · Michael S. Tsirkin
virtio wants to write bitwise types to userspace using
put_user. At the moment this triggers sparse errors, since the value is passed through an integer.For example:
__le32 __user *p; __le32 x; put_user(x, p);Quoted 5 lines
is safe, but currently triggers a sparse warning on tile.
The reason has to do with this code:
__typeof((x)-(x))which seems to be a way to force check for an integer type.
No, it's purely a way to avoid
warning: cast from pointer to integer of different size
Quoted 8 lines
at every place we invoke
put_user()with a pointer - which is in fact pretty frequent throughout the kernel.The idiom of
casting to the difference of the type converts it to a type of the same size as the input (whether integral or pointer), but guaranteed to be an integral type. Then from there it's safe to cast it on to a u64 without generating a warning.
Quoted 7 lines
Thanks for the comments. OK, I see, though I wonder why didn't kbuild notify me about new warnings. Doesn't it build tile?
So if you want to merge your patch, please let me know.
But I think the fix can be much simpler: unsigned long has the same property without any of the complexity, or problems with sparse. So how about this:
Oh, I see you have written a better patch already. Please ignore mine.
Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
In reply to Chris MetcalfQuoted 35 lines · Chris Metcalf
Quoted 24 lines · Michael S. Tsirkin
Tile currently does not trigger sparse warnings when
get_usercauses an illegal assignment across bitwise types.For example:
__le32__user*p;__u32x;put_user(x, p);violates endian-ness rules, but currently does not trigger sparse warning on tile.
Fix this by adding some dead code.
Signed-off-by Michael S. Tsirkin<[email protected]>--- arch/tile/include/asm/uaccess.h | 4 ++++ 1 file changed, 4 insertions(+)arch/tile/include/asm/uaccess.h +0
-0arch/tile/include/asm/uaccess.h extern int __get_user_bad(void) · line 224
Quoted 7 lines
arch/tile/include/asm/uaccess.h +2
-0@@ -218,6 +218,8 @@ extern int __get_user_bad(void)case 8 :__get_user_8 (x, ptr, __ret);break ; \default : __ret =__get_user_bad ();break ; \ } \ +if (0 ) \ + x = *(__force typeof(*ptr) *)(ptr); \ __ret; \ })The "if (0)" suggestion is cute, but pretty hacky :-)
Quoted 4 lines
Here's a revised change that may fix both of your sparse concerns with tile, without having to give up the optimized 64-bit get/put on tilepro. Would this fix both the issue discussed in this change, as well as the issue in the previous change (where you removed the typeof(x-x) cast)?
The patches look good, thanks! they are almost there, however, they do not completely resolve the issue that my patch 1 tried (incorrectly) to
fix: namely x being a bitwise type. Comments below.
Quoted 7 lines
The key changes are to copy the x86 definition of
__inttype(), and then to arrange to use an intermediate integral type that gets assigned to or from the actual typed value so as to expose any sparse issues.If this works for you, I'm happy to queue it in the tile tree, or I can provide a proper git commit for you to include in your series, whichever works better for you.
Please queue it up for 3.20. Extra __force is needed in a couple of places - would you like to fix this up yourself, or do you want me to write a patch on top?
Quoted 25 lines
arch/tile/include/asm/uaccess.h +7
-7@@ -114,14 +114,14 @@ struct exception_table_entry {extern int fixup_exception (struct pt_regs *regs);/* +* This is a type: either unsigned long, if the argument fits into +* that type, or otherwise unsigned long long. +*/ +#define __inttype (x) \ + __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) + +/* * Support macros for __get_user(). -* -* Implementation note: The "case 8" logic of casting to the type of -* the result of subtracting the value from itself is basically a way -* of keeping all integer types the same, but casting any pointers to -* ptrdiff_t, i.e. also an integer type. This way there are no -* questionable casts seen by the compiler on an ILP32 platform. -* * Note that __get_user() and __put_user() assume proper alignment. */
arch/tile/include/asm/uaccess.h extern int fixup_exception(struct pt_regs *regs); · line 184
Quoted 8 lines
arch/tile/include/asm/uaccess.h +1
-1@@ -178,7 +178,7 @@ extern int fixup_exception(struct pt_regs *regs); "9:" \ : "=r" (ret), "=r" (__a), "=&r" (__b) \ : "r" (ptr), "i" (-EFAULT)); \ - (x) = (__typeof (x))(__typeof ((x)-(x))) \ + (x) = (__typeof (x))(__inttype (x)) \ (((u64 )__hi32 (__a, __b) <<32 ) | \__lo32 (__a, __b)); \ })
This cast to __typeof(x) needs to be done with __force, otherwise there will be a warning with bitwise types.
Quoted 8 lines
arch/tile/include/asm/uaccess.h +1
-1@@ -210,14 +210,16 @@ extern int __get_user_bad(void)#define __get_user (x, ptr) \ ({ \ int __ret; \ + __inttype(*(ptr)) __x; \ __chk_user_ptr(ptr); \ switch (sizeof(*(ptr))) { \ - case 1: __get_user_1(x, ptr, __ret); break; \
arch/tile/include/asm/uaccess.h extern int __get_user_bad(void) · line 222
Quoted 10 lines
arch/tile/include/asm/uaccess.h +5
-3-case 2 :__get_user_2 (x, ptr, __ret);break ; \ -case 4 :__get_user_4 (x, ptr, __ret);break ; \ -case 8 :__get_user_8 (x, ptr, __ret);break ; \ +case 1 :__get_user_1 (__x, ptr, __ret);break ; \ +case 2 :__get_user_2 (__x, ptr, __ret);break ; \ +case 4 :__get_user_4 (__x, ptr, __ret);break ; \ +case 8 :__get_user_8 (__x, ptr, __ret);break ; \default : __ret =__get_user_bad ();break ; \ } \ + (x) = (typeof (x ))__x; \
And this one too.
arch/tile/include/asm/uaccess.h extern int __get_user_bad(void) · line 251
Quoted 9 lines
arch/tile/include/asm/uaccess.h +1
-1__ret; \ })@@ -246,7 +248,7 @@ extern int __get_user_bad(void)#define __put_user_4 (x, ptr, ret) __put_user_asm(sw, x, ptr, ret)#define __put_user_8 (x, ptr, ret) \ ({ \ - u64 __x = (__typeof((x)-(x)))(x); \ + u64 __x = (__inttype(x))(x); \
And this cast to __inttype too.
Quoted 25 lines
arch/tile/include/asm/uaccess.h +5
-4int __lo = (int ) __x, __hi = (int ) (__x >>32 ); \ asmvolatile ("1: { sw %1, %2; addi %0, %1, 4 }\n" \ "2: { sw %0, %3; movei %0, 0 }\n" \@@ -289,12 +291,13 @@ extern int __put_user_bad(void)#define __put_user (x, ptr) \ ({ \ int __ret; \ + typeof(*(ptr)) __x = (x); \ __chk_user_ptr(ptr); \ switch (sizeof(*(ptr))) { \ - case 1: __put_user_1(x, ptr, __ret); break; \ - case 2: __put_user_2(x, ptr, __ret); break; \ - case 4: __put_user_4(x, ptr, __ret); break; \ - case 8: __put_user_8(x, ptr, __ret); break; \ + case 1: __put_user_1(__x, ptr, __ret); break; \ + case 2: __put_user_2(__x, ptr, __ret); break; \ + case 4: __put_user_4(__x, ptr, __ret); break; \ + case 8: __put_user_8(__x, ptr, __ret); break; \ default: __ret = __put_user_bad(); break; \ } \ __ret; \Signature · 3 lines
-- Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Re: [PATCH v2 22/40] tile: fix put_user sparse errors
In reply to Chris MetcalfQuoted 1 line · Chris Metcalf
Nack for this patch as-is.
Thanks, I dropped it and the next one from my tree, looks like you are on track to fixing it all in the tile tree.
Quoted 23 lines · Michael S. Tsirkin
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · On Tuesday 06 January 2015 17:43:28 Michael S. Tsirkin wrote:
I tested this on x86 only. Since it's just adding
__force, should be trivially safe everywhere?Arnd, did you merge v1 already? If yes, can you please replace with this version?
Quoted 6 lines
I haven't merged it yet. I see that more Acks and some comments are coming in. Once those are done, could you send a pull request? It might be useful to have a branch that can be shared with architecture trees if necessary to avoid merge conflicts.
Arnd
OK, I got a bunch of acks, mostly it seems to have calmed down. Heiko Carstens (s390 maintainer) says he won't apply whitespace changes:
http://mid.gmane.org/20150107083339.GB4365@osiris
so I dropped s390 patches.
Quoted 6 lines
The rest is tagged:
git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.gittags/uaccess_for_upstream
and pushed out to linux-next.I'll give it a couple of days there, then send a pull request - Arnd, you meant I should send it to you, right?
Dropped tile as well - will go through arch tree. Let's wait a couple more days, then merge into arch tree if all's well.
Makes sense?
Quoted 2 lines
Signature · 1 line
MST
Re: [PATCH v2 01/40] x86/uaccess: fix sparse errors
In reply to Michael S. TsirkinQuoted 7 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.Signed-off-by Michael S. Tsirkin <[email protected]>
Re: [PATCH v2 22/40] tile: fix put_user sparse errors
In reply to Michael S. TsirkinQuoted 2 lines · Michael S. Tsirkin
I wonder why didn't
kbuild notify me about new warnings. Doesn't it build tile?
Kbuild builds tilegx, which is an LP64 kernel. These issues are with the older platform, tilepro, which is an ILP32 kernel.
There's certainly no reason we couldn't be building that with kbuild as well, but for whatever reason it just never started up, and I'm primarily concerned with tilegx anyway, so I haven't pushed.
Signature · 2 lines
Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
In reply to Michael S. TsirkinQuoted 11 lines · Michael S. Tsirkin
Quoted 7 lines · Chris Metcalf
The key changes are to copy the x86 definition of
__inttype(), and then to arrange to use an intermediate integral type that gets assigned to or from the actual typed value so as to expose any sparse issues.If this works for you, I'm happy to queue it in the tile tree, or I can provide a proper git commit for you to include in your series, whichever works better for you.
Please queue it up for 3.20. Extra
__forceis needed in a couple of places - would you like to fix this up yourself, or do you want me to write a patch on top?
I'll fold in your suggestions to my patch.
Quoted 11 lines
arch/tile/include/asm/uaccess.h extern int fixup_exception(struct pt_regs *regs); · line 184
Quoted 9 lines
arch/tile/include/asm/uaccess.h +1
-1@@ -178,7 +178,7 @@ extern int fixup_exception(struct pt_regs *regs); "9:" \ : "=r" (ret), "=r" (__a), "=&r" (__b) \ : "r" (ptr), "i" (-EFAULT)); \ - (x) = (__typeof (x))(__typeof ((x)-(x))) \ + (x) = (__typeof (x))(__inttype (x)) \ (((u64 )__hi32 (__a, __b) <<32 ) | \__lo32 (__a, __b)); \ })This cast to
__typeof(x)needs to be done with__force, otherwise there will be a warning with bitwise types.
Actually, this place no longer needs any casting at all, on reflection. I've changed the __get_user() code to do the "get" into an __inttype uniformly, so __get_user_8 will always have a u64 type for "x" here.
I'll cc you on the updated patch, so if you'd like to add your Reviewed-by tag to it, let me know.
Signature · 2 lines
Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
Quoted 27 lines · Chris Metcalf
Quoted 11 lines · Michael S. Tsirkin
Quoted 7 lines · Chris Metcalf
The key changes are to copy the x86 definition of
__inttype(), and then to arrange to use an intermediate integral type that gets assigned to or from the actual typed value so as to expose any sparse issues.If this works for you, I'm happy to queue it in the tile tree, or I can provide a proper git commit for you to include in your series, whichever works better for you.
Please queue it up for 3.20. Extra
__forceis needed in a couple of places - would you like to fix this up yourself, or do you want me to write a patch on top?I'll fold in your suggestions to my patch.
Quoted 11 lines
arch/tile/include/asm/uaccess.h extern int fixup_exception(struct pt_regs *regs); · line 184
Quoted 9 lines
arch/tile/include/asm/uaccess.h +1
-1@@ -178,7 +178,7 @@ extern int fixup_exception(struct pt_regs *regs); "9:" \ : "=r" (ret), "=r" (__a), "=&r" (__b) \ : "r" (ptr), "i" (-EFAULT)); \ - (x) = (__typeof (x))(__typeof ((x)-(x))) \ + (x) = (__typeof (x))(__inttype (x)) \ (((u64 )__hi32 (__a, __b) <<32 ) | \__lo32 (__a, __b)); \ })This cast to
__typeof(x)needs to be done with__force, otherwise there will be a warning with bitwise types.
Quoted 6 lines
Actually, this place no longer needs any casting at all, on reflection. I've changed the
__get_user()code to do the "get" into an__inttypeuniformly, so__get_user_8will always have a u64 type for "x" here.I'll cc you on the updated patch, so if you'd like to add your Reviewed-by tag to it, let me know.
Sure.
Quoted 3 lines
Signature · 2 lines
Chris Metcalf, EZChip Semiconductor http://www.ezchip.com
Re: [PATCH v2 06/40] cris/uaccess: fix sparse errors
In reply to Michael S. TsirkinQuoted 5 lines · Michael S. Tsirkin
virtio wants to read bitwise types from userspace using
get_user. At the moment this triggers sparse errors, since the value is passed through an integer.Fix that up using
__force.
Looks sane, I'll take this in the CRIS tree since you have a cleanup patch which depends on it.
Thanks!
/Jesper
Quoted 29 lines
Signed-off-by Michael S. Tsirkin <[email protected]>--- arch/cris/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/cris/include/asm/uaccess.h +2
-2@@ -153,7 +153,7 @@ struct __large_struct { unsigned long buf[100]; }; ({ \long __gu_err, __gu_val; \__get_user_size (__gu_val,(ptr),(size),__gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })@@ -163,7 +163,7 @@ struct __large_struct { unsigned long buf[100]; }; const __typeof__(*(ptr)) *__gu_addr = (ptr); \if (access_ok (VERIFY_READ ,__gu_addr,size)) \__get_user_size (__gu_val,__gu_addr,(size),__gu_err); \ - (x) = (__typeof__ (*(ptr )))__gu_val; \ + (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ })Signature · 1 line
MST
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]
Re: [PATCH v2 33/40] cris: macro whitespace fixes
In reply to Michael S. TsirkinQuoted 5 lines · Michael S. Tsirkin
While working on
arch/cris/include/asm/uaccess.h, I noticed that some macros within this header are made harder to read because they violate a coding style rule: space is missing after comma.Fix it up.
Thanks, looks good.
I'll take it into the CRIS tree for 3.20.
Quoted 1 line
Signed-off-by Michael S. Tsirkin <[email protected]>
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]