All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types
@ 2015-01-06 15:43 Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
                   ` (40 more replies)
  0 siblings, 41 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch

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(-)

-- 
MST


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

* [PATCH v2 01/40] x86/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-13 12:33   ` Thomas Gleixner
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                   ` (39 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86

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 <mst@redhat.com>
---
 arch/x86/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 0d592e0..ace9dec 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -179,7 +179,7 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
 	asm volatile("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;							\
 })
 
-- 
MST


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

* [PATCH v2 02/40] alpha/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-06 15:43   ` Michael S. Tsirkin
                   ` (38 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, linux-alpha

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 <mst@redhat.com>
---
 arch/alpha/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h
index 766fdfd..a234de7 100644
--- a/arch/alpha/include/asm/uaccess.h
+++ b/arch/alpha/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
@ 2015-01-06 15:43   ` Michael S. Tsirkin
  2015-01-06 15:43   ` Michael S. Tsirkin
                     ` (38 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Will Deacon, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

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 <mst@redhat.com>

Acked-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 3bf8f4e..9a2069b 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -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)						\
-- 
MST


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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 15:43   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Arnd Bergmann, Catalin Marinas, Will Deacon,
	Christopher Covington, linux-arm-kernel

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 <mst@redhat.com>

Acked-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 3bf8f4e..9a2069b 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -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)						\
-- 
MST

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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 15:43   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-arm-kernel

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 <mst@redhat.com>

Acked-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 3bf8f4e..9a2069b 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -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)						\
-- 
MST

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

* [PATCH v2 04/40] avr32/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2015-01-06 15:43   ` Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 05/40] blackfin/uaccess: " Michael S. Tsirkin
                   ` (36 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Hans-Christian Egtvedt, Haavard Skinnemoen

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 <mst@redhat.com>
Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>
---
 arch/avr32/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h
index 245b2ee..ccd07c4 100644
--- a/arch/avr32/include/asm/uaccess.h
+++ b/arch/avr32/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 05/40] blackfin/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2015-01-06 15:43 ` [PATCH v2 04/40] avr32/uaccess: " Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 06/40] cris/uaccess: " Michael S. Tsirkin
                   ` (35 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Steven Miao, adi-buildroot-devel

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 <mst@redhat.com>
Acked-by: Steven Miao <realmz6@gmail.com>
---
 arch/blackfin/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
index 57701c3..2dcc930 100644
--- a/arch/blackfin/include/asm/uaccess.h
+++ b/arch/blackfin/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 06/40] cris/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2015-01-06 15:43 ` [PATCH v2 05/40] blackfin/uaccess: " Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-27 16:27   ` Jesper Nilsson
  2015-01-06 15:43   ` Michael S. Tsirkin
                   ` (34 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Mikael Starvik, Jesper Nilsson,
	linux-cris-kernel

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 <mst@redhat.com>
---
 arch/cris/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h
index 9145408..9cf5a23 100644
--- a/arch/cris/include/asm/uaccess.h
+++ b/arch/cris/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 07/40] ia64/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:43   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Tony Luck, Fenghua Yu, Thierry Reding,
	linux-ia64

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 <mst@redhat.com>
---
 arch/ia64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
index 103bedc..967c312 100644
--- a/arch/ia64/include/asm/uaccess.h
+++ b/arch/ia64/include/asm/uaccess.h
@@ -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;									\
 })
 
-- 
MST


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

* [PATCH v2 07/40] ia64/uaccess: fix sparse errors
@ 2015-01-06 15:43   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Tony Luck, Fenghua Yu, Thierry Reding,
	linux-ia64

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 <mst@redhat.com>
---
 arch/ia64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
index 103bedc..967c312 100644
--- a/arch/ia64/include/asm/uaccess.h
+++ b/arch/ia64/include/asm/uaccess.h
@@ -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;									\
 })
 
-- 
MST


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

* [PATCH v2 08/40] m32r/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (6 preceding siblings ...)
  2015-01-06 15:43   ` Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 09/40] metag/uaccess: " Michael S. Tsirkin
                   ` (32 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch

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 <mst@redhat.com>
---
 arch/m32r/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h
index 84fe7ba..d076942 100644
--- a/arch/m32r/include/asm/uaccess.h
+++ b/arch/m32r/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 09/40] metag/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (7 preceding siblings ...)
  2015-01-06 15:43 ` [PATCH v2 08/40] m32r/uaccess: " Michael S. Tsirkin
@ 2015-01-06 15:43 ` Michael S. Tsirkin
  2015-01-07  9:47     ` James Hogan
  2015-01-06 15:44 ` [PATCH v2 10/40] microblaze/uaccess: " Michael S. Tsirkin
                   ` (31 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, James Hogan, linux-metag

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 <mst@redhat.com>
---
 arch/metag/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
index 0748b0a..c314b45 100644
--- a/arch/metag/include/asm/uaccess.h
+++ b/arch/metag/include/asm/uaccess.h
@@ -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;                                                       \
 })
 
-- 
MST


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

* [PATCH v2 10/40] microblaze/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (8 preceding siblings ...)
  2015-01-06 15:43 ` [PATCH v2 09/40] metag/uaccess: " Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-07 10:14   ` Michal Simek
  2015-01-06 15:44   ` Michael S. Tsirkin
                   ` (30 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Michal Simek, Chen Gang

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 <mst@redhat.com>
---
 arch/microblaze/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index 59a89a6..e41bebf 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 11/40] openrisc/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Jonas Bonn, linux

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 <mst@redhat.com>
---
 arch/openrisc/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
index ab2e7a1..a6bd07c 100644
--- a/arch/openrisc/include/asm/uaccess.h
+++ b/arch/openrisc/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 11/40] openrisc/uaccess: fix sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, linux, Arnd Bergmann

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 <mst@redhat.com>
---
 arch/openrisc/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
index ab2e7a1..a6bd07c 100644
--- a/arch/openrisc/include/asm/uaccess.h
+++ b/arch/openrisc/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST

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

* [PATCH v2 12/40] parisc/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (10 preceding siblings ...)
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-06 15:44   ` Michael S. Tsirkin
                   ` (28 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Helge Deller, James E.J. Bottomley,
	linux-parisc

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 <mst@redhat.com>
Acked-by: Helge Deller <deller@gmx.de>
---
 arch/parisc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
index a5cb070..6c79311 100644
--- a/arch/parisc/include/asm/uaccess.h
+++ b/arch/parisc/include/asm/uaccess.h
@@ -104,7 +104,7 @@ struct exception_data {
 	    }                                           \
 	}                                               \
 							\
-	(x) = (__typeof__(*(ptr))) __gu_val;            \
+	(x) = (__force __typeof__(*(ptr))) __gu_val;	\
 	__gu_err;                                       \
 })
 
-- 
MST

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

* [PATCH v2 13/40] sh/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-sh

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 <mst@redhat.com>
---
 arch/sh/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h
index 9486376..a49635c 100644
--- a/arch/sh/include/asm/uaccess.h
+++ b/arch/sh/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 13/40] sh/uaccess: fix sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-sh

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 <mst@redhat.com>
---
 arch/sh/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h
index 9486376..a49635c 100644
--- a/arch/sh/include/asm/uaccess.h
+++ b/arch/sh/include/asm/uaccess.h
@@ -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;							\
 })
 
-- 
MST


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

* [PATCH v2 14/40] sparc32/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

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 <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_32.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 9634d08..8b571a0 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -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__(							\
-- 
MST


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

* [PATCH v2 14/40] sparc32/uaccess: fix sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

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 <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_32.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 9634d08..8b571a0 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -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__(							\
-- 
MST


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

* [PATCH v2 15/40] sparc64/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

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 <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index c990a5e..b80866d 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -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__(							\
-- 
MST


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

* [PATCH v2 15/40] sparc64/uaccess: fix sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

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 <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index c990a5e..b80866d 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -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__(							\
-- 
MST


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

* [PATCH v2 16/40] m68k/uaccess: fix sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (14 preceding siblings ...)
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-07 10:38   ` Geert Uytterhoeven
  2015-01-06 15:44   ` Michael S. Tsirkin
                   ` (24 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Geert Uytterhoeven, linux-m68k

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 <mst@redhat.com>
---
 arch/m68k/include/asm/uaccess_mm.h | 40 +++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/arch/m68k/include/asm/uaccess_mm.h b/arch/m68k/include/asm/uaccess_mm.h
index 15901db..d228601 100644
--- a/arch/m68k/include/asm/uaccess_mm.h
+++ b/arch/m68k/include/asm/uaccess_mm.h
@@ -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:							\
-- 
MST


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

* [PATCH v2 17/40] arm: fix put_user sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43   ` Michael S. Tsirkin
                     ` (38 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Russell King, Daniel Thompson,
	Nicolas Pitre, Victor Kamensky,
	=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=,
	Andrey Ryabinin, linux-arm-kernel

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/arm/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 4767eb9..74fcde7 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -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);	\
 })
-- 
MST


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

* [PATCH v2 17/40] arm: fix put_user sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Nicolas Pitre, Daniel Thompson, Russell King,
	Arnd Bergmann, Victor Kamensky, Andrey Ryabinin,
	=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=,
	linux-arm-kernel

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/arm/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 4767eb9..74fcde7 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -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);	\
 })
-- 
MST

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

* [PATCH v2 17/40] arm: fix put_user sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/arm/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 4767eb9..74fcde7 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -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);	\
 })
-- 
MST

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

* [PATCH v2 18/40] blackfin: fix put_user sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (16 preceding siblings ...)
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-06 15:44   ` Michael S. Tsirkin
                   ` (22 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Steven Miao, adi-buildroot-devel

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/blackfin/include/asm/uaccess.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
index 2dcc930..4bf968c 100644
--- a/arch/blackfin/include/asm/uaccess.h
+++ b/arch/blackfin/include/asm/uaccess.h
@@ -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();		\
-- 
MST


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

* [PATCH v2 19/40] ia64: fix put_user sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Tony Luck, Fenghua Yu, Thierry Reding,
	linux-ia64

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/ia64/include/asm/uaccess.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
index 967c312..4f3fb6cc 100644
--- a/arch/ia64/include/asm/uaccess.h
+++ b/arch/ia64/include/asm/uaccess.h
@@ -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 */
 
-- 
MST


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

* [PATCH v2 19/40] ia64: fix put_user sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Tony Luck, Fenghua Yu, Thierry Reding,
	linux-ia64

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/ia64/include/asm/uaccess.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
index 967c312..4f3fb6cc 100644
--- a/arch/ia64/include/asm/uaccess.h
+++ b/arch/ia64/include/asm/uaccess.h
@@ -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 */
 
-- 
MST


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

* [PATCH v2 20/40] metag: fix put_user sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (18 preceding siblings ...)
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-07  9:55     ` James Hogan
  2015-01-06 15:44   ` Michael S. Tsirkin
                   ` (20 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, James Hogan, linux-metag

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 <james.hogan@imgtec.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/metag/include/asm/uaccess.h | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
index c314b45..9627c19 100644
--- a/arch/metag/include/asm/uaccess.h
+++ b/arch/metag/include/asm/uaccess.h
@@ -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();					\
 	}								\
-- 
MST


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

* [PATCH v2 21/40] sh: fix put_user sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-sh

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sh/include/asm/uaccess_64.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/sh/include/asm/uaccess_64.h b/arch/sh/include/asm/uaccess_64.h
index 2e07e0f..c01376c 100644
--- a/arch/sh/include/asm/uaccess_64.h
+++ b/arch/sh/include/asm/uaccess_64.h
@@ -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();				\
-- 
MST


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

* [PATCH v2 21/40] sh: fix put_user sparse errors
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-sh

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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sh/include/asm/uaccess_64.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/sh/include/asm/uaccess_64.h b/arch/sh/include/asm/uaccess_64.h
index 2e07e0f..c01376c 100644
--- a/arch/sh/include/asm/uaccess_64.h
+++ b/arch/sh/include/asm/uaccess_64.h
@@ -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();				\
-- 
MST


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

* [PATCH v2 22/40] tile: fix put_user sparse errors
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (20 preceding siblings ...)
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-12 21:56     ` Chris Metcalf
  2015-01-06 15:44 ` [PATCH v2 23/40] tile: enable sparse checks for get/put_user Michael S. Tsirkin
                   ` (18 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Chris Metcalf

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 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/tile/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
index b6cde32..22cffa1 100644
--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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"		\
-- 
MST


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

* [PATCH v2 23/40] tile: enable sparse checks for get/put_user
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (21 preceding siblings ...)
  2015-01-06 15:44 ` [PATCH v2 22/40] tile: " Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-13  0:08     ` Chris Metcalf
  2015-01-06 15:44 ` [PATCH v2 24/40] avr32: whitespace fix Michael S. Tsirkin
                   ` (17 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Chris Metcalf

Tile 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/tile/include/asm/uaccess.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
index 22cffa1..03d905c 100644
--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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;								\
 })
 
-- 
MST


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

* [PATCH v2 24/40] avr32: whitespace fix
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (22 preceding siblings ...)
  2015-01-06 15:44 ` [PATCH v2 23/40] tile: enable sparse checks for get/put_user Michael S. Tsirkin
@ 2015-01-06 15:44 ` Michael S. Tsirkin
  2015-01-07  6:50   ` Hans-Christian Egtvedt
  2015-01-06 15:44   ` Michael S. Tsirkin
                   ` (16 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Haavard Skinnemoen, Hans-Christian Egtvedt

Align using tabs to make code prettier.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/avr32/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h
index ccd07c4..72607f3 100644
--- a/arch/avr32/include/asm/uaccess.h
+++ b/arch/avr32/include/asm/uaccess.h
@@ -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:						\
-- 
MST


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

* [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

Macros 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_32.h | 364 ++++++++++++++++++++++--------------
 1 file changed, 226 insertions(+), 138 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 8b571a0..03230cb 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -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);
 
-- 
MST


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

* [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

Macros 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_32.h | 364 ++++++++++++++++++++++--------------
 1 file changed, 226 insertions(+), 138 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
index 8b571a0..03230cb 100644
--- a/arch/sparc/include/asm/uaccess_32.h
+++ b/arch/sparc/include/asm/uaccess_32.h
@@ -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);
 
-- 
MST


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

* [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

Macros 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_64.h | 246 +++++++++++++++++++++---------------
 1 file changed, 142 insertions(+), 104 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index b80866d..45d84b1 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -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);
 
-- 
MST


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

* [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 15:44   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, David S. Miller, Sam Ravnborg, sparclinux

Macros 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sparc/include/asm/uaccess_64.h | 246 +++++++++++++++++++++---------------
 1 file changed, 142 insertions(+), 104 deletions(-)

diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index b80866d..45d84b1 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -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);
 
-- 
MST


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

* [PATCH v2 27/40] blackfin: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (25 preceding siblings ...)
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-06 15:45 ` [PATCH v2 28/40] microblaze: whitespace fix Michael S. Tsirkin
                   ` (13 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Steven Miao, adi-buildroot-devel

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/blackfin/include/asm/uaccess.h | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
index 4bf968c..90612a7 100644
--- a/arch/blackfin/include/asm/uaccess.h
+++ b/arch/blackfin/include/asm/uaccess.h
@@ -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
-- 
MST


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

* [PATCH v2 28/40] microblaze: whitespace fix
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (26 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 27/40] blackfin: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-07 10:14   ` Michal Simek
  2015-01-06 15:45 ` [PATCH v2 29/40] alpha: macro whitespace fixes Michael S. Tsirkin
                   ` (12 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Michal Simek, Chen Gang

Align using tabs to make code prettier.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/microblaze/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index e41bebf..62942fd 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -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;						\
 									\
-- 
MST


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

* [PATCH v2 29/40] alpha: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (27 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 28/40] microblaze: whitespace fix Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-06 15:45   ` Michael S. Tsirkin
                   ` (11 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, linux-alpha

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/alpha/include/asm/uaccess.h | 82 ++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 41 deletions(-)

diff --git a/arch/alpha/include/asm/uaccess.h b/arch/alpha/include/asm/uaccess.h
index a234de7..9b0d400 100644
--- a/arch/alpha/include/asm/uaccess.h
+++ b/arch/alpha/include/asm/uaccess.h
@@ -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 *vali
 	return 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;
 }
 
-- 
MST


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

* [PATCH v2 30/40] arm: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:45   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Russell King, Nicolas Pitre,
	Daniel Thompson, Rob Clark, Victor Kamensky,
	=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=,
	Andrey Ryabinin, linux-arm-kernel

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/arm/include/asm/uaccess.h | 92 +++++++++++++++++++++---------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 74fcde7..ce0786e 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -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 void
 extern 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)
-- 
MST


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

* [PATCH v2 30/40] arm: macro whitespace fixes
@ 2015-01-06 15:45   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-arm-kernel

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/arm/include/asm/uaccess.h | 92 +++++++++++++++++++++---------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 74fcde7..ce0786e 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -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 void
 extern 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)
-- 
MST

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

* [PATCH v2 31/40] arm64: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:45   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Catalin Marinas, Will Deacon,
	Christopher Covington, linux-arm-kernel

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 <mst@redhat.com>
---
 arch/arm64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 9a2069b..07e1ba44 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -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.
-- 
MST


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

* [PATCH v2 31/40] arm64: macro whitespace fixes
@ 2015-01-06 15:45   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-arm-kernel

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 <mst@redhat.com>
---
 arch/arm64/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 9a2069b..07e1ba44 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -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.
-- 
MST

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

* [PATCH v2 32/40] avr32: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (30 preceding siblings ...)
  2015-01-06 15:45   ` Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-07  6:52   ` Hans-Christian Egtvedt
  2015-01-06 15:45 ` [PATCH v2 33/40] cris: " Michael S. Tsirkin
                   ` (8 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Haavard Skinnemoen, Hans-Christian Egtvedt

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/avr32/include/asm/uaccess.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h
index 72607f3..a46f7cf 100644
--- a/arch/avr32/include/asm/uaccess.h
+++ b/arch/avr32/include/asm/uaccess.h
@@ -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);
-- 
MST


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

* [PATCH v2 33/40] cris: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (31 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 32/40] avr32: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-27 16:28   ` Jesper Nilsson
  2015-01-06 15:45 ` [PATCH v2 34/40] frv: " Michael S. Tsirkin
                   ` (7 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Mikael Starvik, Jesper Nilsson,
	linux-cris-kernel

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/cris/include/asm/uaccess.h | 113 +++++++++++++++++++++-------------------
 1 file changed, 58 insertions(+), 55 deletions(-)

diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h
index 9cf5a23..a21344a 100644
--- a/arch/cris/include/asm/uaccess.h
+++ b/arch/cris/include/asm/uaccess.h
@@ -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)
 
-- 
MST


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

* [PATCH v2 34/40] frv: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (32 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 33/40] cris: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-06 15:45 ` [PATCH v2 35/40] m32r: " Michael S. Tsirkin
                   ` (6 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, David Howells

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/frv/include/asm/segment.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/frv/include/asm/segment.h b/arch/frv/include/asm/segment.h
index a2320a4..4377c89 100644
--- a/arch/frv/include/asm/segment.h
+++ b/arch/frv/include/asm/segment.h
@@ -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)
 
-- 
MST


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

* [PATCH v2 35/40] m32r: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (33 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 34/40] frv: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-06 15:45 ` [PATCH v2 36/40] m68k: " Michael S. Tsirkin
                   ` (5 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/m32r/include/asm/uaccess.h | 84 ++++++++++++++++++++---------------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h
index d076942..71adff2 100644
--- a/arch/m32r/include/asm/uaccess.h
+++ b/arch/m32r/include/asm/uaccess.h
@@ -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,
-- 
MST


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

* [PATCH v2 36/40] m68k: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (34 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 35/40] m32r: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-07  9:56   ` Geert Uytterhoeven
  2015-01-06 15:45 ` [PATCH v2 37/40] parisc: " Michael S. Tsirkin
                   ` (4 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, Geert Uytterhoeven, linux-m68k

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 <mst@redhat.com>
---
 arch/m68k/include/asm/segment.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/segment.h b/arch/m68k/include/asm/segment.h
index 0fa80e9..98216b8 100644
--- a/arch/m68k/include/asm/segment.h
+++ b/arch/m68k/include/asm/segment.h
@@ -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__ */
 
-- 
MST


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

* [PATCH v2 37/40] parisc: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (35 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 36/40] m68k: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-06 15:45 ` [PATCH v2 38/40] s390: " Michael S. Tsirkin
                   ` (3 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, James E.J. Bottomley, Helge Deller,
	linux-parisc

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/parisc/include/asm/uaccess.h | 116 +++++++++++++++++++-------------------
 1 file changed, 58 insertions(+), 58 deletions(-)

diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
index 6c79311..0abdd4c 100644
--- a/arch/parisc/include/asm/uaccess.h
+++ b/arch/parisc/include/asm/uaccess.h
@@ -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
  */
-- 
MST

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

* [PATCH v2 38/40] s390: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (36 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 37/40] parisc: " Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-07  8:33   ` Heiko Carstens
  2015-01-06 15:45   ` Michael S. Tsirkin
                   ` (2 subsequent siblings)
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Martin Schwidefsky, Heiko Carstens,
	linux390, linux-s390

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 <mst@redhat.com>
---
 arch/s390/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index cd4c68e..71b9c40 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -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)			\
-- 
MST


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

* [PATCH v2 39/40] sh: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
@ 2015-01-06 15:45   ` Michael S. Tsirkin
  2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
                     ` (39 subsequent siblings)
  40 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-sh

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sh/include/asm/segment.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/include/asm/segment.h b/arch/sh/include/asm/segment.h
index 5e2725f..ff795d3 100644
--- a/arch/sh/include/asm/segment.h
+++ b/arch/sh/include/asm/segment.h
@@ -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)
 
-- 
MST


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

* [PATCH v2 39/40] sh: macro whitespace fixes
@ 2015-01-06 15:45   ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-sh

While 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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 arch/sh/include/asm/segment.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sh/include/asm/segment.h b/arch/sh/include/asm/segment.h
index 5e2725f..ff795d3 100644
--- a/arch/sh/include/asm/segment.h
+++ b/arch/sh/include/asm/segment.h
@@ -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)
 
-- 
MST


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

* [PATCH v2 40/40] xtensa: macro whitespace fixes
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (38 preceding siblings ...)
  2015-01-06 15:45   ` Michael S. Tsirkin
@ 2015-01-06 15:45 ` Michael S. Tsirkin
  2015-01-06 23:12   ` Max Filippov
  2015-01-06 19:08 ` [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Arnd Bergmann
  40 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 15:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, linux-arch, Chris Zankel, Max Filippov, linux-xtensa

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 <mst@redhat.com>
---
 arch/xtensa/include/asm/uaccess.h | 90 +++++++++++++++++++--------------------
 1 file changed, 45 insertions(+), 45 deletions(-)

diff --git a/arch/xtensa/include/asm/uaccess.h b/arch/xtensa/include/asm/uaccess.h
index 876eb38..147b26e 100644
--- a/arch/xtensa/include/asm/uaccess.h
+++ b/arch/xtensa/include/asm/uaccess.h
@@ -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
 
-- 
MST


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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 16:53     ` Sam Ravnborg
  -1 siblings, 0 replies; 128+ messages in thread
From: Sam Ravnborg @ 2015-01-06 16:53 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> Macros 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.
As per Davem's earlier mail please prefix using sparc32/sparc64.

> -#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; \
> +})

No matter what coding style says - the above is much less readable than the
original version.



> -#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; \
> +})
> +

Same comment for this code chunk.

	Sam


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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 16:53     ` Sam Ravnborg
  0 siblings, 0 replies; 128+ messages in thread
From: Sam Ravnborg @ 2015-01-06 16:53 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> Macros 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.
As per Davem's earlier mail please prefix using sparc32/sparc64.

> -#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; \
> +})

No matter what coding style says - the above is much less readable than the
original version.



> -#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; \
> +})
> +

Same comment for this code chunk.

	Sam


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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 16:53     ` Sam Ravnborg
@ 2015-01-06 17:19       ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 17:19 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 05:53:39PM +0100, Sam Ravnborg wrote:
> On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> > Macros 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.
> As per Davem's earlier mail please prefix using sparc32/sparc64.

I did put in uaccess_64 - insufficient?

> > -#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; \
> > +})
> 
> 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?


> 
> > -#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; \
> > +})
> > +
> 
> Same comment for this code chunk.
> 
> 	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:

> > -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;

-- 
MST

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 17:19       ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 17:19 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 05:53:39PM +0100, Sam Ravnborg wrote:
> On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> > Macros 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.
> As per Davem's earlier mail please prefix using sparc32/sparc64.

I did put in uaccess_64 - insufficient?

> > -#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; \
> > +})
> 
> 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?


> 
> > -#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; \
> > +})
> > +
> 
> Same comment for this code chunk.
> 
> 	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:

> > -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;

-- 
MST

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

* Re: [PATCH v2 14/40] sparc32/uaccess: fix sparse errors
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 18:21     ` David Miller
  -1 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:21 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:17 +0200

> 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 <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>



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

* Re: [PATCH v2 14/40] sparc32/uaccess: fix sparse errors
@ 2015-01-06 18:21     ` David Miller
  0 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:21 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:17 +0200

> 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 <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>



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

* Re: [PATCH v2 15/40] sparc64/uaccess: fix sparse errors
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 18:21     ` David Miller
  -1 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:21 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:20 +0200

> 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 <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH v2 15/40] sparc64/uaccess: fix sparse errors
@ 2015-01-06 18:21     ` David Miller
  0 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:21 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:20 +0200

> 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 <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 18:22     ` David Miller
  -1 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:22 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:53 +0200

> Macros 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes
@ 2015-01-06 18:22     ` David Miller
  0 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:22 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:53 +0200

> Macros 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 15:44   ` Michael S. Tsirkin
@ 2015-01-06 18:22     ` David Miller
  -1 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:22 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:56 +0200

> Macros 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 18:22     ` David Miller
  0 siblings, 0 replies; 128+ messages in thread
From: David Miller @ 2015-01-06 18:22 UTC (permalink / raw)
  To: mst; +Cc: linux-kernel, arnd, linux-arch, sam, sparclinux

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Tue, 6 Jan 2015 17:44:56 +0200

> Macros 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.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 17:19       ` Michael S. Tsirkin
@ 2015-01-06 18:27         ` Sam Ravnborg
  -1 siblings, 0 replies; 128+ messages in thread
From: Sam Ravnborg @ 2015-01-06 18:27 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 07:19:02PM +0200, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 05:53:39PM +0100, Sam Ravnborg wrote:
> > On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> > > Macros 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.
> > 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

> 
> > > -#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; \
> > > +})
> > 
> > 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 did not look to carefully - but what I saw looked good.

> 
> 
> 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

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 18:27         ` Sam Ravnborg
  0 siblings, 0 replies; 128+ messages in thread
From: Sam Ravnborg @ 2015-01-06 18:27 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 07:19:02PM +0200, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 05:53:39PM +0100, Sam Ravnborg wrote:
> > On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> > > Macros 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.
> > 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

> 
> > > -#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; \
> > > +})
> > 
> > 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 did not look to carefully - but what I saw looked good.

> 
> 
> 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

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

* Re: [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types
  2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
                   ` (39 preceding siblings ...)
  2015-01-06 15:45 ` [PATCH v2 40/40] xtensa: " Michael S. Tsirkin
@ 2015-01-06 19:08 ` Arnd Bergmann
  2015-01-06 21:54   ` Michael S. Tsirkin
  2015-01-11 11:55   ` Michael S. Tsirkin
  40 siblings, 2 replies; 128+ messages in thread
From: Arnd Bergmann @ 2015-01-06 19:08 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, linux-arch

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

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
  2015-01-06 15:43   ` Michael S. Tsirkin
  (?)
@ 2015-01-06 19:14     ` Will Deacon
  -1 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-06 19:14 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

Hi Michael,

On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> 
> Acked-by: Will Deacon <will.deacon@arm.com>
> ---

Did you want us to take this via the arm64 tree, or are you planning to
merge it via another route?

Will

>  arch/arm64/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index 3bf8f4e..9a2069b 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -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)						\
> -- 
> MST
> 
> 

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 19:14     ` Will Deacon
  0 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-06 19:14 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

Hi Michael,

On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> 
> Acked-by: Will Deacon <will.deacon@arm.com>
> ---

Did you want us to take this via the arm64 tree, or are you planning to
merge it via another route?

Will

>  arch/arm64/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index 3bf8f4e..9a2069b 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -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)						\
> -- 
> MST
> 
> 

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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 19:14     ` Will Deacon
  0 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-06 19:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Michael,

On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> 
> Acked-by: Will Deacon <will.deacon@arm.com>
> ---

Did you want us to take this via the arm64 tree, or are you planning to
merge it via another route?

Will

>  arch/arm64/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index 3bf8f4e..9a2069b 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -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)						\
> -- 
> MST
> 
> 

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 18:27         ` Sam Ravnborg
@ 2015-01-06 20:23           ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 20:23 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 07:27:49PM +0100, Sam Ravnborg wrote:
> On Tue, Jan 06, 2015 at 07:19:02PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Jan 06, 2015 at 05:53:39PM +0100, Sam Ravnborg wrote:
> > > On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> > > > Macros 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.
> > > 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

OK.
I see David reviewed and sent acks, so I won't bother
reposting, but I'll tweak this in my tree.

> > 
> > > > -#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; \
> > > > +})
> > > 
> > > 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 did not look to carefully - but what I saw looked good.
> 
> > 
> > 
> > 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.

-- 
MST

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 20:23           ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 20:23 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 07:27:49PM +0100, Sam Ravnborg wrote:
> On Tue, Jan 06, 2015 at 07:19:02PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Jan 06, 2015 at 05:53:39PM +0100, Sam Ravnborg wrote:
> > > On Tue, Jan 06, 2015 at 05:44:56PM +0200, Michael S. Tsirkin wrote:
> > > > Macros 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.
> > > 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

OK.
I see David reviewed and sent acks, so I won't bother
reposting, but I'll tweak this in my tree.

> > 
> > > > -#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; \
> > > > +})
> > > 
> > > 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 did not look to carefully - but what I saw looked good.
> 
> > 
> > 
> > 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.

-- 
MST

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 20:23           ` Michael S. Tsirkin
@ 2015-01-06 20:46             ` Sam Ravnborg
  -1 siblings, 0 replies; 128+ messages in thread
From: Sam Ravnborg @ 2015-01-06 20:46 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

> > sparc64: fix coding style in uaccess_64.h
> 
> OK.
> I see David reviewed and sent acks, so I won't bother
> reposting, but I'll tweak this in my tree.
OK.

> > > 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

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 20:46             ` Sam Ravnborg
  0 siblings, 0 replies; 128+ messages in thread
From: Sam Ravnborg @ 2015-01-06 20:46 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

> > sparc64: fix coding style in uaccess_64.h
> 
> OK.
> I see David reviewed and sent acks, so I won't bother
> reposting, but I'll tweak this in my tree.
OK.

> > > 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

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
  2015-01-06 20:46             ` Sam Ravnborg
@ 2015-01-06 21:44               ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:44 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 09:46:07PM +0100, Sam Ravnborg wrote:
> > > sparc64: fix coding style in uaccess_64.h
> > 
> > OK.
> > I see David reviewed and sent acks, so I won't bother
> > reposting, but I'll tweak this in my tree.
> OK.
> 
> > > > 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.

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.

> 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.

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

* Re: [PATCH v2 26/40] arch/sparc: uaccess_64 macro whitespace fixes
@ 2015-01-06 21:44               ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:44 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: linux-kernel, Arnd Bergmann, linux-arch, David S. Miller, sparclinux

On Tue, Jan 06, 2015 at 09:46:07PM +0100, Sam Ravnborg wrote:
> > > sparc64: fix coding style in uaccess_64.h
> > 
> > OK.
> > I see David reviewed and sent acks, so I won't bother
> > reposting, but I'll tweak this in my tree.
> OK.
> 
> > > > 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.

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.

> 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.

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
  2015-01-06 19:14     ` Will Deacon
  (?)
@ 2015-01-06 21:48       ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:48 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> Hi Michael,
> 
> On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > 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 <mst@redhat.com>
> > 
> > Acked-by: Will Deacon <will.deacon@arm.com>
> > ---
> 
> 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.

> >  arch/arm64/include/asm/uaccess.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> > index 3bf8f4e..9a2069b 100644
> > --- a/arch/arm64/include/asm/uaccess.h
> > +++ b/arch/arm64/include/asm/uaccess.h
> > @@ -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)						\
> > -- 
> > MST
> > 
> > 

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 21:48       ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:48 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> Hi Michael,
> 
> On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > 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 <mst@redhat.com>
> > 
> > Acked-by: Will Deacon <will.deacon@arm.com>
> > ---
> 
> 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.

> >  arch/arm64/include/asm/uaccess.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> > index 3bf8f4e..9a2069b 100644
> > --- a/arch/arm64/include/asm/uaccess.h
> > +++ b/arch/arm64/include/asm/uaccess.h
> > @@ -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)						\
> > -- 
> > MST
> > 
> > 

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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 21:48       ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> Hi Michael,
> 
> On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > 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 <mst@redhat.com>
> > 
> > Acked-by: Will Deacon <will.deacon@arm.com>
> > ---
> 
> 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.

> >  arch/arm64/include/asm/uaccess.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> > index 3bf8f4e..9a2069b 100644
> > --- a/arch/arm64/include/asm/uaccess.h
> > +++ b/arch/arm64/include/asm/uaccess.h
> > @@ -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)						\
> > -- 
> > MST
> > 
> > 

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
  2015-01-06 21:48       ` Michael S. Tsirkin
  (?)
@ 2015-01-06 21:51         ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:51 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 11:48:20PM +0200, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> > Hi Michael,
> > 
> > On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > > 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 <mst@redhat.com>
> > > 
> > > Acked-by: Will Deacon <will.deacon@arm.com>
> > > ---
> > 
> > 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.

> > >  arch/arm64/include/asm/uaccess.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> > > index 3bf8f4e..9a2069b 100644
> > > --- a/arch/arm64/include/asm/uaccess.h
> > > +++ b/arch/arm64/include/asm/uaccess.h
> > > @@ -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)						\
> > > -- 
> > > MST
> > > 
> > > 

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 21:51         ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:51 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 11:48:20PM +0200, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> > Hi Michael,
> > 
> > On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > > 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 <mst@redhat.com>
> > > 
> > > Acked-by: Will Deacon <will.deacon@arm.com>
> > > ---
> > 
> > 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.

> > >  arch/arm64/include/asm/uaccess.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> > > index 3bf8f4e..9a2069b 100644
> > > --- a/arch/arm64/include/asm/uaccess.h
> > > +++ b/arch/arm64/include/asm/uaccess.h
> > > @@ -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)						\
> > > -- 
> > > MST
> > > 
> > > 

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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-06 21:51         ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 06, 2015 at 11:48:20PM +0200, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> > Hi Michael,
> > 
> > On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > > 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 <mst@redhat.com>
> > > 
> > > Acked-by: Will Deacon <will.deacon@arm.com>
> > > ---
> > 
> > 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.

> > >  arch/arm64/include/asm/uaccess.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> > > index 3bf8f4e..9a2069b 100644
> > > --- a/arch/arm64/include/asm/uaccess.h
> > > +++ b/arch/arm64/include/asm/uaccess.h
> > > @@ -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)						\
> > > -- 
> > > MST
> > > 
> > > 

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

* Re: [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types
  2015-01-06 19:08 ` [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Arnd Bergmann
@ 2015-01-06 21:54   ` Michael S. Tsirkin
  2015-01-11 11:55   ` Michael S. Tsirkin
  1 sibling, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-06 21:54 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, linux-arch

On Tue, Jan 06, 2015 at 08:08:57PM +0100, Arnd Bergmann wrote:
> 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?

Sure. So I'll wait some then send you a pull request and you'll merge?

> 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.

-- 
MSR

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

* Re: [PATCH v2 40/40] xtensa: macro whitespace fixes
  2015-01-06 15:45 ` [PATCH v2 40/40] xtensa: " Michael S. Tsirkin
@ 2015-01-06 23:12   ` Max Filippov
  0 siblings, 0 replies; 128+ messages in thread
From: Max Filippov @ 2015-01-06 23:12 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: LKML, Arnd Bergmann, Linux-Arch, Chris Zankel, linux-xtensa

On Tue, Jan 6, 2015 at 6:45 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> 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 <mst@redhat.com>
> ---
>  arch/xtensa/include/asm/uaccess.h | 90 +++++++++++++++++++--------------------
>  1 file changed, 45 insertions(+), 45 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

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

* Re: [PATCH v2 24/40] avr32: whitespace fix
  2015-01-06 15:44 ` [PATCH v2 24/40] avr32: whitespace fix Michael S. Tsirkin
@ 2015-01-07  6:50   ` Hans-Christian Egtvedt
  0 siblings, 0 replies; 128+ messages in thread
From: Hans-Christian Egtvedt @ 2015-01-07  6:50 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Haavard Skinnemoen

Around Tue 06 Jan 2015 17:44:50 +0200 or thereabout, Michael S. Tsirkin wrote:
> Align using tabs to make code prettier.
>

It is already aligned using tabs, but there is one too much. Thanks for
cleaning.

> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>

Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>

> ---
>  arch/avr32/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/avr32/include/asm/uaccess.h b/arch/avr32/include/asm/uaccess.h
> index ccd07c4..72607f3 100644
> --- a/arch/avr32/include/asm/uaccess.h
> +++ b/arch/avr32/include/asm/uaccess.h
> @@ -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:						\
-- 
mvh
Hans-Christian Egtvedt

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

* Re: [PATCH v2 32/40] avr32: macro whitespace fixes
  2015-01-06 15:45 ` [PATCH v2 32/40] avr32: " Michael S. Tsirkin
@ 2015-01-07  6:52   ` Hans-Christian Egtvedt
  0 siblings, 0 replies; 128+ messages in thread
From: Hans-Christian Egtvedt @ 2015-01-07  6:52 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Haavard Skinnemoen

Around Tue 06 Jan 2015 17:45:18 +0200 or thereabout, Michael S. Tsirkin wrote:
> 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 (-:

> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>

Acked-by: Hans-Christian Egtvedt <egtvedt@samfundet.no>

> ---
>  arch/avr32/include/asm/uaccess.h | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

<snipp diff>

-- 
mvh
Hans-Christian Egtvedt

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

* Re: [PATCH v2 38/40] s390: macro whitespace fixes
  2015-01-06 15:45 ` [PATCH v2 38/40] s390: " Michael S. Tsirkin
@ 2015-01-07  8:33   ` Heiko Carstens
  2015-01-07  9:07     ` Michael S. Tsirkin
  0 siblings, 1 reply; 128+ messages in thread
From: Heiko Carstens @ 2015-01-07  8:33 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Martin Schwidefsky,
	linux390, linux-s390

On Tue, Jan 06, 2015 at 05:45:38PM +0200, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---
>  arch/s390/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
> index cd4c68e..71b9c40 100644
> --- a/arch/s390/include/asm/uaccess.h
> +++ b/arch/s390/include/asm/uaccess.h
> @@ -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)		\

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


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

* Re: [PATCH v2 38/40] s390: macro whitespace fixes
  2015-01-07  8:33   ` Heiko Carstens
@ 2015-01-07  9:07     ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-07  9:07 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Martin Schwidefsky,
	linux390, linux-s390

On Wed, Jan 07, 2015 at 09:33:39AM +0100, Heiko Carstens wrote:
> On Tue, Jan 06, 2015 at 05:45:38PM +0200, Michael S. Tsirkin wrote:
> > 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 <mst@redhat.com>
> > ---
> >  arch/s390/include/asm/uaccess.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
> > index cd4c68e..71b9c40 100644
> > --- a/arch/s390/include/asm/uaccess.h
> > +++ b/arch/s390/include/asm/uaccess.h
> > @@ -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)		\
> 
> 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

There's always git blame -w. Anyway, I'll drop s390 patches.
Fix it up yourself if you wish.

-- 
MST

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

* Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
@ 2015-01-07  9:47     ` James Hogan
  0 siblings, 0 replies; 128+ messages in thread
From: James Hogan @ 2015-01-07  9:47 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-metag

[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]

Hi Machael,

On 06/01/15 15:43, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---
>  arch/metag/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> index 0748b0a..c314b45 100644
> --- a/arch/metag/include/asm/uaccess.h
> +++ b/arch/metag/include/asm/uaccess.h
> @@ -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.

>  	__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).

>  	__gu_err;                                                       \
>  })
>  
> 

With those changes,
Acked-by: James Hogan <james.hogan@imgtec.com>

Cheers
James


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
@ 2015-01-07  9:47     ` James Hogan
  0 siblings, 0 replies; 128+ messages in thread
From: James Hogan @ 2015-01-07  9:47 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Arnd Bergmann, linux-arch-u79uwXL29TY76Z2rM5mHXA,
	linux-metag-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1865 bytes --]

Hi Machael,

On 06/01/15 15:43, Michael S. Tsirkin wrote:
> 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 <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  arch/metag/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> index 0748b0a..c314b45 100644
> --- a/arch/metag/include/asm/uaccess.h
> +++ b/arch/metag/include/asm/uaccess.h
> @@ -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.

>  	__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).

>  	__gu_err;                                                       \
>  })
>  
> 

With those changes,
Acked-by: James Hogan <james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>

Cheers
James


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
@ 2015-01-07  9:47     ` James Hogan
  0 siblings, 0 replies; 128+ messages in thread
From: James Hogan @ 2015-01-07  9:47 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-metag

[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]

Hi Machael,

On 06/01/15 15:43, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---
>  arch/metag/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> index 0748b0a..c314b45 100644
> --- a/arch/metag/include/asm/uaccess.h
> +++ b/arch/metag/include/asm/uaccess.h
> @@ -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.

>  	__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).

>  	__gu_err;                                                       \
>  })
>  
> 

With those changes,
Acked-by: James Hogan <james.hogan@imgtec.com>

Cheers
James


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 20/40] metag: fix put_user sparse errors
  2015-01-06 15:44 ` [PATCH v2 20/40] metag: " Michael S. Tsirkin
@ 2015-01-07  9:55     ` James Hogan
  0 siblings, 0 replies; 128+ messages in thread
From: James Hogan @ 2015-01-07  9:55 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-metag

[-- Attachment #1: Type: text/plain, Size: 2808 bytes --]

On 06/01/15 15:44, Michael S. Tsirkin wrote:
> 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 <james.hogan@imgtec.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  arch/metag/include/asm/uaccess.h | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> index c314b45..9627c19 100644
> --- a/arch/metag/include/asm/uaccess.h
> +++ b/arch/metag/include/asm/uaccess.h
> @@ -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) {                                         	\

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):

Acked-by: James Hogan <james.hogan@imgtec.com>

Cheers
James

>  	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();					\
>  	}								\
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 20/40] metag: fix put_user sparse errors
@ 2015-01-07  9:55     ` James Hogan
  0 siblings, 0 replies; 128+ messages in thread
From: James Hogan @ 2015-01-07  9:55 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch, linux-metag

[-- Attachment #1: Type: text/plain, Size: 2808 bytes --]

On 06/01/15 15:44, Michael S. Tsirkin wrote:
> 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 <james.hogan@imgtec.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  arch/metag/include/asm/uaccess.h | 21 +++++++++++++--------
>  1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> index c314b45..9627c19 100644
> --- a/arch/metag/include/asm/uaccess.h
> +++ b/arch/metag/include/asm/uaccess.h
> @@ -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) {                                         	\

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):

Acked-by: James Hogan <james.hogan@imgtec.com>

Cheers
James

>  	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();					\
>  	}								\
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
@ 2015-01-07  9:55       ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-07  9:55 UTC (permalink / raw)
  To: James Hogan; +Cc: linux-kernel, Arnd Bergmann, linux-arch, linux-metag

On Wed, Jan 07, 2015 at 09:47:24AM +0000, James Hogan wrote:
> Hi Machael,
> 
> On 06/01/15 15:43, Michael S. Tsirkin wrote:
> > 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 <mst@redhat.com>
> > ---
> >  arch/metag/include/asm/uaccess.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> > index 0748b0a..c314b45 100644
> > --- a/arch/metag/include/asm/uaccess.h
> > +++ b/arch/metag/include/asm/uaccess.h
> > @@ -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.
> >  	__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).

Oops. Sorry. Will fix both. I won't repost unless there are more issues.

> 
> >  	__gu_err;                                                       \
> >  })
> >  
> > 
> 
> With those changes,
> Acked-by: James Hogan <james.hogan@imgtec.com>
> 
> Cheers
> James
> 



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

* Re: [PATCH v2 09/40] metag/uaccess: fix sparse errors
@ 2015-01-07  9:55       ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-07  9:55 UTC (permalink / raw)
  To: James Hogan
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Arnd Bergmann,
	linux-arch-u79uwXL29TY76Z2rM5mHXA,
	linux-metag-u79uwXL29TY76Z2rM5mHXA

On Wed, Jan 07, 2015 at 09:47:24AM +0000, James Hogan wrote:
> Hi Machael,
> 
> On 06/01/15 15:43, Michael S. Tsirkin wrote:
> > 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 <mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > ---
> >  arch/metag/include/asm/uaccess.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/metag/include/asm/uaccess.h b/arch/metag/include/asm/uaccess.h
> > index 0748b0a..c314b45 100644
> > --- a/arch/metag/include/asm/uaccess.h
> > +++ b/arch/metag/include/asm/uaccess.h
> > @@ -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.
> >  	__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).

Oops. Sorry. Will fix both. I won't repost unless there are more issues.

> 
> >  	__gu_err;                                                       \
> >  })
> >  
> > 
> 
> With those changes,
> Acked-by: James Hogan <james.hogan-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
> 
> Cheers
> James
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2 36/40] m68k: macro whitespace fixes
  2015-01-06 15:45 ` [PATCH v2 36/40] m68k: " Michael S. Tsirkin
@ 2015-01-07  9:56   ` Geert Uytterhoeven
  0 siblings, 0 replies; 128+ messages in thread
From: Geert Uytterhoeven @ 2015-01-07  9:56 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Arnd Bergmann, Linux-Arch, Linux/m68k

On Tue, Jan 6, 2015 at 4:45 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> 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 <mst@redhat.com>

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

Gr{oetje,eeting}s,

                        Geert

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

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

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
  2015-01-06 21:51         ` Michael S. Tsirkin
  (?)
@ 2015-01-07 10:09           ` Will Deacon
  -1 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-07 10:09 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 09:51:15PM +0000, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 11:48:20PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> > > Hi Michael,
> > > 
> > > On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > > > 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 <mst@redhat.com>
> > > > 
> > > > Acked-by: Will Deacon <will.deacon@arm.com>
> > > > ---
> > > 
> > > 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.

Ok, I'll go ack that whitespace fix for you to take then.

Will

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

* Re: [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-07 10:09           ` Will Deacon
  0 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-07 10:09 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 09:51:15PM +0000, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 11:48:20PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> > > Hi Michael,
> > > 
> > > On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > > > 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 <mst@redhat.com>
> > > > 
> > > > Acked-by: Will Deacon <will.deacon@arm.com>
> > > > ---
> > > 
> > > 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.

Ok, I'll go ack that whitespace fix for you to take then.

Will

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

* [PATCH v2 03/40] arm64/uaccess: fix sparse errors
@ 2015-01-07 10:09           ` Will Deacon
  0 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-07 10:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 06, 2015 at 09:51:15PM +0000, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 11:48:20PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Jan 06, 2015 at 07:14:32PM +0000, Will Deacon wrote:
> > > Hi Michael,
> > > 
> > > On Tue, Jan 06, 2015 at 03:43:40PM +0000, Michael S. Tsirkin wrote:
> > > > 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 <mst@redhat.com>
> > > > 
> > > > Acked-by: Will Deacon <will.deacon@arm.com>
> > > > ---
> > > 
> > > 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.

Ok, I'll go ack that whitespace fix for you to take then.

Will

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

* Re: [PATCH v2 31/40] arm64: macro whitespace fixes
  2015-01-06 15:45   ` Michael S. Tsirkin
  (?)
@ 2015-01-07 10:10     ` Will Deacon
  -1 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-07 10:10 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 03:45:15PM +0000, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---

Acked-by: Will Deacon <will.deacon@arm.com>

Will

>  arch/arm64/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index 9a2069b..07e1ba44 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -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.
> -- 
> MST
> 
> 

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

* Re: [PATCH v2 31/40] arm64: macro whitespace fixes
@ 2015-01-07 10:10     ` Will Deacon
  0 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-07 10:10 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Catalin Marinas,
	Christopher Covington, linux-arm-kernel

On Tue, Jan 06, 2015 at 03:45:15PM +0000, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---

Acked-by: Will Deacon <will.deacon@arm.com>

Will

>  arch/arm64/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index 9a2069b..07e1ba44 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -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.
> -- 
> MST
> 
> 

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

* [PATCH v2 31/40] arm64: macro whitespace fixes
@ 2015-01-07 10:10     ` Will Deacon
  0 siblings, 0 replies; 128+ messages in thread
From: Will Deacon @ 2015-01-07 10:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 06, 2015 at 03:45:15PM +0000, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---

Acked-by: Will Deacon <will.deacon@arm.com>

Will

>  arch/arm64/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
> index 9a2069b..07e1ba44 100644
> --- a/arch/arm64/include/asm/uaccess.h
> +++ b/arch/arm64/include/asm/uaccess.h
> @@ -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.
> -- 
> MST
> 
> 

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

* Re: [PATCH v2 10/40] microblaze/uaccess: fix sparse errors
  2015-01-06 15:44 ` [PATCH v2 10/40] microblaze/uaccess: " Michael S. Tsirkin
@ 2015-01-07 10:14   ` Michal Simek
  0 siblings, 0 replies; 128+ messages in thread
From: Michal Simek @ 2015-01-07 10:14 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch, Chen Gang

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

On 01/06/2015 04:44 PM, Michael S. Tsirkin wrote:
> 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 <mst@redhat.com>
> ---
>  arch/microblaze/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
> index 59a89a6..e41bebf 100644
> --- a/arch/microblaze/include/asm/uaccess.h
> +++ b/arch/microblaze/include/asm/uaccess.h
> @@ -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;							\
>  })
>  
> 

Applied.

Thanks,
Michal
-- 
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



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH v2 28/40] microblaze: whitespace fix
  2015-01-06 15:45 ` [PATCH v2 28/40] microblaze: whitespace fix Michael S. Tsirkin
@ 2015-01-07 10:14   ` Michal Simek
  0 siblings, 0 replies; 128+ messages in thread
From: Michal Simek @ 2015-01-07 10:14 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch, Chen Gang

[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]

On 01/06/2015 04:45 PM, Michael S. Tsirkin wrote:
> Align using tabs to make code prettier.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  arch/microblaze/include/asm/uaccess.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
> index e41bebf..62942fd 100644
> --- a/arch/microblaze/include/asm/uaccess.h
> +++ b/arch/microblaze/include/asm/uaccess.h
> @@ -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

-- 
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



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH v2 16/40] m68k/uaccess: fix sparse errors
  2015-01-06 15:44 ` [PATCH v2 16/40] m68k/uaccess: " Michael S. Tsirkin
@ 2015-01-07 10:38   ` Geert Uytterhoeven
  0 siblings, 0 replies; 128+ messages in thread
From: Geert Uytterhoeven @ 2015-01-07 10:38 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Arnd Bergmann, Linux-Arch, Linux/m68k

On Tue, Jan 6, 2015 at 4:44 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> 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 <mst@redhat.com>

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

Gr{oetje,eeting}s,

                        Geert

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

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

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

* Re: [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types
  2015-01-06 19:08 ` [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Arnd Bergmann
  2015-01-06 21:54   ` Michael S. Tsirkin
@ 2015-01-11 11:55   ` Michael S. Tsirkin
  2015-01-13 10:19     ` Michael S. Tsirkin
  1 sibling, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-11 11:55 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, linux-arch

On Tue, Jan 06, 2015 at 08:08:57PM +0100, Arnd Bergmann wrote:
> 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

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?

-- 
MST

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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
  2015-01-06 15:44 ` [PATCH v2 22/40] tile: " Michael S. Tsirkin
@ 2015-01-12 21:56     ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-12 21:56 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch

Nack for this patch as-is.

On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> 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 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:

--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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)


> 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.

Maybe because none of the other 32-bit kernel architectures provide
a 64-bit inline for put_user().

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
@ 2015-01-12 21:56     ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-12 21:56 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch

Nack for this patch as-is.

On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> 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 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:

--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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)


> 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.

Maybe because none of the other 32-bit kernel architectures provide
a 64-bit inline for put_user().

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

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

* Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
  2015-01-06 15:44 ` [PATCH v2 23/40] tile: enable sparse checks for get/put_user Michael S. Tsirkin
@ 2015-01-13  0:08     ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-13  0:08 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch

On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> Tile 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.
>
> Signed-off-by: Michael S. Tsirkin<mst@redhat.com>
> ---
>   arch/tile/include/asm/uaccess.h | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
> index 22cffa1..03d905c 100644
> --- a/arch/tile/include/asm/uaccess.h
> +++ b/arch/tile/include/asm/uaccess.h
> @@ -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.

--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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;                                                          \
  

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


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

* Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
@ 2015-01-13  0:08     ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-13  0:08 UTC (permalink / raw)
  To: Michael S. Tsirkin, linux-kernel; +Cc: Arnd Bergmann, linux-arch

On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> Tile 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.
>
> Signed-off-by: Michael S. Tsirkin<mst@redhat.com>
> ---
>   arch/tile/include/asm/uaccess.h | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
> index 22cffa1..03d905c 100644
> --- a/arch/tile/include/asm/uaccess.h
> +++ b/arch/tile/include/asm/uaccess.h
> @@ -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.

--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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;                                                          \
  

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
  2015-01-12 21:56     ` Chris Metcalf
  (?)
@ 2015-01-13  9:35     ` Michael S. Tsirkin
  2015-01-13  9:40       ` Michael S. Tsirkin
  2015-01-13 13:30         ` Chris Metcalf
  -1 siblings, 2 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-13  9:35 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On Mon, Jan 12, 2015 at 04:56:54PM -0500, Chris Metcalf wrote:
> Nack for this patch as-is.
> 
> On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> >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 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.

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.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

---->

diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
index b6cde32..9fcbe6f 100644
--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -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"		\






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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
  2015-01-13  9:35     ` Michael S. Tsirkin
@ 2015-01-13  9:40       ` Michael S. Tsirkin
  2015-01-13 13:30         ` Chris Metcalf
  1 sibling, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-13  9:40 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On Tue, Jan 13, 2015 at 11:35:35AM +0200, Michael S. Tsirkin wrote:
> On Mon, Jan 12, 2015 at 04:56:54PM -0500, Chris Metcalf wrote:
> > Nack for this patch as-is.
> > 
> > On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> > >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 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.
> 
> 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.

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

* Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
  2015-01-13  0:08     ` Chris Metcalf
  (?)
@ 2015-01-13  9:45     ` Michael S. Tsirkin
  2015-01-13 15:55         ` Chris Metcalf
  -1 siblings, 1 reply; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-13  9:45 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On Mon, Jan 12, 2015 at 07:08:36PM -0500, Chris Metcalf wrote:
> On 1/6/2015 10:44 AM, Michael S. Tsirkin wrote:
> >Tile 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.
> >
> >Signed-off-by: Michael S. Tsirkin<mst@redhat.com>
> >---
> >  arch/tile/include/asm/uaccess.h | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> >diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
> >index 22cffa1..03d905c 100644
> >--- a/arch/tile/include/asm/uaccess.h
> >+++ b/arch/tile/include/asm/uaccess.h
> >@@ -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 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.

> 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?

> --- a/arch/tile/include/asm/uaccess.h
> +++ b/arch/tile/include/asm/uaccess.h
> @@ -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));                             \
>         })

This cast to __typeof(x) needs to be done with __force, otherwise
there will be a warning with bitwise types.


> @@ -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;                                   \

And this one too.

>                 __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.


>                 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;                                                          \
> 
> -- 
> Chris Metcalf, EZChip Semiconductor
> http://www.ezchip.com

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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
  2015-01-12 21:56     ` Chris Metcalf
  (?)
  (?)
@ 2015-01-13  9:50     ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-13  9:50 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On Mon, Jan 12, 2015 at 04:56:54PM -0500, Chris Metcalf wrote:
> 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.

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

* Re: [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types
  2015-01-11 11:55   ` Michael S. Tsirkin
@ 2015-01-13 10:19     ` Michael S. Tsirkin
  0 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-13 10:19 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-kernel, linux-arch

On Sun, Jan 11, 2015 at 01:55:04PM +0200, Michael S. Tsirkin wrote:
> On Tue, Jan 06, 2015 at 08:08:57PM +0100, Arnd Bergmann wrote:
> > 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
> 
> 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?

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?

> -- 
> MST

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

* Re: [PATCH v2 01/40] x86/uaccess: fix sparse errors
  2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
@ 2015-01-13 12:33   ` Thomas Gleixner
  0 siblings, 0 replies; 128+ messages in thread
From: Thomas Gleixner @ 2015-01-13 12:33 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Ingo Molnar,
	H. Peter Anvin, x86

On Tue, 6 Jan 2015, Michael S. Tsirkin wrote:

> 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 <mst@redhat.com>

Acked-by: Thomas Gleixner <tglx@linutronix.de>

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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
  2015-01-13  9:35     ` Michael S. Tsirkin
@ 2015-01-13 13:30         ` Chris Metcalf
  2015-01-13 13:30         ` Chris Metcalf
  1 sibling, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-13 13:30 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On 1/13/2015 4:35 AM, Michael S. Tsirkin wrote:
> 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.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


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

* Re: [PATCH v2 22/40] tile: fix put_user sparse errors
@ 2015-01-13 13:30         ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-13 13:30 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On 1/13/2015 4:35 AM, Michael S. Tsirkin wrote:
> 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.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

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

* Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
  2015-01-13  9:45     ` Michael S. Tsirkin
@ 2015-01-13 15:55         ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-13 15:55 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On 1/13/2015 4:45 AM, Michael S. Tsirkin wrote:
> On Mon, Jan 12, 2015 at 07:08:36PM -0500, Chris Metcalf wrote:
>> 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?

I'll fold in your suggestions to my patch.

>> @@ -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.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


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

* Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
@ 2015-01-13 15:55         ` Chris Metcalf
  0 siblings, 0 replies; 128+ messages in thread
From: Chris Metcalf @ 2015-01-13 15:55 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On 1/13/2015 4:45 AM, Michael S. Tsirkin wrote:
> On Mon, Jan 12, 2015 at 07:08:36PM -0500, Chris Metcalf wrote:
>> 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?

I'll fold in your suggestions to my patch.

>> @@ -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.

-- 
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

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

* Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user
  2015-01-13 15:55         ` Chris Metcalf
  (?)
@ 2015-01-13 16:05         ` Michael S. Tsirkin
  -1 siblings, 0 replies; 128+ messages in thread
From: Michael S. Tsirkin @ 2015-01-13 16:05 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel, Arnd Bergmann, linux-arch

On Tue, Jan 13, 2015 at 10:55:26AM -0500, Chris Metcalf wrote:
> On 1/13/2015 4:45 AM, Michael S. Tsirkin wrote:
> >On Mon, Jan 12, 2015 at 07:08:36PM -0500, Chris Metcalf wrote:
> >>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?
> 
> I'll fold in your suggestions to my patch.
> 
> >>@@ -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.

Sure.

> -- 
> Chris Metcalf, EZChip Semiconductor
> http://www.ezchip.com

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

* Re: [PATCH v2 06/40] cris/uaccess: fix sparse errors
  2015-01-06 15:43 ` [PATCH v2 06/40] cris/uaccess: " Michael S. Tsirkin
@ 2015-01-27 16:27   ` Jesper Nilsson
  0 siblings, 0 replies; 128+ messages in thread
From: Jesper Nilsson @ 2015-01-27 16:27 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Mikael Starvik,
	Jesper Nilsson, linux-cris-kernel

On Tue, Jan 06, 2015 at 04:43:50PM +0100, Michael S. Tsirkin wrote:
> 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

> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  arch/cris/include/asm/uaccess.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/cris/include/asm/uaccess.h b/arch/cris/include/asm/uaccess.h
> index 9145408..9cf5a23 100644
> --- a/arch/cris/include/asm/uaccess.h
> +++ b/arch/cris/include/asm/uaccess.h
> @@ -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;							\
>  })
>  
> -- 
> MST

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

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

* Re: [PATCH v2 33/40] cris: macro whitespace fixes
  2015-01-06 15:45 ` [PATCH v2 33/40] cris: " Michael S. Tsirkin
@ 2015-01-27 16:28   ` Jesper Nilsson
  0 siblings, 0 replies; 128+ messages in thread
From: Jesper Nilsson @ 2015-01-27 16:28 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: linux-kernel, Arnd Bergmann, linux-arch, Mikael Starvik,
	Jesper Nilsson, linux-cris-kernel

On Tue, Jan 06, 2015 at 04:45:21PM +0100, Michael S. Tsirkin wrote:
> 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.

> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

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

end of thread, other threads:[~2015-01-27 16:28 UTC | newest]

Thread overview: 128+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06 15:43 [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 01/40] x86/uaccess: fix sparse errors Michael S. Tsirkin
2015-01-13 12:33   ` Thomas Gleixner
2015-01-06 15:43 ` [PATCH v2 02/40] alpha/uaccess: " Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 03/40] arm64/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 19:14   ` Will Deacon
2015-01-06 19:14     ` Will Deacon
2015-01-06 19:14     ` Will Deacon
2015-01-06 21:48     ` Michael S. Tsirkin
2015-01-06 21:48       ` Michael S. Tsirkin
2015-01-06 21:48       ` Michael S. Tsirkin
2015-01-06 21:51       ` Michael S. Tsirkin
2015-01-06 21:51         ` Michael S. Tsirkin
2015-01-06 21:51         ` Michael S. Tsirkin
2015-01-07 10:09         ` Will Deacon
2015-01-07 10:09           ` Will Deacon
2015-01-07 10:09           ` Will Deacon
2015-01-06 15:43 ` [PATCH v2 04/40] avr32/uaccess: " Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 05/40] blackfin/uaccess: " Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 06/40] cris/uaccess: " Michael S. Tsirkin
2015-01-27 16:27   ` Jesper Nilsson
2015-01-06 15:43 ` [PATCH v2 07/40] ia64/uaccess: " Michael S. Tsirkin
2015-01-06 15:43   ` Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 08/40] m32r/uaccess: " Michael S. Tsirkin
2015-01-06 15:43 ` [PATCH v2 09/40] metag/uaccess: " Michael S. Tsirkin
2015-01-07  9:47   ` James Hogan
2015-01-07  9:47     ` James Hogan
2015-01-07  9:47     ` James Hogan
2015-01-07  9:55     ` Michael S. Tsirkin
2015-01-07  9:55       ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 10/40] microblaze/uaccess: " Michael S. Tsirkin
2015-01-07 10:14   ` Michal Simek
2015-01-06 15:44 ` [PATCH v2 11/40] openrisc/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 12/40] parisc/uaccess: " Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 13/40] sh/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 14/40] sparc32/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 18:21   ` David Miller
2015-01-06 18:21     ` David Miller
2015-01-06 15:44 ` [PATCH v2 15/40] sparc64/uaccess: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 18:21   ` David Miller
2015-01-06 18:21     ` David Miller
2015-01-06 15:44 ` [PATCH v2 16/40] m68k/uaccess: " Michael S. Tsirkin
2015-01-07 10:38   ` Geert Uytterhoeven
2015-01-06 15:44 ` [PATCH v2 17/40] arm: fix put_user " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 18/40] blackfin: " Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 19/40] ia64: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 20/40] metag: " Michael S. Tsirkin
2015-01-07  9:55   ` James Hogan
2015-01-07  9:55     ` James Hogan
2015-01-06 15:44 ` [PATCH v2 21/40] sh: " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 22/40] tile: " Michael S. Tsirkin
2015-01-12 21:56   ` Chris Metcalf
2015-01-12 21:56     ` Chris Metcalf
2015-01-13  9:35     ` Michael S. Tsirkin
2015-01-13  9:40       ` Michael S. Tsirkin
2015-01-13 13:30       ` Chris Metcalf
2015-01-13 13:30         ` Chris Metcalf
2015-01-13  9:50     ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 23/40] tile: enable sparse checks for get/put_user Michael S. Tsirkin
2015-01-13  0:08   ` Chris Metcalf
2015-01-13  0:08     ` Chris Metcalf
2015-01-13  9:45     ` Michael S. Tsirkin
2015-01-13 15:55       ` Chris Metcalf
2015-01-13 15:55         ` Chris Metcalf
2015-01-13 16:05         ` Michael S. Tsirkin
2015-01-06 15:44 ` [PATCH v2 24/40] avr32: whitespace fix Michael S. Tsirkin
2015-01-07  6:50   ` Hans-Christian Egtvedt
2015-01-06 15:44 ` [PATCH v2 25/40] arch/sparc: uaccess_32 macro whitespace fixes Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 18:22   ` David Miller
2015-01-06 18:22     ` David Miller
2015-01-06 15:44 ` [PATCH v2 26/40] arch/sparc: uaccess_64 " Michael S. Tsirkin
2015-01-06 15:44   ` Michael S. Tsirkin
2015-01-06 16:53   ` Sam Ravnborg
2015-01-06 16:53     ` Sam Ravnborg
2015-01-06 17:19     ` Michael S. Tsirkin
2015-01-06 17:19       ` Michael S. Tsirkin
2015-01-06 18:27       ` Sam Ravnborg
2015-01-06 18:27         ` Sam Ravnborg
2015-01-06 20:23         ` Michael S. Tsirkin
2015-01-06 20:23           ` Michael S. Tsirkin
2015-01-06 20:46           ` Sam Ravnborg
2015-01-06 20:46             ` Sam Ravnborg
2015-01-06 21:44             ` Michael S. Tsirkin
2015-01-06 21:44               ` Michael S. Tsirkin
2015-01-06 18:22   ` David Miller
2015-01-06 18:22     ` David Miller
2015-01-06 15:45 ` [PATCH v2 27/40] blackfin: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 28/40] microblaze: whitespace fix Michael S. Tsirkin
2015-01-07 10:14   ` Michal Simek
2015-01-06 15:45 ` [PATCH v2 29/40] alpha: macro whitespace fixes Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 30/40] arm: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 31/40] arm64: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-07 10:10   ` Will Deacon
2015-01-07 10:10     ` Will Deacon
2015-01-07 10:10     ` Will Deacon
2015-01-06 15:45 ` [PATCH v2 32/40] avr32: " Michael S. Tsirkin
2015-01-07  6:52   ` Hans-Christian Egtvedt
2015-01-06 15:45 ` [PATCH v2 33/40] cris: " Michael S. Tsirkin
2015-01-27 16:28   ` Jesper Nilsson
2015-01-06 15:45 ` [PATCH v2 34/40] frv: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 35/40] m32r: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 36/40] m68k: " Michael S. Tsirkin
2015-01-07  9:56   ` Geert Uytterhoeven
2015-01-06 15:45 ` [PATCH v2 37/40] parisc: " Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 38/40] s390: " Michael S. Tsirkin
2015-01-07  8:33   ` Heiko Carstens
2015-01-07  9:07     ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 39/40] sh: " Michael S. Tsirkin
2015-01-06 15:45   ` Michael S. Tsirkin
2015-01-06 15:45 ` [PATCH v2 40/40] xtensa: " Michael S. Tsirkin
2015-01-06 23:12   ` Max Filippov
2015-01-06 19:08 ` [PATCH v2 00/40] uaccess: fix sparse warning on get/put_user for bitwise types Arnd Bergmann
2015-01-06 21:54   ` Michael S. Tsirkin
2015-01-11 11:55   ` Michael S. Tsirkin
2015-01-13 10:19     ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.