Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1166618pxk; Thu, 10 Sep 2020 08:35:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiYY0f7F7F8YOK98KQhnFvKE4AqoIAC+RyeoLg/S/Cq23cxyCsXrrcUXQFv86Lc+IBJ1LP X-Received: by 2002:aa7:c419:: with SMTP id j25mr10068512edq.109.1599752111122; Thu, 10 Sep 2020 08:35:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599752111; cv=none; d=google.com; s=arc-20160816; b=dqVlvs5lkNLIltE9ZNAFhq+MEyL/8u5t5c/7Z6z4d7x/sw3HANISKFB8gf8QY3rZzP o7dXTWA34WQRx+1ZsUAgLaTLAdHIeclzzxJ68Ti/IKIf4/I/FXUhEn0MBbE7wXez3Hhw 6QTBkKU/xKBK+UbEk7B+7CNu1O/Lq6BUWgiafbaXUz+3vO9adMPtzG4TKy5NLSw9RJZa +qsCeVQLG9Tp7rofnDGOXusRWQ+j0nCfvC6Q3NibHTwPJnrSD61vye7bpZp3YuFdbpCz PTT1DHx+/39saKtTFq2+xHbRkLxKexIx/eUYDm9ngdU5rMtYeSahCCg03WkewVBufFt3 tkEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:accept-language:in-reply-to :references:message-id:date:thread-index:thread-topic:subject:cc:to :from; bh=GPKDr8DKDWAb1wN+RCVe3A0DstZowjbGdQEQjEvh1Rc=; b=pv06Q0xbAzfm047Y9Fa3MfVwOZ5v+6bONT3/ovyTlz9RkwXo/tPcqLKRVxOlBybJ2a PVyczLQgNx3mHbIlz91fjFB9BtBY2OU19qdzkZnqGM64JnhsENWF8lgwPhZZF+SII+ci P/kdCzYweDE5/JpVhUffFp8vwnncobs2jMd4e7EWafsvCrnB5kITfBrgDqDzC8+PfzNI g2WLz2AmvngaJMPOiuPYlj+q3xif0qo7OBoEE52F70EQ0+hDzCn5ZTdoT5Pv75Vs+1es TI2cmdCmu3uBmXnaC0A9kda0cb8AfWApa+xQ5YxwBpE7xgaY4ZVwjWHW/2FlujKIOR04 B68A== 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 d26si3651380edx.497.2020.09.10.08.34.43; Thu, 10 Sep 2020 08:35:11 -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 S1731316AbgIJPd7 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 10 Sep 2020 11:33:59 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:40132 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730077AbgIJPcP (ORCPT ); Thu, 10 Sep 2020 11:32:15 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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)