userspace: adjust arch memory domain interface
The current API was assuming too much, in that it expected that arch-specific memory domain configuration is only maintained in some global area, and updates to domains that are not currently active have no effect. This was true when all memory domain state was tracked in page tables or MPU registers, but no longer works when arch-specific memory management information is stored in thread-specific areas. This is needed for: #13441 #13074 #15135 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
fddd550824
commit
8915e41b7b
7 changed files with 131 additions and 67 deletions
|
@ -129,12 +129,7 @@ void k_mem_domain_destroy(struct k_mem_domain *domain)
|
|||
|
||||
key = k_spin_lock(&lock);
|
||||
|
||||
/* Handle architecture-specific destroy
|
||||
* only if it is the current thread.
|
||||
*/
|
||||
if (_current->mem_domain_info.mem_domain == domain) {
|
||||
z_arch_mem_domain_destroy(domain);
|
||||
}
|
||||
z_arch_mem_domain_destroy(domain);
|
||||
|
||||
SYS_DLIST_FOR_EACH_NODE_SAFE(&domain->mem_domain_q, node, next_node) {
|
||||
struct k_thread *thread =
|
||||
|
@ -181,13 +176,7 @@ void k_mem_domain_add_partition(struct k_mem_domain *domain,
|
|||
|
||||
domain->num_partitions++;
|
||||
|
||||
/* Handle architecture-specific add
|
||||
* only if it is the current thread.
|
||||
*/
|
||||
if (_current->mem_domain_info.mem_domain == domain) {
|
||||
z_arch_mem_domain_partition_add(domain, p_idx);
|
||||
}
|
||||
|
||||
z_arch_mem_domain_partition_add(domain, p_idx);
|
||||
k_spin_unlock(&lock, key);
|
||||
}
|
||||
|
||||
|
@ -213,12 +202,7 @@ void k_mem_domain_remove_partition(struct k_mem_domain *domain,
|
|||
/* Assert if not found */
|
||||
__ASSERT(p_idx < max_partitions, "no matching partition found");
|
||||
|
||||
/* Handle architecture-specific remove
|
||||
* only if it is the current thread.
|
||||
*/
|
||||
if (_current->mem_domain_info.mem_domain == domain) {
|
||||
z_arch_mem_domain_partition_remove(domain, p_idx);
|
||||
}
|
||||
z_arch_mem_domain_partition_remove(domain, p_idx);
|
||||
|
||||
/* A zero-sized partition denotes it's a free partition */
|
||||
domain->partitions[p_idx].size = 0U;
|
||||
|
@ -243,9 +227,7 @@ void k_mem_domain_add_thread(struct k_mem_domain *domain, k_tid_t thread)
|
|||
&thread->mem_domain_info.mem_domain_q_node);
|
||||
thread->mem_domain_info.mem_domain = domain;
|
||||
|
||||
if (_current == thread) {
|
||||
z_arch_mem_domain_configure(thread);
|
||||
}
|
||||
z_arch_mem_domain_thread_add(thread);
|
||||
|
||||
k_spin_unlock(&lock, key);
|
||||
}
|
||||
|
@ -258,13 +240,10 @@ void k_mem_domain_remove_thread(k_tid_t thread)
|
|||
__ASSERT(thread->mem_domain_info.mem_domain != NULL, "mem domain set");
|
||||
|
||||
key = k_spin_lock(&lock);
|
||||
if (_current == thread) {
|
||||
z_arch_mem_domain_destroy(thread->mem_domain_info.mem_domain);
|
||||
}
|
||||
z_arch_mem_domain_thread_remove(thread);
|
||||
|
||||
sys_dlist_remove(&thread->mem_domain_info.mem_domain_q_node);
|
||||
thread->mem_domain_info.mem_domain = NULL;
|
||||
|
||||
k_spin_unlock(&lock, key);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue