From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0E159C433F5 for ; Wed, 16 Feb 2022 13:36:06 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JzJrM6FpCz3dmM for ; Thu, 17 Feb 2022 00:36:03 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aculab.com (client-ip=185.58.86.151; helo=eu-smtp-delivery-151.mimecast.com; envelope-from=david.laight@aculab.com; receiver=) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JzJqr2mdvz2xC6 for ; Thu, 17 Feb 2022 00:35:34 +1100 (AEDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mtapsc-5-x7kvjQ_dNbmfJSCohruuVA-1; Wed, 16 Feb 2022 13:35:28 +0000 X-MC-Unique: x7kvjQ_dNbmfJSCohruuVA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Wed, 16 Feb 2022 13:35:25 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Wed, 16 Feb 2022 13:35:25 +0000 From: David Laight To: 'Arnd Bergmann' , Linus Torvalds , Christoph Hellwig , "linux-arch@vger.kernel.org" , "linux-mm@kvack.org" , "linux-api@vger.kernel.org" , "arnd@arndb.de" , "linux-kernel@vger.kernel.org" , "viro@zeniv.linux.org.uk" Subject: RE: [PATCH v2 02/18] uaccess: fix nios2 and microblaze get_user_8() Thread-Topic: [PATCH v2 02/18] uaccess: fix nios2 and microblaze get_user_8() Thread-Index: AQHYIzdfY+IsqXyFuUGlEUsFmAHn6KyWK9Eg Date: Wed, 16 Feb 2022 13:35:25 +0000 Message-ID: <4a7e026b07c94668a18cb4857ad6b7a5@AcuMS.aculab.com> References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-3-arnd@kernel.org> In-Reply-To: <20220216131332.1489939-3-arnd@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "mark.rutland@arm.com" , "dalias@libc.org" , "linux-ia64@vger.kernel.org" , "linux-sh@vger.kernel.org" , "peterz@infradead.org" , "jcmvbkbc@gmail.com" , "guoren@kernel.org" , "sparclinux@vger.kernel.org" , "linux-hexagon@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "will@kernel.org" , "ardb@kernel.org" , "linux-s390@vger.kernel.org" , "bcain@codeaurora.org" , "deller@gmx.de" , "x86@kernel.org" , "linux@armlinux.org.uk" , "linux-csky@vger.kernel.org" , "mingo@redhat.com" , "geert@linux-m68k.org" , "linux-snps-arc@lists.infradead.org" , "linux-xtensa@linux-xtensa.org" , "hca@linux.ibm.com" , "linux-alpha@vger.kernel.org" , "linux-um@lists.infradead.org" , "linux-m68k@lists.linux-m68k.org" , "openrisc@lists.librecores.org" , "green.hu@gmail.com" , "shorne@gmail.com" , "monstr@monstr.eu" , "tsbogend@alpha.franken.de" , "linux-parisc@vger.kernel.org" , "nickhu@andestech.com" , "linux-mips@vger.kernel.org" , "dinguyen@kernel.org" , "ebiederm@xmission.com" , "richard@nod.at" , "akpm@linux-foundation.org" , "linuxppc-dev@lists.ozlabs.org" , "davem@davemloft.net" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Arnd Bergmann > Sent: 16 February 2022 13:13 >=20 > These two architectures implement 8-byte get_user() through > a memcpy() into a four-byte variable, which won't fit. >=20 > 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. >=20 ... > =09case 4:=09=09=09=09=09=09=09=09\ > -=09=09__get_user_asm("lw", (ptr), __gu_val, __gu_err);=09\ > +=09=09__get_user_asm("lw", (ptr), x, __gu_err);=09=09\ > =09=09break;=09=09=09=09=09=09=09\ > -=09case 8:=09=09=09=09=09=09=09=09\ > -=09=09__gu_err =3D __copy_from_user(&__gu_val, ptr, 8);=09=09\ > -=09=09if (__gu_err)=09=09=09=09=09=09\ > -=09=09=09__gu_err =3D -EFAULT;=09=09=09=09\ > +=09case 8: {=09=09=09=09=09=09=09\ > +=09=09__u64 __x =3D 0;=09=09=09=09=09=09\ > +=09=09__gu_err =3D raw_copy_from_user(&__x, ptr, 8) ?=09=09\ > +=09=09=09=09=09=09=09-EFAULT : 0;=09\ > +=09=09(x) =3D (typeof(x))(typeof((x) - (x)))__x;=09=09\ > =09=09break;=09=09=09=09=09=09=09\ Wouldn't it be better to just fetch two 32bit values: Something like (for LE - nios2 is definitely LE: =09=09__u32 val_lo, val_hi; =09=09__get_user_asm("lw", (ptr), val_lo, __gu_err); =09=09__get_user_asm("lw", (ptr) + 4, val_hi, __gu_err); =09=09x =3D val_lo | val_hi << 32; =09=09break; =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)