Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp534183pxb; Tue, 9 Feb 2021 06:38:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzndRJZ2NjllloDGfJTHgGPDecxteGFvCyYS+7CkvzUpVcfBvK5Ahk2PXXI06BzqFHARiBR X-Received: by 2002:a50:d307:: with SMTP id g7mr22277736edh.204.1612881527826; Tue, 09 Feb 2021 06:38:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612881527; cv=none; d=google.com; s=arc-20160816; b=f0s70TkaFsVCsC4JhMUJ8ksZrxxtxLULWfl/fgToQ8XzI8gLbU7Q9rT4nAzKNoqYNF D4C44zFxmJAggQEePXxlHyUeubKFlkBbtDpyYmlAxhuNrT+6f0KIOYwE444WUy+lp3Vx QuANJ4uOyzLiGyMfkIsQVBDUm4tqyYMjwKDCVf9u5JgDWQGi0k5fWm8E3gSehJ2Mag5+ /p4Tg4fcC2m2aiJHlLUNpBx1eKb+GcPaDLmiIVdhmIAR22xN6otBbhlh7h79EAOLhO7r Jve2lHRaefXGZRc0xuIbueNWYFnf7Zkf4MFvDaK6dCBFLTa2C5E4n02g2mfM0Y9k77u0 YIFQ== 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=yLbC15lS2V+XpNeyWkjIgzo/yRMKxc/52GKzHStPGvI=; b=znWe5k8gasFgiM2+nERjavBLzRqnGyv25QwIpPQwfRDQhRrxyCViiZBY+LrwrQO9XQ VR0g3FyaegrG286nH5mOLFAp/bm4A+NWoZvs3yT+i3UehxcGIdrnP3gpycBNpRkdj60z Yf1xoRAl+VcEAOXYzP0PaJchP5Fy1lvwd/FhGS7jOfmJwU1n8p4VLsb7vlo8/kiGy53/ f7RBtvbr3vQedT52y9JHxFl13mxBx66p96CwGLHJZXA4+7/2yvCiO/SrEjdW02KiMQfx WDoyVhDsfbVfZl8ejd9IiE/LYgbsbYBMhyJnSXhJKWy5GI8QHG5HfeFbAPXPjffNoC0T yjnA== 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 p12si13077475ejx.70.2021.02.09.06.38.24; Tue, 09 Feb 2021 06:38:47 -0800 (PST) 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 S232048AbhBIOeg convert rfc822-to-8bit (ORCPT + 99 others); Tue, 9 Feb 2021 09:34:36 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:40625 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232077AbhBIOc6 (ORCPT ); Tue, 9 Feb 2021 09:32:58 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-288-A_ICKLg_PmetPQrYbE_D-A-1; Tue, 09 Feb 2021 14:31:16 +0000 X-MC-Unique: A_ICKLg_PmetPQrYbE_D-A-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; Tue, 9 Feb 2021 14:31:16 +0000 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; Tue, 9 Feb 2021 14:31:16 +0000 From: David Laight To: 'Segher Boessenkool' , Nicholas Piggin CC: "linux-kernel@vger.kernel.org" , "Paul Mackerras" , "msuchanek@suse.de" , "linuxppc-dev@lists.ozlabs.org" Subject: RE: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer Thread-Topic: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer Thread-Index: AQHW/uu6M1m95GjSlEGhmhkEL2m4wKpP4cNQ Date: Tue, 9 Feb 2021 14:31:16 +0000 Message-ID: References: <24804747098369ebcdac38970b8f7a1260bdd248.1612796617.git.christophe.leroy@csgroup.eu> <1612838134.rvncv9kzls.astroid@bobo.none> <20210209135053.GD27854@gate.crashing.org> In-Reply-To: <20210209135053.GD27854@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 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: Segher Boessenkool > Sent: 09 February 2021 13:51 > > On Tue, Feb 09, 2021 at 12:36:20PM +1000, Nicholas Piggin wrote: > > What if you did this? > > > +static inline struct task_struct *get_current(void) > > +{ > > + register struct task_struct *task asm ("r2"); > > + > > + return task; > > +} > > Local register asm variables are *only* guaranteed to live in that > register as operands to an asm. See > https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables > ("The only supported use" etc.) > > You can do something like > > static inline struct task_struct *get_current(void) > { > register struct task_struct *task asm ("r2"); > > asm("" : "+r"(task)); > > return task; > } > > which makes sure that "task" actually is in r2 at the point of that asm. If "r2" always contains current (and is never assigned by the compiler) why not use a global register variable for it? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)