diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2015-02-26 17:40:38 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-04 16:50:52 -0500 |
commit | d441c1f2b73ec742c2e55be804ebc6fee130c77f (patch) | |
tree | f7e1cee1c0507c57368e582c9eacc7c26dc96467 | |
parent | b3ab90b333e94659e7c351843ab41ec0004f73e8 (diff) |
x86/asm/entry/64: Simplify optimistic SYSRET
Avoid redundant load of %r11 (it is already loaded a few
instructions before).
Also simplify %rsp restoration, instead of two steps:
add $0x80, %rsp
mov 0x18(%rsp), %rsp
we can do a simplified single step to restore user-space RSP:
mov 0x98(%rsp), %rsp
and get the same result.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
[ Clarified the changelog. ]
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Borislav Petkov <bp@alien8.de>
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/1aef69b346a6db0d99cdfb0f5ba83e8c985e27d7.1424989793.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/calling.h | 3 | ||||
-rw-r--r-- | arch/x86/kernel/entry_64.S | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h index 337423590b08..f1a962ff7ddf 100644 --- a/arch/x86/include/asm/calling.h +++ b/arch/x86/include/asm/calling.h | |||
@@ -176,6 +176,9 @@ For 32-bit we have the following conventions - kernel is built with | |||
176 | .macro RESTORE_C_REGS_EXCEPT_RCX | 176 | .macro RESTORE_C_REGS_EXCEPT_RCX |
177 | RESTORE_C_REGS_HELPER 1,0,1,1,1 | 177 | RESTORE_C_REGS_HELPER 1,0,1,1,1 |
178 | .endm | 178 | .endm |
179 | .macro RESTORE_C_REGS_EXCEPT_R11 | ||
180 | RESTORE_C_REGS_HELPER 1,1,0,1,1 | ||
181 | .endm | ||
179 | .macro RESTORE_RSI_RDI | 182 | .macro RESTORE_RSI_RDI |
180 | RESTORE_C_REGS_HELPER 0,0,0,0,0 | 183 | RESTORE_C_REGS_HELPER 0,0,0,0,0 |
181 | .endm | 184 | .endm |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index 858e94e86f5e..bc1527889c40 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
@@ -757,9 +757,9 @@ retint_swapgs: /* return to user-space */ | |||
757 | */ | 757 | */ |
758 | irq_return_via_sysret: | 758 | irq_return_via_sysret: |
759 | CFI_REMEMBER_STATE | 759 | CFI_REMEMBER_STATE |
760 | RESTORE_C_REGS | 760 | /* r11 is already restored (see code above) */ |
761 | REMOVE_PT_GPREGS_FROM_STACK 8 | 761 | RESTORE_C_REGS_EXCEPT_R11 |
762 | movq (RSP-RIP)(%rsp),%rsp | 762 | movq RSP(%rsp),%rsp |
763 | USERGS_SYSRET64 | 763 | USERGS_SYSRET64 |
764 | CFI_RESTORE_STATE | 764 | CFI_RESTORE_STATE |
765 | 765 | ||