summaryrefslogtreecommitdiff
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorXin Li (Intel) <xin@zytor.com>2024-08-22 00:39:06 -0700
committerThomas Gleixner <tglx@linutronix.de>2024-08-25 19:23:00 +0200
commitfe85ee391966c4cf3bfe1c405314e894c951f521 (patch)
treec8d6d5e9d3278862419023c0da36ad66d09ef1df /arch/x86/kernel
parentefe508816d2caf83536ff2f308e09043380fb2b7 (diff)
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
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/fred.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kernel/fred.c b/arch/x86/kernel/fred.c
index 266c69e332a4..8d32c3f48abc 100644
--- a/arch/x86/kernel/fred.c
+++ b/arch/x86/kernel/fred.c
@@ -21,6 +21,9 @@
#define FRED_STKLVL(vector, lvl) ((lvl) << (2 * (vector)))
+DEFINE_PER_CPU(unsigned long, fred_rsp0);
+EXPORT_PER_CPU_SYMBOL(fred_rsp0);
+
void cpu_init_fred_exceptions(void)
{
/* When FRED is enabled by default, remove this log message */