[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 50/65] x86/traps: refresh the BSP's rsp0 under FRED when its stack moves



With FRED, the CPU takes its stack pointers from MSRs, and nothing in
hardware reads the TSS's rsp0.  Xen keeps rsp0 naming the stack the CPU
runs on all the same, for show_stack_overflow() to print: init_fred_tss()
sets it for the BSP on cpu0_stack, and for each CPU as it starts or
resumes.

bsp_traps_reinit() runs again when the BSP moves to its heap stack at
the end of __start_xen(), but with FRED it currently only calls
init_fred() (updating the FRED MSRs), not init_fred_tss(); meaning
rsp0 is still pointing at the old value of the stack.  Currently this
just means that a double-fault prints the wrong value for one address;
but later we'll use rsp0 to sanity check the stack value.

Call init_fred_tss() again as well as init_fred().

Fixes: bbfb30f649fc ("x86/traps: Enable FRED when requested")
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
With this change, there's a 1-1 correspondence between init_fred() and
init_fred_tss() calls; is it worth just moving the TSS stuff into
init_fred()?

Changes in v8:
- New in this version

Changes since previously posted version ("x86: adventures in Address Space 
Isolation", v2):
- New: v2 predates FRED support.
- Split out of "x86/mm: switch to a per-CPU mapped stack when using
  ASI" (now "x86/mm: run every CPU on a per-CPU stack address"), as
  reworked since v2 (not posted).
- Call the entire init_fred_tss() instead of open-coding the one thing
  we know needs updating (rsp0)
---
 xen/arch/x86/traps-setup.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/x86/traps-setup.c b/xen/arch/x86/traps-setup.c
index 3fe79ff0d0..db2cb75b7b 100644
--- a/xen/arch/x86/traps-setup.c
+++ b/xen/arch/x86/traps-setup.c
@@ -441,7 +441,10 @@ void __init traps_init(void)
 void __init bsp_traps_reinit(void)
 {
     if ( opt_fred )
+    {
         init_fred();
+        init_fred_tss();
+    }
     else
         load_system_tables();
 
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.