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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5D0FC433FE for ; Wed, 13 Oct 2021 10:01:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1CFF61077 for ; Wed, 13 Oct 2021 10:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239277AbhJMKD5 (ORCPT ); Wed, 13 Oct 2021 06:03:57 -0400 Received: from foss.arm.com ([217.140.110.172]:59792 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239238AbhJMKDz (ORCPT ); Wed, 13 Oct 2021 06:03:55 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 073791063; Wed, 13 Oct 2021 03:01:52 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.73.189]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C3DB3F70D; Wed, 13 Oct 2021 03:01:49 -0700 (PDT) Date: Wed, 13 Oct 2021 11:01:39 +0100 From: Mark Rutland To: Masami Hiramatsu Cc: Steven Rostedt , "Naveen N . Rao" , Ananth N Mavinakayanahalli , Ingo Molnar , linux-kernel@vger.kernel.org, Sven Schnelle , Catalin Marinas , Will Deacon , Russell King , Nathan Chancellor , Nick Desaulniers , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 3/8] arm64: kprobes: Record frame pointer with kretprobe instance Message-ID: <20211013100126.GA3187@C02TD0UTHF1T.local> References: <163369609308.636038.15295764725220907794.stgit@devnote2> <163369611948.636038.11552166777773804729.stgit@devnote2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <163369611948.636038.11552166777773804729.stgit@devnote2> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 08, 2021 at 09:28:39PM +0900, Masami Hiramatsu wrote: > Record the frame pointer instead of stack address with kretprobe > instance as the identifier on the instance list. > Since arm64 always enable CONFIG_FRAME_POINTER, we can use the > actual frame pointer (x29). Just to check, why do we need to use the FP rather than SP? It wasn't clear to me if that's necessary later in the series, or if I'm missing something here. FWIW, I plan to rework arm64's ftrace bits to use FP for HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, so I'm happy to do likewise here. > Signed-off-by: Masami Hiramatsu Regardless of the above: Acked-by: Mark Rutland Mark. > --- > arch/arm64/kernel/probes/kprobes.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c > index e7ad6da980e8..d9dfa82c1f18 100644 > --- a/arch/arm64/kernel/probes/kprobes.c > +++ b/arch/arm64/kernel/probes/kprobes.c > @@ -401,14 +401,14 @@ int __init arch_populate_kprobe_blacklist(void) > > void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs) > { > - return (void *)kretprobe_trampoline_handler(regs, (void *)kernel_stack_pointer(regs)); > + return (void *)kretprobe_trampoline_handler(regs, (void *)regs->regs[29]); > } > > void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, > struct pt_regs *regs) > { > ri->ret_addr = (kprobe_opcode_t *)regs->regs[30]; > - ri->fp = (void *)kernel_stack_pointer(regs); > + ri->fp = (void *)regs->regs[29]; > > /* replace return addr (x30) with trampoline */ > regs->regs[30] = (long)&__kretprobe_trampoline; >