[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4a7e026b07c94668a18cb4857ad6b7a5@AcuMS.aculab.com>
Date: Wed, 16 Feb 2022 13:35:25 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Arnd Bergmann' <arnd@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Christoph Hellwig <hch@....de>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
"arnd@...db.de" <arnd@...db.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>
CC: "linux@...linux.org.uk" <linux@...linux.org.uk>,
"will@...nel.org" <will@...nel.org>,
"guoren@...nel.org" <guoren@...nel.org>,
"bcain@...eaurora.org" <bcain@...eaurora.org>,
"geert@...ux-m68k.org" <geert@...ux-m68k.org>,
"monstr@...str.eu" <monstr@...str.eu>,
"tsbogend@...ha.franken.de" <tsbogend@...ha.franken.de>,
"nickhu@...estech.com" <nickhu@...estech.com>,
"green.hu@...il.com" <green.hu@...il.com>,
"dinguyen@...nel.org" <dinguyen@...nel.org>,
"shorne@...il.com" <shorne@...il.com>,
"deller@....de" <deller@....de>,
"mpe@...erman.id.au" <mpe@...erman.id.au>,
"peterz@...radead.org" <peterz@...radead.org>,
"mingo@...hat.com" <mingo@...hat.com>,
"mark.rutland@....com" <mark.rutland@....com>,
"hca@...ux.ibm.com" <hca@...ux.ibm.com>,
"dalias@...c.org" <dalias@...c.org>,
"davem@...emloft.net" <davem@...emloft.net>,
"richard@....at" <richard@....at>,
"x86@...nel.org" <x86@...nel.org>,
"jcmvbkbc@...il.com" <jcmvbkbc@...il.com>,
"ebiederm@...ssion.com" <ebiederm@...ssion.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"ardb@...nel.org" <ardb@...nel.org>,
"linux-alpha@...r.kernel.org" <linux-alpha@...r.kernel.org>,
"linux-snps-arc@...ts.infradead.org"
<linux-snps-arc@...ts.infradead.org>,
"linux-csky@...r.kernel.org" <linux-csky@...r.kernel.org>,
"linux-hexagon@...r.kernel.org" <linux-hexagon@...r.kernel.org>,
"linux-ia64@...r.kernel.org" <linux-ia64@...r.kernel.org>,
"linux-m68k@...ts.linux-m68k.org" <linux-m68k@...ts.linux-m68k.org>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
"openrisc@...ts.librecores.org" <openrisc@...ts.librecores.org>,
"linux-parisc@...r.kernel.org" <linux-parisc@...r.kernel.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"linux-s390@...r.kernel.org" <linux-s390@...r.kernel.org>,
"linux-sh@...r.kernel.org" <linux-sh@...r.kernel.org>,
"sparclinux@...r.kernel.org" <sparclinux@...r.kernel.org>,
"linux-um@...ts.infradead.org" <linux-um@...ts.infradead.org>,
"linux-xtensa@...ux-xtensa.org" <linux-xtensa@...ux-xtensa.org>
Subject: RE: [PATCH v2 02/18] uaccess: fix nios2 and microblaze get_user_8()
From: Arnd Bergmann
> Sent: 16 February 2022 13:13
>
> These two architectures implement 8-byte get_user() through
> a memcpy() into a four-byte variable, which won't fit.
>
> Use a temporary 64-bit variable instead here, and use a double
> cast the way that risc-v and openrisc do to avoid compile-time
> warnings.
>
...
> case 4: \
> - __get_user_asm("lw", (ptr), __gu_val, __gu_err); \
> + __get_user_asm("lw", (ptr), x, __gu_err); \
> break; \
> - case 8: \
> - __gu_err = __copy_from_user(&__gu_val, ptr, 8); \
> - if (__gu_err) \
> - __gu_err = -EFAULT; \
> + case 8: { \
> + __u64 __x = 0; \
> + __gu_err = raw_copy_from_user(&__x, ptr, 8) ? \
> + -EFAULT : 0; \
> + (x) = (typeof(x))(typeof((x) - (x)))__x; \
> break; \
Wouldn't it be better to just fetch two 32bit values:
Something like (for LE - nios2 is definitely LE:
__u32 val_lo, val_hi;
__get_user_asm("lw", (ptr), val_lo, __gu_err);
__get_user_asm("lw", (ptr) + 4, val_hi, __gu_err);
x = val_lo | val_hi << 32;
break;
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists