arm: fix memory domain arch_ API implementations

All of these should be no-ops for the following reasons:

1. User threads cannot configure memory domains, only supervisor
   threads.
2. The scope of memory domains is user thread memory access,
   supervisor threads can access the entire memory map.

Hence it's never required to reprogram the MPU when a memory domain
API is called.

Fixes a problem where an assertion would fail if a supervisor thread
added a partition and then immediately removes it, and possibly
other problems.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-08-25 16:16:40 -07:00 committed by Anas Nashif
commit 2222fa1426

View file

@ -325,62 +325,18 @@ int arch_mem_domain_max_partitions_get(void)
void arch_mem_domain_thread_add(struct k_thread *thread)
{
if (_current != thread) {
return;
}
/* Request to configure memory domain for a thread.
* This triggers re-programming of the entire dynamic
* memory map.
*/
z_arm_configure_dynamic_mpu_regions(thread);
/* No-op on this architecture */
}
void arch_mem_domain_destroy(struct k_mem_domain *domain)
{
/* This function will reset the access permission configuration
* of the active partitions of the memory domain.
*/
int i;
struct k_mem_partition partition;
if (_current->mem_domain_info.mem_domain != domain) {
return;
}
/* Partitions belonging to the memory domain will be reset
* to default (Privileged RW, Unprivileged NA) permissions.
*/
k_mem_partition_attr_t reset_attr = K_MEM_PARTITION_P_RW_U_NA;
for (i = 0; i < CONFIG_MAX_DOMAIN_PARTITIONS; i++) {
partition = domain->partitions[i];
if (partition.size == 0U) {
/* Zero size indicates a non-existing
* memory partition.
*/
continue;
}
arm_core_mpu_mem_partition_config_update(&partition,
&reset_attr);
}
/* No-op on this architecture */
}
void arch_mem_domain_partition_remove(struct k_mem_domain *domain,
uint32_t partition_id)
{
/* Request to remove a partition from a memory domain.
* This resets the access permissions of the partition
* to default (Privileged RW, Unprivileged NA).
*/
k_mem_partition_attr_t reset_attr = K_MEM_PARTITION_P_RW_U_NA;
if (_current->mem_domain_info.mem_domain != domain) {
return;
}
arm_core_mpu_mem_partition_config_update(
&domain->partitions[partition_id], &reset_attr);
/* No-op on this architecture */
}
void arch_mem_domain_partition_add(struct k_mem_domain *domain,
@ -391,11 +347,7 @@ void arch_mem_domain_partition_add(struct k_mem_domain *domain,
void arch_mem_domain_thread_remove(struct k_thread *thread)
{
if (_current != thread) {
return;
}
arch_mem_domain_destroy(thread->mem_domain_info.mem_domain);
/* No-op on this architecture */
}
int arch_buffer_validate(void *addr, size_t size, int write)