MM gurus help request
Hi all,
To manage put_user(x, ptr) with x a 64bits (long long), I found another way to access the address of x and suggest following solution.
uaccess.h renamed from uaccess.h.orig +39 -2
@@ -35,10 +35,13 @@#define get_user __get_user#if BITS_PER_LONG ==32 +#define LDD_KERNEL (ptr) BUG()#define LDD_USER (ptr) BUG() -#define STD_KERNEL (x, ptr) BUG() -#define STD_USER (x, ptr) BUG() +#define STD_KERNEL (x, ptr) __put_kernel_asm_64(x, ptr) + +#define STD_USER (x, ptr) __put_user_asm_64(x, ptr) +#else #define LDD_KERNEL (ptr) __get_kernel_asm("ldd",ptr)#define LDD_USER (ptr) __get_user_asm("ldd",ptr)
@@ -137,6 +140,7 @@#define __put_user (x,ptr) \ ({ \ register long __pu_err __asm__ ("r8") = 0; \ + register long long * __tmp = 0; \ \ if (segment_eq(get_fs(),KERNEL_DS)) { \ switch (sizeof(*(ptr))) { \
@@ -200,6 +204,22 @@ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err)) +#define __put_kernel_asm_64 (x, ptr) \ + __asm__ __volatile__ ( \ + "\n\tldw\t0(%2),%3\n" \ + "1:\tstw\t%3,0(%1)\n" \ + "\tldw\t4(%2),%3\n" \ + "2:\tstw\t%3,4(%1)\n" \ + "3:\n" \ + "\t.section __ex_table,\"a\"\n" \ + "\t.word\t1b\n" \ + "\t.word\t(3b-1b)+1\n" \ + "\t.word\t2b\n" \ + "\t.word\t(3b-2b)+1\n" \ + "\t.previous" \ + : "=r"(__pu_err) \ + : "r"(ptr), "r"(&x), "r"(__tmp), "0"(__pu_err)) +#define __put_user_asm (stx,x,ptr) \ __asm__ __volatile__ ( \ "\n1:\t" stx "\t%2,0(%%sr3,%1)\n" \
@@ -210,6 +230,23 @@ "\t.previous" \ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err)) + +#define __put_user_asm_64(x, ptr) \ + __asm__ __volatile__ ( \ +"\n\tldw\t0(%%sr3,%2),%3\n" \ +"1:\tstw\t%3,0(%%sr3,%1)\n" \ +"\tldw\t4(%%sr3,%2),%3\n" \ +"2:\tstw\t%3,4(%%sr3,%1)\n" \ +"3:\n" \ +"\t.section __ex_table,\"a\"\n" \ +"\t.word\t1b\n" \ +"\t.word\t(3b-1b)+1\n" \ +"\t.word\t2b\n" \ +"\t.word\t(3b-2b)+1\n" \ +"\t.previous" \ + :"=r" (__pu_err) \ + : "r"(ptr), "r"(&x), "r"(__tmp), "0"(__pu_err)) +#endif
Could a mm gurus help me to check if I do not break memory management?
Thanks in advance for additional help,
Joel
Sorry it is bad :(
Quoted 4 lines
Hi all,
To manage
put_user(x, ptr)with x a 64bits (long long), I found another
way
Quoted 64 lines
to access the address of x and suggest following solution.
uaccess.h renamed from uaccess.h.orig +31
-2@@ -35,10 +35,13 @@#define get_user __get_user#if BITS_PER_LONG ==32 +#define LDD_KERNEL (ptr) BUG()#define LDD_USER (ptr) BUG() -#define STD_KERNEL (x, ptr) BUG() -#define STD_USER (x, ptr) BUG() +#define STD_KERNEL (x, ptr) __put_kernel_asm_64(x, ptr) + +#define STD_USER (x, ptr) __put_user_asm_64(x, ptr) +#else #define LDD_KERNEL (ptr) __get_kernel_asm("ldd",ptr)#define LDD_USER (ptr) __get_user_asm("ldd",ptr)@@ -137,6 +140,7 @@#define __put_user (x,ptr) \ ({ \ register long __pu_err __asm__ ("r8") = 0; \ + register long long * __tmp = 0; \ \ if (segment_eq(get_fs(),KERNEL_DS)) { \ switch (sizeof(*(ptr))) { \@@ -200,6 +204,22 @@ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err)) +#define __put_kernel_asm_64 (x, ptr) \ + __asm__ __volatile__ ( \ + "\n\tldw\t0(%2),%3\n" \ + "1:\tstw\t%3,0(%1)\n" \ + "\tldw\t4(%2),%3\n" \ + "2:\tstw\t%3,4(%1)\n" \ + "3:\n" \ + "\t.section __ex_table,\"a\"\n" \ + "\t.word\t1b\n" \ + "\t.word\t(3b-1b)+1\n" \ + "\t.word\t2b\n" \ + "\t.word\t(3b-2b)+1\n" \ + "\t.previous" \ + : "=r"(__pu_err) \ + : "r"(ptr), "r"(&x), "r"(__tmp), "0"(__pu_err)) +#define __put_user_asm (stx,x,ptr) \ __asm__ __volatile__ ( \ "\n1:\t" stx "\t%2,0(%%sr3,%1)\n" \@@ -210,6 +230,23 @@ "\t.previous" \ : "=r"(__pu_err) \ : "r"(ptr), "r"(x), "0"(__pu_err)) + +#define __put_user_asm_64(x, ptr) \ + __asm__ __volatile__ ( \ +"\n\tldw\t0(%%sr3,%2),%3\n" \ +"1:\tstw\t%3,0(%%sr3,%1)\n" \ +"\tldw\t4(%%sr3,%2),%3\n" \ +"2:\tstw\t%3,4(%%sr3,%1)\n" \ +"3:\n" \ + "\t.section __ex_table,\"a\"\n" \
uaccess.h line 251
Quoted 10 lines
uaccess.h renamed from uaccess.h.orig +8
-0+ "\t.word\t1b\n" \ + "\t.word\t(3b-1b)+1\n" \ + "\t.word\t2b\n" \ + "\t.word\t(3b-2b)+1\n" \ + "\t.previous" \ + : "=r"(__pu_err) \ + : "r"(ptr), "r"(&x), "r"(__tmp), "0"(__pu_err)) + #endif
(&x) works when it is a variable not with a symbolic constant as 0.
Sorry,
Joel