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=-2.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, TVD_SUBJ_WIPE_DEBT,URIBL_BLOCKED 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 6CC2CC43461 for ; Thu, 10 Sep 2020 15:33:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BC26208E4 for ; Thu, 10 Sep 2020 15:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731009AbgIJPdD convert rfc822-to-8bit (ORCPT ); Thu, 10 Sep 2020 11:33:03 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:39154 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727887AbgIJPcQ (ORCPT ); Thu, 10 Sep 2020 11:32:16 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-276-Rr3yeOHPPMud0l-oIQnsyA-1; Thu, 10 Sep 2020 16:31:54 +0100 X-MC-Unique: Rr3yeOHPPMud0l-oIQnsyA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 10 Sep 2020 16:31:53 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 10 Sep 2020 16:31:53 +0100 From: David Laight To: 'Segher Boessenkool' CC: 'Christophe Leroy' , 'Linus Torvalds' , linux-arch , Kees Cook , the arch/x86 maintainers , Nick Desaulniers , Linux Kernel Mailing List , Alexey Dobriyan , "Luis Chamberlain" , Al Viro , linux-fsdevel , linuxppc-dev , Christoph Hellwig Subject: RE: remove the last set_fs() in common code, and remove it for x86 and powerpc v3 Thread-Topic: remove the last set_fs() in common code, and remove it for x86 and powerpc v3 Thread-Index: AQHWhvDyD2c/lZfV3kC0Ftay5UVebqlhgjnw///zuACAABnIEIAAOoMggAAi9ACAABJI8A== Date: Thu, 10 Sep 2020 15:31:53 +0000 Message-ID: <18fdbaeacba349a0a8bf7568f709e991@AcuMS.aculab.com> References: <20200903142242.925828-1-hch@lst.de> <20200903142803.GM1236603@ZenIV.linux.org.uk> <20200909184001.GB28786@gate.crashing.org> <3beb8b019e4a4f7b81fdb1bc68bd1e2d@AcuMS.aculab.com> <186a62fc-042c-d6ab-e7dc-e61b18945498@csgroup.eu> <59a64e9a210847b59f70f9bd2d02b5c3@AcuMS.aculab.com> <5050b43687c84515a49b345174a98822@AcuMS.aculab.com> <20200910152030.GJ28786@gate.crashing.org> In-Reply-To: <20200910152030.GJ28786@gate.crashing.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.001 X-Mimecast-Originator: aculab.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org > -----Original Message----- > From: Segher Boessenkool > Sent: 10 September 2020 16:21 > To: David Laight > Cc: 'Christophe Leroy' ; 'Linus Torvalds' foundation.org>; linux-arch ; Kees Cook ; the > arch/x86 maintainers ; Nick Desaulniers ; Linux Kernel > Mailing List ; Alexey Dobriyan ; Luis Chamberlain > ; Al Viro ; linux-fsdevel ; > linuxppc-dev ; Christoph Hellwig > Subject: Re: remove the last set_fs() in common code, and remove it for x86 and powerpc v3 > > On Thu, Sep 10, 2020 at 12:26:53PM +0000, David Laight wrote: > > Actually this is pretty sound: > > __label__ label; > > register int eax asm ("eax"); > > // Ensure eax can't be reloaded from anywhere > > // In particular it can't be reloaded after the asm goto line > > asm volatile ("" : "=r" (eax)); > > This asm is fine. It says it writes the "eax" variable, which lives in > the eax register *in that asm* (so *not* guaranteed after it!). > > > // Provided gcc doesn't save eax here... > > asm volatile goto ("xxxxx" ::: "eax" : label); > > So this is incorrect. >From the other email: > It is neither input nor output operand here! Only *then* is a local > register asm guaranteed to be in the given reg: as input or output to an > inline asm. Ok, so adding '"r" (eax)' to the input section helps a bit. > > // ... and reload the saved value here. > > // The input value here will be that modified by the 'asm goto'. > > // Since this modifies eax it can't be moved before the 'asm goto'. > > asm volatile ("" : "+r" (eax)); > > // So here eax must contain the value set by the "xxxxx" instructions. > > No, the register eax will contain the value of the eax variable. In the > asm; it might well be there before or after the asm as well, but none of > that is guaranteed. Perhaps not 'guaranteed', but very unlikely to be wrong. It doesn't give gcc much scope for not generating the desired code. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)