Skip to content

Commit ef0cd5d

Browse files
dvlasenkIngo Molnar
authored andcommitted
x86/asm/entry/32: Open-code CLEAR_RREGS
This macro is small, has only four 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]> [ Added comments. ] 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 61b1e3e commit ef0cd5d

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

arch/x86/entry/ia32entry.S

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@
2929

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

32-
/* clobbers %rax */
33-
.macro CLEAR_RREGS _r9=rax
34-
xorl %eax,%eax
35-
movq %rax,R11(%rsp)
36-
movq %rax,R10(%rsp)
37-
movq %\_r9,R9(%rsp)
38-
movq %rax,R8(%rsp)
39-
.endm
40-
4132
/*
4233
* Reload arg registers from stack in case ptrace changed them.
4334
* We don't reload %eax because syscall_trace_enter() returned
@@ -243,7 +234,11 @@ sysexit_from_sys_call:
243234
TRACE_IRQS_OFF
244235
testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
245236
jz \exit
246-
CLEAR_RREGS
237+
xorl %eax, %eax /* do not leak kernel information */
238+
movq %rax, R11(%rsp)
239+
movq %rax, R10(%rsp)
240+
movq %rax, R9(%rsp)
241+
movq %rax, R8(%rsp)
247242
jmp int_with_check
248243
.endm
249244

@@ -267,7 +262,11 @@ sysenter_tracesys:
267262
jz sysenter_auditsys
268263
#endif
269264
SAVE_EXTRA_REGS
270-
CLEAR_RREGS
265+
xorl %eax, %eax /* do not leak kernel information */
266+
movq %rax, R11(%rsp)
267+
movq %rax, R10(%rsp)
268+
movq %rax, R9(%rsp)
269+
movq %rax, R8(%rsp)
271270
movq %rsp,%rdi /* &pt_regs -> arg1 */
272271
call syscall_trace_enter
273272
LOAD_ARGS32 /* reload args from stack in case ptrace changed it */
@@ -407,7 +406,11 @@ cstar_tracesys:
407406
#endif
408407
xchgl %r9d,%ebp
409408
SAVE_EXTRA_REGS
410-
CLEAR_RREGS r9
409+
xorl %eax, %eax /* do not leak kernel information */
410+
movq %rax, R11(%rsp)
411+
movq %rax, R10(%rsp)
412+
movq %r9, R9(%rsp)
413+
movq %rax, R8(%rsp)
411414
movq %rsp,%rdi /* &pt_regs -> arg1 */
412415
call syscall_trace_enter
413416
LOAD_ARGS32 1 /* reload args from stack in case ptrace changed it */
@@ -422,7 +425,11 @@ ia32_badarg:
422425
jmp ia32_sysret
423426

424427
ia32_ret_from_sys_call:
425-
CLEAR_RREGS
428+
xorl %eax, %eax /* do not leak kernel information */
429+
movq %rax, R11(%rsp)
430+
movq %rax, R10(%rsp)
431+
movq %rax, R9(%rsp)
432+
movq %rax, R8(%rsp)
426433
jmp int_ret_from_sys_call
427434

428435
/*

0 commit comments

Comments
 (0)