From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754108AbcBZKfy (ORCPT ); Fri, 26 Feb 2016 05:35:54 -0500 Received: from ozlabs.org ([103.22.144.67]:56559 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752001AbcBZKft (ORCPT ); Fri, 26 Feb 2016 05:35:49 -0500 Message-ID: <1456482947.25691.10.camel@ellerman.id.au> Subject: Re: [PATCH 03/12] powerpc/module: Create a special stub for ftrace_caller() From: Michael Ellerman To: Torsten Duwe , Balbir Singh Cc: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, kamalesh@linux.vnet.ibm.com, pmladek@suse.com, jeyu@redhat.com, jkosina@suse.cz, live-patching@vger.kernel.org, mbenes@suse.cz Date: Fri, 26 Feb 2016 21:35:47 +1100 In-Reply-To: <20160225133133.GE21932@lst.de> References: <1456324115-21144-1-git-send-email-mpe@ellerman.id.au> <1456324115-21144-3-git-send-email-mpe@ellerman.id.au> <56CE4616.9080100@gmail.com> <20160225133133.GE21932@lst.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5-1ubuntu3.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2016-02-25 at 14:31 +0100, Torsten Duwe wrote: > On Thu, Feb 25, 2016 at 11:08:54AM +1100, Balbir Singh wrote: > > How about some comments on r2 > > r2 is still pointing to the module's toc, will be saved by ftrace_caller and restored by the instruction following bl ftrace_caller (after patching _mcount/nop) > > To be precise: ftrace_caller needs to save _and_ restore r2 in case of -mprofile-kernel. > > > + /* Stub uses address relative to kernel_toc */ > > > + reladdr = (unsigned long)ftrace_caller - get_paca()->kernel_toc; Yeah true. I originally wrote it with the address of ftrace_caller passed as an argument, so it had to be computed at runtime, and getting it from the paca is ~= to getting it out of the GOT. > kernel_toc is a compile time constant; do you really want to look it up in > memory at runtime each time? It's a bit tricky to get the +- 0x8000 right > OTOH... > > I wrote: > extern unsigned long __toc_start; > reladdr = addr - ((unsigned long)(&__toc_start) + 0x8000UL); > > looks a bit odd, but evaluates to a constant for ftrace_caller. Yeah that makes sense. I'll add a helper to do the + 32k. cheers