userspace: make mem domain lock non-static Strictly speaking, any access to a mem domain or its containing partitions should be serialized on this lock. Architecture code may need to grab this lock if it is using this data during, for example, context switches, especially if they support SMP as locking interrupts is not enough. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
diff --git a/kernel/include/kernel_internal.h b/kernel/include/kernel_internal.h index 19b8a5a..277cea7 100644 --- a/kernel/include/kernel_internal.h +++ b/kernel/include/kernel_internal.h
@@ -132,6 +132,18 @@ /* Memory domain teardown hook, called from z_thread_single_abort() */ void z_mem_domain_exit_thread(struct k_thread *thread); + +/* This spinlock: + * + * - Protects the full set of active k_mem_domain objects and their contents + * - Serializes calls to arch_mem_domain_* APIs + * + * If architecture code needs to access k_mem_domain structures or the + * partitions they contain at any other point, this spinlock should be held. + * Uniprocessor systems can get away with just locking interrupts but this is + * not recommended. + */ +extern struct k_spinlock z_mem_domain_lock; #endif /* CONFIG_USERSPACE */ #ifdef CONFIG_GDBSTUB