* [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs
@ 2015-04-27 13:21 Denys Vlasenko
2015-04-27 13:21 ` [PATCH 2/2] x86/asm/entry/64: Clean up usage of TEST insns Denys Vlasenko
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Denys Vlasenko @ 2015-04-27 13:21 UTC (permalink / raw)
To: Ingo Molnar
Cc: Denys Vlasenko, Linus Torvalds, Steven Rostedt, Borislav Petkov,
H. Peter Anvin, Andy Lutomirski, Oleg Nesterov,
Frederic Weisbecker, Alexei Starovoitov, Will Drewry, Kees Cook,
x86, linux-kernel
After TESTs, use logically correct JZ/JNZ mnemonics instead of JE/JNE.
This doesn't change code.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Borislav Petkov <bp@alien8.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Alexei Starovoitov <ast@plumgrid.com>
CC: Will Drewry <wad@chromium.org>
CC: Kees Cook <keescook@chromium.org>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
arch/x86/kernel/entry_64.S | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e952f6b..8f8b22a 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -666,7 +666,7 @@ END(irq_entries_start)
leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
testl $3, CS-RBP(%rsp)
- je 1f
+ jz 1f
SWAPGS
1:
/*
@@ -721,7 +721,7 @@ ret_from_intr:
CFI_ADJUST_CFA_OFFSET RBP
testl $3,CS(%rsp)
- je retint_kernel
+ jz retint_kernel
/* Interrupt came from user space */
GET_THREAD_INFO(%rcx)
@@ -1310,7 +1310,7 @@ ENTRY(error_entry)
SAVE_EXTRA_REGS 8
xorl %ebx,%ebx
testl $3,CS+8(%rsp)
- je error_kernelspace
+ jz error_kernelspace
error_swapgs:
SWAPGS
error_sti:
@@ -1361,7 +1361,7 @@ ENTRY(error_exit)
TRACE_IRQS_OFF
GET_THREAD_INFO(%rcx)
testl %eax,%eax
- jne retint_kernel
+ jnz retint_kernel
LOCKDEP_SYS_EXIT_IRQ
movl TI_flags(%rcx),%edx
movl $_TIF_WORK_MASK,%edi
--
1.8.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] x86/asm/entry/64: Clean up usage of TEST insns
2015-04-27 13:21 [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Denys Vlasenko
@ 2015-04-27 13:21 ` Denys Vlasenko
2015-05-08 9:25 ` [tip:x86/asm] " tip-bot for Denys Vlasenko
2015-04-27 21:13 ` [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Andy Lutomirski
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Denys Vlasenko @ 2015-04-27 13:21 UTC (permalink / raw)
To: Ingo Molnar
Cc: Denys Vlasenko, Linus Torvalds, Steven Rostedt, Borislav Petkov,
H. Peter Anvin, Andy Lutomirski, Oleg Nesterov,
Frederic Weisbecker, Alexei Starovoitov, Will Drewry, Kees Cook,
x86, linux-kernel
By the nature of TEST operation, it is often possible
to test a narrower part of the operand:
"testl $3, mem" -> "testb $3, mem"
This results in shorter insns, because TEST insn has no
sign-entending byte-immediate forms unlike other ALU ops.
text data bss dec hex filename
11674 0 0 11674 2d9a entry_64.o.before
11658 0 0 11658 2d8a entry_64.o
Changes in object code:
- f7 84 24 88 00 00 00 03 00 00 00 testl $0x3,0x88(%rsp)
+ f6 84 24 88 00 00 00 03 testb $0x3,0x88(%rsp)
- f7 44 24 68 03 00 00 00 testl $0x3,0x68(%rsp)
+ f6 44 24 68 03 testb $0x3,0x68(%rsp)
- f7 84 24 90 00 00 00 03 00 00 00 testl $0x3,0x90(%rsp)
+ f6 84 24 90 00 00 00 03 testb $0x3,0x90(%rsp)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Steven Rostedt <rostedt@goodmis.org>
CC: Ingo Molnar <mingo@kernel.org>
CC: Borislav Petkov <bp@alien8.de>
CC: "H. Peter Anvin" <hpa@zytor.com>
CC: Andy Lutomirski <luto@amacapital.net>
CC: Oleg Nesterov <oleg@redhat.com>
CC: Frederic Weisbecker <fweisbec@gmail.com>
CC: Alexei Starovoitov <ast@plumgrid.com>
CC: Will Drewry <wad@chromium.org>
CC: Kees Cook <keescook@chromium.org>
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
---
arch/x86/kernel/entry_64.S | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8f8b22a..60705b03 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -601,7 +601,7 @@ ENTRY(ret_from_fork)
RESTORE_EXTRA_REGS
- testl $3,CS(%rsp) # from kernel_thread?
+ testb $3, CS(%rsp) # from kernel_thread?
/*
* By the time we get here, we have no idea whether our pt_regs,
@@ -665,7 +665,7 @@ END(irq_entries_start)
leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
- testl $3, CS-RBP(%rsp)
+ testb $3, CS-RBP(%rsp)
jz 1f
SWAPGS
1:
@@ -720,7 +720,7 @@ ret_from_intr:
CFI_DEF_CFA_REGISTER rsp
CFI_ADJUST_CFA_OFFSET RBP
- testl $3,CS(%rsp)
+ testb $3, CS(%rsp)
jz retint_kernel
/* Interrupt came from user space */
@@ -968,7 +968,7 @@ ENTRY(\sym)
.if \paranoid
.if \paranoid == 1
CFI_REMEMBER_STATE
- testl $3, CS(%rsp) /* If coming from userspace, switch */
+ testb $3, CS(%rsp) /* If coming from userspace, switch */
jnz 1f /* stacks. */
.endif
call paranoid_entry
@@ -1309,7 +1309,7 @@ ENTRY(error_entry)
SAVE_C_REGS 8
SAVE_EXTRA_REGS 8
xorl %ebx,%ebx
- testl $3,CS+8(%rsp)
+ testb $3, CS+8(%rsp)
jz error_kernelspace
error_swapgs:
SWAPGS
@@ -1606,7 +1606,6 @@ end_repeat_nmi:
je 1f
movq %r12, %cr2
1:
-
testl %ebx,%ebx /* swapgs needed? */
jnz nmi_restore
nmi_swapgs:
--
1.8.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs
2015-04-27 13:21 [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Denys Vlasenko
2015-04-27 13:21 ` [PATCH 2/2] x86/asm/entry/64: Clean up usage of TEST insns Denys Vlasenko
@ 2015-04-27 21:13 ` Andy Lutomirski
2015-04-27 22:16 ` H. Peter Anvin
2015-05-08 9:25 ` [tip:x86/asm] " tip-bot for Denys Vlasenko
3 siblings, 0 replies; 7+ messages in thread
From: Andy Lutomirski @ 2015-04-27 21:13 UTC (permalink / raw)
To: Denys Vlasenko
Cc: Ingo Molnar, Linus Torvalds, Steven Rostedt, Borislav Petkov,
H. Peter Anvin, Oleg Nesterov, Frederic Weisbecker,
Alexei Starovoitov, Will Drewry, Kees Cook, X86 ML,
linux-kernel@vger.kernel.org
On Mon, Apr 27, 2015 at 6:21 AM, Denys Vlasenko <dvlasenk@redhat.com> wrote:
> After TESTs, use logically correct JZ/JNZ mnemonics instead of JE/JNE.
> This doesn't change code.
>
Acked-by: Andy Lutomirski <luto@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs
2015-04-27 13:21 [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Denys Vlasenko
2015-04-27 13:21 ` [PATCH 2/2] x86/asm/entry/64: Clean up usage of TEST insns Denys Vlasenko
2015-04-27 21:13 ` [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Andy Lutomirski
@ 2015-04-27 22:16 ` H. Peter Anvin
2015-04-28 10:05 ` Denys Vlasenko
2015-05-08 9:25 ` [tip:x86/asm] " tip-bot for Denys Vlasenko
3 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2015-04-27 22:16 UTC (permalink / raw)
To: Denys Vlasenko, Ingo Molnar
Cc: Linus Torvalds, Steven Rostedt, Borislav Petkov, Andy Lutomirski,
Oleg Nesterov, Frederic Weisbecker, Alexei Starovoitov,
Will Drewry, Kees Cook, x86, linux-kernel
On 04/27/2015 06:21 AM, Denys Vlasenko wrote:
>
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index e952f6b..8f8b22a 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -666,7 +666,7 @@ END(irq_entries_start)
> leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
>
> testl $3, CS-RBP(%rsp)
> - je 1f
> + jz 1f
> SWAPGS
> 1:
Please don't insert tabs between opcode and operand unless that is the
style of the surrounding code.
Otherwise this patchset looks good.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs
2015-04-27 22:16 ` H. Peter Anvin
@ 2015-04-28 10:05 ` Denys Vlasenko
0 siblings, 0 replies; 7+ messages in thread
From: Denys Vlasenko @ 2015-04-28 10:05 UTC (permalink / raw)
To: H. Peter Anvin, Ingo Molnar
Cc: Linus Torvalds, Steven Rostedt, Borislav Petkov, Andy Lutomirski,
Oleg Nesterov, Frederic Weisbecker, Alexei Starovoitov,
Will Drewry, Kees Cook, x86, linux-kernel
On 04/28/2015 12:16 AM, H. Peter Anvin wrote:
> On 04/27/2015 06:21 AM, Denys Vlasenko wrote:
>>
>> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
>> index e952f6b..8f8b22a 100644
>> --- a/arch/x86/kernel/entry_64.S
>> +++ b/arch/x86/kernel/entry_64.S
>> @@ -666,7 +666,7 @@ END(irq_entries_start)
>> leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
>>
>> testl $3, CS-RBP(%rsp)
>> - je 1f
>> + jz 1f
>> SWAPGS
>> 1:
>
> Please don't insert tabs between opcode and operand unless that is the
> style of the surrounding code.
The next patch inserts tab in the preceding TEST insn too,
converting entire mini-block of code to "tab" style.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:x86/asm] x86/asm/entry/64: Tidy up JZ insns after TESTs
2015-04-27 13:21 [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Denys Vlasenko
` (2 preceding siblings ...)
2015-04-27 22:16 ` H. Peter Anvin
@ 2015-05-08 9:25 ` tip-bot for Denys Vlasenko
3 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Denys Vlasenko @ 2015-05-08 9:25 UTC (permalink / raw)
To: linux-tip-commits
Cc: bp, linux-kernel, wad, oleg, keescook, dvlasenk, rostedt, tglx,
mingo, brgerst, fweisbec, torvalds, luto, ast, hpa
Commit-ID: dde74f2e4a4447ef838c57e407f7139de3df68cb
Gitweb: http://git.kernel.org/tip/dde74f2e4a4447ef838c57e407f7139de3df68cb
Author: Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Mon, 27 Apr 2015 15:21:51 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 8 May 2015 11:07:31 +0200
x86/asm/entry/64: Tidy up JZ insns after TESTs
After TESTs, use logically correct JZ/JNZ mnemonics instead of
JE/JNE. This doesn't change code.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1430140912-7960-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/entry_64.S | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index e952f6b..8f8b22a 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -666,7 +666,7 @@ END(irq_entries_start)
leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
testl $3, CS-RBP(%rsp)
- je 1f
+ jz 1f
SWAPGS
1:
/*
@@ -721,7 +721,7 @@ ret_from_intr:
CFI_ADJUST_CFA_OFFSET RBP
testl $3,CS(%rsp)
- je retint_kernel
+ jz retint_kernel
/* Interrupt came from user space */
GET_THREAD_INFO(%rcx)
@@ -1310,7 +1310,7 @@ ENTRY(error_entry)
SAVE_EXTRA_REGS 8
xorl %ebx,%ebx
testl $3,CS+8(%rsp)
- je error_kernelspace
+ jz error_kernelspace
error_swapgs:
SWAPGS
error_sti:
@@ -1361,7 +1361,7 @@ ENTRY(error_exit)
TRACE_IRQS_OFF
GET_THREAD_INFO(%rcx)
testl %eax,%eax
- jne retint_kernel
+ jnz retint_kernel
LOCKDEP_SYS_EXIT_IRQ
movl TI_flags(%rcx),%edx
movl $_TIF_WORK_MASK,%edi
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [tip:x86/asm] x86/asm/entry/64: Clean up usage of TEST insns
2015-04-27 13:21 ` [PATCH 2/2] x86/asm/entry/64: Clean up usage of TEST insns Denys Vlasenko
@ 2015-05-08 9:25 ` tip-bot for Denys Vlasenko
0 siblings, 0 replies; 7+ messages in thread
From: tip-bot for Denys Vlasenko @ 2015-05-08 9:25 UTC (permalink / raw)
To: linux-tip-commits
Cc: bp, luto, rostedt, oleg, linux-kernel, wad, dvlasenk, keescook,
torvalds, fweisbec, hpa, brgerst, mingo, ast, tglx
Commit-ID: 03335e95e27fc1f2b17b05b27342ad76986b3cf0
Gitweb: http://git.kernel.org/tip/03335e95e27fc1f2b17b05b27342ad76986b3cf0
Author: Denys Vlasenko <dvlasenk@redhat.com>
AuthorDate: Mon, 27 Apr 2015 15:21:52 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 8 May 2015 11:07:32 +0200
x86/asm/entry/64: Clean up usage of TEST insns
By the nature of TEST operation, it is often possible
to test a narrower part of the operand:
"testl $3, mem" -> "testb $3, mem"
This results in shorter insns, because TEST insn has no
sign-entending byte-immediate forms unlike other ALU ops.
text data bss dec hex filename
11674 0 0 11674 2d9a entry_64.o.before
11658 0 0 11658 2d8a entry_64.o
Changes in object code:
- f7 84 24 88 00 00 00 03 00 00 00 testl $0x3,0x88(%rsp)
+ f6 84 24 88 00 00 00 03 testb $0x3,0x88(%rsp)
- f7 44 24 68 03 00 00 00 testl $0x3,0x68(%rsp)
+ f6 44 24 68 03 testb $0x3,0x68(%rsp)
- f7 84 24 90 00 00 00 03 00 00 00 testl $0x3,0x90(%rsp)
+ f6 84 24 90 00 00 00 03 testb $0x3,0x90(%rsp)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1430140912-7960-2-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/entry_64.S | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8f8b22a..60705b03 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -601,7 +601,7 @@ ENTRY(ret_from_fork)
RESTORE_EXTRA_REGS
- testl $3,CS(%rsp) # from kernel_thread?
+ testb $3, CS(%rsp) # from kernel_thread?
/*
* By the time we get here, we have no idea whether our pt_regs,
@@ -665,7 +665,7 @@ END(irq_entries_start)
leaq -RBP(%rsp),%rdi /* arg1 for \func (pointer to pt_regs) */
- testl $3, CS-RBP(%rsp)
+ testb $3, CS-RBP(%rsp)
jz 1f
SWAPGS
1:
@@ -720,7 +720,7 @@ ret_from_intr:
CFI_DEF_CFA_REGISTER rsp
CFI_ADJUST_CFA_OFFSET RBP
- testl $3,CS(%rsp)
+ testb $3, CS(%rsp)
jz retint_kernel
/* Interrupt came from user space */
@@ -968,7 +968,7 @@ ENTRY(\sym)
.if \paranoid
.if \paranoid == 1
CFI_REMEMBER_STATE
- testl $3, CS(%rsp) /* If coming from userspace, switch */
+ testb $3, CS(%rsp) /* If coming from userspace, switch */
jnz 1f /* stacks. */
.endif
call paranoid_entry
@@ -1309,7 +1309,7 @@ ENTRY(error_entry)
SAVE_C_REGS 8
SAVE_EXTRA_REGS 8
xorl %ebx,%ebx
- testl $3,CS+8(%rsp)
+ testb $3, CS+8(%rsp)
jz error_kernelspace
error_swapgs:
SWAPGS
@@ -1606,7 +1606,6 @@ end_repeat_nmi:
je 1f
movq %r12, %cr2
1:
-
testl %ebx,%ebx /* swapgs needed? */
jnz nmi_restore
nmi_swapgs:
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-05-08 9:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-27 13:21 [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Denys Vlasenko
2015-04-27 13:21 ` [PATCH 2/2] x86/asm/entry/64: Clean up usage of TEST insns Denys Vlasenko
2015-05-08 9:25 ` [tip:x86/asm] " tip-bot for Denys Vlasenko
2015-04-27 21:13 ` [PATCH 1/2] x86/asm/entry/64: Tidy up JZ insns after TESTs Andy Lutomirski
2015-04-27 22:16 ` H. Peter Anvin
2015-04-28 10:05 ` Denys Vlasenko
2015-05-08 9:25 ` [tip:x86/asm] " tip-bot for Denys Vlasenko
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.