LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ftrace/x86: Call text_ip_addr() instead of the duplicated code
@ 2014-06-03 16:23 Petr Mladek
  2014-06-03 23:01 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Mladek @ 2014-06-03 16:23 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Frederic Weisbecker, Masami Hiramatsu, Jiri Kosina, linux-kernel,
	x86, Petr Mladek

I just went over this when looking at some Xen-related ftrace initialization
problems. They were related to Xen code that is not upstream but this clean up
would make sense here.

I think that this was already the intention when text_ip_addr() was introduced
in the commit 87fbb2ac6073a703930 (ftrace/x86: Use breakpoints for converting
function graph caller). Anyway, better do it now before it shots people into
their leg ;-)

Signed-off-by: Petr Mladek <pmladek@suse.cz>
---
 arch/x86/kernel/ftrace.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 89de3eaf8772..cbc4a91b131e 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -297,16 +297,7 @@ int ftrace_int3_handler(struct pt_regs *regs)
 
 static int ftrace_write(unsigned long ip, const char *val, int size)
 {
-	/*
-	 * On x86_64, kernel text mappings are mapped read-only with
-	 * CONFIG_DEBUG_RODATA. So we use the kernel identity mapping instead
-	 * of the kernel text mapping to modify the kernel text.
-	 *
-	 * For 32bit kernels, these mappings are same and we can use
-	 * kernel identity mapping to modify code.
-	 */
-	if (within(ip, (unsigned long)_text, (unsigned long)_etext))
-		ip = (unsigned long)__va(__pa_symbol(ip));
+	ip = text_ip_addr(ip);
 
 	if (probe_kernel_write((void *)ip, val, size))
 		return -EPERM;
-- 
1.8.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ftrace/x86: Call text_ip_addr() instead of the duplicated code
  2014-06-03 16:23 [PATCH] ftrace/x86: Call text_ip_addr() instead of the duplicated code Petr Mladek
@ 2014-06-03 23:01 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2014-06-03 23:01 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Frederic Weisbecker, Masami Hiramatsu, Jiri Kosina, linux-kernel, x86

On Tue,  3 Jun 2014 18:23:21 +0200
Petr Mladek <pmladek@suse.cz> wrote:

> I just went over this when looking at some Xen-related ftrace initialization
> problems. They were related to Xen code that is not upstream but this clean up
> would make sense here.
> 
> I think that this was already the intention when text_ip_addr() was introduced
> in the commit 87fbb2ac6073a703930 (ftrace/x86: Use breakpoints for converting
> function graph caller). Anyway, better do it now before it shots people into
> their leg ;-)

You know, I made this change. It somehow got lost :-/

I better analyze this a bit to make sure it was just lost and I didn't
find some odd ball reason not to apply it. But I doubt I'll find
anything. If not, I'll get it enqueued for 3.16.

Thanks!

-- Steve


> 
> Signed-off-by: Petr Mladek <pmladek@suse.cz>
> ---
>  arch/x86/kernel/ftrace.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 89de3eaf8772..cbc4a91b131e 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -297,16 +297,7 @@ int ftrace_int3_handler(struct pt_regs *regs)
>  
>  static int ftrace_write(unsigned long ip, const char *val, int size)
>  {
> -	/*
> -	 * On x86_64, kernel text mappings are mapped read-only with
> -	 * CONFIG_DEBUG_RODATA. So we use the kernel identity mapping instead
> -	 * of the kernel text mapping to modify the kernel text.
> -	 *
> -	 * For 32bit kernels, these mappings are same and we can use
> -	 * kernel identity mapping to modify code.
> -	 */
> -	if (within(ip, (unsigned long)_text, (unsigned long)_etext))
> -		ip = (unsigned long)__va(__pa_symbol(ip));
> +	ip = text_ip_addr(ip);
>  
>  	if (probe_kernel_write((void *)ip, val, size))
>  		return -EPERM;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-03 16:23 [PATCH] ftrace/x86: Call text_ip_addr() instead of the duplicated code Petr Mladek
2014-06-03 23:01 ` Steven Rostedt

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git