From patchwork Fri Oct 28 14:33:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sathvika Vasireddy X-Patchwork-Id: 12364 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp871017wru; Fri, 28 Oct 2022 07:44:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JekhD/ax3bYORWklw0tasX5bm9Vp4aCoohZNEMqdDmRj6N8yRXSUEvsmNR37g9mDTO3Pv X-Received: by 2002:a17:907:7f24:b0:78d:ee20:5c62 with SMTP id qf36-20020a1709077f2400b0078dee205c62mr47297951ejc.177.1666968290647; Fri, 28 Oct 2022 07:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666968290; cv=none; d=google.com; s=arc-20160816; b=bZn8WvldorOq9Y6GPISj57rrGDVOtuR3WpfgWPbIybimdxWZMZECW583hVaWbypc2C Mrxw2libNGTyWK79Mh38VcFgzundsJAL4xRPO0nvkD8MU7YS732dvhFNXsenp0V63iGb iu1Uvth/HOnJy1Bof8WIMIJDVPBJtJ5ojOdNaNaIlAzohmWiSp/hDgwIVjVBwV/4IjXx Ep0NmqA1x9sWXjjLBnNtLA4OwuO3wMRRx6zf1fFhZRMLRSqdeVDwemd7G3py2iX5c5LR AA2GumCRxAyeWwCgbMdtAImt2N0gGjFAllLnmW2QiYjfLcl2gQFWwM4MA04zAAzFdEaT Y4Xw== 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 :dkim-signature; bh=1PlQTx08gDNMcuSjsgLHsbCJyxz3KNMlbtE73QKmjvI=; b=K2G9/B6qPy/D0xhGwG6018ffpxIrqkN4ar58gqsgiZ4l+VfleqoquKyGyeCjCbKzhE TtsRiv6n7+gYZCQvlSSYzxz0I7wSIeEMeDb6nePo9Q9s8w/r4+8P7gGgcW6Q3qy5K4g8 TeSsKd5LdVUTGVITTk3ZPnwcq6ZRTjrTrjTZUCAO3p1tMtRD4zdKAb8P4ClW4Z9E2oYr sbjrG/JWg5gnRUqDQ3F3Yoqw4TJ0Gdq2YW+5m0nEZx4x0qeikVvudMGOg3ERNA497RiY soECl/yozxbHOWXYlKIg+r1RphNegUz+gGd4LDKO1+UgrSfp9jENQWErwuxT/F0gls1d csBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Fj1v+UwD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a056402280100b00461eff7bb0csi5987716ede.31.2022.10.28.07.44.27; Fri, 28 Oct 2022 07:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Fj1v+UwD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231314AbiJ1OhD (ORCPT + 99 others); Fri, 28 Oct 2022 10:37:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbiJ1OgV (ORCPT ); Fri, 28 Oct 2022 10:36:21 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42A3E1E8B8F for ; Fri, 28 Oct 2022 07:35:56 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29SEVqdj014128; Fri, 28 Oct 2022 14:35:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=1PlQTx08gDNMcuSjsgLHsbCJyxz3KNMlbtE73QKmjvI=; b=Fj1v+UwD4m51chJrBywiI3gQRLo8OGwJE/JVoZVg4kRiuBaOIt6f309r7KoVW50j03a5 YYfoFm3tRGqv8JEAQfooNkbKvTw01WAFwj7b1FnaD67DQjNtnHvfD7XsLFp0y7mlefem kKsFfIBbH63hswEJdHuQOtSPexlHquuEJuh3APCP9FrjKrlHalqWVwoVFU3NqzlC500S E06PInH2G9cmQpKSOeOVTMqfl71llALjUNl9YAmCn6xVCXwirp573wb+sdJMrli3OpVc JA43YrRNNckqp3TDRUhlPCL05vvRYNs/0Y74erXOKRlugIp+76aIlFmqaGet2jeitfdW 2w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kggx586ue-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 14:35:38 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29SEWAss014906; Fri, 28 Oct 2022 14:35:37 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kggx586sb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 14:35:37 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29SEKhFB019348; Fri, 28 Oct 2022 14:35:34 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma02fra.de.ibm.com with ESMTP id 3kfahmjqge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 14:35:34 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29SEZVmt51577334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Oct 2022 14:35:32 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE414A4051; Fri, 28 Oct 2022 14:35:31 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD5BFA4040; Fri, 28 Oct 2022 14:35:27 +0000 (GMT) Received: from li-c3569c4c-1ef8-11b2-a85c-ee139cda3133.ibm.com.com (unknown [9.43.124.163]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Oct 2022 14:35:27 +0000 (GMT) From: Sathvika Vasireddy To: linuxppc-dev@lists.ozlabs.org Cc: jpoimboe@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, aik@ozlabs.ru, mpe@ellerman.id.au, mingo@redhat.com, christophe.leroy@csgroup.eu, rostedt@goodmis.org, mbenes@suse.cz, npiggin@gmail.com, chenzhongjin@huawei.com, naveen.n.rao@linux.vnet.ibm.com, sv@linux.ibm.com Subject: [PATCH v5 16/16] objtool/powerpc: Add --mcount specific implementation Date: Fri, 28 Oct 2022 20:03:46 +0530 Message-Id: <20221028143346.183569-17-sv@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221028143346.183569-1-sv@linux.ibm.com> References: <20221028143346.183569-1-sv@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hI6smG1Z_9eYCsOgk5DaoR0-m1o6WEfM X-Proofpoint-ORIG-GUID: 0mOoM1qbGu1BcSaKbAE5cYShNgE33o5C X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-28_07,2022-10-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 adultscore=0 clxscore=1015 spamscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2210280090 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747942942468492472?= X-GMAIL-MSGID: =?utf-8?q?1747942942468492472?= This patch enables objtool --mcount on powerpc, and adds implementation specific to powerpc. Tested-by: Naveen N. Rao Reviewed-by: Naveen N. Rao Reviewed-by: Christophe Leroy Acked-by: Josh Poimboeuf Signed-off-by: Sathvika Vasireddy --- arch/powerpc/Kconfig | 1 + tools/objtool/arch/powerpc/decode.c | 16 ++++++++++++++++ tools/objtool/arch/powerpc/include/arch/elf.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 12e6c16be54e..9c07068ba5e5 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -239,6 +239,7 @@ config PPC select HAVE_NMI if PERF_EVENTS || (PPC64 && PPC_BOOK3S) select HAVE_OPTPROBES select HAVE_OBJTOOL if PPC32 || MPROFILE_KERNEL + select HAVE_OBJTOOL_MCOUNT if HAVE_OBJTOOL select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS_NMI if PPC64 select HAVE_PERF_REGS diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c index dcd0975cad6b..01cade98b49e 100644 --- a/tools/objtool/arch/powerpc/decode.c +++ b/tools/objtool/arch/powerpc/decode.c @@ -9,6 +9,11 @@ #include #include +int arch_ftrace_match(char *name) +{ + return !strcmp(name, "_mcount"); +} + unsigned long arch_dest_reloc_offset(int addend) { return addend; @@ -50,6 +55,17 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec typ = INSN_OTHER; imm = 0; + switch (opcode) { + case 18: /* b[l][a] */ + if ((insn & 3) == 1) /* bl */ + typ = INSN_CALL; + + imm = insn & 0x3fffffc; + if (imm & 0x2000000) + imm -= 0x4000000; + break; + } + if (opcode == 1) *len = 8; else diff --git a/tools/objtool/arch/powerpc/include/arch/elf.h b/tools/objtool/arch/powerpc/include/arch/elf.h index 3c8ebb7d2a6b..73f9ae172fe5 100644 --- a/tools/objtool/arch/powerpc/include/arch/elf.h +++ b/tools/objtool/arch/powerpc/include/arch/elf.h @@ -4,5 +4,7 @@ #define _OBJTOOL_ARCH_ELF #define R_NONE R_PPC_NONE +#define R_ABS64 R_PPC64_ADDR64 +#define R_ABS32 R_PPC_ADDR32 #endif /* _OBJTOOL_ARCH_ELF */