Add a new TIF flag to indicate whether the kernel needs to be careful and take additional steps to mitigate micro-architectural issues during entry into user or guest mode.
This new flag will be used by the series to determine if waiting is needed or not, during exit to user or guest mode. Tested-by: Julien Desfossez <jdesfos...@digitalocean.com> Reviewed-by: Aubrey Li <aubrey.in...@gmail.com> Signed-off-by: Joel Fernandes (Google) <j...@joelfernandes.org> --- arch/x86/include/asm/thread_info.h | 2 ++ kernel/sched/sched.h | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 93277a8d2ef0..ae4f6196e38c 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -99,6 +99,7 @@ struct thread_info { #define TIF_SPEC_FORCE_UPDATE 23 /* Force speculation MSR update in context switch */ #define TIF_FORCED_TF 24 /* true if TF in eflags artificially */ #define TIF_BLOCKSTEP 25 /* set when we want DEBUGCTLMSR_BTF */ +#define TIF_UNSAFE_RET 26 /* On return to process/guest, perform safety checks. */ #define TIF_LAZY_MMU_UPDATES 27 /* task is updating the mmu lazily */ #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */ #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */ @@ -127,6 +128,7 @@ struct thread_info { #define _TIF_SPEC_FORCE_UPDATE (1 << TIF_SPEC_FORCE_UPDATE) #define _TIF_FORCED_TF (1 << TIF_FORCED_TF) #define _TIF_BLOCKSTEP (1 << TIF_BLOCKSTEP) +#define _TIF_UNSAFE_RET (1 << TIF_UNSAFE_RET) #define _TIF_LAZY_MMU_UPDATES (1 << TIF_LAZY_MMU_UPDATES) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_ADDR32 (1 << TIF_ADDR32) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 5c258ab64052..615092cb693c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2851,3 +2851,9 @@ static inline bool is_per_cpu_kthread(struct task_struct *p) void swake_up_all_locked(struct swait_queue_head *q); void __prepare_to_swait(struct swait_queue_head *q, struct swait_queue *wait); + +#ifdef CONFIG_SCHED_CORE +#ifndef TIF_UNSAFE_RET +#define TIF_UNSAFE_RET (0) +#endif +#endif -- 2.29.2.299.gdc1121823c-goog