public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kprobes: x86: mark 2 bytes NOP as boostable.
@ 2015-02-09 12:45 Wang Nan
  2015-02-09 23:34 ` Masami Hiramatsu
  0 siblings, 1 reply; 5+ messages in thread
From: Wang Nan @ 2015-02-09 12:45 UTC (permalink / raw)
  To: masami.hiramatsu.pt, tglx, mingo, x86; +Cc: linux-kernel, lizefan

x86 kprobes is unable to probe at 2 bytes nop like:

nopl 0x0(%rax,%rax,1)

which is 0x0f 0x1f 0x44 0x00 0x00.

Such nops have exactly 5 bytes which is able to hold a relative jmp
instruction. Boosting them should be obviously safe.

This patch enable boosting such nops by simply updating
twobyte_is_boostable[] array.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
---
 arch/x86/kernel/kprobes/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 98f654d..6a1146e 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -84,7 +84,7 @@ static volatile u32 twobyte_is_boostable[256 / 32] = {
 	/*      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f          */
 	/*      ----------------------------------------------          */
 	W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
-	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 10 */
+	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
 	W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
 	W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
 	W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
-- 
1.8.4


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

* Re: [PATCH] kprobes: x86: mark 2 bytes NOP as boostable.
  2015-02-09 12:45 [PATCH] kprobes: x86: mark 2 bytes NOP as boostable Wang Nan
@ 2015-02-09 23:34 ` Masami Hiramatsu
  2015-02-10  1:34   ` [PATCH][RESEND] " Wang Nan
  0 siblings, 1 reply; 5+ messages in thread
From: Masami Hiramatsu @ 2015-02-09 23:34 UTC (permalink / raw)
  To: Wang Nan; +Cc: tglx, mingo, x86, linux-kernel, lizefan

(2015/02/09 21:45), Wang Nan wrote:
> x86 kprobes is unable to probe at 2 bytes nop like:
                           ^^^^^ boost

> 
> nopl 0x0(%rax,%rax,1)
> 
> which is 0x0f 0x1f 0x44 0x00 0x00.
> 
> Such nops have exactly 5 bytes which is able to hold a relative jmp
> instruction. Boosting them should be obviously safe.
> 
> This patch enable boosting such nops by simply updating
> twobyte_is_boostable[] array.

Anyway, this looks good to me.
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Thank you!

> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> ---
>  arch/x86/kernel/kprobes/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index 98f654d..6a1146e 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -84,7 +84,7 @@ static volatile u32 twobyte_is_boostable[256 / 32] = {
>  	/*      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f          */
>  	/*      ----------------------------------------------          */
>  	W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
> -	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 10 */
> +	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
>  	W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
>  	W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
>  	W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



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

* [PATCH][RESEND] kprobes: x86: mark 2 bytes NOP as boostable.
  2015-02-09 23:34 ` Masami Hiramatsu
@ 2015-02-10  1:34   ` Wang Nan
  2015-02-11  4:18     ` Wang Nan
  2015-02-19  0:26     ` [tip:perf/urgent] kprobes/x86: Mark " tip-bot for Wang Nan
  0 siblings, 2 replies; 5+ messages in thread
From: Wang Nan @ 2015-02-10  1:34 UTC (permalink / raw)
  To: masami.hiramatsu.pt, mingo; +Cc: tglx, x86, linux-kernel, lizefan

Currently, x86 kprobes is unable to boost 2 bytes nop like:

nopl 0x0(%rax,%rax,1)

which is 0x0f 0x1f 0x44 0x00 0x00.

Such nops have exactly 5 bytes to hold a relative jmp instruction.
Boosting them should be obviously safe.

This patch enable boosting such nops by simply updating
twobyte_is_boostable[] array.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 arch/x86/kernel/kprobes/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 98f654d..6a1146e 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -84,7 +84,7 @@ static volatile u32 twobyte_is_boostable[256 / 32] = {
 	/*      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f          */
 	/*      ----------------------------------------------          */
 	W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
-	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 10 */
+	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
 	W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
 	W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
 	W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
-- 
1.8.4


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

* Re: [PATCH][RESEND] kprobes: x86: mark 2 bytes NOP as boostable.
  2015-02-10  1:34   ` [PATCH][RESEND] " Wang Nan
@ 2015-02-11  4:18     ` Wang Nan
  2015-02-19  0:26     ` [tip:perf/urgent] kprobes/x86: Mark " tip-bot for Wang Nan
  1 sibling, 0 replies; 5+ messages in thread
From: Wang Nan @ 2015-02-11  4:18 UTC (permalink / raw)
  To: Andrew Morton
  Cc: masami.hiramatsu.pt, mingo, tglx, x86, linux-kernel, lizefan

Hi Andrew,

Could you please queue this patch onto your -mm tree? Masami has given an Acked-by already.

Thank you!

On 2015/2/10 9:34, Wang Nan wrote:
> Currently, x86 kprobes is unable to boost 2 bytes nop like:
> 
> nopl 0x0(%rax,%rax,1)
> 
> which is 0x0f 0x1f 0x44 0x00 0x00.
> 
> Such nops have exactly 5 bytes to hold a relative jmp instruction.
> Boosting them should be obviously safe.
> 
> This patch enable boosting such nops by simply updating
> twobyte_is_boostable[] array.
> 
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> ---
>  arch/x86/kernel/kprobes/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> index 98f654d..6a1146e 100644
> --- a/arch/x86/kernel/kprobes/core.c
> +++ b/arch/x86/kernel/kprobes/core.c
> @@ -84,7 +84,7 @@ static volatile u32 twobyte_is_boostable[256 / 32] = {
>  	/*      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f          */
>  	/*      ----------------------------------------------          */
>  	W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
> -	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 10 */
> +	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
>  	W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
>  	W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
>  	W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */
> 



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

* [tip:perf/urgent] kprobes/x86: Mark 2 bytes NOP as boostable
  2015-02-10  1:34   ` [PATCH][RESEND] " Wang Nan
  2015-02-11  4:18     ` Wang Nan
@ 2015-02-19  0:26     ` tip-bot for Wang Nan
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Wang Nan @ 2015-02-19  0:26 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: wangnan0, lizefan, masami.hiramatsu.pt, mingo, linux-kernel, tglx,
	hpa

Commit-ID:  b7e37567d080301d38a302bb93ba79d1ca446dca
Gitweb:     http://git.kernel.org/tip/b7e37567d080301d38a302bb93ba79d1ca446dca
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Tue, 10 Feb 2015 09:34:05 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 18 Feb 2015 21:50:12 +0100

kprobes/x86: Mark 2 bytes NOP as boostable

Currently, x86 kprobes is unable to boost 2 bytes nop like:

  nopl 0x0(%rax,%rax,1)

which is 0x0f 0x1f 0x44 0x00 0x00.

Such nops have exactly 5 bytes to hold a relative jmp
instruction. Boosting them should be obviously safe.

This patch enable boosting such nops by simply updating
twobyte_is_boostable[] array.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1423532045-41049-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/kprobes/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 98f654d..6a1146e 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -84,7 +84,7 @@ static volatile u32 twobyte_is_boostable[256 / 32] = {
 	/*      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f          */
 	/*      ----------------------------------------------          */
 	W(0x00, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0) | /* 00 */
-	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 10 */
+	W(0x10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1) , /* 10 */
 	W(0x20, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | /* 20 */
 	W(0x30, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) , /* 30 */
 	W(0x40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) | /* 40 */

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

end of thread, other threads:[~2015-02-19  0:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-09 12:45 [PATCH] kprobes: x86: mark 2 bytes NOP as boostable Wang Nan
2015-02-09 23:34 ` Masami Hiramatsu
2015-02-10  1:34   ` [PATCH][RESEND] " Wang Nan
2015-02-11  4:18     ` Wang Nan
2015-02-19  0:26     ` [tip:perf/urgent] kprobes/x86: Mark " tip-bot for Wang Nan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox