x86/asm/entry/64: Merge the field offset into the THREAD_INFO() macro

Before:

   TI_sysenter_return+THREAD_INFO(%rsp,3*8),%r10d

After:

   movl    THREAD_INFO(TI_sysenter_return, %rsp, 3*8), %r10d

to turn it into a clear thread_info accessor.

No code changed:

 md5:
   fb4cb2b3ce05d89940ca304efc8ff183  ia32entry.o.before.asm
   fb4cb2b3ce05d89940ca304efc8ff183  ia32entry.o.after.asm

   e39f2958a5d1300158e276e4f7663263  entry_64.o.before.asm
   e39f2958a5d1300158e276e4f7663263  entry_64.o.after.asm

Acked-by: Andy Lutomirski <luto@kernel.org>
Acked-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: Borislav Petkov <bp@suse.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/20150324184411.GB14760@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2015-03-24 19:44:11 +01:00
Родитель 1ddc6f3c60
Коммит f9d71854b4
3 изменённых файлов: 19 добавлений и 19 удалений

Просмотреть файл

@ -127,7 +127,7 @@ ENTRY(ia32_sysenter_target)
CFI_REL_OFFSET rsp,0 CFI_REL_OFFSET rsp,0
pushfq_cfi pushfq_cfi
/*CFI_REL_OFFSET rflags,0*/ /*CFI_REL_OFFSET rflags,0*/
movl TI_sysenter_return+THREAD_INFO(%rsp,3*8),%r10d movl THREAD_INFO(TI_sysenter_return, %rsp, 3*8), %r10d
CFI_REGISTER rip,r10 CFI_REGISTER rip,r10
pushq_cfi $__USER32_CS pushq_cfi $__USER32_CS
/*CFI_REL_OFFSET cs,0*/ /*CFI_REL_OFFSET cs,0*/
@ -159,8 +159,8 @@ ENTRY(ia32_sysenter_target)
jnz sysenter_fix_flags jnz sysenter_fix_flags
sysenter_flags_fixed: sysenter_flags_fixed:
orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,SIZEOF_PTREGS) orl $TS_COMPAT, THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_WORK_SYSCALL_ENTRY, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
CFI_REMEMBER_STATE CFI_REMEMBER_STATE
jnz sysenter_tracesys jnz sysenter_tracesys
cmpq $(IA32_NR_syscalls-1),%rax cmpq $(IA32_NR_syscalls-1),%rax
@ -177,10 +177,10 @@ sysenter_dispatch:
movq %rax,RAX(%rsp) movq %rax,RAX(%rsp)
DISABLE_INTERRUPTS(CLBR_NONE) DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF TRACE_IRQS_OFF
testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_ALLWORK_MASK, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz sysexit_audit jnz sysexit_audit
sysexit_from_sys_call: sysexit_from_sys_call:
andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,SIZEOF_PTREGS) andl $~TS_COMPAT,THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
/* clear IF, that popfq doesn't enable interrupts early */ /* clear IF, that popfq doesn't enable interrupts early */
andl $~0x200,EFLAGS(%rsp) andl $~0x200,EFLAGS(%rsp)
movl RIP(%rsp),%edx /* User %eip */ movl RIP(%rsp),%edx /* User %eip */
@ -225,7 +225,7 @@ sysexit_from_sys_call:
.endm .endm
.macro auditsys_exit exit .macro auditsys_exit exit
testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT), THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz ia32_ret_from_sys_call jnz ia32_ret_from_sys_call
TRACE_IRQS_ON TRACE_IRQS_ON
ENABLE_INTERRUPTS(CLBR_NONE) ENABLE_INTERRUPTS(CLBR_NONE)
@ -240,7 +240,7 @@ sysexit_from_sys_call:
movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
DISABLE_INTERRUPTS(CLBR_NONE) DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF TRACE_IRQS_OFF
testl %edi,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl %edi, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jz \exit jz \exit
CLEAR_RREGS CLEAR_RREGS
jmp int_with_check jmp int_with_check
@ -262,7 +262,7 @@ sysenter_fix_flags:
sysenter_tracesys: sysenter_tracesys:
#ifdef CONFIG_AUDITSYSCALL #ifdef CONFIG_AUDITSYSCALL
testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jz sysenter_auditsys jz sysenter_auditsys
#endif #endif
SAVE_EXTRA_REGS SAVE_EXTRA_REGS
@ -346,8 +346,8 @@ ENTRY(ia32_cstar_target)
1: movl (%r8),%r9d 1: movl (%r8),%r9d
_ASM_EXTABLE(1b,ia32_badarg) _ASM_EXTABLE(1b,ia32_badarg)
ASM_CLAC ASM_CLAC
orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,SIZEOF_PTREGS) orl $TS_COMPAT, THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_WORK_SYSCALL_ENTRY, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
CFI_REMEMBER_STATE CFI_REMEMBER_STATE
jnz cstar_tracesys jnz cstar_tracesys
cmpq $IA32_NR_syscalls-1,%rax cmpq $IA32_NR_syscalls-1,%rax
@ -364,10 +364,10 @@ cstar_dispatch:
movq %rax,RAX(%rsp) movq %rax,RAX(%rsp)
DISABLE_INTERRUPTS(CLBR_NONE) DISABLE_INTERRUPTS(CLBR_NONE)
TRACE_IRQS_OFF TRACE_IRQS_OFF
testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_ALLWORK_MASK, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz sysretl_audit jnz sysretl_audit
sysretl_from_sys_call: sysretl_from_sys_call:
andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,SIZEOF_PTREGS) andl $~TS_COMPAT, THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
RESTORE_RSI_RDI_RDX RESTORE_RSI_RDI_RDX
movl RIP(%rsp),%ecx movl RIP(%rsp),%ecx
CFI_REGISTER rip,rcx CFI_REGISTER rip,rcx
@ -402,7 +402,7 @@ sysretl_audit:
cstar_tracesys: cstar_tracesys:
#ifdef CONFIG_AUDITSYSCALL #ifdef CONFIG_AUDITSYSCALL
testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jz cstar_auditsys jz cstar_auditsys
#endif #endif
xchgl %r9d,%ebp xchgl %r9d,%ebp
@ -469,8 +469,8 @@ ENTRY(ia32_syscall)
this could be a problem. */ this could be a problem. */
ALLOC_PT_GPREGS_ON_STACK ALLOC_PT_GPREGS_ON_STACK
SAVE_C_REGS_EXCEPT_R891011 SAVE_C_REGS_EXCEPT_R891011
orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,SIZEOF_PTREGS) orl $TS_COMPAT, THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_WORK_SYSCALL_ENTRY, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz ia32_tracesys jnz ia32_tracesys
cmpq $(IA32_NR_syscalls-1),%rax cmpq $(IA32_NR_syscalls-1),%rax
ja ia32_badsys ja ia32_badsys

Просмотреть файл

@ -222,7 +222,7 @@ static inline unsigned long current_stack_pointer(void)
* currently at exactly SIZEOF_PTREGS bytes away from the top of the * currently at exactly SIZEOF_PTREGS bytes away from the top of the
* stack: * stack:
* *
* mov TI_flags+THREAD_INFO(%rsp, SIZEOF_PTREGS), %eax * mov THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS), %eax
* *
* will translate to: * will translate to:
* *
@ -230,7 +230,7 @@ static inline unsigned long current_stack_pointer(void)
* *
* which is below the current RSP by almost 16K. * which is below the current RSP by almost 16K.
*/ */
#define THREAD_INFO(reg, off) ((off)-THREAD_SIZE)(reg) #define THREAD_INFO(field, reg, off) ((field)+(off)-THREAD_SIZE)(reg)
#endif #endif

Просмотреть файл

@ -249,7 +249,7 @@ GLOBAL(system_call_after_swapgs)
pushq_cfi_reg r11 /* pt_regs->r11 */ pushq_cfi_reg r11 /* pt_regs->r11 */
sub $(6*8),%rsp /* pt_regs->bp,bx,r12-15 not saved */ sub $(6*8),%rsp /* pt_regs->bp,bx,r12-15 not saved */
testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_WORK_SYSCALL_ENTRY, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz tracesys jnz tracesys
system_call_fastpath: system_call_fastpath:
#if __SYSCALL_MASK == ~0 #if __SYSCALL_MASK == ~0
@ -267,7 +267,7 @@ system_call_fastpath:
* Has incompletely filled pt_regs, iret frame is also incomplete. * Has incompletely filled pt_regs, iret frame is also incomplete.
*/ */
ret_from_sys_call: ret_from_sys_call:
testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,SIZEOF_PTREGS) testl $_TIF_ALLWORK_MASK, THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
jnz int_ret_from_sys_call /* Go the slow path */ jnz int_ret_from_sys_call /* Go the slow path */
LOCKDEP_SYS_EXIT LOCKDEP_SYS_EXIT