Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6008327pxb; Mon, 14 Feb 2022 13:01:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBYe+5Gvqfyn9TmuEJz3F/59bPVcgrz15WT4x/Ny9vkk2zqzRRHOVlMuSgCgkqiQOQltXH X-Received: by 2002:a63:950b:: with SMTP id p11mr714514pgd.365.1644872512657; Mon, 14 Feb 2022 13:01:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644872512; cv=none; d=google.com; s=arc-20160816; b=tnZX7TzRzAcOIxcH6CWLwmY6Lh0DUBg5KfaQBs1EallUwGZfkqg1X5983ZKH72T/q5 jgkK5280qGh2cmsXWQkNDCBrsEE3ba+i6FUEkqzkLRKaAEWB1kyWcSCtKXE4taB1jorW O/YtbsyTmuY/M4OHrEugQo4j0OmERp3IJLQ/N5IZYxlV5jGogvw0ixp2bfKvTEh38KKK bQ44pXIB1qqR2Z93HvpP0M1Jc14pjA0e4GtLT6aaz9lovvq39DAvmeZtfVSNLDQu1AE8 J5eFgH7SGq2Xsm6JVDUVIny+uGoBGAppgFnJkFPDC9khRtS8ufQllxqMQ5zC8J5t/Mjd +d5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :mime-version:in-reply-to:references:cc:to:subject:from:date :dkim-signature; bh=fRPquwuW8qfyOuoD5PevBKzhtO7/iuKYb7YoEXWc2zY=; b=jKfHXNaXWfVjlISBWp6pQoCdFtGSC+E3NKR2mrFBB8rwvGvogwVtNTwh4kPXX1+DOZ 9zUe9JrjyCbwtFdq5uFH7IrflJfCwEfv4YcnSXlp3Wo1b7qNJc6dHnyfj397+aS8sPGR n7cG2dh1kfnLbpH+FQ9PPpQcSDRJvXFxi+aWlSb1HaPVsKweTMmzJTSyk8KNBpazzPG9 FbjICZ0u39+T9bIvDS8bTh7LBi+dqozCCD2BzRKT+9v9tcenOhCfOoDuHqONgTrIEQMd AwCz3HKm9J9+FxWUc9wBT89AuRrNYSEA6r5tVFLL6Vlrm0wpqnK5o4t8H8gCrxpPU4m/ ixlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=fewXgRXs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l13si14993611pls.127.2022.02.14.13.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:01:52 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=fewXgRXs; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5C64D1354A1; Mon, 14 Feb 2022 12:24:00 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357264AbiBNRwk (ORCPT + 99 others); Mon, 14 Feb 2022 12:52:40 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350284AbiBNRwj (ORCPT ); Mon, 14 Feb 2022 12:52:39 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9B27C40; Mon, 14 Feb 2022 09:52:31 -0800 (PST) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21EFhdPB012468; Mon, 14 Feb 2022 17:52:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : subject : to : cc : references : in-reply-to : mime-version : message-id : content-type : content-transfer-encoding; s=pp1; bh=fRPquwuW8qfyOuoD5PevBKzhtO7/iuKYb7YoEXWc2zY=; b=fewXgRXsLQhcvs481DRc1VIa9vX7Qv/66B8bzHiTZD6FMUQsCJvPf5vAIFdg0p/5v7C1 cC8JVZpL9RygXWZqlrRAGFRONPbaDv/2/9j5rl0ndWMthOIx/MEUuZOOHYP5CJezRF37 WdZAf3SokDrXknfATw/tXmqIzalzviV3VVMR57KQOwIJi0MOLk6BAn4EhD4g+Y9mFzXG iefN5h1XiTAN27jk68GWZGcj8PqngOWovnZyHvzEGAJuQKx2otf8uT6VrdNoOqJnkoQe mdzvqadb8ESqn2RUjsezCPvj1s+J2uvDNotim4DoJwqJ9DPj62rUMsEo0+ZztwRuNkAW dQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e7c4e5a24-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Feb 2022 17:52:03 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 21EHmYgb024211; Mon, 14 Feb 2022 17:52:03 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e7c4e5a1e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Feb 2022 17:52:03 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21EHbtVT026816; Mon, 14 Feb 2022 17:52:01 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 3e64h9qrpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Feb 2022 17:52:01 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21EHfeTi46137692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Feb 2022 17:41:40 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1890DA4065; Mon, 14 Feb 2022 17:51:59 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1017A4060; Mon, 14 Feb 2022 17:51:58 +0000 (GMT) Received: from localhost (unknown [9.43.124.167]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 14 Feb 2022 17:51:58 +0000 (GMT) Date: Mon, 14 Feb 2022 23:21:56 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH v2 12/13] powerpc/ftrace: Prepare ftrace_64_mprofile.S for reuse by PPC32 To: Christophe Leroy , Jiri Kosina , Joe Lawrence , Josh Poimboeuf , Miroslav Benes , Ingo Molnar , Petr Mladek , Steven Rostedt Cc: "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "live-patching@vger.kernel.org" References: <82a732915dc71ee766e31809350939331944006d.1640017960.git.christophe.leroy@csgroup.eu> In-Reply-To: <82a732915dc71ee766e31809350939331944006d.1640017960.git.christophe.leroy@csgroup.eu> MIME-Version: 1.0 User-Agent: astroid/4d6b06ad (https://github.com/astroidmail/astroid) Message-Id: <1644860537.hyunv1mld0.naveen@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: HHrAwynjC0tZxVMXEag7CCqPQklgAug1 X-Proofpoint-ORIG-GUID: 0pFoWuFbKJHIjrYfR2q_vw0OCvLFxAEO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-14_07,2022-02-14_03,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 adultscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 mlxscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202140104 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe Leroy wrote: > PPC64 mprofile versions and PPC32 are very similar. >=20 > Modify PPC64 version so that if can be reused for PPC32. >=20 > Signed-off-by: Christophe Leroy > --- > .../powerpc/kernel/trace/ftrace_64_mprofile.S | 73 +++++++++++++------ > 1 file changed, 51 insertions(+), 22 deletions(-) While I agree that ppc32 and -mprofile-kernel ftrace code are very=20 similar, I think this patch adds way too many #ifdefs. IMHO, this makes the resultant code quite difficult to follow. - Naveen >=20 > diff --git a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S b/arch/powerp= c/kernel/trace/ftrace_64_mprofile.S > index 6071e0122797..56da60e98327 100644 > --- a/arch/powerpc/kernel/trace/ftrace_64_mprofile.S > +++ b/arch/powerpc/kernel/trace/ftrace_64_mprofile.S > @@ -34,13 +34,16 @@ > */ > _GLOBAL(ftrace_regs_caller) > /* Save the original return address in A's stack frame */ > - std r0,LRSAVE(r1) > +#ifdef CONFIG_MPROFILE_KERNEL > + PPC_STL r0,LRSAVE(r1) > +#endif > =20 > /* Create our stack frame + pt_regs */ > - stdu r1,-SWITCH_FRAME_SIZE(r1) > + PPC_STLU r1,-SWITCH_FRAME_SIZE(r1) > =20 > /* Save all gprs to pt_regs */ > SAVE_GPR(0, r1) > +#ifdef CONFIG_PPC64 > SAVE_GPRS(2, 11, r1) > =20 > /* Ok to continue? */ > @@ -49,10 +52,13 @@ _GLOBAL(ftrace_regs_caller) > beq ftrace_no_trace > =20 > SAVE_GPRS(12, 31, r1) > +#else > + stmw r2, GPR2(r1) > +#endif > =20 > /* Save previous stack pointer (r1) */ > addi r8, r1, SWITCH_FRAME_SIZE > - std r8, GPR1(r1) > + PPC_STL r8, GPR1(r1) > =20 > /* Load special regs for save below */ > mfmsr r8 > @@ -63,10 +69,11 @@ _GLOBAL(ftrace_regs_caller) > /* Get the _mcount() call site out of LR */ > mflr r7 > /* Save it as pt_regs->nip */ > - std r7, _NIP(r1) > + PPC_STL r7, _NIP(r1) > /* Save the read LR in pt_regs->link */ > - std r0, _LINK(r1) > + PPC_STL r0, _LINK(r1) > =20 > +#ifdef CONFIG_PPC64 > /* Save callee's TOC in the ABI compliant location */ > std r2, 24(r1) > ld r2,PACATOC(r13) /* get kernel TOC in r2 */ > @@ -74,8 +81,12 @@ _GLOBAL(ftrace_regs_caller) > addis r3,r2,function_trace_op@toc@ha > addi r3,r3,function_trace_op@toc@l > ld r5,0(r3) > +#else > + lis r3,function_trace_op@ha > + lwz r5,function_trace_op@l(r3) > +#endif > =20 > -#ifdef CONFIG_LIVEPATCH > +#ifdef CONFIG_LIVEPATCH_64 > mr r14,r7 /* remember old NIP */ > #endif > /* Calculate ip from nip-4 into r3 for call below */ > @@ -85,10 +96,10 @@ _GLOBAL(ftrace_regs_caller) > mr r4, r0 > =20 > /* Save special regs */ > - std r8, _MSR(r1) > - std r9, _CTR(r1) > - std r10, _XER(r1) > - std r11, _CCR(r1) > + PPC_STL r8, _MSR(r1) > + PPC_STL r9, _CTR(r1) > + PPC_STL r10, _XER(r1) > + PPC_STL r11, _CCR(r1) > =20 > /* Load &pt_regs in r6 for call below */ > addi r6, r1 ,STACK_FRAME_OVERHEAD > @@ -100,27 +111,32 @@ ftrace_regs_call: > nop > =20 > /* Load ctr with the possibly modified NIP */ > - ld r3, _NIP(r1) > + PPC_LL r3, _NIP(r1) > mtctr r3 > -#ifdef CONFIG_LIVEPATCH > +#ifdef CONFIG_LIVEPATCH_64 > cmpd r14, r3 /* has NIP been altered? */ > #endif > =20 > /* Restore gprs */ > - REST_GPR(0, r1) > +#ifdef CONFIG_PPC64 > REST_GPRS(2, 31, r1) > +#else > + lmw r2, GPR2(r1) > +#endif > =20 > /* Restore possibly modified LR */ > - ld r0, _LINK(r1) > + PPC_LL r0, _LINK(r1) > mtlr r0 > =20 > +#ifdef CONFIG_PPC64 > /* Restore callee's TOC */ > ld r2, 24(r1) > +#endif > =20 > /* Pop our stack frame */ > addi r1, r1, SWITCH_FRAME_SIZE > =20 > -#ifdef CONFIG_LIVEPATCH > +#ifdef CONFIG_LIVEPATCH_64 > /* Based on the cmpd above, if the NIP was altered handle livepa= tch */ > bne- livepatch_handler > #endif > @@ -129,6 +145,7 @@ ftrace_regs_call: > _GLOBAL(ftrace_stub) > blr > =20 > +#ifdef CONFIG_PPC64 > ftrace_no_trace: > mflr r3 > mtctr r3 > @@ -136,25 +153,31 @@ ftrace_no_trace: > addi r1, r1, SWITCH_FRAME_SIZE > mtlr r0 > bctr > +#endif > =20 > _GLOBAL(ftrace_caller) > /* Save the original return address in A's stack frame */ > - std r0, LRSAVE(r1) > +#ifdef CONFIG_MPROFILE_KERNEL > + PPC_STL r0, LRSAVE(r1) > +#endif > =20 > /* Create our stack frame + pt_regs */ > - stdu r1, -SWITCH_FRAME_SIZE(r1) > + PPC_STLU r1, -SWITCH_FRAME_SIZE(r1) > =20 > /* Save all gprs to pt_regs */ > SAVE_GPRS(3, 10, r1) > =20 > +#ifdef CONFIG_PPC64 > lbz r3, PACA_FTRACE_ENABLED(r13) > cmpdi r3, 0 > beq ftrace_no_trace > +#endif > =20 > /* Get the _mcount() call site out of LR */ > mflr r7 > - std r7, _NIP(r1) > + PPC_STL r7, _NIP(r1) > =20 > +#ifdef CONFIG_PPC64 > /* Save callee's TOC in the ABI compliant location */ > std r2, 24(r1) > ld r2, PACATOC(r13) /* get kernel TOC in r2 */ > @@ -162,6 +185,10 @@ _GLOBAL(ftrace_caller) > addis r3, r2, function_trace_op@toc@ha > addi r3, r3, function_trace_op@toc@l > ld r5, 0(r3) > +#else > + lis r3,function_trace_op@ha > + lwz r5,function_trace_op@l(r3) > +#endif > =20 > #ifdef CONFIG_LIVEPATCH_64 > SAVE_GPR(14, r1) > @@ -171,7 +198,7 @@ _GLOBAL(ftrace_caller) > subi r3, r7, MCOUNT_INSN_SIZE > =20 > /* Put the original return address in r4 as parent_ip */ > - std r0, _LINK(r1) > + PPC_STL r0, _LINK(r1) > mr r4, r0 > =20 > /* Load &pt_regs in r6 for call below */ > @@ -183,7 +210,7 @@ ftrace_call: > bl ftrace_stub > nop > =20 > - ld r3, _NIP(r1) > + PPC_LL r3, _NIP(r1) > mtctr r3 > #ifdef CONFIG_LIVEPATCH_64 > cmpd r14, r3 /* has NIP been altered? */ > @@ -193,11 +220,13 @@ ftrace_call: > /* Restore gprs */ > REST_GPRS(3, 10, r1) > =20 > +#ifdef CONFIG_PPC64 > /* Restore callee's TOC */ > ld r2, 24(r1) > +#endif > =20 > /* Restore possibly modified LR */ > - ld r0, _LINK(r1) > + PPC_LL r0, _LINK(r1) > mtlr r0 > =20 > /* Pop our stack frame */ > @@ -209,7 +238,7 @@ ftrace_call: > #endif > bctr /* jump after _mcount site */ > =20 > -#ifdef CONFIG_LIVEPATCH > +#ifdef CONFIG_LIVEPATCH_64 > /* > * This function runs in the mcount context, between two functions. As > * such it can only clobber registers which are volatile and used in > --=20 > 2.33.1 >=20