From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9434C433E0 for ; Fri, 17 Jul 2020 17:31:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E934208C7 for ; Fri, 17 Jul 2020 17:31:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h/XGbBrY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E934208C7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=75Y0XW0uBJUcGaa0+Q8J4zOOmZXgzTrUnB2hnoawjro=; b=h/XGbBrYAMjesT1IHLiYvBbym 66rKSybcrsqtPUa3zBF5LGD0iWNjC8EfhLRO9smG6ZJFa4oULCS+8UXPTPgnb+g0beSpe8c20QLp/ uKkK2V6Q1eo1e1PQJAt/qTn6vbyWoIZu5Pqg8A6UF0oBLXm4/s6z9mnlHza5JnkN9PhVRMj3Fo9xx YAElLOoNinarUAA/61iRy3KoiWB3OzBqt7hF61lhcDlVTBSdscuXzAoz5AZV7ES1hOM8HslCZ9CJ0 UvJADeWTVcXtL8LP5ACEymQbM4As02JkYVIQodlXSl1SgelNktwHJa4E6ULr43ep/DCal7dCquOeV 1v45Tf8NQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwUBU-0004Ak-U0; Fri, 17 Jul 2020 17:30:08 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwUBS-0004A7-Lz for linux-arm-kernel@lists.infradead.org; Fri, 17 Jul 2020 17:30:07 +0000 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2914D2074B; Fri, 17 Jul 2020 17:30:05 +0000 (UTC) Date: Fri, 17 Jul 2020 13:30:03 -0400 From: Steven Rostedt To: gregory.herrero@oracle.com Subject: Re: [PATCH] recordmcount: only record relocation of type R_AARCH64_CALL26 on arm64. Message-ID: <20200717133003.025f2096@oasis.local.home> In-Reply-To: <20200717143338.19302-1-gregory.herrero@oracle.com> References: <20200717143338.19302-1-gregory.herrero@oracle.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200717_133006_803175_F25D0A76 X-CRM114-Status: GOOD ( 23.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 17 Jul 2020 16:33:38 +0200 gregory.herrero@oracle.com wrote: > From: Gregory Herrero > > Currently, if a section has a relocation to '_mcount' symbol, a new > __mcount_loc entry will be added whatever the relocation type is. > This is problematic when a relocation to '_mcount' is in the middle of a > section and is not a call for ftrace use. > > Such relocation could be generated with below code for example: > bool is_mcount(unsigned long addr) > { > return (target == (unsigned long) &_mcount); > } > > With this snippet of code, ftrace will try to patch the mcount location > generated by this code on module load and fail with: > > Call trace: > ftrace_bug+0xa0/0x28c > ftrace_process_locs+0x2f4/0x430 > ftrace_module_init+0x30/0x38 > load_module+0x14f0/0x1e78 > __do_sys_finit_module+0x100/0x11c > __arm64_sys_finit_module+0x28/0x34 > el0_svc_common+0x88/0x194 > el0_svc_handler+0x38/0x8c > el0_svc+0x8/0xc > ---[ end trace d828d06b36ad9d59 ]--- > ftrace failed to modify > [] 0xffffa2dbf3a3a41c > actual: 66:a9:3c:90 > Initializing ftrace call sites > ftrace record flags: 2000000 > (0) > expected tramp: ffffa2dc6cf66724 > > So Limit the relocation type to R_AARCH64_CALL26 as in perl version of > recordmcount. > I'd rather have this go through the arm64 tree, as they can test it better than I can. Acked-by: Steven Rostedt (VMware) -- Steve > Fixes: ed60453fa8f8 ("ARM: 6511/1: ftrace: add ARM support for C version of recordmcount") > Signed-off-by: Gregory Herrero > --- > scripts/recordmcount.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c > index 7225107a9aaf..e59022b3f125 100644 > --- a/scripts/recordmcount.c > +++ b/scripts/recordmcount.c > @@ -434,6 +434,11 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp) > return 1; > } > > +static int arm64_is_fake_mcount(Elf64_Rel const *rp) > +{ > + return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26; > +} > + > /* 64-bit EM_MIPS has weird ELF64_Rela.r_info. > * http://techpubs.sgi.com/library/manuals/4000/007-4658-001/pdf/007-4658-001.pdf > * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40] > @@ -547,6 +552,7 @@ static int do_file(char const *const fname) > make_nop = make_nop_arm64; > rel_type_nop = R_AARCH64_NONE; > ideal_nop = ideal_nop4_arm64; > + is_fake_mcount64 = arm64_is_fake_mcount; > break; > case EM_IA_64: reltype = R_IA64_IMM64; break; > case EM_MIPS: /* reltype: e_class */ break; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel