mirror of
https://github.com/torvalds/linux.git
synced 2026-11-24 15:33:28 +00:00
Ensure that a core serializing instruction is issued before returning to user-mode. x86 implements return to user-space through sysexit, sysrel, and sysretq, which are not core serializing. Signed-off-by: Mathieu Desnoyers <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: Andrea Parri <[email protected]> Cc: Andrew Hunter <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Avi Kivity <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Boqun Feng <[email protected]> Cc: Dave Watson <[email protected]> Cc: David Sehr <[email protected]> Cc: Greg Hackmann <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Maged Michael <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Paul E. McKenney <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Russell King <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
29 lines
744 B
C
29 lines
744 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_X86_SYNC_CORE_H
|
|
#define _ASM_X86_SYNC_CORE_H
|
|
|
|
#include <linux/preempt.h>
|
|
#include <asm/processor.h>
|
|
#include <asm/cpufeature.h>
|
|
|
|
/*
|
|
* Ensure that a core serializing instruction is issued before returning
|
|
* to user-mode. x86 implements return to user-space through sysexit,
|
|
* sysrel, and sysretq, which are not core serializing.
|
|
*/
|
|
static inline void sync_core_before_usermode(void)
|
|
{
|
|
/* With PTI, we unconditionally serialize before running user code. */
|
|
if (static_cpu_has(X86_FEATURE_PTI))
|
|
return;
|
|
/*
|
|
* Return from interrupt and NMI is done through iret, which is core
|
|
* serializing.
|
|
*/
|
|
if (in_irq() || in_nmi())
|
|
return;
|
|
sync_core();
|
|
}
|
|
|
|
#endif /* _ASM_X86_SYNC_CORE_H */
|