Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 643165c8 authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

Merge tag 'uaccess_for_upstream' of...

Merge tag 'uaccess_for_upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

 into asm-generic

Merge "uaccess: fix sparse warning on get/put_user for bitwise types" from Michael S. Tsirkin:

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)
might 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.
Included patches to fix them up.

Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>

* tag 'uaccess_for_upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (37 commits)
  sparc32: nocheck uaccess coding style tweaks
  sparc64: nocheck uaccess coding style tweaks
  xtensa: macro whitespace fixes
  sh: macro whitespace fixes
  parisc: macro whitespace fixes
  m68k: macro whitespace fixes
  m32r: macro whitespace fixes
  frv: macro whitespace fixes
  cris: macro whitespace fixes
  avr32: macro whitespace fixes
  arm64: macro whitespace fixes
  arm: macro whitespace fixes
  alpha: macro whitespace fixes
  blackfin: macro whitespace fixes
  sparc64: uaccess_64 macro whitespace fixes
  sparc32: uaccess_32 macro whitespace fixes
  avr32: whitespace fix
  sh: fix put_user sparse errors
  metag: fix put_user sparse errors
  ia64: fix put_user sparse errors
  ...
parents eaa27f34 0795cb1b
Loading
Loading
Loading
Loading
+43 −43
Original line number Diff line number Diff line
@@ -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;							\
})

+48 −48
Original line number Diff line number Diff line
@@ -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);	\
})
+2 −2
Original line number Diff line number Diff line
@@ -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)						\
+12 −12
Original line number Diff line number Diff line
@@ -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;							\
})

+16 −16
Original line number Diff line number Diff line
@@ -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();		\
@@ -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;							\
})

Loading