Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1524345pxb; Thu, 28 Oct 2021 05:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOdWXO7lsPmi66AyJRT0j3wPS2YXtBOvb3dvFfrhq/pXtWf939du15wWTszsP2nzqbfqyP X-Received: by 2002:a17:906:b884:: with SMTP id hb4mr4874502ejb.376.1635424093803; Thu, 28 Oct 2021 05:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635424093; cv=none; d=google.com; s=arc-20160816; b=lyd0IYYDXRHcNcMujkFicK7fkxmU5vUh1NBY9HwjZGMjGWpRXPo4hMhfUhXNMphsFu bWgK10Vp6RspJC1Yk7m7kG6BP5gAhvCUZvyj0VQPm6d8ntQaRcVw9l7+/FYJ/zKp09WV 2AGlf+cgtdtJq/kGgDS/QOd0MYkzina6qGExsjcWVc7xPtlbAO90sOmorG+XEZ6qoFOV ooufoBNBXDV9UJtqKz98aKmnNgNn9KhOVzrWLFoMsRTeoR3Yw7nPWb2BBILzgsL2uR+M fU0/KfkhgemSSxnIdXOetXn6FuiZtgIfxYB39gBN3cRu//gzb7I9W3M4gE5ci4gZNmEz WbkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TeZF67b5P0Cbkj7pn269Ad/zybAz8ThbBQUcfPX+FqI=; b=Ao+NJ9jFhHPx0YK58Cp4oP4IP2fn/LTAaTpUIFdH65i5oLgDofqUBeo79IpFZLoH6I 4MNu5xkOHKNeOHw6lPTwm0D1m3di7WsVsG5JYg76Osr8dq23/4M5TjsI9Mk/wJ0uhoSC jj146zfVxxyNfpG/LoWyS8UFa3vvaI/PYPGm0CaJDssFBvB3bLjLRmn2iLBwB7UmQn+C LZU8dpmA1akTHrUrsXD0FPll1z+zJKA0YgCXWHCm7mgT2XyQQB/dCcTH0AmxDicVaFjX QrNhOQFApaj2vGj1ICe6DWw1bUlcO35hshUL6Rk1CVWDzcp5tYeMSURmMZMABpcCEHYA v1rw== 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 i22si3461420ejy.198.2021.10.28.05.27.36; Thu, 28 Oct 2021 05:28:13 -0700 (PDT) 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 S230425AbhJ1M1V (ORCPT + 99 others); Thu, 28 Oct 2021 08:27:21 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:41035 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230443AbhJ1M1U (ORCPT ); Thu, 28 Oct 2021 08:27:20 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Hg4Vr1nryz9sT4; Thu, 28 Oct 2021 14:24:20 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g1IAStAKYEEo; Thu, 28 Oct 2021 14:24:20 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4Hg4Vl6129z9sTG; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id AC44B8B794; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id s4wV9EDYhJfg; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.232.214]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2FBFD8B78C; Thu, 28 Oct 2021 14:24:15 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (localhost [127.0.0.1]) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1) with ESMTPS id 19SCO7gP194392 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 28 Oct 2021 14:24:07 +0200 Received: (from chleroy@localhost) by PO20335.IDSI0.si.c-s.fr (8.16.1/8.16.1/Submit) id 19SCO74x194391; Thu, 28 Oct 2021 14:24:07 +0200 X-Authentication-Warning: PO20335.IDSI0.si.c-s.fr: chleroy set sender to christophe.leroy@csgroup.eu using -f From: Christophe Leroy To: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Steven Rostedt , Ingo Molnar , "Naveen N . Rao" Cc: Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, live-patching@vger.kernel.org Subject: [PATCH v1 2/5] powerpc/ftrace: No need to read LR from stack in _mcount() Date: Thu, 28 Oct 2021 14:24:02 +0200 Message-Id: <24a3ba7db388537c44a038026f926d885372e6d3.1635423081.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1635423843; l=1773; s=20211009; h=from:subject:message-id; bh=BdgcxgTnhLIQz+nFCg438ZdJlGpUJGv35y1aicj1AGk=; b=OQDvBxfJM6arTMja8VXsBuAHwTfB589E+cNZpkX8AmZBoTGmSV0VjxkW4braPU2V3ZXFmuIareBJ 1cSqV0G/Ck1dzwV0GqIVSeuABBpJBOMCkxWpsANCFpPmjv/F7Hi+ X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org All functions calling _mcount do it exactly the same way, with the following sequence of instructions: c07de788: 7c 08 02 a6 mflr r0 c07de78c: 90 01 00 04 stw r0,4(r1) c07de790: 4b 84 13 65 bl c001faf4 <_mcount> Allthough LR is pushed on stack, it is still in r0 while entering _mcount(). Function arguments are in r3-r10, so r11 and r12 are still available at that point. Do like PPC64 and use r12 to move LR into CTR, so that r0 is preserved and doesn't need to be restored from the stack. While at it, bring back the EXPORT_SYMBOL at the end of _mcount. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/trace/ftrace_32.S | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/trace/ftrace_32.S b/arch/powerpc/kernel/trace/ftrace_32.S index e023ae59c429..c7d57124cc59 100644 --- a/arch/powerpc/kernel/trace/ftrace_32.S +++ b/arch/powerpc/kernel/trace/ftrace_32.S @@ -14,16 +14,16 @@ _GLOBAL(mcount) _GLOBAL(_mcount) /* * It is required that _mcount on PPC32 must preserve the - * link register. But we have r0 to play with. We use r0 + * link register. But we have r12 to play with. We use r12 * to push the return address back to the caller of mcount * into the ctr register, restore the link register and * then jump back using the ctr register. */ - mflr r0 - mtctr r0 - lwz r0, 4(r1) + mflr r12 + mtctr r12 mtlr r0 bctr +EXPORT_SYMBOL(_mcount) _GLOBAL(ftrace_caller) MCOUNT_SAVE_FRAME @@ -43,7 +43,6 @@ _GLOBAL(ftrace_graph_stub) /* old link register ends up in ctr reg */ bctr -EXPORT_SYMBOL(_mcount) _GLOBAL(ftrace_stub) blr -- 2.31.1