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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF24EC433FE for ; Mon, 13 Dec 2021 18:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238386AbhLMSyQ (ORCPT ); Mon, 13 Dec 2021 13:54:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233160AbhLMSyP (ORCPT ); Mon, 13 Dec 2021 13:54:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B4B5C061574; Mon, 13 Dec 2021 10:54:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3E2F7B81249; Mon, 13 Dec 2021 18:54:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C30A4C34604; Mon, 13 Dec 2021 18:54:11 +0000 (UTC) Date: Mon, 13 Dec 2021 13:54:10 -0500 From: Steven Rostedt To: Christophe Leroy Cc: Josh Poimboeuf , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Ingo Molnar , "Naveen N . Rao" , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "live-patching@vger.kernel.org" , "linux-s390@vger.kernel.org" Subject: Re: [PATCH v1 0/5] Implement livepatch on PPC32 Message-ID: <20211213135410.12642d8f@gandalf.local.home> In-Reply-To: References: <20211028093547.48c69dfe@gandalf.local.home> <6209682d-0caa-b779-8763-376a984d8ed8@csgroup.eu> <20211213121536.25e5488d@gandalf.local.home> <5511f43c-192a-622b-7c72-52e07f0032c2@csgroup.eu> <20211213123338.65eda5a0@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 Dec 2021 17:50:52 +0000 Christophe Leroy wrote: > @@ -958,6 +942,12 @@ unsigned long prepare_ftrace_return(unsigned long > parent, unsigned long ip, > out: > return parent; > } > + > +void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, > + struct ftrace_ops *op, struct ftrace_regs *fregs) > +{ > + prepare_ftrace_return(ip, kernel_stack_pointer(&fregs->regs), 0); > +} I have for powerpc prepare_ftrace_return as: unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip, unsigned long sp) { unsigned long return_hooker; if (unlikely(ftrace_graph_is_dead())) goto out; if (unlikely(atomic_read(¤t->tracing_graph_pause))) goto out; return_hooker = ppc_function_entry(return_to_handler); if (!function_graph_enter(parent, ip, 0, (unsigned long *)sp)) parent = return_hooker; out: return parent; } Which means you'll need different parameters to it than what x86 has, which has the prototype of: void prepare_ftrace_return(unsigned long ip, unsigned long *parent, unsigned long frame_pointer) and it does not use the frame_pointer for this case, which is why it is zero. For powerpc though, it uses the stack pointer, so you parameters are incorrect. Looks like it should be: prepare_ftrace_return(parent_ip, ip, kernel_stack_pointer(&fregs->regs)); And that will likely not be enough. I'll need to update the ctr register, as that is where the return address is saved. So you'll probably need it to be: void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) { unsigned long parent; parent = prepare_ftrace_return(parent_ip, ip, kernel_stack_pointer(&fregs->regs)); fregs->regs.ctr = parent; } -- Steve 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACB0FC433EF for ; Mon, 13 Dec 2021 18:54:42 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JCW010FzTz3c5h for ; Tue, 14 Dec 2021 05:54:41 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=2604:1380:4601:e00::1; helo=ams.source.kernel.org; envelope-from=srs0=gc06=q6=goodmis.org=rostedt@kernel.org; receiver=) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JCVzX5G6vz2yNY for ; Tue, 14 Dec 2021 05:54:16 +1100 (AEDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2CA14B8124B; Mon, 13 Dec 2021 18:54:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C30A4C34604; Mon, 13 Dec 2021 18:54:11 +0000 (UTC) Date: Mon, 13 Dec 2021 13:54:10 -0500 From: Steven Rostedt To: Christophe Leroy Subject: Re: [PATCH v1 0/5] Implement livepatch on PPC32 Message-ID: <20211213135410.12642d8f@gandalf.local.home> In-Reply-To: References: <20211028093547.48c69dfe@gandalf.local.home> <6209682d-0caa-b779-8763-376a984d8ed8@csgroup.eu> <20211213121536.25e5488d@gandalf.local.home> <5511f43c-192a-622b-7c72-52e07f0032c2@csgroup.eu> <20211213123338.65eda5a0@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , Joe Lawrence , "linux-s390@vger.kernel.org" , Jiri Kosina , "linux-kernel@vger.kernel.org" , Ingo Molnar , Josh Poimboeuf , "live-patching@vger.kernel.org" , "Naveen N . Rao" , Miroslav Benes , "linuxppc-dev@lists.ozlabs.org" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, 13 Dec 2021 17:50:52 +0000 Christophe Leroy wrote: > @@ -958,6 +942,12 @@ unsigned long prepare_ftrace_return(unsigned long > parent, unsigned long ip, > out: > return parent; > } > + > +void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, > + struct ftrace_ops *op, struct ftrace_regs *fregs) > +{ > + prepare_ftrace_return(ip, kernel_stack_pointer(&fregs->regs), 0); > +} I have for powerpc prepare_ftrace_return as: unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip, unsigned long sp) { unsigned long return_hooker; if (unlikely(ftrace_graph_is_dead())) goto out; if (unlikely(atomic_read(¤t->tracing_graph_pause))) goto out; return_hooker = ppc_function_entry(return_to_handler); if (!function_graph_enter(parent, ip, 0, (unsigned long *)sp)) parent = return_hooker; out: return parent; } Which means you'll need different parameters to it than what x86 has, which has the prototype of: void prepare_ftrace_return(unsigned long ip, unsigned long *parent, unsigned long frame_pointer) and it does not use the frame_pointer for this case, which is why it is zero. For powerpc though, it uses the stack pointer, so you parameters are incorrect. Looks like it should be: prepare_ftrace_return(parent_ip, ip, kernel_stack_pointer(&fregs->regs)); And that will likely not be enough. I'll need to update the ctr register, as that is where the return address is saved. So you'll probably need it to be: void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs) { unsigned long parent; parent = prepare_ftrace_return(parent_ip, ip, kernel_stack_pointer(&fregs->regs)); fregs->regs.ctr = parent; } -- Steve