|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v7 41/50] x86/smp: move smp_send_stop()'s AP-stop flag off the stack
Per-CPU stack mappings, to come as part of Address Space Isolation,
give some contexts page-tables which map only the stack of the CPU
they run on. A CPU in such a context cannot reach another CPU's
stack, so an IPI handler cannot dereference a pointer into the
initiating CPU's stack. Payloads handed to other CPUs via
smp_call_function() must live somewhere globally reachable.
smp_send_stop() hands the address of a stack-local bool to the other
CPUs via an asynchronous (@wait == 0) smp_call_function(). The
callees then poll that bool from stop_this_cpu(), waiting for the
initiating CPU to set it - which it does further down the same
function, once the interrupt controllers have been disabled, before
waiting for the APs to go offline. The initiator is executing
smp_send_stop() the whole time the APs poll, so the frame stays alive
and the current code is correct; but with per-CPU mapped stacks the
flag would no longer be reachable and the poll would fault.
Make the flag a function-scope static, re-initialised at function
entry. The reset must remain an explicit statement rather than become
an initialiser: on sequential reuse a stale "true" would release the
APs before the interrupt controllers are quiesced. The signalling
protocol is otherwise unchanged. Concurrent invocations of
smp_send_stop() were not usefully supported before (the function
disables interrupt controllers system-wide); a static flag does not
change that.
Groundwork for per-CPU stack mappings, which take away a CPU's access
to other CPUs' stacks: besides get_cpu_current(), cross-CPU rendezvous
and call-function payloads are what reads another CPU's stack at run
time.
Assisted-by: Claude Code:claude-opus-4-8, Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v7:
- New in this version.
---
xen/arch/x86/smp.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c
index ae4e5a66d7..8a26c001e0 100644
--- a/xen/arch/x86/smp.c
+++ b/xen/arch/x86/smp.c
@@ -360,7 +360,15 @@ static void noreturn cf_check stop_this_cpu(void *dummy)
void smp_send_stop(void)
{
unsigned int cpu = smp_processor_id();
- bool stop_aps = false;
+ /*
+ * Polled by the APs from the IPI handler, so not on the stack, which
+ * other CPUs need not be able to reach. Reset on every call, not by an
+ * initialiser, so that a stale "true" cannot release the APs before the
+ * interrupt controllers below are quiesced.
+ */
+ static bool stop_aps;
+
+ stop_aps = false;
/*
* Perform AP offlining and disabling of interrupt controllers with all
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |