lkml.org 
[lkml]   [2008]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 33/39] merge __get_user_asm and its users.
    Date
    Move __get_user_asm and __get_user_size and __get_user_nocheck
    to uaccess.h. This requires us to define a macro at __get_user_size
    for the 64-bit access case.

    Signed-off-by: Glauber Costa <gcosta@redhat.com>
    ---
    include/asm-x86/uaccess.h | 50 +++++++++++++++++++++++++++++++++++++++++-
    include/asm-x86/uaccess_32.h | 41 ----------------------------------
    include/asm-x86/uaccess_64.h | 43 ------------------------------------
    3 files changed, 49 insertions(+), 85 deletions(-)

    diff --git a/include/asm-x86/uaccess.h b/include/asm-x86/uaccess.h
    index 8479be3..4ff31c5 100644
    --- a/include/asm-x86/uaccess.h
    +++ b/include/asm-x86/uaccess.h
    @@ -234,6 +234,47 @@ do { \

    #endif

    +#ifdef CONFIG_X86_32
    +#define __get_user_asm_u64(x, ptr, retval, errret) (x) = __get_user_bad()
    +#else
    +#define __get_user_asm_u64(x, ptr, retval, errret) \
    + __get_user_asm(x, ptr, retval, "q", "", "=r", errret)
    +#endif
    +
    +#define __get_user_size(x, ptr, size, retval, errret) \
    +do { \
    + retval = 0; \
    + __chk_user_ptr(ptr); \
    + switch (size) { \
    + case 1: \
    + __get_user_asm(x, ptr, retval, "b", "b", "=q", errret); \
    + break; \
    + case 2: \
    + __get_user_asm(x, ptr, retval, "w", "w", "=r", errret); \
    + break; \
    + case 4: \
    + __get_user_asm(x, ptr, retval, "l", "k", "=r", errret); \
    + break; \
    + case 8: \
    + __get_user_asm_u64(x, ptr, retval, errret); \
    + break; \
    + default: \
    + (x) = __get_user_bad(); \
    + } \
    +} while (0)
    +
    +#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
    + asm volatile("1: mov"itype" %2,%"rtype"1\n" \
    + "2:\n" \
    + ".section .fixup,\"ax\"\n" \
    + "3: mov %3,%0\n" \
    + " xor"itype" %"rtype"1,%"rtype"1\n" \
    + " jmp 2b\n" \
    + ".previous\n" \
    + _ASM_EXTABLE(1b, 3b) \
    + : "=r" (err), ltype(x) \
    + : "m" (__m(addr)), "i" (errret), "0" (err))
    +
    #define __put_user_nocheck(x, ptr, size) \
    ({ \
    long __pu_err; \
    @@ -241,7 +282,14 @@ do { \
    __pu_err; \
    })

    -
    +#define __get_user_nocheck(x, ptr, size) \
    +({ \
    + long __gu_err; \
    + unsigned long __gu_val; \
    + __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
    + (x) = (__force __typeof__(*(ptr)))__gu_val; \
    + __gu_err; \
    +})

    /* FIXME: this hack is definitely wrong -AK */
    struct __large_struct { unsigned long buf[100]; };
    diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h
    index fab7557..ebfe6b2 100644
    --- a/include/asm-x86/uaccess_32.h
    +++ b/include/asm-x86/uaccess_32.h
    @@ -145,47 +145,6 @@ extern void __put_user_8(void);
    #define __put_user(x, ptr) \
    __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))

    -#define __get_user_nocheck(x, ptr, size) \
    -({ \
    - long __gu_err; \
    - unsigned long __gu_val; \
    - __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
    - (x) = (__typeof__(*(ptr)))__gu_val; \
    - __gu_err; \
    -})
    -
    -#define __get_user_size(x, ptr, size, retval, errret) \
    -do { \
    - retval = 0; \
    - __chk_user_ptr(ptr); \
    - switch (size) { \
    - case 1: \
    - __get_user_asm(x, ptr, retval, "b", "b", "=q", errret); \
    - break; \
    - case 2: \
    - __get_user_asm(x, ptr, retval, "w", "w", "=r", errret); \
    - break; \
    - case 4: \
    - __get_user_asm(x, ptr, retval, "l", "", "=r", errret); \
    - break; \
    - default: \
    - (x) = __get_user_bad(); \
    - } \
    -} while (0)
    -
    -#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
    - asm volatile("1: mov"itype" %2,%"rtype"1\n" \
    - "2:\n" \
    - ".section .fixup,\"ax\"\n" \
    - "3: movl %3,%0\n" \
    - " xor"itype" %"rtype"1,%"rtype"1\n" \
    - " jmp 2b\n" \
    - ".previous\n" \
    - _ASM_EXTABLE(1b, 3b) \
    - : "=r" (err), ltype (x) \
    - : "m" (__m(addr)), "i" (errret), "0" (err))
    -
    -
    unsigned long __must_check __copy_to_user_ll
    (void __user *to, const void *from, unsigned long n);
    unsigned long __must_check __copy_from_user_ll
    diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h
    index e0875d7..42a9769 100644
    --- a/include/asm-x86/uaccess_64.h
    +++ b/include/asm-x86/uaccess_64.h
    @@ -57,49 +57,6 @@ extern void __put_user_bad(void);
    __pu_err; \
    })

    -#define __get_user_nocheck(x, ptr, size) \
    -({ \
    - int __gu_err; \
    - unsigned long __gu_val; \
    - __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT);\
    - (x) = (__force typeof(*(ptr)))__gu_val; \
    - __gu_err; \
    -})
    -
    -#define __get_user_size(x, ptr, size, retval, errret) \
    -do { \
    - retval = 0; \
    - __chk_user_ptr(ptr); \
    - switch (size) { \
    - case 1: \
    - __get_user_asm(x, ptr, retval, "b", "b", "=q", errret);\
    - break; \
    - case 2: \
    - __get_user_asm(x, ptr, retval, "w", "w", "=r", errret);\
    - break; \
    - case 4: \
    - __get_user_asm(x, ptr, retval, "l", "k", "=r", errret);\
    - break; \
    - case 8: \
    - __get_user_asm(x, ptr, retval, "q", "", "=r", errret); \
    - break; \
    - default: \
    - (x) = __get_user_bad(); \
    - } \
    -} while (0)
    -
    -#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \
    - asm volatile("1: mov"itype" %2,%"rtype"1\n" \
    - "2:\n" \
    - ".section .fixup, \"ax\"\n" \
    - "3: mov %3,%0\n" \
    - " xor"itype" %"rtype"1,%"rtype"1\n" \
    - " jmp 2b\n" \
    - ".previous\n" \
    - _ASM_EXTABLE(1b, 3b) \
    - : "=r" (err), ltype (x) \
    - : "m" (__m(addr)), "i"(errno), "0"(err))
    -
    /*
    * Copy To/From Userspace
    */
    --
    1.5.5.1


    \
     
     \ /
      Last update: 2008-06-27 23:53    [W:0.034 / U:29.176 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site