mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "chengjian (D)" <cj.chengjian@huawei.com>
To: <x86@kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <xiexiuqi@huawei.com>, <huawei.libin@huawei.com>,
	<bobo.shaobowang@huawei.com>, <rostedt@goodmis.org>,
	<mingo@redhat.com>, <tglx@linutronix.de>
Subject: Re: [PATCH] x86/ftrace: usr ftrace_write to simplify code
Date: Tue, 14 Jan 2020 09:37:41 +0800	[thread overview]
Message-ID: <8ab66ffb-614b-063d-7362-2f01906aec51@huawei.com> (raw)
In-Reply-To: <20200113073347.22748-1-cj.chengjian@huawei.com>

I am sorry.

usr => use in subject.

I will resend this patch.

  --Cheng Jian

On 2020/1/13 15:33, Cheng Jian wrote:
> ftrace_write() can be used directly in ftrace_modify_code_direct(),
> that make the code more brief.
>
> Signed-off-by: Cheng Jian <cj.chengjian@huawei.com>
> ---
>   arch/x86/kernel/ftrace.c | 24 +++++++++++-------------
>   1 file changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
> index 024c3053dbba..6b36ed2fd04d 100644
> --- a/arch/x86/kernel/ftrace.c
> +++ b/arch/x86/kernel/ftrace.c
> @@ -114,6 +114,16 @@ static const unsigned char *ftrace_nop_replace(void)
>   	return ideal_nops[NOP_ATOMIC5];
>   }
>   
> +static int ftrace_write(unsigned long ip, const char *val, int size)
> +{
> +	ip = text_ip_addr(ip);
> +
> +	if (probe_kernel_write((void *)ip, val, size))
> +		return -EPERM;
> +
> +	return 0;
> +}
> +
>   static int
>   ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
>   		   unsigned const char *new_code)
> @@ -138,10 +148,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
>   	if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0)
>   		return -EINVAL;
>   
> -	ip = text_ip_addr(ip);
> -
>   	/* replace the text with the new text */
> -	if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE))
> +	if (ftrace_write(ip, new_code, MCOUNT_INSN_SIZE))
>   		return -EPERM;
>   
>   	sync_core();
> @@ -326,16 +334,6 @@ int ftrace_int3_handler(struct pt_regs *regs)
>   }
>   NOKPROBE_SYMBOL(ftrace_int3_handler);
>   
> -static int ftrace_write(unsigned long ip, const char *val, int size)
> -{
> -	ip = text_ip_addr(ip);
> -
> -	if (probe_kernel_write((void *)ip, val, size))
> -		return -EPERM;
> -
> -	return 0;
> -}
> -
>   static int add_break(unsigned long ip, const char *old)
>   {
>   	unsigned char replaced[MCOUNT_INSN_SIZE];


  reply	other threads:[~2020-01-14  1:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13  7:33 Cheng Jian
2020-01-14  1:37 ` chengjian (D) [this message]
2020-01-14  3:34   ` Steven Rostedt
2020-01-14  9:14     ` chengjian (D)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ab66ffb-614b-063d-7362-2f01906aec51@huawei.com \
    --to=cj.chengjian@huawei.com \
    --cc=bobo.shaobowang@huawei.com \
    --cc=huawei.libin@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xiexiuqi@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®