• Peter Zijlstra's avatar
    sched/x86: Save [ER]FLAGS on context switch · 0a62aaee
    Peter Zijlstra authored
    commit 6690e86b upstream.
    
    Effectively reverts commit:
    
      2c7577a7 ("sched/x86_64: Don't save flags on context switch")
    
    Specifically because SMAP uses FLAGS.AC which invalidates the claim
    that the kernel has clean flags.
    
    In particular; while preemption from interrupt return is fine (the
    IRET frame on the exception stack contains FLAGS) it breaks any code
    that does synchonous scheduling, including preempt_enable().
    
    This has become a significant issue ever since commit:
    
      5b24a7a2 ("Add 'unsafe' user access functions for batched accesses")
    
    provided for means of having 'normal' C code between STAC / CLAC,
    exposing the FLAGS.AC state. So far this hasn't led to trouble,
    however fix it before it comes apart.
    Reported-by: default avatarJulien Thierry <julien.thierry@arm.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: default avatarAndy Lutomirski <luto@amacapital.net>
    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>
    Cc: stable@kernel.org
    Fixes: 5b24a7a2 ("Add 'unsafe' user access functions for batched accesses")
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0a62aaee
entry_64.S 46.7 KB