Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1617522pxu; Sun, 6 Dec 2020 01:42:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJySNOncQ1id2aDjlewRXTTshj9qQBQfsX6S/xEfIqG4X6zmPTXWx4t77yifJ0paT/fXlZhV X-Received: by 2002:a17:906:26c6:: with SMTP id u6mr14267286ejc.349.1607247746546; Sun, 06 Dec 2020 01:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607247746; cv=none; d=google.com; s=arc-20160816; b=f17RsZRzhQDcx3NDhakYiqJD1ednnzocOSyg8WDzMW8kH3A2iSoIQRYEjPLoSSB9Nf za5WSMnKZEVEqyIckltR8n06tAcBIAr8hQlF97h1NwIGigSYO1NCaU1UVr0ZLs9HZVC9 awvfOxdN13hthtIG+eEsto3Q2059bCENqQXzlBTG24hFt0ryJlDG0oQfgUjW/pldO/nj XNKwILi4BHasaAXqNJdnUlQI+o1PnrirowqpaUQlDgcjTJssrHU6s7WZhTw7fPIld+Mu Tv194oRxLEdH6bq6FqICKXX6wJIBYdnzLrZebgyr7sUL78pMp6xwZ3MvriBekDIky3OD gEPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date; bh=WSM94AJIEUP+hS4WIdCCzkS6TnJwkHrdyLNW3Dn37jA=; b=uCYezF62NoRTIhgCdAnNwyHT7WUpjX3cb11Mr9htyqHIMpArAQUzd27ov3h4An7ls5 gToTPBEQziBmo3zyZ9f3ocETyB3hFwA71jBteACCHehOjrcTZVsfgIG1WSVQGIjeb00c EbFDwgwMQutrMYPAwWvEDVWeifpnTRVDeiG8+bhrBhCZrPKviK31qSuYAc1z8aJhFd9d Kgonots9oKNPs3R8A+NQw8cJI0oxa3QVF3R44e5+vOqyqQ1165f1cDDRkuEEIX0KyIJw 0H5GDDjqBqF18wqrVwH6NiDPiJoLymd/SSRlrgx5qEIlzxh75tHWfcha3tT83S5rWxWX ifuw== 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 gn22si4440925ejc.749.2020.12.06.01.42.03; Sun, 06 Dec 2020 01:42:26 -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 S1726451AbgLFJie (ORCPT + 99 others); Sun, 6 Dec 2020 04:38:34 -0500 Received: from [157.25.102.26] ([157.25.102.26]:44596 "EHLO orcam.me.uk" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726141AbgLFJid (ORCPT ); Sun, 6 Dec 2020 04:38:33 -0500 Received: from bugs.linux-mips.org (eddie.linux-mips.org [IPv6:2a01:4f8:201:92aa::3]) by orcam.me.uk (Postfix) with ESMTPS id E168B2BE0ED; Sun, 6 Dec 2020 09:37:59 +0000 (GMT) Date: Sun, 6 Dec 2020 09:36:16 +0000 (GMT) From: "Maciej W. Rozycki" To: Anders Roxell cc: Thomas Bogendoerfer , natechancellor@gmail.com, ndesaulniers@google.com, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH] mips: lib: uncached: fix uninitialized variable 'sp' In-Reply-To: <20201127083938.2666770-1-anders.roxell@linaro.org> Message-ID: References: <20201127083938.2666770-1-anders.roxell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 27 Nov 2020, Anders Roxell wrote: > When building mips tinyconfig with clang the following warning show up: > > /tmp/arch/mips/lib/uncached.c:40:18: note: initialize the variable 'sp' to silence this warning > register long sp __asm__("$sp"); > ^ > = 0 > > Rework to make an explicit inline move. It's not uninitialised, because by definition $sp has been initialised. This code wouldn't have worked for the last 15 years otherwise. It is however non-standard usage (which may not have been clarified at the time this piece was made; I recall extensive discussions around this feature over the years): "6.47.5.2 Specifying Registers for Local Variables ................................................. [...] "The only supported use for this feature is to specify registers for input and output operands when calling Extended 'asm' (*note Extended Asm::). [...]" so the change description should refer to that as the rationale rather than an implementation-specific misleading warning (although that can be quoted for a reference of course). > diff --git a/arch/mips/lib/uncached.c b/arch/mips/lib/uncached.c > index 09d5deea747f..21a4b94a0558 100644 > --- a/arch/mips/lib/uncached.c > +++ b/arch/mips/lib/uncached.c > @@ -37,10 +37,11 @@ > */ > unsigned long run_uncached(void *func) > { > - register long sp __asm__("$sp"); > register long ret __asm__("$2"); > long lfunc = (long)func, ufunc; > long usp; > + long sp; > + asm ("move %0, $sp" : "=r" (sp)); Missing newline between the variable block and code here; you may well swap it with the empty line below you have left. Also use `__asm__' for consistency, and remove the extraneous space ahead of the parenthesis as we don't use them in Linux. Using a tab to separate the mnemonic from operands is also preferable, i.e. "move\t%0, $sp" in this case (using actual tabs works better with multi-line assembly, but this is not one). I think this should be OK once the issues I mentioned here have been addressed. Maciej