Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1086969pxj; Sat, 8 May 2021 07:21:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8772dkMGR1WrT4ujohh8z50hMZPc6/lLzq8AXlGAkO/nyZkXsvJ9qavYe9NXwBp+ritzX X-Received: by 2002:a92:360e:: with SMTP id d14mr13747653ila.106.1620483699113; Sat, 08 May 2021 07:21:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620483699; cv=none; d=google.com; s=arc-20160816; b=I21c3SfIkxvuZAGgWgoMD5Qfr3EooJ974FX2PQpu3OJ5mUT+AEP1/SFoo0YYz8tBBz pApxY2LE2TJU900CF5srvFFJXD6j/ZbJFuKo67Bhk/Yd5aXVeEdKl5H0ituIvdfw1YsW pFdfnnEkKN0X7wsas/S52GXlsIM/J7z2HbWc9CSKEMbZux/eTVx66Na9Iz+AimHsUcmy ytne9fhVFPPaH/gJ6i9tvHfNutMiamZ0lmOQqiWaS/S296nOqEIyGNl+kKX23OJn7sNZ JLgmfNTV66JfL510u9+41K+z9Wr2vn/XKFYkCN7uopImA+1JqmgDrQyE36yr6Tw7ujjc C4tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=nmtyleKzz2IgAAPH00/zvBxO/6VFf+U4TdM12Wzs0mA=; b=lAT8e6JCW/fO4gVuYTmY/VpcbEm+sgi9Yx7yykI49Z91zlAFzyEmqAS3MfYQFUGuF6 NJtfTlVEOSLIg2tXPwtAmqxEzCF54UTrYppsy1BV9+SO8gpLD4HZXPipkh9WrXLxTAcZ PHuKNo0FJeh23kLqlxkuUbeOyVC9EPQyyyFb5L+TPjbIRN0pqRvx+9zMy+k+7hFOKcEk w9Ri5WrPxBrZ3oskD4UyXPoT12ZwN8PaMcSJHKMAH5bEJCYQGCbhGQp39RfjuWKKFYBe J6L0guxu3nR8+2A/7v+VcTr11ItFrEWJj1FxlOvcfYBXZpfqTEt+bxWsMwjJOoqMkCcp 5P3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si9452917jap.32.2021.05.08.07.21.26; Sat, 08 May 2021 07:21:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229500AbhEHOUH convert rfc822-to-8bit (ORCPT + 99 others); Sat, 8 May 2021 10:20:07 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:33801 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229617AbhEHOUD (ORCPT ); Sat, 8 May 2021 10:20:03 -0400 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-7-Y7zwXQ6EN4uScP4hg-f8Eg-1; Sat, 08 May 2021 15:18:58 +0100 X-MC-Unique: Y7zwXQ6EN4uScP4hg-f8Eg-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; Sat, 8 May 2021 15:18:56 +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; Sat, 8 May 2021 15:18:56 +0100 From: David Laight To: 'Arnd Bergmann' , "'linux-arch@vger.kernel.org'" CC: 'Linus Torvalds' , 'Vineet Gupta' , 'Arnd Bergmann' , "'linux-kernel@vger.kernel.org'" Subject: RE: [RFC 12/12] asm-generic: simplify asm/unaligned.h Thread-Topic: [RFC 12/12] asm-generic: simplify asm/unaligned.h Thread-Index: AQHXQ44THJRTTBSqUkSVDsewAlm13qrZaWdAgAA4mTA= Date: Sat, 8 May 2021 14:18:56 +0000 Message-ID: <98e7af705bf54b88a99dfec46308bb7a@AcuMS.aculab.com> References: <20210507220813.365382-1-arnd@kernel.org> <20210507220813.365382-13-arnd@kernel.org> <0b599cc80612436bb8d688fa2ad1dc34@AcuMS.aculab.com> In-Reply-To: <0b599cc80612436bb8d688fa2ad1dc34@AcuMS.aculab.com> 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: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Laight > Sent: 08 May 2021 12:03 > > From: Arnd Bergmann > > Sent: 07 May 2021 23:08 > > > > The get_unaligned()/put_unaligned() implementations are much more complex > > than necessary, now that all architectures use the same code. > > > ... > > +#define __get_unaligned_t(type, ptr) ({ \ > > + const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \ > > + __pptr->x; \ > > +}) > > I thought gcc was likely to track through the alignment of the > variable holding the source pointer (through any (void *) casts > implied by inlined function calls) through to the pointer used > for the actual access - so it would tend to issue a single > instruction that assumed an aligned address. > > I know that has caused grief trying to copy unaligned data > to an aligned structure. > > Possibly adding: > asm ("" :: "+r" (__pptr)) ); > in the middle stops that assumption without generating any code. That is the wrong asm. You need the one where an input operand and output operand share the same register and use it for the assignment. I've been trying to get godbolt to do something useful. But it seems to be stuck in C++ mode and is missing something like sparc which definitely doesn't do misaligned accesses. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)