Skip to content

Commit 73cbf68

Browse files
dvlasenkIngo Molnar
authored andcommitted
x86/asm/entry/32: Open-code LOAD_ARGS32
This macro is small, has only three callsites, and one of them is slightly different using a conditional parameter. A few saved lines aren't worth the resulting obfuscation. Generated machine code is identical. Signed-off-by: Denys Vlasenko <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Kees Cook <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Drewry <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent ef0cd5d commit 73cbf68

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

arch/x86/entry/ia32entry.S

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,6 @@
2929

3030
.section .entry.text, "ax"
3131

32-
/*
33-
* Reload arg registers from stack in case ptrace changed them.
34-
* We don't reload %eax because syscall_trace_enter() returned
35-
* the %rax value we should see. Instead, we just truncate that
36-
* value to 32 bits again as we did on entry from user mode.
37-
* If it's a new value set by user_regset during entry tracing,
38-
* this matches the normal truncation of the user-mode value.
39-
* If it's -1 to make us punt the syscall, then (u32)-1 is still
40-
* an appropriately invalid value.
41-
*/
42-
.macro LOAD_ARGS32 _r9=0
43-
.if \_r9
44-
movl R9(%rsp),%r9d
45-
.endif
46-
movl RCX(%rsp),%ecx
47-
movl RDX(%rsp),%edx
48-
movl RSI(%rsp),%esi
49-
movl RDI(%rsp),%edi
50-
movl %eax,%eax /* zero extension */
51-
.endm
52-
53-
5432
#ifdef CONFIG_PARAVIRT
5533
ENTRY(native_usergs_sysret32)
5634
swapgs
@@ -269,7 +247,14 @@ sysenter_tracesys:
269247
movq %rax, R8(%rsp)
270248
movq %rsp,%rdi /* &pt_regs -> arg1 */
271249
call syscall_trace_enter
272-
LOAD_ARGS32 /* reload args from stack in case ptrace changed it */
250+
251+
/* Reload arg registers from stack. (see sysenter_tracesys) */
252+
movl RCX(%rsp), %ecx
253+
movl RDX(%rsp), %edx
254+
movl RSI(%rsp), %esi
255+
movl RDI(%rsp), %edi
256+
movl %eax, %eax /* zero extension */
257+
273258
RESTORE_EXTRA_REGS
274259
jmp sysenter_do_call
275260
ENDPROC(ia32_sysenter_target)
@@ -413,7 +398,15 @@ cstar_tracesys:
413398
movq %rax, R8(%rsp)
414399
movq %rsp,%rdi /* &pt_regs -> arg1 */
415400
call syscall_trace_enter
416-
LOAD_ARGS32 1 /* reload args from stack in case ptrace changed it */
401+
movl R9(%rsp),%r9d
402+
403+
/* Reload arg registers from stack. (see sysenter_tracesys) */
404+
movl RCX(%rsp), %ecx
405+
movl RDX(%rsp), %edx
406+
movl RSI(%rsp), %esi
407+
movl RDI(%rsp), %edi
408+
movl %eax, %eax /* zero extension */
409+
417410
RESTORE_EXTRA_REGS
418411
xchgl %ebp,%r9d
419412
jmp cstar_do_call
@@ -502,7 +495,18 @@ ia32_tracesys:
502495
SAVE_EXTRA_REGS
503496
movq %rsp,%rdi /* &pt_regs -> arg1 */
504497
call syscall_trace_enter
505-
LOAD_ARGS32 /* reload args from stack in case ptrace changed it */
498+
/*
499+
* Reload arg registers from stack in case ptrace changed them.
500+
* Don't reload %eax because syscall_trace_enter() returned
501+
* the %rax value we should see. But do truncate it to 32 bits.
502+
* If it's -1 to make us punt the syscall, then (u32)-1 is still
503+
* an appropriately invalid value.
504+
*/
505+
movl RCX(%rsp), %ecx
506+
movl RDX(%rsp), %edx
507+
movl RSI(%rsp), %esi
508+
movl RDI(%rsp), %edi
509+
movl %eax, %eax /* zero extension */
506510
RESTORE_EXTRA_REGS
507511
jmp ia32_do_call
508512
END(ia32_syscall)

0 commit comments

Comments
 (0)