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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0FFFC433B4 for ; Tue, 18 May 2021 21:16:21 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44623611BF for ; Tue, 18 May 2021 21:16:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44623611BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References:Message-ID:Date: Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5hELr0lBv9ZUlLTtIds56Pktf6EL10Y4qR3QTvZ4LKU=; b=P9m/4lVx8YKi+hDA4Tm6lsom2 9Z6o340/37jbpqxw1444ZDNvBHGHxgORjvMqknLufZO7lMH/H19FKWBMd9MRtwjuxOzzONjxLM3uB 6JLdZ4u2F65odMLevrj1ekGYw1n//X3TcFGL7iuYTqWYsA/vAhOGNpHvgyeSqtG4cQB3zu8cZn2Tm 9rVZym6bqifbjEgJ5AI66HrcJxNnJP9PGXY9Acm/IxlShfCag+RCj2so9vfK34En0Uau6RTMJnvwK zcFCWD/ZJzUpUrgXy8/QX1a5dpYU4Bk3eImm9vp9CGCKGGsQB/f7isZCT1rNz7JePSvNJvUi7ewYo MY2NXrbTA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lj72e-001u4v-J4; Tue, 18 May 2021 21:14:17 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lj72b-001u4W-4P for linux-arm-kernel@desiato.infradead.org; Tue, 18 May 2021 21:14:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:In-Reply-To:References:Message-ID:Date:Subject:CC: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=Uvo8h7AUuhCO3LknpnOTGZ9jfvXEMkY4tKxi5Q7USNE=; b=XGQCS2ccPM1EjHlt8Y5wRANU11 ppZItWGmdqabGXT+W6bWqmQHgNphHKd+/4Z+nZOHGvjYh683jjJw9KtI8RmG0IBysNQ9+Bqa6TG5c aBdafMFd1s8CtoHpfbLLmfUU77Sao4iy2jXkGujwDanQXW9Ub5dmAdMSeIUa+OLT5uDfZf1p7RRQp uJTiabHcNhUHsZefGKb/ao50ch78vInJyg52+IyPVvRAgBV8Mn3nC43TpjvulukeDW4ykYxmaKzfR Igq4jJrL2TmCw3IqBBAzBUfAUhJDH8E+8nM7CSbLLH85P9yLPkjjSDxM7pk7KSVl1HwuPHAgQUMcL d06NNP2A==; Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lj72X-00EyHF-Rw for linux-arm-kernel@lists.infradead.org; Tue, 18 May 2021 21:14:11 +0000 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-258-XZiFWQz-NZmRbfTBBekA3Q-1; Tue, 18 May 2021 22:14:06 +0100 X-MC-Unique: XZiFWQz-NZmRbfTBBekA3Q-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.2; Tue, 18 May 2021 22:14:04 +0100 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.015; Tue, 18 May 2021 22:14:04 +0100 From: David Laight To: 'Linus Torvalds' , Arnd Bergmann CC: Eric Biggers , linux-arch , Vineet Gupta , "Russell King" , Herbert Xu , "David S. Miller" , Thomas Bogendoerfer , Linux ARM , Linux Kernel Mailing List , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , "open list:BROADCOM NVRAM DRIVER" Subject: RE: [PATCH v2 07/13] asm-generic: unaligned always use struct helpers Thread-Topic: [PATCH v2 07/13] asm-generic: unaligned always use struct helpers Thread-Index: AQHXS/YCMZkjEhef40atSxJR3LrT4Krpu4HQ Date: Tue, 18 May 2021 21:14:04 +0000 Message-ID: <2a31acad459d4e37b31da5b270dcf0ba@AcuMS.aculab.com> References: <20210514100106.3404011-1-arnd@kernel.org> <20210514100106.3404011-8-arnd@kernel.org> In-Reply-To: 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_141410_198401_0649EBDA X-CRM114-Status: GOOD ( 17.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Linus Torvalds > Sent: 18 May 2021 15:56 > > On Tue, May 18, 2021 at 12:27 AM Arnd Bergmann wrote: > > > > > > I wonder if the kernel should do the same, or whether there are still cases > > > where memcpy() isn't compiled optimally. armv6/7 used to be one such case, but > > > it was fixed in gcc 6. > > > > It would have to be memmove(), not memcpy() in this case, right? > > No, it would simply be something like > > #define __get_unaligned_t(type, ptr) \ > ({ type __val; memcpy(&__val, ptr, sizeof(type)); __val; }) You still need something to ensure that gcc can't assume that 'ptr' has an aligned type. If there is an 'int *ptr' visible in the call chain no amount of (void *) casts will make gcc forget the alignment. So the memcpy() will get converted to an aligned load-store pair. (This has always caused grief on sparc.) A cast though (long) might be enough, as might a cast to a __packed struct pointer type. Using a union of the two pointer types might be ok - but might generate a store/load to stack. An alternative is an asm statement with input and output of different pointer types but using the same register for both. That ought to force the compile to forget any tracked type and value. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel