diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2015-03-27 06:36:21 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-27 07:27:57 -0400 |
commit | 4ee8ec17ba00fce4af042543771f996fb9d98d34 (patch) | |
tree | 768bd1721024814da059c730d9dc0f6f796d16a7 | |
parent | a232e3d558eef421fbb539ede5483dfb668e38f2 (diff) |
x86/asm/entry/32: Make register zero-extension more prominent
There are a couple of syscall argument zero-extension instructions in
the 32-bit compat entry code, and it was mentioned that people keep
trying to optimize them out, introducing bugs.
Make them more visible, and add a "do not remove" comment.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andy Lutomirski <luto@amacapital.net>
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: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1427452582-21624-3-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/ia32/ia32entry.S | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index 7502ff0b938e..dec8c1de9c9e 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S | |||
@@ -122,8 +122,11 @@ ENTRY(ia32_sysenter_target) | |||
122 | movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp | 122 | movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp |
123 | ENABLE_INTERRUPTS(CLBR_NONE) | 123 | ENABLE_INTERRUPTS(CLBR_NONE) |
124 | 124 | ||
125 | /* Zero-extending 32-bit regs, do not remove */ | ||
126 | movl %ebp, %ebp | ||
127 | movl %eax, %eax | ||
128 | |||
125 | /* Construct iret frame (ss,rsp,rflags,cs,rip) */ | 129 | /* Construct iret frame (ss,rsp,rflags,cs,rip) */ |
126 | movl %ebp,%ebp /* zero extension */ | ||
127 | pushq_cfi $__USER32_DS | 130 | pushq_cfi $__USER32_DS |
128 | /*CFI_REL_OFFSET ss,0*/ | 131 | /*CFI_REL_OFFSET ss,0*/ |
129 | pushq_cfi %rbp | 132 | pushq_cfi %rbp |
@@ -134,7 +137,6 @@ ENTRY(ia32_sysenter_target) | |||
134 | CFI_REGISTER rip,r10 | 137 | CFI_REGISTER rip,r10 |
135 | pushq_cfi $__USER32_CS | 138 | pushq_cfi $__USER32_CS |
136 | /*CFI_REL_OFFSET cs,0*/ | 139 | /*CFI_REL_OFFSET cs,0*/ |
137 | movl %eax, %eax | ||
138 | /* Store thread_info->sysenter_return in rip stack slot */ | 140 | /* Store thread_info->sysenter_return in rip stack slot */ |
139 | pushq_cfi %r10 | 141 | pushq_cfi %r10 |
140 | CFI_REL_OFFSET rip,0 | 142 | CFI_REL_OFFSET rip,0 |
@@ -329,9 +331,11 @@ ENTRY(ia32_cstar_target) | |||
329 | movq PER_CPU_VAR(kernel_stack),%rsp | 331 | movq PER_CPU_VAR(kernel_stack),%rsp |
330 | ENABLE_INTERRUPTS(CLBR_NONE) | 332 | ENABLE_INTERRUPTS(CLBR_NONE) |
331 | 333 | ||
334 | /* Zero-extending 32-bit regs, do not remove */ | ||
335 | movl %eax,%eax | ||
336 | |||
332 | ALLOC_PT_GPREGS_ON_STACK 6*8 /* 6*8: space for orig_ax and iret frame */ | 337 | ALLOC_PT_GPREGS_ON_STACK 6*8 /* 6*8: space for orig_ax and iret frame */ |
333 | SAVE_C_REGS_EXCEPT_RCX_R891011 | 338 | SAVE_C_REGS_EXCEPT_RCX_R891011 |
334 | movl %eax,%eax /* zero extension */ | ||
335 | movq %rax,ORIG_RAX(%rsp) | 339 | movq %rax,ORIG_RAX(%rsp) |
336 | movq %rcx,RIP(%rsp) | 340 | movq %rcx,RIP(%rsp) |
337 | CFI_REL_OFFSET rip,RIP | 341 | CFI_REL_OFFSET rip,RIP |
@@ -471,7 +475,9 @@ ENTRY(ia32_syscall) | |||
471 | SWAPGS | 475 | SWAPGS |
472 | ENABLE_INTERRUPTS(CLBR_NONE) | 476 | ENABLE_INTERRUPTS(CLBR_NONE) |
473 | 477 | ||
474 | movl %eax,%eax | 478 | /* Zero-extending 32-bit regs, do not remove */ |
479 | movl %eax,%eax | ||
480 | |||
475 | pushq_cfi %rax /* store orig_ax */ | 481 | pushq_cfi %rax /* store orig_ax */ |
476 | cld | 482 | cld |
477 | /* note the registers are not zero extended to the sf. | 483 | /* note the registers are not zero extended to the sf. |