Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp503515pxb; Tue, 9 Feb 2021 06:01:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJza9gzDyGkZIP8FrUpou8OkFiwIWG5wJy1ujXeUW2YoE7SaxNBzW/Lb2acPJryKyx1OZQCK X-Received: by 2002:a1f:99d4:: with SMTP id b203mr12925383vke.21.1612879288355; Tue, 09 Feb 2021 06:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612879288; cv=none; d=google.com; s=arc-20160816; b=jTByHNHW/dGdP7q6Z8CDj5DEPc2wc/fycjlSmGQEXVfEW7quV1ABhIkvq13SN728vc GXZUH34aiBqb7wyILtWNk3Ud07E2S00cRaiwiWrsv6uuXTGdu/iOL7ZxDJM9kXwz/vRV tN8ifinP+0q00IW+Lo1yHYNbK7W2zzR2Ik4lhj8CiCklyy2FbOhC6vPjK2jFEjvI+533 7ESg46IMcL/NvwEuN+a5UbPOphW9aemoe0lI4IVoUsZQGg3GxUEm/Wpc0HPxWqSLHERq m/ms4Sy/zqehYz6Y6no593KXqq8IUoExCCY7AZlPNGTGni3Xad+Z0urlomkT9gLACF4i zXWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7FWG8WalxPRg/x+h19aeNJaen68MMlMPkG3OUT0wuPA=; b=HdHSHQ9eFK0eA5vcO0wAMpM3d8wA7ldJUdhxILHBj6GjkUYgCNgbpksdzm1QnLcxc+ s3eXzJIy1ml92kiBwhSeydTZBugxAcQJdR2onmy7O5K7kZ6mqvfI+7PTzJ4V8kddT/Ie 5C8CxvjDGrw6uxoJivP/Bk7w/0s6SspGJMxvKyC3FjI/kKLYA3PQZnb9UBm+zxAGyKOH h10JFDyrcAtFsZP41t8Iu11RhOBxPTsCZDB68x/vLXZWTFjmjLRh1DLyRuU21gIkWFWz 60t7tFBJ7xZN2HQmdx9E1E5P8wdSs7TFGb9x5SaJOQtuu0CVXRNeywsWS/STLBGx7aBH V9hA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si7185853edg.104.2021.02.09.06.01.02; Tue, 09 Feb 2021 06:01:28 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231962AbhBIN7K (ORCPT + 99 others); Tue, 9 Feb 2021 08:59:10 -0500 Received: from gate.crashing.org ([63.228.1.57]:41868 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbhBIN6S (ORCPT ); Tue, 9 Feb 2021 08:58:18 -0500 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 119Dot0b023626; Tue, 9 Feb 2021 07:50:55 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 119DorgE023625; Tue, 9 Feb 2021 07:50:53 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 9 Feb 2021 07:50:53 -0600 From: Segher Boessenkool To: Nicholas Piggin Cc: Benjamin Herrenschmidt , Christophe Leroy , Michael Ellerman , msuchanek@suse.de, Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 20/22] powerpc/syscall: Avoid storing 'current' in another pointer Message-ID: <20210209135053.GD27854@gate.crashing.org> References: <24804747098369ebcdac38970b8f7a1260bdd248.1612796617.git.christophe.leroy@csgroup.eu> <1612838134.rvncv9kzls.astroid@bobo.none> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1612838134.rvncv9kzls.astroid@bobo.none> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Segher