|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v8 52/65] x86/smpboot: track per-CPU stack pages alongside stack_base
stack_base[] holds each CPU's stack as a directmap (or image) virtual
address, and users needing the underlying MFNs translate with
virt_to_mfn(). Once stacks can come from the domain heap, so that the
sparse directmap view, which maps the xenheap, holds no alias of them,
a stack's directmap address is no longer one that every context can
use: the authoritative datum is the page, not a virtual address.
Introduce stack_pg[], filled by cpu_alloc_stack() and cleared by the
free path. It has no users yet: per-CPU stack mappings, which build
on the page rather than on a virtual address, are to come.
Assisted-by: Claude Code:claude-opus-4-8, 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):
- New: v2 took the stacks' MFNs from stack_base[] with virt_to_mfn(),
its stacks being xenheap pages.
---
xen/arch/x86/include/asm/smp.h | 3 +++
xen/arch/x86/smpboot.c | 10 ++++++++++
2 files changed, 13 insertions(+)
diff --git a/xen/arch/x86/include/asm/smp.h b/xen/arch/x86/include/asm/smp.h
index 572b39b01c..8278d0b225 100644
--- a/xen/arch/x86/include/asm/smp.h
+++ b/xen/arch/x86/include/asm/smp.h
@@ -72,6 +72,9 @@ extern cpumask_t **socket_cpumask;
extern unsigned int disabled_cpus;
extern bool unaccounted_cpus;
+/* The page underlying each CPU's stack; see stack_base[]. */
+extern struct page_info *stack_pg[NR_CPUS];
+
void *cpu_alloc_stack(unsigned int cpu);
#endif /* !__ASSEMBLER__ */
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 285215b615..d03c19f4c0 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -89,6 +89,12 @@ static enum cpu_state {
#define set_cpu_state(state) do { smp_mb(); cpu_state = (state); } while (0)
void *stack_base[NR_CPUS];
+/*
+ * The page underlying each CPU's stack. stack_base[] names the same stack,
+ * except that stack_base[0] holds the BSP's image stack (cpu0_stack) until
+ * the BSP moves to its heap stack, which stack_pg[0] names from allocation.
+ */
+struct page_info *stack_pg[NR_CPUS];
void initialize_cpu_data(unsigned int cpu)
{
@@ -1034,6 +1040,7 @@ static void cpu_smpboot_free(unsigned int cpu, bool
remove)
{
memguard_unguard_stack(stack_base[cpu]);
FREE_XENHEAP_PAGES(stack_base[cpu], STACK_ORDER);
+ stack_pg[cpu] = NULL;
}
}
}
@@ -1050,7 +1057,10 @@ void *cpu_alloc_stack(unsigned int cpu)
stack = alloc_xenheap_pages(STACK_ORDER, memflags);
if ( stack )
+ {
+ stack_pg[cpu] = virt_to_page(stack);
memguard_guard_stack(stack);
+ }
return stack;
}
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |