Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1629830pxb; Mon, 12 Apr 2021 02:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQqppK+CAfd2kn/aR8ZtQuYOoc7EVORP7qT50d9DUbFQjbVR6t/qF13vGDc4hDlgp49DeG X-Received: by 2002:a17:902:8308:b029:e9:d69:a2f with SMTP id bd8-20020a1709028308b02900e90d690a2fmr25571321plb.20.1618221201401; Mon, 12 Apr 2021 02:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618221201; cv=none; d=google.com; s=arc-20160816; b=QFnrOcu1cslql4uwEDSEkdf8BMWoHcFeV/xpo4yjJXC/qsHvYIbobPBV6gQA17ijRM FptwiLwMtjRfwYje0UQ0WLrnQ5Y95cJurAech9bsQuYLQzpunF3so7h678plWZlnDFlK MGRWhxCT3Yrk+s2rFezzjBxG38+eGfb3QLu9n6uyR9pEgfPrBVtC8+3K83wNSsVfSoYK YXkq2Q2f0J0FSuRPONGe+4AtdJGaP2Sbk20t1ztXnG49xtQhIYRnuo7GPPNYurm3QBoR v5vZv+SRskliSsNHCt2b1x8zo68rACg6wIGbS1c4PcbzCgu3lUgMkogxCwoEkYxn9tEg bE2w== 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=51qFDTV2dyYHhuLGA38pBE9gTp0H3eppDE7HuGddR1k=; b=xZRzQTQQkXjlSXcu8I7aiqZGKHwboeEEXuIqlcdOvsHyCndHoqXH3yDCG8j/i3pKet tO8kiEEyBVZPr78xkpl2GJ/NalYo6Ctf9xR094Na/Fvz/R/QZumSv57DmttVMx23DoHW zAKntRZapD+0M43gh+yPw303ETcHI2gRD+0w25wb9GhsOAleyMkiBHUuG2jjczhd8t6O 7EOCDRSId/uc3qCPBwkpjEvSgxQ1SdpDCAAogTjByW0dZhsezBhaAastQ7lqbBCcxd5z W8iuVZq0Pxk2qZlg5I5xHCrgOnLX3Ym63ls8uevvcM61iFxPKt96r14y98gTs1ROMUyF aXhA== 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 1si13256259pgz.322.2021.04.12.02.53.08; Mon, 12 Apr 2021 02:53:21 -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 S242633AbhDLJui convert rfc822-to-8bit (ORCPT + 99 others); Mon, 12 Apr 2021 05:50:38 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]:20915 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239403AbhDLJhp (ORCPT ); Mon, 12 Apr 2021 05:37:45 -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-82-C7COxs-EPmWmM_DfUiqZhw-1; Mon, 12 Apr 2021 10:37:23 +0100 X-MC-Unique: C7COxs-EPmWmM_DfUiqZhw-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; Mon, 12 Apr 2021 10:37:22 +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.012; Mon, 12 Apr 2021 10:37:22 +0100 From: David Laight To: 'Christoph Hellwig' , Catalin Marinas , Will Deacon , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "David S. Miller" , "x86@kernel.org" , Arnd Bergmann CC: "linux-arch@vger.kernel.org" , "linux-s390@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mips@vger.kernel.org" , "sparclinux@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Subject: RE: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Thread-Topic: [PATCH 5/5] compat: consolidate the compat_flock{,64} definition Thread-Index: AQHXL3nAXViKKuH90kqxIUkBtWSuL6qwmWXw Date: Mon, 12 Apr 2021 09:37:21 +0000 Message-ID: <15be19af19174c7692dd795297884096@AcuMS.aculab.com> References: <20210412085545.2595431-1-hch@lst.de> <20210412085545.2595431-6-hch@lst.de> In-Reply-To: <20210412085545.2595431-6-hch@lst.de> 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: Christoph Hellwig > Sent: 12 April 2021 09:56 > > Provide a single common definition for the compat_flock and > compat_flock64 structures using the same tricks as for the native > variants. An extra define is added for the packing required on x86. > ... > /* > - * IA32 uses 4 byte alignment for 64 bit quantities, > - * so we need to pack this structure. > + * IA32 uses 4 byte alignment for 64 bit quantities, so we need to pack the > + * compat flock64 structure. > */ > -struct compat_flock64 { > - short l_type; > - short l_whence; > - compat_loff_t l_start; > - compat_loff_t l_len; > - compat_pid_t l_pid; > -} __attribute__((packed)); > +#define __ARCH_NEED_COMPAT_FLOCK64_PACKED That shouldn't need to be packed at all. (Since the 32bit variant isn't packed.) compat_loff_t should itself have __attribute__((aligned(4))) probably inherited from compat_s64. So l_start will be at offset 4 without the __packed. I'm guessing that compat_pid_t is 16 bits? So the native 32bit version has an unnamed 2 byte structure pad. The 'packed' removes this pad from the compat structure. AFAICT (apart from mips) the __ARCH_COMPAT_FLOCK_PAD is just adding an explicit pad for the implicit pad the compiler would generate because compat_pid_t is 16 bits. If the padding need not be named for the 64bit system calls. (Where there is probably rather more padding all over the place.) then it doesn't need to be named for the compat variants. Even the mips extra padding could be removed. F_GETLK might be expected to do a read-write of them, so return EFAULT if not mapped. But nothing should be testing the EFAULT is returned! David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)