Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Sat, Feb 09, 2013 at 11:41:42AM +0100, Borislav Petkov wrote: > On Fri, Feb 08, 2013 at 11:08:52AM -0800, H. Peter Anvin wrote: > > Yes, or anything else getting a pointer in memory from user space. > > Here are some more from a 32-bit build here: > > fs/exec.c: In function ‘get_user_arg_ptr’: > fs/exec.c:414:6: warning: cast to pointer from integer of different size > [-Wint-to-pointer-cast] > fs/splice.c: In function ‘vmsplice_to_user’: > fs/splice.c:1556:11: warning: cast to pointer from integer of different size > [-Wint-to-pointer-cast] > ipc/syscall.c: In function ‘sys_ipc’: > ipc/syscall.c:39:7: warning: cast to pointer from integer of different size > [-Wint-to-pointer-cast] Note that there's no need to build the entire tree to check for these - you just need to have enough test cases which cover those found in the kernel. The set of test functions I replied with on the previous thread covers all the cases I'm aware of in the kernel that matter, and should be warning free except for the final test function (which is there to check that the typechecking in get_user() does work.) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Fri, Feb 08, 2013 at 11:08:52AM -0800, H. Peter Anvin wrote: > Yes, or anything else getting a pointer in memory from user space. Here are some more from a 32-bit build here: fs/exec.c: In function ‘get_user_arg_ptr’: fs/exec.c:414:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] fs/splice.c: In function ‘vmsplice_to_user’: fs/splice.c:1556:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] ipc/syscall.c: In function ‘sys_ipc’: ipc/syscall.c:39:7: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Thanks. -- Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Fri, Feb 08, 2013 at 11:08:52AM -0800, H. Peter Anvin wrote: Yes, or anything else getting a pointer in memory from user space. Here are some more from a 32-bit build here: fs/exec.c: In function ‘get_user_arg_ptr’: fs/exec.c:414:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] fs/splice.c: In function ‘vmsplice_to_user’: fs/splice.c:1556:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] ipc/syscall.c: In function ‘sys_ipc’: ipc/syscall.c:39:7: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Thanks. -- Regards/Gruss, Boris. Sent from a fat crate under my desk. Formatting is fine. -- -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Sat, Feb 09, 2013 at 11:41:42AM +0100, Borislav Petkov wrote: On Fri, Feb 08, 2013 at 11:08:52AM -0800, H. Peter Anvin wrote: Yes, or anything else getting a pointer in memory from user space. Here are some more from a 32-bit build here: fs/exec.c: In function ‘get_user_arg_ptr’: fs/exec.c:414:6: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] fs/splice.c: In function ‘vmsplice_to_user’: fs/splice.c:1556:11: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] ipc/syscall.c: In function ‘sys_ipc’: ipc/syscall.c:39:7: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] Note that there's no need to build the entire tree to check for these - you just need to have enough test cases which cover those found in the kernel. The set of test functions I replied with on the previous thread covers all the cases I'm aware of in the kernel that matter, and should be warning free except for the final test function (which is there to check that the typechecking in get_user() does work.) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
Yes, or anything else getting a pointer in memory from user space. "Ville Syrjälä" wrote: >On Fri, Feb 08, 2013 at 09:30:05AM -0800, H. Peter Anvin wrote: >> On 02/08/2013 08:24 AM, Ville Syrjälä wrote: >> >> >> >> How have you tested it? >> > >> > I've tried it with my drm/kms atomic pageflip/modeset code. I also >had >> > a small test module that did a couple of different sized get_user() >> > calls, but I'll be damned if I can find it again. >> > >> >> Did you see the warning spewage for pointers when you built it? > >Apparently my config was too small to genenerate enough of those to >catch >my eye. Most of those seem to come from drivers that have pointers in >their >ioctl structs, no? -- Sent from my mobile phone. Please excuse brevity and lack of formatting. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Fri, Feb 08, 2013 at 09:30:05AM -0800, H. Peter Anvin wrote: > On 02/08/2013 08:24 AM, Ville Syrjälä wrote: > >> > >> How have you tested it? > > > > I've tried it with my drm/kms atomic pageflip/modeset code. I also had > > a small test module that did a couple of different sized get_user() > > calls, but I'll be damned if I can find it again. > > > > Did you see the warning spewage for pointers when you built it? Apparently my config was too small to genenerate enough of those to catch my eye. Most of those seem to come from drivers that have pointers in their ioctl structs, no? -- Ville Syrjälä Intel OTC -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On 02/08/2013 08:24 AM, Ville Syrjälä wrote: >> >> How have you tested it? > > I've tried it with my drm/kms atomic pageflip/modeset code. I also had > a small test module that did a couple of different sized get_user() > calls, but I'll be damned if I can find it again. > Did you see the warning spewage for pointers when you built it? -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Thu, Feb 07, 2013 at 09:59:00AM -0800, H. Peter Anvin wrote: > On 02/07/2013 08:53 AM, Ville Syrjälä wrote: > > > > Based on the initial response there seems to be some interest towards > > it at least. So I'm wondering what's the next step. Is it OK as is, > > or does it need more work, or would people want to extend it to include > > more of the original work? > > > > I have quite a lot of other stuff on my plate currently, so it'd > > actually be nice if I could find someone to adopt this patch, > > especially if there's interest in increasing the scope. > > > > Well, we can put it in and see what happens. It looks good from what I > can see. > > How have you tested it? I've tried it with my drm/kms atomic pageflip/modeset code. I also had a small test module that did a couple of different sized get_user() calls, but I'll be damned if I can find it again. -- Ville Syrjälä Intel OTC -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Thu, Feb 07, 2013 at 09:59:00AM -0800, H. Peter Anvin wrote: On 02/07/2013 08:53 AM, Ville Syrjälä wrote: Based on the initial response there seems to be some interest towards it at least. So I'm wondering what's the next step. Is it OK as is, or does it need more work, or would people want to extend it to include more of the original work? I have quite a lot of other stuff on my plate currently, so it'd actually be nice if I could find someone to adopt this patch, especially if there's interest in increasing the scope. Well, we can put it in and see what happens. It looks good from what I can see. How have you tested it? I've tried it with my drm/kms atomic pageflip/modeset code. I also had a small test module that did a couple of different sized get_user() calls, but I'll be damned if I can find it again. -- Ville Syrjälä Intel OTC -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On 02/08/2013 08:24 AM, Ville Syrjälä wrote: How have you tested it? I've tried it with my drm/kms atomic pageflip/modeset code. I also had a small test module that did a couple of different sized get_user() calls, but I'll be damned if I can find it again. Did you see the warning spewage for pointers when you built it? -hpa -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Fri, Feb 08, 2013 at 09:30:05AM -0800, H. Peter Anvin wrote: On 02/08/2013 08:24 AM, Ville Syrjälä wrote: How have you tested it? I've tried it with my drm/kms atomic pageflip/modeset code. I also had a small test module that did a couple of different sized get_user() calls, but I'll be damned if I can find it again. Did you see the warning spewage for pointers when you built it? Apparently my config was too small to genenerate enough of those to catch my eye. Most of those seem to come from drivers that have pointers in their ioctl structs, no? -- Ville Syrjälä Intel OTC -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
Yes, or anything else getting a pointer in memory from user space. Ville Syrjälä ville.syrj...@linux.intel.com wrote: On Fri, Feb 08, 2013 at 09:30:05AM -0800, H. Peter Anvin wrote: On 02/08/2013 08:24 AM, Ville Syrjälä wrote: How have you tested it? I've tried it with my drm/kms atomic pageflip/modeset code. I also had a small test module that did a couple of different sized get_user() calls, but I'll be damned if I can find it again. Did you see the warning spewage for pointers when you built it? Apparently my config was too small to genenerate enough of those to catch my eye. Most of those seem to come from drivers that have pointers in their ioctl structs, no? -- Sent from my mobile phone. Please excuse brevity and lack of formatting. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On 02/07/2013 08:53 AM, Ville Syrjälä wrote: > > Based on the initial response there seems to be some interest towards > it at least. So I'm wondering what's the next step. Is it OK as is, > or does it need more work, or would people want to extend it to include > more of the original work? > > I have quite a lot of other stuff on my plate currently, so it'd > actually be nice if I could find someone to adopt this patch, > especially if there's interest in increasing the scope. > Well, we can put it in and see what happens. It looks good from what I can see. How have you tested it? -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Wed, Dec 12, 2012 at 01:34:03PM +0200, ville.syrj...@linux.intel.com wrote: > From: Ville Syrjälä > > Implement __get_user_8() for x86-32. It will return the > 64bit result in edx:eax register pair, and ecx is used > to pass in the address and return the error value. > > For consistency, change the register assignment for all > other __get_user_x() variants, so that address is passed in > ecx/rcx, the error value is returned in ecx/rcx, and eax/rax > contains the actual value. > > This is a partial refresh of a patch [1] by Jamie Lokier from > 2004. Only the minimal changes to implement 64bit get_user() > were picked from the original patch. > > [1] http://article.gmane.org/gmane.linux.kernel/198823 Ping. I pretty much forgot about this patch since I posted it. Based on the initial response there seems to be some interest towards it at least. So I'm wondering what's the next step. Is it OK as is, or does it need more work, or would people want to extend it to include more of the original work? I have quite a lot of other stuff on my plate currently, so it'd actually be nice if I could find someone to adopt this patch, especially if there's interest in increasing the scope. > Cc: Jamie Lokier > Signed-off-by: Ville Syrjälä > --- > arch/x86/include/asm/uaccess.h | 17 ++-- > arch/x86/kernel/i386_ksyms_32.c |1 + > arch/x86/lib/getuser.S | 82 ++ > 3 files changed, 69 insertions(+), 31 deletions(-) > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 7ccf8d1..3f4387e 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -127,7 +127,7 @@ extern int __get_user_bad(void); > > #define __get_user_x(size, ret, x, ptr)\ > asm volatile("call __get_user_" #size \ > - : "=a" (ret), "=d" (x) \ > + : "=c" (ret), "=a" (x) \ >: "0" (ptr)) \ > > /* Careful: we have to cast the result to the type of the pointer > @@ -151,8 +151,11 @@ extern int __get_user_bad(void); > * On error, the variable @x is set to zero. > */ > #ifdef CONFIG_X86_32 > -#define __get_user_8(__ret_gu, __val_gu, ptr) > \ > - __get_user_x(X, __ret_gu, __val_gu, ptr) > +#define __get_user_8(ret, x, ptr) \ > + asm volatile("call __get_user_8" \ > + : "=c" (ret), "=A" (x) \ > + : "0" (ptr)) \ > + > #else > #define __get_user_8(__ret_gu, __val_gu, ptr) > \ > __get_user_x(8, __ret_gu, __val_gu, ptr) > @@ -162,6 +165,7 @@ extern int __get_user_bad(void); > ({ \ > int __ret_gu; \ > unsigned long __val_gu; \ > + unsigned long long __val_gu8; \ > __chk_user_ptr(ptr);\ > might_fault(); \ > switch (sizeof(*(ptr))) { \ > @@ -175,13 +179,16 @@ extern int __get_user_bad(void); > __get_user_x(4, __ret_gu, __val_gu, ptr); \ > break; \ > case 8: \ > - __get_user_8(__ret_gu, __val_gu, ptr); \ > + __get_user_8(__ret_gu, __val_gu8, ptr); \ > break; \ > default:\ > __get_user_x(X, __ret_gu, __val_gu, ptr); \ > break; \ > } \ > - (x) = (__typeof__(*(ptr)))__val_gu; \ > + if (sizeof(*(ptr)) == 8)\ > + (x) = (__typeof__(*(ptr)))__val_gu8;\ > + else\ > + (x) = (__typeof__(*(ptr)))__val_gu; \ > __ret_gu; \ > }) > > diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c > index 9c3bd4a..0fa6912 100644 > --- a/arch/x86/kernel/i386_ksyms_32.c > +++ b/arch/x86/kernel/i386_ksyms_32.c > @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); > EXPORT_SYMBOL(__get_user_1); > EXPORT_SYMBOL(__get_user_2); > EXPORT_SYMBOL(__get_user_4); > +EXPORT_SYMBOL(__get_user_8); > >
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Wed, Dec 12, 2012 at 01:34:03PM +0200, ville.syrj...@linux.intel.com wrote: From: Ville Syrjälä ville.syrj...@linux.intel.com Implement __get_user_8() for x86-32. It will return the 64bit result in edx:eax register pair, and ecx is used to pass in the address and return the error value. For consistency, change the register assignment for all other __get_user_x() variants, so that address is passed in ecx/rcx, the error value is returned in ecx/rcx, and eax/rax contains the actual value. This is a partial refresh of a patch [1] by Jamie Lokier from 2004. Only the minimal changes to implement 64bit get_user() were picked from the original patch. [1] http://article.gmane.org/gmane.linux.kernel/198823 Ping. I pretty much forgot about this patch since I posted it. Based on the initial response there seems to be some interest towards it at least. So I'm wondering what's the next step. Is it OK as is, or does it need more work, or would people want to extend it to include more of the original work? I have quite a lot of other stuff on my plate currently, so it'd actually be nice if I could find someone to adopt this patch, especially if there's interest in increasing the scope. Cc: Jamie Lokier ja...@shareable.org Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com --- arch/x86/include/asm/uaccess.h | 17 ++-- arch/x86/kernel/i386_ksyms_32.c |1 + arch/x86/lib/getuser.S | 82 ++ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 7ccf8d1..3f4387e 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -127,7 +127,7 @@ extern int __get_user_bad(void); #define __get_user_x(size, ret, x, ptr)\ asm volatile(call __get_user_ #size \ - : =a (ret), =d (x) \ + : =c (ret), =a (x) \ : 0 (ptr)) \ /* Careful: we have to cast the result to the type of the pointer @@ -151,8 +151,11 @@ extern int __get_user_bad(void); * On error, the variable @x is set to zero. */ #ifdef CONFIG_X86_32 -#define __get_user_8(__ret_gu, __val_gu, ptr) \ - __get_user_x(X, __ret_gu, __val_gu, ptr) +#define __get_user_8(ret, x, ptr) \ + asm volatile(call __get_user_8 \ + : =c (ret), =A (x) \ + : 0 (ptr)) \ + #else #define __get_user_8(__ret_gu, __val_gu, ptr) \ __get_user_x(8, __ret_gu, __val_gu, ptr) @@ -162,6 +165,7 @@ extern int __get_user_bad(void); ({ \ int __ret_gu; \ unsigned long __val_gu; \ + unsigned long long __val_gu8; \ __chk_user_ptr(ptr);\ might_fault(); \ switch (sizeof(*(ptr))) { \ @@ -175,13 +179,16 @@ extern int __get_user_bad(void); __get_user_x(4, __ret_gu, __val_gu, ptr); \ break; \ case 8: \ - __get_user_8(__ret_gu, __val_gu, ptr); \ + __get_user_8(__ret_gu, __val_gu8, ptr); \ break; \ default:\ __get_user_x(X, __ret_gu, __val_gu, ptr); \ break; \ } \ - (x) = (__typeof__(*(ptr)))__val_gu; \ + if (sizeof(*(ptr)) == 8)\ + (x) = (__typeof__(*(ptr)))__val_gu8;\ + else\ + (x) = (__typeof__(*(ptr)))__val_gu; \ __ret_gu; \ }) diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index 9c3bd4a..0fa6912 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); EXPORT_SYMBOL(__get_user_1); EXPORT_SYMBOL(__get_user_2); EXPORT_SYMBOL(__get_user_4); +EXPORT_SYMBOL(__get_user_8); EXPORT_SYMBOL(__put_user_1);
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On 02/07/2013 08:53 AM, Ville Syrjälä wrote: Based on the initial response there seems to be some interest towards it at least. So I'm wondering what's the next step. Is it OK as is, or does it need more work, or would people want to extend it to include more of the original work? I have quite a lot of other stuff on my plate currently, so it'd actually be nice if I could find someone to adopt this patch, especially if there's interest in increasing the scope. Well, we can put it in and see what happens. It looks good from what I can see. How have you tested it? -hpa -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
It's a good change -- and one which opens up even more unification -- but right now we're worried about 3.8. "Ville Syrjälä" wrote: >On Wed, Dec 12, 2012 at 08:15:12AM -0800, H. Peter Anvin wrote: >> Can we worry about this after the merge window? > >Sure. The only use I have for this is in my drm/kms atomic >modeset/pageflip patch set, and that's not 3.8 material. > >> >> ville.syrj...@linux.intel.com wrote: >> >> >From: Ville Syrjälä >> > >> >Implement __get_user_8() for x86-32. It will return the >> >64bit result in edx:eax register pair, and ecx is used >> >to pass in the address and return the error value. >> > >> >For consistency, change the register assignment for all >> >other __get_user_x() variants, so that address is passed in >> >ecx/rcx, the error value is returned in ecx/rcx, and eax/rax >> >contains the actual value. >> > >> >This is a partial refresh of a patch [1] by Jamie Lokier from >> >2004. Only the minimal changes to implement 64bit get_user() >> >were picked from the original patch. >> > >> >[1] http://article.gmane.org/gmane.linux.kernel/198823 >> > >> >Cc: Jamie Lokier >> >Signed-off-by: Ville Syrjälä >> >--- >> > arch/x86/include/asm/uaccess.h | 17 ++-- >> > arch/x86/kernel/i386_ksyms_32.c |1 + >> >arch/x86/lib/getuser.S | 82 >> >++ >> > 3 files changed, 69 insertions(+), 31 deletions(-) >> > >> >diff --git a/arch/x86/include/asm/uaccess.h >> >b/arch/x86/include/asm/uaccess.h >> >index 7ccf8d1..3f4387e 100644 >> >--- a/arch/x86/include/asm/uaccess.h >> >+++ b/arch/x86/include/asm/uaccess.h >> >@@ -127,7 +127,7 @@ extern int __get_user_bad(void); >> > >> > #define __get_user_x(size, ret, x, ptr) \ >> >asm volatile("call __get_user_" #size \ >> >-: "=a" (ret), "=d" (x) \ >> >+: "=c" (ret), "=a" (x) \ >> > : "0" (ptr)) \ >> > >> > /* Careful: we have to cast the result to the type of the pointer >> >@@ -151,8 +151,11 @@ extern int __get_user_bad(void); >> > * On error, the variable @x is set to zero. >> > */ >> > #ifdef CONFIG_X86_32 >> >-#define __get_user_8(__ret_gu, __val_gu, ptr) >> >\ >> >- __get_user_x(X, __ret_gu, __val_gu, ptr) >> >+#define __get_user_8(ret, x, ptr)\ >> >+ asm volatile("call __get_user_8" \ >> >+: "=c" (ret), "=A" (x) \ >> >+: "0" (ptr)) \ >> >+ >> > #else >> > #define __get_user_8(__ret_gu, __val_gu, ptr) >> > \ >> >__get_user_x(8, __ret_gu, __val_gu, ptr) >> >@@ -162,6 +165,7 @@ extern int __get_user_bad(void); >> > ({ \ >> >int __ret_gu; \ >> >unsigned long __val_gu; \ >> >+ unsigned long long __val_gu8; \ >> >__chk_user_ptr(ptr);\ >> >might_fault(); \ >> >switch (sizeof(*(ptr))) { \ >> >@@ -175,13 +179,16 @@ extern int __get_user_bad(void); >> >__get_user_x(4, __ret_gu, __val_gu, ptr); \ >> >break; \ >> >case 8: \ >> >- __get_user_8(__ret_gu, __val_gu, ptr); \ >> >+ __get_user_8(__ret_gu, __val_gu8, ptr); \ >> >break; \ >> >default:\ >> >__get_user_x(X, __ret_gu, __val_gu, ptr); \ >> >break; \ >> >} \ >> >- (x) = (__typeof__(*(ptr)))__val_gu; \ >> >+ if (sizeof(*(ptr)) == 8)\ >> >+ (x) = (__typeof__(*(ptr)))__val_gu8;\ >> >+ else\ >> >+ (x) = (__typeof__(*(ptr)))__val_gu; \ >> >__ret_gu; \ >> > }) >> > >> >diff --git a/arch/x86/kernel/i386_ksyms_32.c >> >b/arch/x86/kernel/i386_ksyms_32.c >> >index 9c3bd4a..0fa6912 100644 >> >--- a/arch/x86/kernel/i386_ksyms_32.c >> >+++ b/arch/x86/kernel/i386_ksyms_32.c >> >@@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); >> > EXPORT_SYMBOL(__get_user_1); >> > EXPORT_SYMBOL(__get_user_2); >> > EXPORT_SYMBOL(__get_user_4); >> >+EXPORT_SYMBOL(__get_user_8); >> > >> > EXPORT_SYMBOL(__put_user_1); >> >
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Wed, Dec 12, 2012 at 08:15:12AM -0800, H. Peter Anvin wrote: > Can we worry about this after the merge window? Sure. The only use I have for this is in my drm/kms atomic modeset/pageflip patch set, and that's not 3.8 material. > > ville.syrj...@linux.intel.com wrote: > > >From: Ville Syrjälä > > > >Implement __get_user_8() for x86-32. It will return the > >64bit result in edx:eax register pair, and ecx is used > >to pass in the address and return the error value. > > > >For consistency, change the register assignment for all > >other __get_user_x() variants, so that address is passed in > >ecx/rcx, the error value is returned in ecx/rcx, and eax/rax > >contains the actual value. > > > >This is a partial refresh of a patch [1] by Jamie Lokier from > >2004. Only the minimal changes to implement 64bit get_user() > >were picked from the original patch. > > > >[1] http://article.gmane.org/gmane.linux.kernel/198823 > > > >Cc: Jamie Lokier > >Signed-off-by: Ville Syrjälä > >--- > > arch/x86/include/asm/uaccess.h | 17 ++-- > > arch/x86/kernel/i386_ksyms_32.c |1 + > >arch/x86/lib/getuser.S | 82 > >++ > > 3 files changed, 69 insertions(+), 31 deletions(-) > > > >diff --git a/arch/x86/include/asm/uaccess.h > >b/arch/x86/include/asm/uaccess.h > >index 7ccf8d1..3f4387e 100644 > >--- a/arch/x86/include/asm/uaccess.h > >+++ b/arch/x86/include/asm/uaccess.h > >@@ -127,7 +127,7 @@ extern int __get_user_bad(void); > > > > #define __get_user_x(size, ret, x, ptr) \ > > asm volatile("call __get_user_" #size \ > >- : "=a" (ret), "=d" (x) \ > >+ : "=c" (ret), "=a" (x) \ > > : "0" (ptr)) \ > > > > /* Careful: we have to cast the result to the type of the pointer > >@@ -151,8 +151,11 @@ extern int __get_user_bad(void); > > * On error, the variable @x is set to zero. > > */ > > #ifdef CONFIG_X86_32 > >-#define __get_user_8(__ret_gu, __val_gu, ptr) > >\ > >-__get_user_x(X, __ret_gu, __val_gu, ptr) > >+#define __get_user_8(ret, x, ptr) \ > >+asm volatile("call __get_user_8" \ > >+ : "=c" (ret), "=A" (x) \ > >+ : "0" (ptr)) \ > >+ > > #else > > #define __get_user_8(__ret_gu, __val_gu, ptr) > > \ > > __get_user_x(8, __ret_gu, __val_gu, ptr) > >@@ -162,6 +165,7 @@ extern int __get_user_bad(void); > > ({ \ > > int __ret_gu; \ > > unsigned long __val_gu; \ > >+unsigned long long __val_gu8; \ > > __chk_user_ptr(ptr);\ > > might_fault(); \ > > switch (sizeof(*(ptr))) { \ > >@@ -175,13 +179,16 @@ extern int __get_user_bad(void); > > __get_user_x(4, __ret_gu, __val_gu, ptr); \ > > break; \ > > case 8: \ > >-__get_user_8(__ret_gu, __val_gu, ptr); \ > >+__get_user_8(__ret_gu, __val_gu8, ptr); \ > > break; \ > > default:\ > > __get_user_x(X, __ret_gu, __val_gu, ptr); \ > > break; \ > > } \ > >-(x) = (__typeof__(*(ptr)))__val_gu; \ > >+if (sizeof(*(ptr)) == 8)\ > >+(x) = (__typeof__(*(ptr)))__val_gu8;\ > >+else\ > >+(x) = (__typeof__(*(ptr)))__val_gu; \ > > __ret_gu; \ > > }) > > > >diff --git a/arch/x86/kernel/i386_ksyms_32.c > >b/arch/x86/kernel/i386_ksyms_32.c > >index 9c3bd4a..0fa6912 100644 > >--- a/arch/x86/kernel/i386_ksyms_32.c > >+++ b/arch/x86/kernel/i386_ksyms_32.c > >@@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); > > EXPORT_SYMBOL(__get_user_1); > > EXPORT_SYMBOL(__get_user_2); > > EXPORT_SYMBOL(__get_user_4); > >+EXPORT_SYMBOL(__get_user_8); > > > > EXPORT_SYMBOL(__put_user_1); > > EXPORT_SYMBOL(__put_user_2); > >diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S > >index 156b9c8..38afef0 100644 > >--- a/arch/x86/lib/getuser.S > >+++ b/arch/x86/lib/getuser.S > >@@ -14,12 +14,11 @@
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
Can we worry about this after the merge window? ville.syrj...@linux.intel.com wrote: >From: Ville Syrjälä > >Implement __get_user_8() for x86-32. It will return the >64bit result in edx:eax register pair, and ecx is used >to pass in the address and return the error value. > >For consistency, change the register assignment for all >other __get_user_x() variants, so that address is passed in >ecx/rcx, the error value is returned in ecx/rcx, and eax/rax >contains the actual value. > >This is a partial refresh of a patch [1] by Jamie Lokier from >2004. Only the minimal changes to implement 64bit get_user() >were picked from the original patch. > >[1] http://article.gmane.org/gmane.linux.kernel/198823 > >Cc: Jamie Lokier >Signed-off-by: Ville Syrjälä >--- > arch/x86/include/asm/uaccess.h | 17 ++-- > arch/x86/kernel/i386_ksyms_32.c |1 + >arch/x86/lib/getuser.S | 82 >++ > 3 files changed, 69 insertions(+), 31 deletions(-) > >diff --git a/arch/x86/include/asm/uaccess.h >b/arch/x86/include/asm/uaccess.h >index 7ccf8d1..3f4387e 100644 >--- a/arch/x86/include/asm/uaccess.h >+++ b/arch/x86/include/asm/uaccess.h >@@ -127,7 +127,7 @@ extern int __get_user_bad(void); > > #define __get_user_x(size, ret, x, ptr) \ > asm volatile("call __get_user_" #size \ >- : "=a" (ret), "=d" (x) \ >+ : "=c" (ret), "=a" (x) \ >: "0" (ptr)) \ > > /* Careful: we have to cast the result to the type of the pointer >@@ -151,8 +151,11 @@ extern int __get_user_bad(void); > * On error, the variable @x is set to zero. > */ > #ifdef CONFIG_X86_32 >-#define __get_user_8(__ret_gu, __val_gu, ptr) \ >- __get_user_x(X, __ret_gu, __val_gu, ptr) >+#define __get_user_8(ret, x, ptr) \ >+ asm volatile("call __get_user_8" \ >+ : "=c" (ret), "=A" (x) \ >+ : "0" (ptr)) \ >+ > #else > #define __get_user_8(__ret_gu, __val_gu, ptr) \ > __get_user_x(8, __ret_gu, __val_gu, ptr) >@@ -162,6 +165,7 @@ extern int __get_user_bad(void); > ({\ > int __ret_gu; \ > unsigned long __val_gu; \ >+ unsigned long long __val_gu8; \ > __chk_user_ptr(ptr);\ > might_fault(); \ > switch (sizeof(*(ptr))) { \ >@@ -175,13 +179,16 @@ extern int __get_user_bad(void); > __get_user_x(4, __ret_gu, __val_gu, ptr); \ > break; \ > case 8: \ >- __get_user_8(__ret_gu, __val_gu, ptr); \ >+ __get_user_8(__ret_gu, __val_gu8, ptr); \ > break; \ > default:\ > __get_user_x(X, __ret_gu, __val_gu, ptr); \ > break; \ > } \ >- (x) = (__typeof__(*(ptr)))__val_gu; \ >+ if (sizeof(*(ptr)) == 8)\ >+ (x) = (__typeof__(*(ptr)))__val_gu8;\ >+ else\ >+ (x) = (__typeof__(*(ptr)))__val_gu; \ > __ret_gu; \ > }) > >diff --git a/arch/x86/kernel/i386_ksyms_32.c >b/arch/x86/kernel/i386_ksyms_32.c >index 9c3bd4a..0fa6912 100644 >--- a/arch/x86/kernel/i386_ksyms_32.c >+++ b/arch/x86/kernel/i386_ksyms_32.c >@@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); > EXPORT_SYMBOL(__get_user_1); > EXPORT_SYMBOL(__get_user_2); > EXPORT_SYMBOL(__get_user_4); >+EXPORT_SYMBOL(__get_user_8); > > EXPORT_SYMBOL(__put_user_1); > EXPORT_SYMBOL(__put_user_2); >diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S >index 156b9c8..38afef0 100644 >--- a/arch/x86/lib/getuser.S >+++ b/arch/x86/lib/getuser.S >@@ -14,12 +14,11 @@ > /* > * __get_user_X > * >- * Inputs:%[r|e]ax contains the address. >- *The register is modified, but all changes are undone >- *before returning because the C code doesn't know about it. >+ * Inputs:%[r|e]cx contains the address. > * >- * Outputs: %[r|e]ax is error code (0 or -EFAULT) >- *
[PATCH] x86: Add support for 64bit get_user() on x86-32
From: Ville Syrjälä Implement __get_user_8() for x86-32. It will return the 64bit result in edx:eax register pair, and ecx is used to pass in the address and return the error value. For consistency, change the register assignment for all other __get_user_x() variants, so that address is passed in ecx/rcx, the error value is returned in ecx/rcx, and eax/rax contains the actual value. This is a partial refresh of a patch [1] by Jamie Lokier from 2004. Only the minimal changes to implement 64bit get_user() were picked from the original patch. [1] http://article.gmane.org/gmane.linux.kernel/198823 Cc: Jamie Lokier Signed-off-by: Ville Syrjälä --- arch/x86/include/asm/uaccess.h | 17 ++-- arch/x86/kernel/i386_ksyms_32.c |1 + arch/x86/lib/getuser.S | 82 ++ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 7ccf8d1..3f4387e 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -127,7 +127,7 @@ extern int __get_user_bad(void); #define __get_user_x(size, ret, x, ptr) \ asm volatile("call __get_user_" #size \ -: "=a" (ret), "=d" (x) \ +: "=c" (ret), "=a" (x) \ : "0" (ptr)) \ /* Careful: we have to cast the result to the type of the pointer @@ -151,8 +151,11 @@ extern int __get_user_bad(void); * On error, the variable @x is set to zero. */ #ifdef CONFIG_X86_32 -#define __get_user_8(__ret_gu, __val_gu, ptr) \ - __get_user_x(X, __ret_gu, __val_gu, ptr) +#define __get_user_8(ret, x, ptr)\ + asm volatile("call __get_user_8" \ +: "=c" (ret), "=A" (x) \ +: "0" (ptr)) \ + #else #define __get_user_8(__ret_gu, __val_gu, ptr) \ __get_user_x(8, __ret_gu, __val_gu, ptr) @@ -162,6 +165,7 @@ extern int __get_user_bad(void); ({ \ int __ret_gu; \ unsigned long __val_gu; \ + unsigned long long __val_gu8; \ __chk_user_ptr(ptr);\ might_fault(); \ switch (sizeof(*(ptr))) { \ @@ -175,13 +179,16 @@ extern int __get_user_bad(void); __get_user_x(4, __ret_gu, __val_gu, ptr); \ break; \ case 8: \ - __get_user_8(__ret_gu, __val_gu, ptr); \ + __get_user_8(__ret_gu, __val_gu8, ptr); \ break; \ default:\ __get_user_x(X, __ret_gu, __val_gu, ptr); \ break; \ } \ - (x) = (__typeof__(*(ptr)))__val_gu; \ + if (sizeof(*(ptr)) == 8)\ + (x) = (__typeof__(*(ptr)))__val_gu8;\ + else\ + (x) = (__typeof__(*(ptr)))__val_gu; \ __ret_gu; \ }) diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index 9c3bd4a..0fa6912 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); EXPORT_SYMBOL(__get_user_1); EXPORT_SYMBOL(__get_user_2); EXPORT_SYMBOL(__get_user_4); +EXPORT_SYMBOL(__get_user_8); EXPORT_SYMBOL(__put_user_1); EXPORT_SYMBOL(__put_user_2); diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 156b9c8..38afef0 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -14,12 +14,11 @@ /* * __get_user_X * - * Inputs: %[r|e]ax contains the address. - * The register is modified, but all changes are undone - * before returning because the C code doesn't know about it. + * Inputs: %[r|e]cx contains the address. * - * Outputs:%[r|e]ax is error code (0 or -EFAULT) - * %[r|e]dx contains zero-extended value + * Outputs:%[r|e]cx is error code (0 or -EFAULT) + * %[r|e]ax contains zero-extended value + *
[PATCH] x86: Add support for 64bit get_user() on x86-32
From: Ville Syrjälä ville.syrj...@linux.intel.com Implement __get_user_8() for x86-32. It will return the 64bit result in edx:eax register pair, and ecx is used to pass in the address and return the error value. For consistency, change the register assignment for all other __get_user_x() variants, so that address is passed in ecx/rcx, the error value is returned in ecx/rcx, and eax/rax contains the actual value. This is a partial refresh of a patch [1] by Jamie Lokier from 2004. Only the minimal changes to implement 64bit get_user() were picked from the original patch. [1] http://article.gmane.org/gmane.linux.kernel/198823 Cc: Jamie Lokier ja...@shareable.org Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com --- arch/x86/include/asm/uaccess.h | 17 ++-- arch/x86/kernel/i386_ksyms_32.c |1 + arch/x86/lib/getuser.S | 82 ++ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 7ccf8d1..3f4387e 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -127,7 +127,7 @@ extern int __get_user_bad(void); #define __get_user_x(size, ret, x, ptr) \ asm volatile(call __get_user_ #size \ -: =a (ret), =d (x) \ +: =c (ret), =a (x) \ : 0 (ptr)) \ /* Careful: we have to cast the result to the type of the pointer @@ -151,8 +151,11 @@ extern int __get_user_bad(void); * On error, the variable @x is set to zero. */ #ifdef CONFIG_X86_32 -#define __get_user_8(__ret_gu, __val_gu, ptr) \ - __get_user_x(X, __ret_gu, __val_gu, ptr) +#define __get_user_8(ret, x, ptr)\ + asm volatile(call __get_user_8 \ +: =c (ret), =A (x) \ +: 0 (ptr)) \ + #else #define __get_user_8(__ret_gu, __val_gu, ptr) \ __get_user_x(8, __ret_gu, __val_gu, ptr) @@ -162,6 +165,7 @@ extern int __get_user_bad(void); ({ \ int __ret_gu; \ unsigned long __val_gu; \ + unsigned long long __val_gu8; \ __chk_user_ptr(ptr);\ might_fault(); \ switch (sizeof(*(ptr))) { \ @@ -175,13 +179,16 @@ extern int __get_user_bad(void); __get_user_x(4, __ret_gu, __val_gu, ptr); \ break; \ case 8: \ - __get_user_8(__ret_gu, __val_gu, ptr); \ + __get_user_8(__ret_gu, __val_gu8, ptr); \ break; \ default:\ __get_user_x(X, __ret_gu, __val_gu, ptr); \ break; \ } \ - (x) = (__typeof__(*(ptr)))__val_gu; \ + if (sizeof(*(ptr)) == 8)\ + (x) = (__typeof__(*(ptr)))__val_gu8;\ + else\ + (x) = (__typeof__(*(ptr)))__val_gu; \ __ret_gu; \ }) diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index 9c3bd4a..0fa6912 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); EXPORT_SYMBOL(__get_user_1); EXPORT_SYMBOL(__get_user_2); EXPORT_SYMBOL(__get_user_4); +EXPORT_SYMBOL(__get_user_8); EXPORT_SYMBOL(__put_user_1); EXPORT_SYMBOL(__put_user_2); diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 156b9c8..38afef0 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -14,12 +14,11 @@ /* * __get_user_X * - * Inputs: %[r|e]ax contains the address. - * The register is modified, but all changes are undone - * before returning because the C code doesn't know about it. + * Inputs: %[r|e]cx contains the address. * - * Outputs:%[r|e]ax is error code (0 or -EFAULT) - * %[r|e]dx contains zero-extended value + * Outputs:%[r|e]cx is error code (0 or -EFAULT) + *
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
Can we worry about this after the merge window? ville.syrj...@linux.intel.com wrote: From: Ville Syrjälä ville.syrj...@linux.intel.com Implement __get_user_8() for x86-32. It will return the 64bit result in edx:eax register pair, and ecx is used to pass in the address and return the error value. For consistency, change the register assignment for all other __get_user_x() variants, so that address is passed in ecx/rcx, the error value is returned in ecx/rcx, and eax/rax contains the actual value. This is a partial refresh of a patch [1] by Jamie Lokier from 2004. Only the minimal changes to implement 64bit get_user() were picked from the original patch. [1] http://article.gmane.org/gmane.linux.kernel/198823 Cc: Jamie Lokier ja...@shareable.org Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com --- arch/x86/include/asm/uaccess.h | 17 ++-- arch/x86/kernel/i386_ksyms_32.c |1 + arch/x86/lib/getuser.S | 82 ++ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 7ccf8d1..3f4387e 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -127,7 +127,7 @@ extern int __get_user_bad(void); #define __get_user_x(size, ret, x, ptr) \ asm volatile(call __get_user_ #size \ - : =a (ret), =d (x) \ + : =c (ret), =a (x) \ : 0 (ptr)) \ /* Careful: we have to cast the result to the type of the pointer @@ -151,8 +151,11 @@ extern int __get_user_bad(void); * On error, the variable @x is set to zero. */ #ifdef CONFIG_X86_32 -#define __get_user_8(__ret_gu, __val_gu, ptr) \ - __get_user_x(X, __ret_gu, __val_gu, ptr) +#define __get_user_8(ret, x, ptr) \ + asm volatile(call __get_user_8 \ + : =c (ret), =A (x) \ + : 0 (ptr)) \ + #else #define __get_user_8(__ret_gu, __val_gu, ptr) \ __get_user_x(8, __ret_gu, __val_gu, ptr) @@ -162,6 +165,7 @@ extern int __get_user_bad(void); ({\ int __ret_gu; \ unsigned long __val_gu; \ + unsigned long long __val_gu8; \ __chk_user_ptr(ptr);\ might_fault(); \ switch (sizeof(*(ptr))) { \ @@ -175,13 +179,16 @@ extern int __get_user_bad(void); __get_user_x(4, __ret_gu, __val_gu, ptr); \ break; \ case 8: \ - __get_user_8(__ret_gu, __val_gu, ptr); \ + __get_user_8(__ret_gu, __val_gu8, ptr); \ break; \ default:\ __get_user_x(X, __ret_gu, __val_gu, ptr); \ break; \ } \ - (x) = (__typeof__(*(ptr)))__val_gu; \ + if (sizeof(*(ptr)) == 8)\ + (x) = (__typeof__(*(ptr)))__val_gu8;\ + else\ + (x) = (__typeof__(*(ptr)))__val_gu; \ __ret_gu; \ }) diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index 9c3bd4a..0fa6912 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); EXPORT_SYMBOL(__get_user_1); EXPORT_SYMBOL(__get_user_2); EXPORT_SYMBOL(__get_user_4); +EXPORT_SYMBOL(__get_user_8); EXPORT_SYMBOL(__put_user_1); EXPORT_SYMBOL(__put_user_2); diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 156b9c8..38afef0 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -14,12 +14,11 @@ /* * __get_user_X * - * Inputs:%[r|e]ax contains the address. - *The register is modified, but all changes are undone - *before returning because the C code doesn't know about it. + * Inputs:%[r|e]cx contains the address. * - * Outputs: %[r|e]ax is error code (0 or -EFAULT) - *%[r|e]dx contains zero-extended value + * Outputs:
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
On Wed, Dec 12, 2012 at 08:15:12AM -0800, H. Peter Anvin wrote: Can we worry about this after the merge window? Sure. The only use I have for this is in my drm/kms atomic modeset/pageflip patch set, and that's not 3.8 material. ville.syrj...@linux.intel.com wrote: From: Ville Syrjälä ville.syrj...@linux.intel.com Implement __get_user_8() for x86-32. It will return the 64bit result in edx:eax register pair, and ecx is used to pass in the address and return the error value. For consistency, change the register assignment for all other __get_user_x() variants, so that address is passed in ecx/rcx, the error value is returned in ecx/rcx, and eax/rax contains the actual value. This is a partial refresh of a patch [1] by Jamie Lokier from 2004. Only the minimal changes to implement 64bit get_user() were picked from the original patch. [1] http://article.gmane.org/gmane.linux.kernel/198823 Cc: Jamie Lokier ja...@shareable.org Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com --- arch/x86/include/asm/uaccess.h | 17 ++-- arch/x86/kernel/i386_ksyms_32.c |1 + arch/x86/lib/getuser.S | 82 ++ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 7ccf8d1..3f4387e 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -127,7 +127,7 @@ extern int __get_user_bad(void); #define __get_user_x(size, ret, x, ptr) \ asm volatile(call __get_user_ #size \ - : =a (ret), =d (x) \ + : =c (ret), =a (x) \ : 0 (ptr)) \ /* Careful: we have to cast the result to the type of the pointer @@ -151,8 +151,11 @@ extern int __get_user_bad(void); * On error, the variable @x is set to zero. */ #ifdef CONFIG_X86_32 -#define __get_user_8(__ret_gu, __val_gu, ptr) \ -__get_user_x(X, __ret_gu, __val_gu, ptr) +#define __get_user_8(ret, x, ptr) \ +asm volatile(call __get_user_8 \ + : =c (ret), =A (x) \ + : 0 (ptr)) \ + #else #define __get_user_8(__ret_gu, __val_gu, ptr) \ __get_user_x(8, __ret_gu, __val_gu, ptr) @@ -162,6 +165,7 @@ extern int __get_user_bad(void); ({ \ int __ret_gu; \ unsigned long __val_gu; \ +unsigned long long __val_gu8; \ __chk_user_ptr(ptr);\ might_fault(); \ switch (sizeof(*(ptr))) { \ @@ -175,13 +179,16 @@ extern int __get_user_bad(void); __get_user_x(4, __ret_gu, __val_gu, ptr); \ break; \ case 8: \ -__get_user_8(__ret_gu, __val_gu, ptr); \ +__get_user_8(__ret_gu, __val_gu8, ptr); \ break; \ default:\ __get_user_x(X, __ret_gu, __val_gu, ptr); \ break; \ } \ -(x) = (__typeof__(*(ptr)))__val_gu; \ +if (sizeof(*(ptr)) == 8)\ +(x) = (__typeof__(*(ptr)))__val_gu8;\ +else\ +(x) = (__typeof__(*(ptr)))__val_gu; \ __ret_gu; \ }) diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index 9c3bd4a..0fa6912 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); EXPORT_SYMBOL(__get_user_1); EXPORT_SYMBOL(__get_user_2); EXPORT_SYMBOL(__get_user_4); +EXPORT_SYMBOL(__get_user_8); EXPORT_SYMBOL(__put_user_1); EXPORT_SYMBOL(__put_user_2); diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 156b9c8..38afef0 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -14,12 +14,11 @@ /* * __get_user_X * - * Inputs: %[r|e]ax contains the address. - * The register is modified, but all changes are undone - *
Re: [PATCH] x86: Add support for 64bit get_user() on x86-32
It's a good change -- and one which opens up even more unification -- but right now we're worried about 3.8. Ville Syrjälä ville.syrj...@linux.intel.com wrote: On Wed, Dec 12, 2012 at 08:15:12AM -0800, H. Peter Anvin wrote: Can we worry about this after the merge window? Sure. The only use I have for this is in my drm/kms atomic modeset/pageflip patch set, and that's not 3.8 material. ville.syrj...@linux.intel.com wrote: From: Ville Syrjälä ville.syrj...@linux.intel.com Implement __get_user_8() for x86-32. It will return the 64bit result in edx:eax register pair, and ecx is used to pass in the address and return the error value. For consistency, change the register assignment for all other __get_user_x() variants, so that address is passed in ecx/rcx, the error value is returned in ecx/rcx, and eax/rax contains the actual value. This is a partial refresh of a patch [1] by Jamie Lokier from 2004. Only the minimal changes to implement 64bit get_user() were picked from the original patch. [1] http://article.gmane.org/gmane.linux.kernel/198823 Cc: Jamie Lokier ja...@shareable.org Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com --- arch/x86/include/asm/uaccess.h | 17 ++-- arch/x86/kernel/i386_ksyms_32.c |1 + arch/x86/lib/getuser.S | 82 ++ 3 files changed, 69 insertions(+), 31 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 7ccf8d1..3f4387e 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -127,7 +127,7 @@ extern int __get_user_bad(void); #define __get_user_x(size, ret, x, ptr) \ asm volatile(call __get_user_ #size \ -: =a (ret), =d (x) \ +: =c (ret), =a (x) \ : 0 (ptr)) \ /* Careful: we have to cast the result to the type of the pointer @@ -151,8 +151,11 @@ extern int __get_user_bad(void); * On error, the variable @x is set to zero. */ #ifdef CONFIG_X86_32 -#define __get_user_8(__ret_gu, __val_gu, ptr) \ - __get_user_x(X, __ret_gu, __val_gu, ptr) +#define __get_user_8(ret, x, ptr)\ + asm volatile(call __get_user_8 \ +: =c (ret), =A (x) \ +: 0 (ptr)) \ + #else #define __get_user_8(__ret_gu, __val_gu, ptr) \ __get_user_x(8, __ret_gu, __val_gu, ptr) @@ -162,6 +165,7 @@ extern int __get_user_bad(void); ({ \ int __ret_gu; \ unsigned long __val_gu; \ + unsigned long long __val_gu8; \ __chk_user_ptr(ptr);\ might_fault(); \ switch (sizeof(*(ptr))) { \ @@ -175,13 +179,16 @@ extern int __get_user_bad(void); __get_user_x(4, __ret_gu, __val_gu, ptr); \ break; \ case 8: \ - __get_user_8(__ret_gu, __val_gu, ptr); \ + __get_user_8(__ret_gu, __val_gu8, ptr); \ break; \ default:\ __get_user_x(X, __ret_gu, __val_gu, ptr); \ break; \ } \ - (x) = (__typeof__(*(ptr)))__val_gu; \ + if (sizeof(*(ptr)) == 8)\ + (x) = (__typeof__(*(ptr)))__val_gu8;\ + else\ + (x) = (__typeof__(*(ptr)))__val_gu; \ __ret_gu; \ }) diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c index 9c3bd4a..0fa6912 100644 --- a/arch/x86/kernel/i386_ksyms_32.c +++ b/arch/x86/kernel/i386_ksyms_32.c @@ -26,6 +26,7 @@ EXPORT_SYMBOL(csum_partial_copy_generic); EXPORT_SYMBOL(__get_user_1); EXPORT_SYMBOL(__get_user_2); EXPORT_SYMBOL(__get_user_4); +EXPORT_SYMBOL(__get_user_8); EXPORT_SYMBOL(__put_user_1); EXPORT_SYMBOL(__put_user_2); diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S index 156b9c8..38afef0 100644 --- a/arch/x86/lib/getuser.S +++ b/arch/x86/lib/getuser.S @@ -14,12 +14,11 @@ /* *