Skip to content

Commit

Permalink
x86/asm/entry/32: Open-code CLEAR_RREGS
Browse files Browse the repository at this point in the history
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 <dvlasenk@redhat.com>
[ Added comments. ]
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1433271842-9139-1-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Denys Vlasenko authored and Ingo Molnar committed Jun 5, 2015
1 parent 61b1e3e commit ef0cd5d
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions arch/x86/entry/ia32entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@

.section .entry.text, "ax"

/* clobbers %rax */
.macro CLEAR_RREGS _r9=rax
xorl %eax,%eax
movq %rax,R11(%rsp)
movq %rax,R10(%rsp)
movq %\_r9,R9(%rsp)
movq %rax,R8(%rsp)
.endm

/*
* Reload arg registers from stack in case ptrace changed them.
* We don't reload %eax because syscall_trace_enter() returned
Expand Down Expand Up @@ -243,7 +234,11 @@ sysexit_from_sys_call:
TRACE_IRQS_OFF
testl %edi, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jz \exit
CLEAR_RREGS
xorl %eax, %eax /* do not leak kernel information */
movq %rax, R11(%rsp)
movq %rax, R10(%rsp)
movq %rax, R9(%rsp)
movq %rax, R8(%rsp)
jmp int_with_check
.endm

Expand All @@ -267,7 +262,11 @@ sysenter_tracesys:
jz sysenter_auditsys
#endif
SAVE_EXTRA_REGS
CLEAR_RREGS
xorl %eax, %eax /* do not leak kernel information */
movq %rax, R11(%rsp)
movq %rax, R10(%rsp)
movq %rax, R9(%rsp)
movq %rax, R8(%rsp)
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace_enter
LOAD_ARGS32 /* reload args from stack in case ptrace changed it */
Expand Down Expand Up @@ -407,7 +406,11 @@ cstar_tracesys:
#endif
xchgl %r9d,%ebp
SAVE_EXTRA_REGS
CLEAR_RREGS r9
xorl %eax, %eax /* do not leak kernel information */
movq %rax, R11(%rsp)
movq %rax, R10(%rsp)
movq %r9, R9(%rsp)
movq %rax, R8(%rsp)
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace_enter
LOAD_ARGS32 1 /* reload args from stack in case ptrace changed it */
Expand All @@ -422,7 +425,11 @@ ia32_badarg:
jmp ia32_sysret

ia32_ret_from_sys_call:
CLEAR_RREGS
xorl %eax, %eax /* do not leak kernel information */
movq %rax, R11(%rsp)
movq %rax, R10(%rsp)
movq %rax, R9(%rsp)
movq %rax, R8(%rsp)
jmp int_ret_from_sys_call

/*
Expand Down

0 comments on commit ef0cd5d

Please sign in to comment.