Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/x86_64: Don't save flags on context switch

Now that we have objtool validating AC=1 state for all x86_64 code,
we can once again guarantee clean flags on schedule.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Peter Zijlstra and committed by
Ingo Molnar
64604d54 2f0f9e9a

+1 -10
-2
arch/x86/entry/entry_64.S
··· 291 291 pushq %r13 292 292 pushq %r14 293 293 pushq %r15 294 - pushfq 295 294 296 295 /* switch stack */ 297 296 movq %rsp, TASK_threadsp(%rdi) ··· 313 314 #endif 314 315 315 316 /* restore callee-saved registers */ 316 - popfq 317 317 popq %r15 318 318 popq %r14 319 319 popq %r13
+1 -1
arch/x86/include/asm/switch_to.h
··· 40 40 * order of the fields must match the code in __switch_to_asm(). 41 41 */ 42 42 struct inactive_task_frame { 43 - unsigned long flags; 44 43 #ifdef CONFIG_X86_64 45 44 unsigned long r15; 46 45 unsigned long r14; 47 46 unsigned long r13; 48 47 unsigned long r12; 49 48 #else 49 + unsigned long flags; 50 50 unsigned long si; 51 51 unsigned long di; 52 52 #endif
-7
arch/x86/kernel/process_64.c
··· 393 393 fork_frame = container_of(childregs, struct fork_frame, regs); 394 394 frame = &fork_frame->frame; 395 395 396 - /* 397 - * For a new task use the RESET flags value since there is no before. 398 - * All the status flags are zero; DF and all the system flags must also 399 - * be 0, specifically IF must be 0 because we context switch to the new 400 - * task with interrupts disabled. 401 - */ 402 - frame->flags = X86_EFLAGS_FIXED; 403 396 frame->bp = 0; 404 397 frame->ret_addr = (unsigned long) ret_from_fork; 405 398 p->thread.sp = (unsigned long) fork_frame;