Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3036235ybc; Thu, 21 Nov 2019 02:18:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzxNqk+J/W+Caon+PkPeIizo7+4IhmopNfGDGxoCjEcnfbEVm2v1QYf/Q2PFsnrmySWbwhJ X-Received: by 2002:a17:906:70d6:: with SMTP id g22mr12543291ejk.221.1574331494271; Thu, 21 Nov 2019 02:18:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574331494; cv=none; d=google.com; s=arc-20160816; b=L88pzDFyuHihzqfXXajht5YmMJD3R75ehfHPL5GutbdwL6U+W/epH+91Uf6WYFltle 0yuNtzs980i7xxQwiZsLB0d3+czzGbWwzn7Q4Lsf/B5dEUsmCzxHVO8DsHvq0H/aczxF HUEB9l2rjLKEi79llDMULAtE/95OpJlM4BGoHBCPd1AhGAqcaDy0x3/jc7tkaie1+9jt YKOV3mhZTd2IWmU4EziCM9N7Cn6xhwtxb7PjkuHVnA+sXY3Yey5VS4MGjs260Pyex7kT Ge3Hn2Vx1GdfXXwOtsg1cc0DLuwjzxBFd8uoXrYKrUVH1aYjcWI0xVwdDC6PCkuOUPRm L9Vw== 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=expCqQC//bpMztFhP2ekRqwflDvtsCi6zmSR7s5Xx+w=; b=QVo42klJMCV5SXHb4BExsARdoxGB0rhSIlSVteW23xd35b1jzn14ZiI0G1V9SY5wIm dd0TRNC4ze1ukbJ9myFzgvfGAF2Kxs0028NSI4Oq8qFYt5WmU3vytQ+jXVKAx8Sk7jiE Ai/zBeMf0AuZm5/jnCCSNiDWTWrHgFLiPySPGJB/A2ZEI2aMimk4gm3MNqbHKkyDz4wG BeYou3InQsiYWtyTI9PEgng61JYCKtP5mM7ddxCHkce0AFAJDlnAebOysS5BB7+3dW61 sL+aG45iCBgjv77tLSi8Qih0/HlfatVGSE4klDXSQQKNwOfRzrrVwDpOEAi64PQjE7yN oZkQ== 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 q7si1400031ejn.26.2019.11.21.02.17.50; Thu, 21 Nov 2019 02:18:14 -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 S1727130AbfKUKQ1 (ORCPT + 99 others); Thu, 21 Nov 2019 05:16:27 -0500 Received: from gate.crashing.org ([63.228.1.57]:34826 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727106AbfKUKQY (ORCPT ); Thu, 21 Nov 2019 05:16:24 -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 xALAFrfK013183; Thu, 21 Nov 2019 04:15:53 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id xALAFq0D013181; Thu, 21 Nov 2019 04:15:52 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 21 Nov 2019 04:15:52 -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 v4 2/2] powerpc/irq: inline call_do_irq() and call_do_softirq() Message-ID: <20191121101552.GR16031@gate.crashing.org> References: <5ca6639b7c1c21ee4b4138b7cfb31d6245c4195c.1570684298.git.christophe.leroy@c-s.fr> <877e3tbvsa.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877e3tbvsa.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 On Thu, Nov 21, 2019 at 05:14:45PM +1100, Michael Ellerman wrote: > Christophe Leroy writes: > That breaks 64-bit with GCC9: > > arch/powerpc/kernel/irq.c: In function 'do_IRQ': > arch/powerpc/kernel/irq.c:650:2: error: PIC register clobbered by 'r2' in 'asm' > 650 | asm volatile( > | ^~~ > arch/powerpc/kernel/irq.c: In function 'do_softirq_own_stack': > arch/powerpc/kernel/irq.c:711:2: error: PIC register clobbered by 'r2' in 'asm' > 711 | asm volatile( > | ^~~ > > > > diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c > > index 04204be49577..d62fe18405a0 100644 > > --- a/arch/powerpc/kernel/irq.c > > +++ b/arch/powerpc/kernel/irq.c > > @@ -642,6 +642,22 @@ void __do_irq(struct pt_regs *regs) > > irq_exit(); > > } > > > > +static inline void call_do_irq(struct pt_regs *regs, void *sp) > > +{ > > + register unsigned long r3 asm("r3") = (unsigned long)regs; > > + > > + /* Temporarily switch r1 to sp, call __do_irq() then restore r1 */ > > + asm volatile( > > + " "PPC_STLU" 1, %2(%1);\n" > > + " mr 1, %1;\n" > > + " bl %3;\n" > > + " "PPC_LL" 1, 0(1);\n" : > > + "+r"(r3) : > > + "b"(sp), "i"(THREAD_SIZE - STACK_FRAME_OVERHEAD), "i"(__do_irq) : > > + "lr", "xer", "ctr", "memory", "cr0", "cr1", "cr5", "cr6", "cr7", > > + "r0", "r2", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12"); > > +} > > If we add a nop after the bl, so the linker could insert a TOC restore, > then I don't think there's any circumstance under which we expect this > to actually clobber r2, is there? That is mostly correct. If call_do_irq was a no-inline function, there would not be problems. What TOC does __do_irq require in r2 on entry, and what will be there when it returns? Segher