It was mentioned that people keep trying to optimize them out,
introducing bugs. Make them more visible, and add "do not remove"
comment.

Signed-off-by: Denys Vlasenko <dvlas...@redhat.com>
CC: Linus Torvalds <torva...@linux-foundation.org>
CC: Steven Rostedt <rost...@goodmis.org>
CC: Ingo Molnar <mi...@kernel.org>
CC: Borislav Petkov <b...@alien8.de>
CC: "H. Peter Anvin" <h...@zytor.com>
CC: Andy Lutomirski <l...@amacapital.net>
CC: Oleg Nesterov <o...@redhat.com>
CC: Frederic Weisbecker <fweis...@gmail.com>
CC: Alexei Starovoitov <a...@plumgrid.com>
CC: Will Drewry <w...@chromium.org>
CC: Kees Cook <keesc...@chromium.org>
CC: x...@kernel.org
CC: linux-kernel@vger.kernel.org
---
 arch/x86/ia32/ia32entry.S | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 7502ff0..dec8c1d 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -122,8 +122,11 @@ ENTRY(ia32_sysenter_target)
        movq    PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp
        ENABLE_INTERRUPTS(CLBR_NONE)
 
+       /* Zero-extending 32-bit regs, do not remove */
+       movl    %ebp, %ebp
+       movl    %eax, %eax
+
        /* Construct iret frame (ss,rsp,rflags,cs,rip) */
-       movl    %ebp,%ebp               /* zero extension */
        pushq_cfi $__USER32_DS
        /*CFI_REL_OFFSET ss,0*/
        pushq_cfi %rbp
@@ -134,7 +137,6 @@ ENTRY(ia32_sysenter_target)
        CFI_REGISTER rip,r10
        pushq_cfi $__USER32_CS
        /*CFI_REL_OFFSET cs,0*/
-       movl    %eax, %eax
        /* Store thread_info->sysenter_return in rip stack slot */
        pushq_cfi %r10
        CFI_REL_OFFSET rip,0
@@ -329,9 +331,11 @@ ENTRY(ia32_cstar_target)
        movq    PER_CPU_VAR(kernel_stack),%rsp
        ENABLE_INTERRUPTS(CLBR_NONE)
 
+       /* Zero-extending 32-bit regs, do not remove */
+       movl    %eax,%eax
+
        ALLOC_PT_GPREGS_ON_STACK 6*8 /* 6*8: space for orig_ax and iret frame */
        SAVE_C_REGS_EXCEPT_RCX_R891011
-       movl    %eax,%eax       /* zero extension */
        movq    %rax,ORIG_RAX(%rsp)
        movq    %rcx,RIP(%rsp)
        CFI_REL_OFFSET rip,RIP
@@ -471,7 +475,9 @@ ENTRY(ia32_syscall)
        SWAPGS
        ENABLE_INTERRUPTS(CLBR_NONE)
 
-       movl %eax,%eax
+       /* Zero-extending 32-bit regs, do not remove */
+       movl    %eax,%eax
+
        pushq_cfi %rax          /* store orig_ax */
        cld
        /* note the registers are not zero extended to the sf.
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to