mirror of
https://github.com/torvalds/linux.git
synced 2026-05-05 15:02:40 -04:00
x86/entry: Set FRED RSP0 on return to userspace instead of context switch
The FRED RSP0 MSR points to the top of the kernel stack for user level event delivery. As this is the task stack it needs to be updated when a task is scheduled in. The update is done at context switch. That means it's also done when switching to kernel threads, which is pointless as those never go out to user space. For KVM threads this means there are two writes to FRED_RSP0 as KVM has to switch to the guest value before VMENTER. Defer the update to the exit to user space path and cache the per CPU FRED_RSP0 value, so redundant writes can be avoided. Provide fred_sync_rsp0() for KVM to keep the cache in sync with the actual MSR value after returning from guest to host mode. [ tglx: Massage change log ] Suggested-by: Sean Christopherson <seanjc@google.com> Suggested-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Xin Li (Intel) <xin@zytor.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20240822073906.2176342-4-xin@zytor.com
This commit is contained in:
committed by
Thomas Gleixner
parent
efe508816d
commit
fe85ee3919
@@ -70,12 +70,9 @@ static inline void update_task_stack(struct task_struct *task)
|
||||
#ifdef CONFIG_X86_32
|
||||
this_cpu_write(cpu_tss_rw.x86_tss.sp1, task->thread.sp0);
|
||||
#else
|
||||
if (cpu_feature_enabled(X86_FEATURE_FRED)) {
|
||||
wrmsrns(MSR_IA32_FRED_RSP0, (unsigned long)task_stack_page(task) + THREAD_SIZE);
|
||||
} else if (cpu_feature_enabled(X86_FEATURE_XENPV)) {
|
||||
if (!cpu_feature_enabled(X86_FEATURE_FRED) && cpu_feature_enabled(X86_FEATURE_XENPV))
|
||||
/* Xen PV enters the kernel on the thread stack. */
|
||||
load_sp0(task_top_of_stack(task));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user