Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16990617ybl; Wed, 1 Jan 2020 19:04:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzQI6iWsmrId3fZzmHN7mIE9jtY9icndLZh6tuXrRkOa6HKZChGgWyFoXkPCw88/bdHkqsS X-Received: by 2002:a05:6830:3050:: with SMTP id p16mr44949909otr.301.1577934295424; Wed, 01 Jan 2020 19:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577934295; cv=none; d=google.com; s=arc-20160816; b=gBehCSFN228rlizkxHwNpHdf4D2owwEe8rilG/4WD9wC/OlvWQHIfhHPWWetu4LK1j Pp7NlWlnM58c/LCQ11RosfUObEwBqAIPl2EPYXYy8ema0U1gTRt02e+lm7zYgXsmAWhX K/vZyb6dffEACD7ZhZlctkEPmGnhHfeo2zdbTkkzDxAjkQt73DqGlzxpb/Y2juUrwktL n8Msqm3ZZQ6iGEcZ3thDA0vpK0K5NafQ/Upfku26ZfQossLjsIaWBKMBnFyXyRq72RkX Y0ssWNYtZSzm5TH4iAnYjvHz8X+l88zbhbCMhjnnNiu9VF9NDRlwiLt+wYobjIO6H7NH RIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Fsf4Kv4GKfEO6/i6UJSN8gP+gZz4MfI3CR+WieAs89w=; b=i2W3gJbBTvYlEXmf5PuYWuI8QHt93o0Nlw+5hX9FMfH6CCKud7+ZB7KFvMyA9G/nJw 3N56yKyQ5JoQY68nrCDh6SXm5HhngidkgIvpLwxnrcd5vFHnttRVmCmqwGf1juIdnCCf xFyMNpwHpO42qX0/e8nM1oTNbytKDlmKzYNkiEp7DFMQ+oRQrumsvwyghh8yB260yCb1 hgxbc7qIHM3MJdSxXP1KDaIf1sczA0yvaAbKEq+Gn3I+abvt7HMW7wkzK5EBykdM2P2c 0fgMMzGZDSOVSXC/ruo7YXjWnspnysxxD7lMWbQGj8BAczXWYXbXCKSToNOKwKgsQ6kj hg9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vIBadxwj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si28194895otj.282.2020.01.01.19.04.19; Wed, 01 Jan 2020 19:04:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vIBadxwj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727566AbgABDCd (ORCPT + 99 others); Wed, 1 Jan 2020 22:02:33 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:44101 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727509AbgABDCc (ORCPT ); Wed, 1 Jan 2020 22:02:32 -0500 Received: by mail-ot1-f67.google.com with SMTP id h9so52592777otj.11; Wed, 01 Jan 2020 19:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Fsf4Kv4GKfEO6/i6UJSN8gP+gZz4MfI3CR+WieAs89w=; b=vIBadxwjvV/v/SLLefWz19+1AioDTALvEnFaP8rT95BPmtN3e/62j76b1AOORG48Qe IDRXd+Xn+DAvBi7BY4A2BoUsUDhOYPA2wTwCW9bLcOGsVAgjRzd0910Z/na4RFILuHWS J1a+YJq0keFdCwqEOd+rz6C0zUZLekApIqb9XNDErzrJKaKjqaIBWuo0wLgV4p7wuuy8 m/jfmtsJh2BpuCR4QdYB9/YRgPhbWtCCELjI9A42EHfX2CuG496gcAF5iqwsVOwRVQEq kZhJeb4E2Lz1tQZPYSZvfzqxBf7mWqh1TExjAXqitiBtYF+eS63SV1Ox26gC7H+B/+B8 pqNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Fsf4Kv4GKfEO6/i6UJSN8gP+gZz4MfI3CR+WieAs89w=; b=pl1LlwxnZzk7k9b30XD2447vxNUFkSKDbgiTihwyf8+k4P1ta1S0rvtoFU+G5Q8pvQ F3sjmhJEAZq74X+k7jz6OatZZlqKyb96Pj7aDbIIB27yYchtsCr2PSe4mSyOKefJkAov XFiXkVYS41kDXQ9GsPXEpqx0M67ITVphnpx0lr5bRbrmLPNj1+hNmbUGPBdDtZGiof4Y WMGhsojrqDVP6eL3AsCzthXlxw6XO8ZbF96lmJguAEsk2dszBPsTNjgXjZEgh5xMTorg Gf0L3FX9y/RzLx3Jogkz5ctr9lV1T608or8R4bTO4sX5N46xILrJoCHs686nD9LwOFz3 hHVw== X-Gm-Message-State: APjAAAVCGvWx6gcK5te6G8iXMnrtAkTnNk1DESaB2BL1jO14dWdBJvW+ coZ5BODNNIvlSEx9FSIrDrw= X-Received: by 2002:a05:6830:15a:: with SMTP id j26mr85700884otp.137.1577934151509; Wed, 01 Jan 2020 19:02:31 -0800 (PST) Received: from ubuntu-m2-xlarge-x86 ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id o20sm15235472oie.23.2020.01.01.19.02.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Jan 2020 19:02:30 -0800 (PST) Date: Wed, 1 Jan 2020 20:02:29 -0700 From: Nathan Chancellor To: Arvind Sankar Cc: Arnd Bergmann , Paul Burton , "open list:BROADCOM NVRAM DRIVER" , "linux-kernel@vger.kernel.org" , "Jason A. Donenfeld" , Christian Brauner , Vincenzo Frascino , "# 3.4.x" , clang-built-linux@googlegroups.com Subject: Re: [PATCH] MIPS: Don't declare __current_thread_info globally Message-ID: <20200102030229.GA4478@ubuntu-m2-xlarge-x86> References: <20200101175916.558284-1-paulburton@kernel.org> <20200102005343.GA495913@rani.riverdale.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200102005343.GA495913@rani.riverdale.lan> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 01, 2020 at 07:53:45PM -0500, Arvind Sankar wrote: > On Wed, Jan 01, 2020 at 09:51:02PM +0100, Arnd Bergmann wrote: > > On Wed, Jan 1, 2020 at 6:57 PM Paul Burton wrote: > > > diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h > > > index 4993db40482c..aceefc3f9a1a 100644 > > > --- a/arch/mips/include/asm/thread_info.h > > > +++ b/arch/mips/include/asm/thread_info.h > > > @@ -50,10 +50,10 @@ struct thread_info { > > > } > > > > > > /* How to get the thread information struct from C. */ > > > -register struct thread_info *__current_thread_info __asm__("$28"); > > > - > > > static inline struct thread_info *current_thread_info(void) > > > { > > > + register struct thread_info *__current_thread_info __asm__("$28"); > > > + > > > return __current_thread_info; > > > } > > > > This looks like a nice fix, but are you sure it doesn't allow the compiler to > > reuse $28 for another purpose in the kernel under register pressure, > > which would break current_thread_info()? > > > > I see in the MIPS ABI document that $28 is preserved across function > > calls, but I don't see any indication that a function is not allowed > > to modify it and later restore the original content. > > > > Arnd > > The compiler can already do that even with a global definition. > > The doc since gcc 9 [1] says: > > "Accesses to the variable may be optimized as usual and the register > remains available for allocation and use in any computations, provided > that observable values of the variable are not affected." > > and > > "Furthermore, since the register is not reserved exclusively for the > variable, accessing it from handlers of asynchronous signals may observe > unrelated temporary values residing in the register." > > I'm not sure if this was a change in gcc 9 or simply the doc was wrong > earlier. > > Should there be a -ffixed-28 cflag for MIPS? alpha and hexagon seem to > have that and they also keep current_thread_info in a register. > > Also, commit fe92da0f355e9 ("MIPS: Changed current_thread_info() to an > equivalent supported by both clang and GCC") moved this from local to > global because local apparently didn't work on clang? > > [1] https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Global-Register-Variables.html Yeah this patch appears to break booting malta_defconfig in QEMU when built with clang; additionally, there are a TON of warnings about this variable being uninitialized: ../arch/mips/include/asm/thread_info.h:57:9: warning: variable '__current_thread_info' is uninitialized when used here [-Wuninitialized] return __current_thread_info; ^~~~~~~~~~~~~~~~~~~~~ ../arch/mips/include/asm/thread_info.h:55:52: note: initialize the variable '__current_thread_info' to silence this warning register struct thread_info *__current_thread_info __asm__("$28"); ^ = NULL 1 warning generated. Seems like this is expected according to that previous commit? I noticed there is another instance in arch/mips but it doesn't appear to affect everything. https://github.com/ClangBuiltLinux/linux/issues/606 Cheers, Nathan