Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp331528ybl; Fri, 24 Jan 2020 00:59:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwrktH4eZKgCa+Z8qA5nUdfiynYinqE6w85ke7JJuXH5fsdt600KHFU5121SJCynNuamfKM X-Received: by 2002:a9d:6513:: with SMTP id i19mr1996872otl.103.1579856344582; Fri, 24 Jan 2020 00:59:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579856344; cv=none; d=google.com; s=arc-20160816; b=A7LV2/wrbTOc1kX/YUsMNAnojRnpiNTkYyE/KHC7L+rMp/m5cfYZDkH2EOy38yniyI k4LCD55vSIamDH1GykV7wmIaEuR63EIo7WH2S5wmQvRzvgDXCxhsNQkNNdwqKvNjdP8b 9szJzQIwZsx7kPOlbwcXaZqkFculVpX7aKYadTcJk1n3Hy1PXhBZd+Hwx5PV3Ypzsl2g jch4m0nBXlTwQG3kVdXiRaHeURgride8fLkxAQnomNGSOTb3HKSG1gKsX4b7lb0revcO g47Xp2gKYeGSckD9Aa4G+qfegtDQEhLzil6fdS1uxsJv1ShySnJ/1zNU9MmbcFL72ajH fDjw== 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; bh=7aRXOR9fQQqCF8OLyf7R4ubyN/i8wQyLyGt1NrxB5/E=; b=mRmdrxdRbFYT3wzJeU52Xp4QLzWgHoyizQkIS4pZffUSys7AB9EBPitx8Io4REp3vV Zp3bEATFU+5Pw9e9z/B0qkPv11jR3/zi8xSS+hRSIYBsN72C+Kp+qEHcXke9ZT1mis9S 6R+vgiph4rBsK2+cEH6sgYozQlqwZx2WQOjXkZ/RIgpDyACnR4B68PchuqgeOw8QXHwR 7Lv2vo4kxD30ul5cmHA/gWCu9Qg3Im90uOlYJCCgI1R4m1OgGQz/rtJgt0dJ2TbEz1JG 1Oa3HBq3+mzqfetoeXYHENjnCpKXx6mbgRmPbKngwDuVPhqrYP3Ba9l9mzEcsnt2bNox Ntzg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7si1580822otl.17.2020.01.24.00.58.51; Fri, 24 Jan 2020 00:59:04 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729418AbgAXIpV (ORCPT + 99 others); Fri, 24 Jan 2020 03:45:21 -0500 Received: from gate.crashing.org ([63.228.1.57]:53033 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbgAXIpV (ORCPT ); Fri, 24 Jan 2020 03:45:21 -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 00O8ipf2015536; Fri, 24 Jan 2020 02:44:51 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 00O8ioUT015535; Fri, 24 Jan 2020 02:44:50 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Fri, 24 Jan 2020 02:44:50 -0600 From: Segher Boessenkool To: Michael Ellerman Cc: Christophe Leroy , Benjamin Herrenschmidt , Paul Mackerras , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 1/2] powerpc/irq: don't use current_stack_pointer() in check_stack_overflow() Message-ID: <20200124084450.GS3191@gate.crashing.org> References: <87d0b9iez3.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d0b9iez3.fsf@mpe.ellerman.id.au> User-Agent: Mutt/1.4.2.3i Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On Fri, Jan 24, 2020 at 04:46:24PM +1100, Michael Ellerman wrote: > Christophe Leroy writes: > > static inline void check_stack_overflow(void) > > { > > #ifdef CONFIG_DEBUG_STACKOVERFLOW > > - long sp; > > - > > - sp = current_stack_pointer() & (THREAD_SIZE-1); > > + register unsigned long r1 asm("r1"); > > + long sp = r1 & (THREAD_SIZE - 1); > > This appears to work but seems to be "unsupported" by GCC, and clang > actually complains about it: > > /linux/arch/powerpc/kernel/irq.c:603:12: error: variable 'r1' is uninitialized when used here [-Werror,-Wuninitialized] > long sp = r1 & (THREAD_SIZE - 1); > ^~ > > The GCC docs say: > > The only supported use for this feature is to specify registers for > input and output operands when calling Extended asm (see Extended > Asm). > > https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Local-Register-Variables.html#Local-Register-Variables Yes. Don't use local register variables any other way. It *will* break. > If I do this it seems to work, but feels a little dicey: > > asm ("" : "=r" (r1)); > sp = r1 & (THREAD_SIZE - 1); The only thing dicey about that is that you are writing to r1. Heh. Well that certainly is bad enough, the compiler does not know how to handle that at all... Of course you aren't *actually* changing anything, so it might just work. Segher