linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Benjamin LaHaise <bcrl@kvack.org>, Ingo Molnar <mingo@redhat.com>,
	Russell King <rmk@arm.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86_32: add support for 64 bit __get_user()
Date: Wed, 09 Mar 2016 09:36:30 -0800	[thread overview]
Message-ID: <C08B33D1-0DC2-4470-8165-10DC62A6A94D@zytor.com> (raw)
In-Reply-To: <20160309172225.GN12913@kvack.org>

On March 9, 2016 9:22:25 AM PST, Benjamin LaHaise <bcrl@kvack.org> wrote:
>The existing __get_user() implementation does not support fetching
>64 bit values on 32 bit x86.  Implement this in a way that does not 
>generate any incorrect warnings as cautioned by Russell King.  Test 
>code available at http://www.kvack.org/~bcrl/x86_32-get_user.tar .  
>
>Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
>
>diff --git a/arch/x86/include/asm/uaccess.h
>b/arch/x86/include/asm/uaccess.h
>index a4a30e4..2d0607a 100644
>--- a/arch/x86/include/asm/uaccess.h
>+++ b/arch/x86/include/asm/uaccess.h
>@@ -333,7 +333,23 @@ 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) \
>@@ -420,11 +436,20 @@ do {									\
> #define __get_user_nocheck(x, ptr, size)				\
> ({									\
> 	int __gu_err;							\
>-	unsigned long __gu_val;						\
>-	__uaccess_begin();						\
>-	__get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT);	\
>-	__uaccess_end();						\
>-	(x) = (__force __typeof__(*(ptr)))__gu_val;			\
>+	if (size == 8) {						\
>+		unsigned long __gu_val[2];				\
>+		__gu_err = 0;						\
>+		__uaccess_begin();					\
>+		__get_user_asm_u64(__gu_val, ptr, __gu_err, -EFAULT);	\
>+		__uaccess_end();					\
>+		(x) = *(__force __typeof__((ptr)))__gu_val;		\
>+	} else {							\
>+		unsigned long __gu_val;					\
>+		__uaccess_begin();					\
>+		__get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
>+		__uaccess_end();					\
>+		(x) = (__force __typeof__(*(ptr)))__gu_val;		\
>+	}								\
> 	__builtin_expect(__gu_err, 0);					\
> })
> 

Weird.  I could swear we had already fixed this a few years ago.
-- 
Sent from my Android device with K-9 Mail. Please excuse brevity and formatting.

  reply	other threads:[~2016-03-09 17:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09 17:22 [PATCH] x86_32: add support for 64 bit __get_user() Benjamin LaHaise
2016-03-09 17:36 ` H. Peter Anvin [this message]
2016-03-09 17:50   ` Benjamin LaHaise
2016-03-09 18:22     ` H. Peter Anvin
2016-03-09 18:27       ` Benjamin LaHaise
2016-03-09 19:30       ` [PATCH] x86_32: add support for 64 bit __get_user() v2 Benjamin LaHaise
2016-03-09 19:41         ` kbuild test robot
2016-03-09 20:05         ` [PATCH] x86_32: add support for 64 bit __get_user() v3 Benjamin LaHaise
2016-03-14 15:37           ` Benjamin LaHaise
2016-03-14 16:39             ` Ingo Molnar
2016-03-09 20:24         ` [PATCH] x86_32: add support for 64 bit __get_user() v2 kbuild test robot
2016-03-09 18:17 ` [PATCH] x86_32: add support for 64 bit __get_user() kbuild test robot
2016-03-09 18:22 ` kbuild test robot
2016-03-09 18:23 ` kbuild test robot

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=C08B33D1-0DC2-4470-8165-10DC62A6A94D@zytor.com \
    --to=hpa@zytor.com \
    --cc=bcrl@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rmk@arm.linux.org.uk \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).