Skip to content

Commit

Permalink
s390/uaccess: normalize order of parameters of indirect uaccess funct…
Browse files Browse the repository at this point in the history
…ion calls

For some unknown reason the indirect uaccess functions on s390 implement a
different parameter order than what is usual.

e.g.:

unsigned long copy_to_user(void *to, const void *from, unsigned long n);
vs.
size_t (*copy_to_user)(size_t n, void __user * to, const void *from);

Let's get rid of this confusing parameter reordering.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Heiko Carstens authored and Martin Schwidefsky committed Feb 21, 2014
1 parent 137a14f commit cfa785e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 54 deletions.
54 changes: 27 additions & 27 deletions arch/s390/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ static inline unsigned long extable_fixup(const struct exception_table_entry *x)
#define ARCH_HAS_SEARCH_EXTABLE

struct uaccess_ops {
size_t (*copy_from_user)(size_t, const void __user *, void *);
size_t (*copy_to_user)(size_t, void __user *, const void *);
size_t (*copy_in_user)(size_t, void __user *, const void __user *);
size_t (*clear_user)(size_t, void __user *);
size_t (*strnlen_user)(size_t, const char __user *);
size_t (*strncpy_from_user)(size_t, const char __user *, char *);
size_t (*copy_from_user)(void *, const void __user *, size_t);
size_t (*copy_to_user)(void __user *, const void *, size_t);
size_t (*copy_in_user)(void __user *, const void __user *, size_t);
size_t (*clear_user)(void __user *, size_t);
size_t (*strnlen_user)(const char __user *, size_t);
size_t (*strncpy_from_user)(char *, const char __user *, size_t);
int (*futex_atomic_op)(int op, u32 __user *, int oparg, int *old);
int (*futex_atomic_cmpxchg)(u32 *, u32 __user *, u32 old, u32 new);
};
Expand All @@ -109,15 +109,15 @@ extern struct uaccess_ops uaccess_pt;

extern int __handle_fault(unsigned long, unsigned long, int);

static inline int __put_user_fn(size_t size, void __user *ptr, void *x)
static inline int __put_user_fn(void *x, void __user *ptr, size_t size)
{
size = uaccess.copy_to_user(size, ptr, x);
size = uaccess.copy_to_user(ptr, x, size);
return size ? -EFAULT : size;
}

static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
static inline int __get_user_fn(void *x, const void __user *ptr, size_t size)
{
size = uaccess.copy_from_user(size, ptr, x);
size = uaccess.copy_from_user(x, ptr, size);
return size ? -EFAULT : size;
}

Expand All @@ -135,8 +135,8 @@ static inline int __get_user_fn(size_t size, const void __user *ptr, void *x)
case 2: \
case 4: \
case 8: \
__pu_err = __put_user_fn(sizeof (*(ptr)), \
ptr, &__x); \
__pu_err = __put_user_fn(&__x, ptr, \
sizeof(*(ptr))); \
break; \
default: \
__put_user_bad(); \
Expand All @@ -161,29 +161,29 @@ extern int __put_user_bad(void) __attribute__((noreturn));
switch (sizeof(*(ptr))) { \
case 1: { \
unsigned char __x; \
__gu_err = __get_user_fn(sizeof (*(ptr)), \
ptr, &__x); \
__gu_err = __get_user_fn(&__x, ptr, \
sizeof(*(ptr))); \
(x) = *(__force __typeof__(*(ptr)) *) &__x; \
break; \
}; \
case 2: { \
unsigned short __x; \
__gu_err = __get_user_fn(sizeof (*(ptr)), \
ptr, &__x); \
__gu_err = __get_user_fn(&__x, ptr, \
sizeof(*(ptr))); \
(x) = *(__force __typeof__(*(ptr)) *) &__x; \
break; \
}; \
case 4: { \
unsigned int __x; \
__gu_err = __get_user_fn(sizeof (*(ptr)), \
ptr, &__x); \
__gu_err = __get_user_fn(&__x, ptr, \
sizeof(*(ptr))); \
(x) = *(__force __typeof__(*(ptr)) *) &__x; \
break; \
}; \
case 8: { \
unsigned long long __x; \
__gu_err = __get_user_fn(sizeof (*(ptr)), \
ptr, &__x); \
__gu_err = __get_user_fn(&__x, ptr, \
sizeof(*(ptr))); \
(x) = *(__force __typeof__(*(ptr)) *) &__x; \
break; \
}; \
Expand Down Expand Up @@ -222,7 +222,7 @@ extern int __get_user_bad(void) __attribute__((noreturn));
static inline unsigned long __must_check
__copy_to_user(void __user *to, const void *from, unsigned long n)
{
return uaccess.copy_to_user(n, to, from);
return uaccess.copy_to_user(to, from, n);
}

#define __copy_to_user_inatomic __copy_to_user
Expand Down Expand Up @@ -268,7 +268,7 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
static inline unsigned long __must_check
__copy_from_user(void *to, const void __user *from, unsigned long n)
{
return uaccess.copy_from_user(n, from, to);
return uaccess.copy_from_user(to, from, n);
}

extern void copy_from_user_overflow(void)
Expand Down Expand Up @@ -309,7 +309,7 @@ copy_from_user(void *to, const void __user *from, unsigned long n)
static inline unsigned long __must_check
__copy_in_user(void __user *to, const void __user *from, unsigned long n)
{
return uaccess.copy_in_user(n, to, from);
return uaccess.copy_in_user(to, from, n);
}

static inline unsigned long __must_check
Expand All @@ -326,14 +326,14 @@ static inline long __must_check
strncpy_from_user(char *dst, const char __user *src, long count)
{
might_fault();
return uaccess.strncpy_from_user(count, src, dst);
return uaccess.strncpy_from_user(dst, src, count);
}

static inline unsigned long
strnlen_user(const char __user * src, unsigned long n)
{
might_fault();
return uaccess.strnlen_user(n, src);
return uaccess.strnlen_user(src, n);
}

/**
Expand All @@ -359,14 +359,14 @@ strnlen_user(const char __user * src, unsigned long n)
static inline unsigned long __must_check
__clear_user(void __user *to, unsigned long n)
{
return uaccess.clear_user(n, to);
return uaccess.clear_user(to, n);
}

static inline unsigned long __must_check
clear_user(void __user *to, unsigned long n)
{
might_fault();
return uaccess.clear_user(n, to);
return uaccess.clear_user(to, n);
}

extern int copy_to_user_real(void __user *dest, void *src, size_t count);
Expand Down
20 changes: 10 additions & 10 deletions arch/s390/lib/uaccess_mvcos.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define SLR "slgr"
#endif

static size_t copy_from_user_mvcos(size_t size, const void __user *ptr, void *x)
static size_t copy_from_user_mvcos(void *x, const void __user *ptr, size_t size)
{
register unsigned long reg0 asm("0") = 0x81UL;
unsigned long tmp1, tmp2;
Expand Down Expand Up @@ -65,7 +65,7 @@ static size_t copy_from_user_mvcos(size_t size, const void __user *ptr, void *x)
return size;
}

static size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x)
static size_t copy_to_user_mvcos(void __user *ptr, const void *x, size_t size)
{
register unsigned long reg0 asm("0") = 0x810000UL;
unsigned long tmp1, tmp2;
Expand Down Expand Up @@ -94,8 +94,8 @@ static size_t copy_to_user_mvcos(size_t size, void __user *ptr, const void *x)
return size;
}

static size_t copy_in_user_mvcos(size_t size, void __user *to,
const void __user *from)
static size_t copy_in_user_mvcos(void __user *to, const void __user *from,
size_t size)
{
register unsigned long reg0 asm("0") = 0x810081UL;
unsigned long tmp1, tmp2;
Expand All @@ -117,7 +117,7 @@ static size_t copy_in_user_mvcos(size_t size, void __user *to,
return size;
}

static size_t clear_user_mvcos(size_t size, void __user *to)
static size_t clear_user_mvcos(void __user *to, size_t size)
{
register unsigned long reg0 asm("0") = 0x810000UL;
unsigned long tmp1, tmp2;
Expand Down Expand Up @@ -145,7 +145,7 @@ static size_t clear_user_mvcos(size_t size, void __user *to)
return size;
}

static size_t strnlen_user_mvcos(size_t count, const char __user *src)
static size_t strnlen_user_mvcos(const char __user *src, size_t count)
{
size_t done, len, offset, len_str;
char buf[256];
Expand All @@ -155,7 +155,7 @@ static size_t strnlen_user_mvcos(size_t count, const char __user *src)
offset = (size_t)src & ~PAGE_MASK;
len = min(256UL, PAGE_SIZE - offset);
len = min(count - done, len);
if (copy_from_user_mvcos(len, src, buf))
if (copy_from_user_mvcos(buf, src, len))
return 0;
len_str = strnlen(buf, len);
done += len_str;
Expand All @@ -164,8 +164,8 @@ static size_t strnlen_user_mvcos(size_t count, const char __user *src)
return done + 1;
}

static size_t strncpy_from_user_mvcos(size_t count, const char __user *src,
char *dst)
static size_t strncpy_from_user_mvcos(char *dst, const char __user *src,
size_t count)
{
size_t done, len, offset, len_str;

Expand All @@ -175,7 +175,7 @@ static size_t strncpy_from_user_mvcos(size_t count, const char __user *src,
do {
offset = (size_t)src & ~PAGE_MASK;
len = min(count - done, PAGE_SIZE - offset);
if (copy_from_user_mvcos(len, src, dst))
if (copy_from_user_mvcos(dst, src, len))
return -EFAULT;
len_str = strnlen(dst, len);
done += len_str;
Expand Down
34 changes: 17 additions & 17 deletions arch/s390/lib/uaccess_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define SLR "slgr"
#endif

static size_t strnlen_kernel(size_t count, const char __user *src)
static size_t strnlen_kernel(const char __user *src, size_t count)
{
register unsigned long reg0 asm("0") = 0UL;
unsigned long tmp1, tmp2;
Expand All @@ -42,8 +42,8 @@ static size_t strnlen_kernel(size_t count, const char __user *src)
return count;
}

static size_t copy_in_kernel(size_t count, void __user *to,
const void __user *from)
static size_t copy_in_kernel(void __user *to, const void __user *from,
size_t count)
{
unsigned long tmp1;

Expand Down Expand Up @@ -211,26 +211,26 @@ static __always_inline unsigned long __dat_user_addr(unsigned long uaddr,
return 0;
}

static size_t copy_from_user_pt(size_t n, const void __user *from, void *to)
static size_t copy_from_user_pt(void *to, const void __user *from, size_t n)
{
size_t rc;

if (segment_eq(get_fs(), KERNEL_DS))
return copy_in_kernel(n, (void __user *) to, from);
return copy_in_kernel((void __user *) to, from, n);
rc = __user_copy_pt((unsigned long) from, to, n, 0);
if (unlikely(rc))
memset(to + n - rc, 0, rc);
return rc;
}

static size_t copy_to_user_pt(size_t n, void __user *to, const void *from)
static size_t copy_to_user_pt(void __user *to, const void *from, size_t n)
{
if (segment_eq(get_fs(), KERNEL_DS))
return copy_in_kernel(n, to, (void __user *) from);
return copy_in_kernel(to, (void __user *) from, n);
return __user_copy_pt((unsigned long) to, (void *) from, n, 1);
}

static size_t clear_user_pt(size_t n, void __user *to)
static size_t clear_user_pt(void __user *to, size_t n)
{
void *zpage = (void *) empty_zero_page;
long done, size, ret;
Expand All @@ -242,7 +242,7 @@ static size_t clear_user_pt(size_t n, void __user *to)
else
size = n - done;
if (segment_eq(get_fs(), KERNEL_DS))
ret = copy_in_kernel(n, to, (void __user *) zpage);
ret = copy_in_kernel(to, (void __user *) zpage, n);
else
ret = __user_copy_pt((unsigned long) to, zpage, size, 1);
done += size;
Expand All @@ -253,7 +253,7 @@ static size_t clear_user_pt(size_t n, void __user *to)
return 0;
}

static size_t strnlen_user_pt(size_t count, const char __user *src)
static size_t strnlen_user_pt(const char __user *src, size_t count)
{
unsigned long uaddr = (unsigned long) src;
struct mm_struct *mm = current->mm;
Expand All @@ -263,7 +263,7 @@ static size_t strnlen_user_pt(size_t count, const char __user *src)
if (unlikely(!count))
return 0;
if (segment_eq(get_fs(), KERNEL_DS))
return strnlen_kernel(count, src);
return strnlen_kernel(src, count);
if (!mm)
return 0;
done = 0;
Expand All @@ -289,8 +289,8 @@ static size_t strnlen_user_pt(size_t count, const char __user *src)
goto retry;
}

static size_t strncpy_from_user_pt(size_t count, const char __user *src,
char *dst)
static size_t strncpy_from_user_pt(char *dst, const char __user *src,
size_t count)
{
size_t done, len, offset, len_str;

Expand All @@ -301,7 +301,7 @@ static size_t strncpy_from_user_pt(size_t count, const char __user *src,
offset = (size_t)src & ~PAGE_MASK;
len = min(count - done, PAGE_SIZE - offset);
if (segment_eq(get_fs(), KERNEL_DS)) {
if (copy_in_kernel(len, (void __user *) dst, src))
if (copy_in_kernel((void __user *) dst, src, len))
return -EFAULT;
} else {
if (__user_copy_pt((unsigned long) src, dst, len, 0))
Expand All @@ -315,8 +315,8 @@ static size_t strncpy_from_user_pt(size_t count, const char __user *src,
return done;
}

static size_t copy_in_user_pt(size_t n, void __user *to,
const void __user *from)
static size_t copy_in_user_pt(void __user *to, const void __user *from,
size_t n)
{
struct mm_struct *mm = current->mm;
unsigned long offset_max, uaddr, done, size, error_code;
Expand All @@ -326,7 +326,7 @@ static size_t copy_in_user_pt(size_t n, void __user *to,
int write_user;

if (segment_eq(get_fs(), KERNEL_DS))
return copy_in_kernel(n, to, from);
return copy_in_kernel(to, from, n);
if (!mm)
return n;
done = 0;
Expand Down

0 comments on commit cfa785e

Please sign in to comment.