All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin LaHaise <bcrl@kvack.org>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Linux-Next <linux-next@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: linux-next: build failure after merge of the aio tree
Date: Thu, 4 Feb 2016 13:48:25 -0500	[thread overview]
Message-ID: <20160204184825.GG16315@kvack.org> (raw)
In-Reply-To: <20160204161741.GH10826@n2100.arm.linux.org.uk>

On Thu, Feb 04, 2016 at 04:17:42PM +0000, Russell King - ARM Linux wrote:
> __gu_val will be 32-bit, even when you're wanting a 64-bit quantity.
> That's where the fun and games start...

Okay, I figured out how to do it: instead of using a 64 bit unsigned long 
long for __gu_val, use an array of 2 unsigned longs.  See the patch below 
which I verified boots, passes your tests and doesn't truncate 64 bit 
values.  Comments?  A simple test module to verify things is located at 
http://www.kvack.org/~bcrl/test_module2.c .

		-ben
-- 
"Thought is the essence of where you are now."


diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 09b1b0a..53244ae 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -326,7 +326,22 @@ do {									\
 } while (0)
 
 #ifdef CONFIG_X86_32
-#define __get_user_asm_u64(x, ptr, retval, errret)	(x) = __get_user_bad()
+#define __get_user_asm_u64(x, addr, err, errret)			\
+	asm volatile(ASM_STAC "\n"					\
+		     "1:	movl %2,%%eax\n"			\
+		     "2:	movl %3,%%edx\n"			\
+		     "3: " ASM_CLAC "\n"				\
+		     ".section .fixup,\"ax\"\n"				\
+		     "4:	mov %4,%0\n"				\
+		     "	xorl %%eax,%%eax\n"				\
+		     "	xorl %%edx,%%edx\n"				\
+		     "	jmp 3b\n"					\
+		     ".previous\n"					\
+		     _ASM_EXTABLE(1b, 4b)				\
+		     _ASM_EXTABLE(2b, 4b)				\
+		     : "=r" (err), "=A"(x)				\
+		     : "m" (__m(addr)), "m" __m(((u32 *)addr) + 1), "i" (errret), "0" (err))
+
 #define __get_user_asm_ex_u64(x, ptr)			(x) = __get_user_bad()
 #else
 #define __get_user_asm_u64(x, ptr, retval, errret) \
@@ -407,9 +422,16 @@ do {									\
 #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;			\
+	if (size == 8) {						\
+		unsigned long __gu_val[2];				\
+		__gu_err = 0;						\
+		__get_user_asm_u64(__gu_val, ptr, __gu_err, -EFAULT);	\
+		(x) = *(__force __typeof__((ptr)))__gu_val;		\
+	} else {							\
+		unsigned long __gu_val;					\
+		__get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
+		(x) = (__force __typeof__(*(ptr)))__gu_val;		\
+	}								\
 	__builtin_expect(__gu_err, 0);					\
 })
 

WARNING: multiple messages have this Message-ID (diff)
From: bcrl@kvack.org (Benjamin LaHaise)
To: linux-arm-kernel@lists.infradead.org
Subject: linux-next: build failure after merge of the aio tree
Date: Thu, 4 Feb 2016 13:48:25 -0500	[thread overview]
Message-ID: <20160204184825.GG16315@kvack.org> (raw)
In-Reply-To: <20160204161741.GH10826@n2100.arm.linux.org.uk>

On Thu, Feb 04, 2016 at 04:17:42PM +0000, Russell King - ARM Linux wrote:
> __gu_val will be 32-bit, even when you're wanting a 64-bit quantity.
> That's where the fun and games start...

Okay, I figured out how to do it: instead of using a 64 bit unsigned long 
long for __gu_val, use an array of 2 unsigned longs.  See the patch below 
which I verified boots, passes your tests and doesn't truncate 64 bit 
values.  Comments?  A simple test module to verify things is located at 
http://www.kvack.org/~bcrl/test_module2.c .

		-ben
-- 
"Thought is the essence of where you are now."


diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 09b1b0a..53244ae 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -326,7 +326,22 @@ do {									\
 } while (0)
 
 #ifdef CONFIG_X86_32
-#define __get_user_asm_u64(x, ptr, retval, errret)	(x) = __get_user_bad()
+#define __get_user_asm_u64(x, addr, err, errret)			\
+	asm volatile(ASM_STAC "\n"					\
+		     "1:	movl %2,%%eax\n"			\
+		     "2:	movl %3,%%edx\n"			\
+		     "3: " ASM_CLAC "\n"				\
+		     ".section .fixup,\"ax\"\n"				\
+		     "4:	mov %4,%0\n"				\
+		     "	xorl %%eax,%%eax\n"				\
+		     "	xorl %%edx,%%edx\n"				\
+		     "	jmp 3b\n"					\
+		     ".previous\n"					\
+		     _ASM_EXTABLE(1b, 4b)				\
+		     _ASM_EXTABLE(2b, 4b)				\
+		     : "=r" (err), "=A"(x)				\
+		     : "m" (__m(addr)), "m" __m(((u32 *)addr) + 1), "i" (errret), "0" (err))
+
 #define __get_user_asm_ex_u64(x, ptr)			(x) = __get_user_bad()
 #else
 #define __get_user_asm_u64(x, ptr, retval, errret) \
@@ -407,9 +422,16 @@ do {									\
 #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;			\
+	if (size == 8) {						\
+		unsigned long __gu_val[2];				\
+		__gu_err = 0;						\
+		__get_user_asm_u64(__gu_val, ptr, __gu_err, -EFAULT);	\
+		(x) = *(__force __typeof__((ptr)))__gu_val;		\
+	} else {							\
+		unsigned long __gu_val;					\
+		__get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
+		(x) = (__force __typeof__(*(ptr)))__gu_val;		\
+	}								\
 	__builtin_expect(__gu_err, 0);					\
 })
 

  parent reply	other threads:[~2016-02-04 18:48 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12  5:40 linux-next: build failure after merge of the aio tree Stephen Rothwell
2016-01-12 16:38 ` Benjamin LaHaise
2016-01-27  2:40   ` Stephen Rothwell
2016-01-27  2:40     ` Stephen Rothwell
2016-01-29 11:30     ` Russell King - ARM Linux
2016-01-29 11:30       ` Russell King - ARM Linux
2016-01-29 12:03       ` Geert Uytterhoeven
2016-01-29 12:03         ` Geert Uytterhoeven
2016-01-29 12:03         ` Geert Uytterhoeven
2016-02-04  2:19         ` Stephen Rothwell
2016-02-04  2:19           ` Stephen Rothwell
2016-02-04  2:19           ` Stephen Rothwell
2016-02-04 13:41           ` Benjamin LaHaise
2016-02-04 13:41             ` Benjamin LaHaise
2016-02-04 13:41             ` Benjamin LaHaise
2016-02-04 13:50             ` Russell King - ARM Linux
2016-02-04 13:50               ` Russell King - ARM Linux
2016-02-04 13:50               ` Russell King - ARM Linux
2016-02-04 14:08               ` Benjamin LaHaise
2016-02-04 14:08                 ` Benjamin LaHaise
2016-02-04 14:08                 ` Benjamin LaHaise
2016-02-04 14:12                 ` Russell King - ARM Linux
2016-02-04 14:12                   ` Russell King - ARM Linux
2016-02-04 14:12                   ` Russell King - ARM Linux
2016-02-04 14:32                   ` Benjamin LaHaise
2016-02-04 14:32                     ` Benjamin LaHaise
2016-02-04 14:32                     ` Benjamin LaHaise
2016-02-04 14:39                     ` Russell King - ARM Linux
2016-02-04 14:39                       ` Russell King - ARM Linux
2016-02-04 14:39                       ` Russell King - ARM Linux
2016-02-04 16:01                       ` Benjamin LaHaise
2016-02-04 16:01                         ` Benjamin LaHaise
2016-02-04 16:01                         ` Benjamin LaHaise
2016-02-04 16:17                         ` Russell King - ARM Linux
2016-02-04 16:17                           ` Russell King - ARM Linux
2016-02-04 16:17                           ` Russell King - ARM Linux
2016-02-04 16:27                           ` Benjamin LaHaise
2016-02-04 16:27                             ` Benjamin LaHaise
2016-02-04 16:27                             ` Benjamin LaHaise
2016-02-04 16:47                           ` Benjamin LaHaise
2016-02-04 16:47                             ` Benjamin LaHaise
2016-02-04 16:47                             ` Benjamin LaHaise
2016-02-04 18:48                           ` Benjamin LaHaise [this message]
2016-02-04 18:48                             ` Benjamin LaHaise
2016-02-04 18:48                             ` Benjamin LaHaise
2016-01-15  2:24 ` Stephen Rothwell
2016-01-15  7:39 ` Christoph Hellwig
2016-01-15  9:23   ` Stephen Rothwell
2016-01-15  9:25     ` Christoph Hellwig
2016-01-15 15:18       ` Benjamin LaHaise
2016-01-15 22:55         ` Stephen Rothwell
2016-03-14  4:49           ` Stephen Rothwell
2016-03-14 17:08             ` Benjamin LaHaise
2016-03-14 20:41               ` Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2016-03-15  6:46 Stephen Rothwell
2016-03-15  6:46 ` Stephen Rothwell
2016-03-15 14:38 ` Andy Shevchenko
2016-03-15 16:42   ` Arnd Bergmann
2016-03-15 16:19 ` Sudip Mukherjee
2016-03-15 16:22   ` Benjamin LaHaise
2016-03-15 22:02     ` Arnd Bergmann
2016-03-16 11:12       ` Andy Shevchenko
2016-03-16 13:59         ` Arnd Bergmann
2016-03-16 14:07           ` Benjamin LaHaise
2013-08-30  7:55 Stephen Rothwell
2013-08-30 14:26 ` Benjamin LaHaise
2013-08-30 17:38 ` Linus Torvalds
2013-08-30 17:42   ` Benjamin LaHaise
2013-08-21  7:45 Stephen Rothwell
2013-08-21 15:52 ` Dave Kleikamp
2013-08-21 23:53   ` Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160204184825.GG16315@kvack.org \
    --to=bcrl@kvack.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.