aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2015-03-31 13:00:04 -0400
committerIngo Molnar <mingo@kernel.org>2015-04-01 07:17:38 -0400
commit4c9c0e919fef05b3bc6a8aff1db7a31b2ba4f4b6 (patch)
tree224993138c78826f35404af48fbae1f2c4313275
parent4416c5a6dacdddd55378e7011f9c8720d2a7470f (diff)
x86/asm/entry/32: Use smaller PUSH instructions instead of MOV, to build 'pt_regs' on stack
This mimics the recent similar 64-bit change. Saves ~110 bytes of code. Patch was run-tested on 32 and 64 bits, Intel and AMD CPU. I also looked at the diff of entry_64.o disassembly, to have a different view of the changes. 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/1427821211-25099-2-git-send-email-dvlasenk@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/ia32/ia32entry.S82
1 files changed, 46 insertions, 36 deletions
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index dec8c1de9c9e..8d01cce7b6b8 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -126,26 +126,27 @@ ENTRY(ia32_sysenter_target)
126 movl %ebp, %ebp 126 movl %ebp, %ebp
127 movl %eax, %eax 127 movl %eax, %eax
128 128
129 /* Construct iret frame (ss,rsp,rflags,cs,rip) */ 129 movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 0), %r10d
130 pushq_cfi $__USER32_DS
131 /*CFI_REL_OFFSET ss,0*/
132 pushq_cfi %rbp
133 CFI_REL_OFFSET rsp,0
134 pushfq_cfi
135 /*CFI_REL_OFFSET rflags,0*/
136 movl ASM_THREAD_INFO(TI_sysenter_return, %rsp, 3*8), %r10d
137 CFI_REGISTER rip,r10 130 CFI_REGISTER rip,r10
138 pushq_cfi $__USER32_CS 131
139 /*CFI_REL_OFFSET cs,0*/ 132 /* Construct struct pt_regs on stack */
140 /* Store thread_info->sysenter_return in rip stack slot */ 133 pushq_cfi $__USER32_DS /* pt_regs->ss */
141 pushq_cfi %r10 134 pushq_cfi %rbp /* pt_regs->sp */
142 CFI_REL_OFFSET rip,0 135 CFI_REL_OFFSET rsp,0
143 /* Store orig_ax */ 136 pushfq_cfi /* pt_regs->flags */
144 pushq_cfi %rax 137 pushq_cfi $__USER32_CS /* pt_regs->cs */
145 /* Construct the rest of "struct pt_regs" */ 138 pushq_cfi %r10 /* pt_regs->ip = thread_info->sysenter_return */
139 CFI_REL_OFFSET rip,0
140 pushq_cfi_reg rax /* pt_regs->orig_ax */
141 pushq_cfi_reg rdi /* pt_regs->di */
142 pushq_cfi_reg rsi /* pt_regs->si */
143 pushq_cfi_reg rdx /* pt_regs->dx */
144 pushq_cfi_reg rcx /* pt_regs->cx */
145 pushq_cfi_reg rax /* pt_regs->ax */
146 cld 146 cld
147 ALLOC_PT_GPREGS_ON_STACK 147 sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
148 SAVE_C_REGS_EXCEPT_R891011 148 CFI_ADJUST_CFA_OFFSET 10*8
149
149 /* 150 /*
150 * no need to do an access_ok check here because rbp has been 151 * no need to do an access_ok check here because rbp has been
151 * 32bit zero extended 152 * 32bit zero extended
@@ -334,20 +335,24 @@ ENTRY(ia32_cstar_target)
334 /* Zero-extending 32-bit regs, do not remove */ 335 /* Zero-extending 32-bit regs, do not remove */
335 movl %eax,%eax 336 movl %eax,%eax
336 337
337 ALLOC_PT_GPREGS_ON_STACK 6*8 /* 6*8: space for orig_ax and iret frame */ 338 /* Construct struct pt_regs on stack */
338 SAVE_C_REGS_EXCEPT_RCX_R891011 339 pushq_cfi $__USER32_DS /* pt_regs->ss */
339 movq %rax,ORIG_RAX(%rsp) 340 pushq_cfi %r8 /* pt_regs->sp */
340 movq %rcx,RIP(%rsp) 341 CFI_REL_OFFSET rsp,0
341 CFI_REL_OFFSET rip,RIP 342 pushq_cfi %r11 /* pt_regs->flags */
342 movq %rbp,RCX(%rsp) /* this lies slightly to ptrace */ 343 pushq_cfi $__USER32_CS /* pt_regs->cs */
344 pushq_cfi %rcx /* pt_regs->ip */
345 CFI_REL_OFFSET rip,0
346 pushq_cfi_reg rax /* pt_regs->orig_ax */
347 pushq_cfi_reg rdi /* pt_regs->di */
348 pushq_cfi_reg rsi /* pt_regs->si */
349 pushq_cfi_reg rdx /* pt_regs->dx */
350 pushq_cfi_reg rbp /* pt_regs->cx */
343 movl %ebp,%ecx 351 movl %ebp,%ecx
344 movq $__USER32_CS,CS(%rsp) 352 pushq_cfi_reg rax /* pt_regs->ax */
345 movq $__USER32_DS,SS(%rsp) 353 sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
346 movq %r11,EFLAGS(%rsp) 354 CFI_ADJUST_CFA_OFFSET 10*8
347 /*CFI_REL_OFFSET rflags,EFLAGS*/ 355
348 movq %r8,RSP(%rsp)
349 CFI_REL_OFFSET rsp,RSP
350 /* iret stack frame is complete now */
351 /* 356 /*
352 * no need to do an access_ok check here because r8 has been 357 * no need to do an access_ok check here because r8 has been
353 * 32bit zero extended 358 * 32bit zero extended
@@ -478,12 +483,17 @@ ENTRY(ia32_syscall)
478 /* Zero-extending 32-bit regs, do not remove */ 483 /* Zero-extending 32-bit regs, do not remove */
479 movl %eax,%eax 484 movl %eax,%eax
480 485
481 pushq_cfi %rax /* store orig_ax */ 486 /* Construct struct pt_regs on stack (iret frame is already on stack) */
487 pushq_cfi_reg rax /* pt_regs->orig_ax */
488 pushq_cfi_reg rdi /* pt_regs->di */
489 pushq_cfi_reg rsi /* pt_regs->si */
490 pushq_cfi_reg rdx /* pt_regs->dx */
491 pushq_cfi_reg rcx /* pt_regs->cx */
492 pushq_cfi_reg rax /* pt_regs->ax */
482 cld 493 cld
483 /* note the registers are not zero extended to the sf. 494 sub $(10*8),%rsp /* pt_regs->r8-11,bp,bx,r12-15 not saved */
484 this could be a problem. */ 495 CFI_ADJUST_CFA_OFFSET 10*8
485 ALLOC_PT_GPREGS_ON_STACK 496
486 SAVE_C_REGS_EXCEPT_R891011
487 orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS) 497 orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
488 testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS) 498 testl $_TIF_WORK_SYSCALL_ENTRY, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
489 jnz ia32_tracesys 499 jnz ia32_tracesys