kernel: mem_domain: Add to current thread should configure immediately.

when a current thread is added to a memory domain the pages/sections
must be configured immediately.
A problem occurs when we add a thread to current and then drop
down to usermode. In such a case memory domain will become active
the next time a swap occurs.

Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
Adithya Baglody 2017-12-06 16:48:28 +05:30 committed by Andrew Boie
commit 9cde20aefa
2 changed files with 6 additions and 9 deletions

View file

@ -260,18 +260,11 @@ static inline void _x86_mem_domain_pages_update(struct k_mem_domain *mem_domain,
return;
}
/* Load the required parttions of the new incoming thread */
static inline void _x86_mmu_mem_domain_load(struct k_thread *thread)
{
_x86_mem_domain_pages_update(thread->mem_domain_info.mem_domain,
X86_MEM_DOMAIN_SET_PAGES);
}
/* Load the partitions of the thread. */
void _arch_mem_domain_configure(struct k_thread *thread)
{
_x86_mmu_mem_domain_load(thread);
_x86_mem_domain_pages_update(thread->mem_domain_info.mem_domain,
X86_MEM_DOMAIN_SET_PAGES);
}
/* Destroy or reset the mmu page tables when necessary.

View file

@ -158,6 +158,10 @@ 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) {
_arch_mem_domain_configure(thread);
}
irq_unlock(key);
}