Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3207430ybc; Mon, 25 Nov 2019 10:38:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwOgu8Hz0J0wi6yACAuXN+K9P665rWci5TxwKX3tZZp7K1vCaohfrqHrv5H3bLw8+ADm633 X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr38553536ejw.286.1574707107749; Mon, 25 Nov 2019 10:38:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574707107; cv=none; d=google.com; s=arc-20160816; b=oU/lIr/VMuGoDx1pXLPx3GtUs68evA12g+UkPFedw6QcGmdlsVxVTybOYTrZVxtCpp k8r4dj/YwOXOnMGGDovcbE1D6oChiRXsLjOHTsLVuOoGsNDfL05CR3Hs058M1mNhIiYW MfwXBCJ/mYliOPuwGhFbXhzmB1flG68+hKb8VDfHfdLDvNzeLwI7rgjhuhFlkhSIP+6t +zQnrxwxq88YHnN1HqmIcE6WQVxIcq038ABal7KQluGUilgLDa/J0Kpxw3vgGYrkV64F 1TRulXl7ZXscRXfJueIjRyB4RX4Cl6zj/lcIHsAOCfaTJzQsA2XvBRAORB3kQkME6yJP GZtQ== 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=9jBBbZRhmnSN3KkQ2LS6GDGqvJZv1027giLS5K1W3Lg=; b=ozch5v36KyjkQJ4Bb6b5u6ttZDpNqnLLXE7bt+mokmBNJ6R7Wl9k4T/WY8AxFzU+6/ lTEhgmEdlGqt4GaERc0xXH5oSniKK8f7BdOUg+jaWsoJbSl08PZFEByBdHoPfd3bpN++ Kv+73hdBq/KWRpKC+0nYcNPRWNkSccDwZ7Gw43O0hFspDm5E8xyH8B0839nzLJgYGM/y KCC//oviDePL0DTOrbg57ZcNkMkudcyXsCXdvFT18Vo23t4Heuus3PUyNOjWLMwqUvlo +Avtq47XUr7IdapubZv2kqeUxvgSIT2EnDhVeuzhMsXoq8CCla/1Ui0Fcrm2dedmFVqp 54KQ== 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 g12si5561841edp.190.2019.11.25.10.38.02; Mon, 25 Nov 2019 10:38:27 -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 S1728106AbfKYO00 (ORCPT + 99 others); Mon, 25 Nov 2019 09:26:26 -0500 Received: from gate.crashing.org ([63.228.1.57]:57482 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728016AbfKYO00 (ORCPT ); Mon, 25 Nov 2019 09:26:26 -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 xAPEPvGa014695; Mon, 25 Nov 2019 08:25:57 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id xAPEPuZS014692; Mon, 25 Nov 2019 08:25:56 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 25 Nov 2019 08:25:56 -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: <20191125142556.GU9491@gate.crashing.org> References: <5ca6639b7c1c21ee4b4138b7cfb31d6245c4195c.1570684298.git.christophe.leroy@c-s.fr> <877e3tbvsa.fsf@mpe.ellerman.id.au> <20191121101552.GR16031@gate.crashing.org> <87y2w49rgo.fsf@mpe.ellerman.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87y2w49rgo.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 Mon, Nov 25, 2019 at 09:32:23PM +1100, Michael Ellerman wrote: > Segher Boessenkool writes: > >> > +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. > > That's the standard I aspire to :P > > > 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? > > The kernel TOC, and also the kernel TOC, unless something's gone wrong > or I'm missing something. If that is the case, we can just do the bl, no nop at all? And that works for all of our ABIs. If we can be certain that we have the kernel TOC in r2 on entry to call_do_irq, that is! (Or it establishes it itself). Segher