x86/asm: Move 'status' from thread_struct to thread_info
The TS_COMPAT bit is very hot and is accessed from code paths that mostly also touch thread_info::flags. Move it into struct thread_info to improve cache locality. The only reason it was in thread_struct is that there was a brief period during which arch-specific fields were not allowed in struct thread_info. Linus suggested further changing: ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED); to: if (unlikely(ti->status & (TS_COMPAT|TS_I386_REGS_POKED))) ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED); on the theory that frequently dirtying the cacheline even in pure 64-bit code that never needs to modify status hurts performance. That could be a reasonable followup patch, but I suspect it matters less on top of this patch. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Ingo Molnar <mingo@kernel.org> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Kernel Hardening <kernel-hardening@lists.openwall.com> Link: https://lkml.kernel.org/r/03148bcc1b217100e6e8ecf6a5468c45cf4304b6.1517164461.git.luto@kernel.org
This commit is contained in:

committed by
Thomas Gleixner

parent
d1f7732009
commit
37a8f7c383
@@ -557,7 +557,7 @@ static void __set_personality_x32(void)
|
||||
* Pretend to come from a x32 execve.
|
||||
*/
|
||||
task_pt_regs(current)->orig_ax = __NR_x32_execve | __X32_SYSCALL_BIT;
|
||||
current->thread.status &= ~TS_COMPAT;
|
||||
current_thread_info()->status &= ~TS_COMPAT;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ static void __set_personality_ia32(void)
|
||||
current->personality |= force_personality32;
|
||||
/* Prepare the first "return" to user space */
|
||||
task_pt_regs(current)->orig_ax = __NR_ia32_execve;
|
||||
current->thread.status |= TS_COMPAT;
|
||||
current_thread_info()->status |= TS_COMPAT;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user