|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v8 64/65] x86/traps: name the CPU whose stack a fatal page fault hit
With per-CPU stacks, each pCPU runs on its stack at PCPU_STACK_VIRT(),
and the page-tables of a cpu_stack vCPU map there the stack of the pCPU
it runs on and no other. Code which reaches into another pCPU's stack
while such page-tables are loaded takes a fatal page fault, as does
code touching a part of its own stack which the page-tables leave
unmapped. The console then shows an address in the per-CPU stack
sub-area, which says whose stack it is only to someone who works it
out from the layout.
When a fatal page fault in Xen hits the per-CPU stack sub-area, add a
line to the panic message naming the CPU whose stack the address lies
in, the page of that stack, and whether it is this CPU's or another's;
or saying that no CPU's stack is there. Nothing else changes, and
nothing is added without per-CPU stacks. The panic, with the two dumps
before it, moves into fatal_page_fault(), not inlined, so that the
line's buffer is not in handle_PF()'s stack frame.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v8:
- New in this version.
---
xen/arch/x86/traps.c | 43 +++++++++++++++++++++++++++++++++++++------
1 file changed, 37 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 6d3c16bebb..042f820d8e 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1723,6 +1723,42 @@ static int fixup_page_fault(unsigned long addr, struct
cpu_user_regs *regs)
return 0;
}
+/*
+ * A fatal page fault in Xen. With per-CPU stacks, also name the CPU whose
+ * stack @addr lies in, if it lies in the per-CPU stack sub-area. Not
+ * inlined, so that the line's buffer is not in handle_PF()'s frame.
+ */
+static void noinline noreturn fatal_page_fault(
+ const struct cpu_user_regs *regs, unsigned int error_code,
+ unsigned long addr)
+{
+ unsigned long off = addr - PCPU_STACK_VIRT_START;
+ unsigned int cpu = off >> (STACK_ORDER + PAGE_SHIFT);
+ char stack[80] = "";
+
+ if ( cpu_stack_enabled &&
+ off < PCPU_STACK_VIRT_END - PCPU_STACK_VIRT_START )
+ {
+ if ( cpu < nr_cpu_ids && stack_pg[cpu] )
+ snprintf(stack, sizeof(stack),
+ "In CPU%u's stack, page %lu of %u: %s CPU's\n", cpu,
+ PFN_DOWN(off) & ((1UL << STACK_ORDER) - 1),
+ 1U << STACK_ORDER,
+ cpu == smp_processor_id() ? "this" : "another");
+ else
+ snprintf(stack, sizeof(stack),
+ "In the per-CPU stack area, at no CPU's stack\n");
+ }
+
+ show_execution_state(regs);
+ show_page_walk(addr);
+ panic("FATAL PAGE FAULT\n"
+ "[error_code=%04x]\n"
+ "Faulting linear address: %p\n"
+ "%s",
+ error_code, _p(addr), stack);
+}
+
static void handle_PF(struct cpu_user_regs *regs, unsigned long addr /* cr2 */)
{
unsigned int error_code;
@@ -1776,12 +1812,7 @@ static void handle_PF(struct cpu_user_regs *regs,
unsigned long addr /* cr2 */)
}
fatal:
- show_execution_state(regs);
- show_page_walk(addr);
- panic("FATAL PAGE FAULT\n"
- "[error_code=%04x]\n"
- "Faulting linear address: %p\n",
- error_code, _p(addr));
+ fatal_page_fault(regs, error_code, addr);
}
pv_inject_page_fault(regs->error_code, addr);
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |