|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v8 51/65] x86/traps: have show_stack_overflow() expect the stack the TSS names
show_stack_overflow() says when a double fault's stack pointer is off
the CPU's stack, by comparing the stack it is on with stack_base[],
the address the stack was allocated at. Eventually we plan to have
stack_base[] be zero under some conditions.
The TSS's rsp0 names the stack the CPU was set up to run on:
load_system_tables() takes it from the running stack pointer, as
init_fred_tss() does with FRED, and the report prints it already.
Compare with that instead. Once smp_prepare_cpus() has recorded the
BSP's stack, the two name the same stack; a later change runs CPUs on
their stacks at an address other than the one they were allocated at.
Before smp_prepare_cpus(), stack_base[0] is NULL, so the check as it
stands reports any double fault on the BSP as off its stack; rsp0
names the BSP's stack from traps_init() on.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v8:
- New in this version.
Changes since previously posted version ("x86: adventures in Address Space
Isolation", v2):
- 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"), where
PCPU_STACK_VIRT() was expected with per-CPU stacks in use only; rsp0
is now expected in all cases.
---
xen/arch/x86/traps.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 256f240546..6ecbe171fc 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -856,10 +856,13 @@ static void show_stack_overflow(unsigned int cpu, const
struct cpu_user_regs *re
unsigned long esp = regs->rsp;
unsigned long curr_stack_base = esp & ~(STACK_SIZE - 1);
unsigned long esp_top, esp_bottom;
+ /* The stack this CPU runs on, as its TSS names it. */
+ const void *stack =
+ _p(per_cpu(tss_page, cpu).tss.rsp0 & ~(STACK_SIZE - 1));
- if ( _p(curr_stack_base) != stack_base[cpu] )
+ if ( _p(curr_stack_base) != stack )
printk("Current stack base %p differs from expected %p\n",
- _p(curr_stack_base), stack_base[cpu]);
+ _p(curr_stack_base), stack);
esp_bottom = (esp | (STACK_SIZE - 1)) + 1;
esp_top = esp_bottom - PRIMARY_STACK_SIZE;
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |