All of lore.kernel.org
 help / color / mirror / Atom feed
From: wangnan0@huawei.com (Wang Nan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v17 11/11] ARM: optprobes: execute instruction during restoring if possible.
Date: Mon, 29 Dec 2014 12:10:56 +0800	[thread overview]
Message-ID: <54A0D450.6060909@huawei.com> (raw)
In-Reply-To: <54A07FBE.3010206@hitachi.com>

On 2014/12/29 6:10, Masami Hiramatsu wrote:
> (2014/12/27 16:36), Wang Nan wrote:
>> This patch removes software emulation or simulation for most of probed
>> instructions. If the instruction doesn't use PC relative addressing,
>> it will be translated into following instructions in the restore code
>> in code template:
>>
>>  ldmia {r0 - r14}  // restore all instruction except PC
>>  <instruction>     // direct execute the probed instruction
>>  b next_insn       // branch to next instruction.
>>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> ---
>>  arch/arm/include/asm/kprobes.h    |  3 +++
>>  arch/arm/include/asm/probes.h     |  1 +
>>  arch/arm/probes/kprobes/opt-arm.c | 47 +++++++++++++++++++++++++++++++++++++--
>>  3 files changed, 49 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
>> index 50ff3bc..3ea9be5 100644
>> --- a/arch/arm/include/asm/kprobes.h
>> +++ b/arch/arm/include/asm/kprobes.h
>> @@ -57,6 +57,9 @@ extern __visible kprobe_opcode_t optprobe_template_call;
>>  extern __visible kprobe_opcode_t optprobe_template_end;
>>  extern __visible kprobe_opcode_t optprobe_template_sub_sp;
>>  extern __visible kprobe_opcode_t optprobe_template_add_sp;
>> +extern __visible kprobe_opcode_t optprobe_template_restore_begin;
>> +extern __visible kprobe_opcode_t optprobe_template_restore_orig_insn;
>> +extern __visible kprobe_opcode_t optprobe_template_restore_end;
>>  
>>  #define MAX_OPTIMIZED_LENGTH	4
>>  #define MAX_OPTINSN_SIZE				\
>> diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h
>> index ee8725c..8ebbe83 100644
>> --- a/arch/arm/include/asm/probes.h
>> +++ b/arch/arm/include/asm/probes.h
>> @@ -50,6 +50,7 @@ struct arch_probes_insn {
>>  #define set_register_nouse(m, n)	__clear_register_flag(m, n, REG_NO_USE)
>>  #define set_register_use(m, n)	__set_register_flag(m, n, REG_USE)
>>  	int register_usage_mask;
>> +	bool kprobe_direct_exec;
>>  };
>>  
>>  #endif /* __ASSEMBLY__ */
>> diff --git a/arch/arm/probes/kprobes/opt-arm.c b/arch/arm/probes/kprobes/opt-arm.c
>> index 6a60df3..f3bd1cc 100644
>> --- a/arch/arm/probes/kprobes/opt-arm.c
>> +++ b/arch/arm/probes/kprobes/opt-arm.c
>> @@ -32,6 +32,13 @@
>>  #include "core.h"
>>  
>>  /*
>> + * See register_usage_mask. If the probed instruction doesn't use PC,
>> + * we can copy it into template and have it executed directly without
>> + * simulation or emulation.
>> + */
>> +#define can_kprobe_direct_exec(m)	(!((m) & 0xc0000000UL))
> 
> I think you'd better define a macro for this bitmask.
> 
> 
>> +
>> +/*
>>   * NOTE: the first sub and add instruction will be modified according
>>   * to the stack cost of the instruction.
>>   */
>> @@ -66,7 +73,15 @@ asm (
>>  			"	orrne	r2, #1\n"
>>  			"	strne	r2, [sp, #60] @ set bit0 of PC for thumb\n"
>>  			"	msr	cpsr_cxsf, r1\n"
>> +			".global optprobe_template_restore_begin\n"
>> +			"optprobe_template_restore_begin:\n"
>>  			"	ldmia	sp, {r0 - r15}\n"
>> +			".global optprobe_template_restore_orig_insn\n"
>> +			"optprobe_template_restore_orig_insn:\n"
>> +			"	nop\n"
>> +			".global optprobe_template_restore_end\n"
>> +			"optprobe_template_restore_end:\n"
>> +			"	ldmia	sp, {r13 - r15}\n"
> 
> Why this can't be a nop too?
> 
> Thank you,
> 

Good suggestion. I'll send a new version of patch 10 and 11.

Thank you.

WARNING: multiple messages have this Message-ID (diff)
From: Wang Nan <wangnan0@huawei.com>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: <tixy@linaro.org>, <linux@arm.linux.org.uk>, <lizefan@huawei.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v17 11/11] ARM: optprobes: execute instruction during restoring if possible.
Date: Mon, 29 Dec 2014 12:10:56 +0800	[thread overview]
Message-ID: <54A0D450.6060909@huawei.com> (raw)
In-Reply-To: <54A07FBE.3010206@hitachi.com>

On 2014/12/29 6:10, Masami Hiramatsu wrote:
> (2014/12/27 16:36), Wang Nan wrote:
>> This patch removes software emulation or simulation for most of probed
>> instructions. If the instruction doesn't use PC relative addressing,
>> it will be translated into following instructions in the restore code
>> in code template:
>>
>>  ldmia {r0 - r14}  // restore all instruction except PC
>>  <instruction>     // direct execute the probed instruction
>>  b next_insn       // branch to next instruction.
>>
>> Signed-off-by: Wang Nan <wangnan0@huawei.com>
>> ---
>>  arch/arm/include/asm/kprobes.h    |  3 +++
>>  arch/arm/include/asm/probes.h     |  1 +
>>  arch/arm/probes/kprobes/opt-arm.c | 47 +++++++++++++++++++++++++++++++++++++--
>>  3 files changed, 49 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/kprobes.h b/arch/arm/include/asm/kprobes.h
>> index 50ff3bc..3ea9be5 100644
>> --- a/arch/arm/include/asm/kprobes.h
>> +++ b/arch/arm/include/asm/kprobes.h
>> @@ -57,6 +57,9 @@ extern __visible kprobe_opcode_t optprobe_template_call;
>>  extern __visible kprobe_opcode_t optprobe_template_end;
>>  extern __visible kprobe_opcode_t optprobe_template_sub_sp;
>>  extern __visible kprobe_opcode_t optprobe_template_add_sp;
>> +extern __visible kprobe_opcode_t optprobe_template_restore_begin;
>> +extern __visible kprobe_opcode_t optprobe_template_restore_orig_insn;
>> +extern __visible kprobe_opcode_t optprobe_template_restore_end;
>>  
>>  #define MAX_OPTIMIZED_LENGTH	4
>>  #define MAX_OPTINSN_SIZE				\
>> diff --git a/arch/arm/include/asm/probes.h b/arch/arm/include/asm/probes.h
>> index ee8725c..8ebbe83 100644
>> --- a/arch/arm/include/asm/probes.h
>> +++ b/arch/arm/include/asm/probes.h
>> @@ -50,6 +50,7 @@ struct arch_probes_insn {
>>  #define set_register_nouse(m, n)	__clear_register_flag(m, n, REG_NO_USE)
>>  #define set_register_use(m, n)	__set_register_flag(m, n, REG_USE)
>>  	int register_usage_mask;
>> +	bool kprobe_direct_exec;
>>  };
>>  
>>  #endif /* __ASSEMBLY__ */
>> diff --git a/arch/arm/probes/kprobes/opt-arm.c b/arch/arm/probes/kprobes/opt-arm.c
>> index 6a60df3..f3bd1cc 100644
>> --- a/arch/arm/probes/kprobes/opt-arm.c
>> +++ b/arch/arm/probes/kprobes/opt-arm.c
>> @@ -32,6 +32,13 @@
>>  #include "core.h"
>>  
>>  /*
>> + * See register_usage_mask. If the probed instruction doesn't use PC,
>> + * we can copy it into template and have it executed directly without
>> + * simulation or emulation.
>> + */
>> +#define can_kprobe_direct_exec(m)	(!((m) & 0xc0000000UL))
> 
> I think you'd better define a macro for this bitmask.
> 
> 
>> +
>> +/*
>>   * NOTE: the first sub and add instruction will be modified according
>>   * to the stack cost of the instruction.
>>   */
>> @@ -66,7 +73,15 @@ asm (
>>  			"	orrne	r2, #1\n"
>>  			"	strne	r2, [sp, #60] @ set bit0 of PC for thumb\n"
>>  			"	msr	cpsr_cxsf, r1\n"
>> +			".global optprobe_template_restore_begin\n"
>> +			"optprobe_template_restore_begin:\n"
>>  			"	ldmia	sp, {r0 - r15}\n"
>> +			".global optprobe_template_restore_orig_insn\n"
>> +			"optprobe_template_restore_orig_insn:\n"
>> +			"	nop\n"
>> +			".global optprobe_template_restore_end\n"
>> +			"optprobe_template_restore_end:\n"
>> +			"	ldmia	sp, {r13 - r15}\n"
> 
> Why this can't be a nop too?
> 
> Thank you,
> 

Good suggestion. I'll send a new version of patch 10 and 11.

Thank you.




  parent reply	other threads:[~2014-12-29  4:10 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-27  7:33 [PATCH v17 00/11] ARM: kprobes: OPTPROBES and other improvements Wang Nan
2014-12-27  7:33 ` Wang Nan
2014-12-27  7:34 ` [PATCH v17 01/11] ARM: probes: move all probe code to dedicate directory Wang Nan
2014-12-27  7:34   ` Wang Nan
2014-12-27  7:34 ` [PATCH v17 02/11] ARM: kprobes: remove unused ARM decoder actions Wang Nan
2014-12-27  7:34   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 03/11] ARM: kprobes: introduces checker Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 04/11] ARM: kprobes: collects stack consumption for store instructions Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 05/11] ARM: kprobes: disallow probing stack consuming instructions Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 06/11] ARM: kprobes: Add test cases for " Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 07/11] kprobes: Pass the original kprobe for preparing optimized kprobe Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 08/11] ARM: kprobes: enable OPTPROBES for ARM 32 Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 09/11] ARM: kprobes: Fix unreliable MRS instruction tests Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:35 ` [PATCH v17 10/11] ARM: kprobes: check register usage for probed instruction Wang Nan
2014-12-27  7:35   ` Wang Nan
2014-12-27  7:36 ` [PATCH v17 11/11] ARM: optprobes: execute instruction during restoring if possible Wang Nan
2014-12-27  7:36   ` Wang Nan
2014-12-28 22:10   ` Masami Hiramatsu
2014-12-28 22:10     ` Masami Hiramatsu
2014-12-29  4:07     ` [PATCH v18 10/11] ARM: kprobes: check register usage for probed instruction Wang Nan
2014-12-29  4:07       ` Wang Nan
2015-01-04  5:05       ` Masami Hiramatsu
2015-01-04  5:05         ` Masami Hiramatsu
2015-01-04  5:16         ` Wang Nan
2015-01-04  5:16           ` Wang Nan
2014-12-29  4:07     ` [PATCH v18 11/11] ARM: optprobes: execute instruction during restoring if possible Wang Nan
2014-12-29  4:07       ` Wang Nan
2015-01-04  5:25       ` Masami Hiramatsu
2015-01-04  5:25         ` Masami Hiramatsu
2014-12-29  4:10     ` Wang Nan [this message]
2014-12-29  4:10       ` [PATCH v17 " Wang Nan

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=54A0D450.6060909@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.