Commit 00f71b0d authored by Andrew Boie's avatar Andrew Boie Committed by Anas Nashif
Browse files

kernel: add CONFIG_ARCH_MEM_DOMAIN_SYNCHRONOUS_API



Saves us a few bytes of program text on arches that don't need
these implemented, currently all uniprocessor MPU-based systems.

Signed-off-by: default avatarAndrew Boie <andrew.p.boie@intel.com>
parent d11e3c34
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ config X86
	select ARCH_HAS_CUSTOM_SWAP_TO_MAIN if !X86_64
	select ARCH_SUPPORTS_COREDUMP
	select CPU_HAS_MMU
	select ARCH_MEM_DOMAIN_SYNCHRONOUS_API if USERSPACE
	help
	  x86 architecture

+0 −36
Original line number Diff line number Diff line
@@ -32,42 +32,6 @@ int arch_mem_domain_max_partitions_get(void)
	return arc_core_mpu_get_max_domain_partition_regions();
}

/*
 * Reset MPU region for a single memory partition
 */
void arch_mem_domain_partition_remove(struct k_mem_domain *domain,
				      uint32_t partition_id)
{
	/* No-op on this architecture */
}

/*
 * Configure MPU memory domain
 */
void arch_mem_domain_thread_add(struct k_thread *thread)
{
	/* No-op on this architecture */
}

/*
 * Destroy MPU regions for the mem domain
 */
void arch_mem_domain_destroy(struct k_mem_domain *domain)
{
	/* No-op on this architecture */
}

void arch_mem_domain_partition_add(struct k_mem_domain *domain,
				   uint32_t partition_id)
{
	/* No-op on this architecture */
}

void arch_mem_domain_thread_remove(struct k_thread *thread)
{
	/* No-op on this architecture */
}

/*
 * Validate the given buffer is user accessible or not
 */
+0 −27
Original line number Diff line number Diff line
@@ -323,33 +323,6 @@ int arch_mem_domain_max_partitions_get(void)
	return ARM_CORE_MPU_MAX_DOMAIN_PARTITIONS_GET(available_regions);
}

void arch_mem_domain_thread_add(struct k_thread *thread)
{
	/* No-op on this architecture */
}

void arch_mem_domain_destroy(struct k_mem_domain *domain)
{
	/* No-op on this architecture */
}

void arch_mem_domain_partition_remove(struct k_mem_domain *domain,
				      uint32_t partition_id)
{
	/* No-op on this architecture */
}

void arch_mem_domain_partition_add(struct k_mem_domain *domain,
				   uint32_t partition_id)
{
	/* No-op on this architecture */
}

void arch_mem_domain_thread_remove(struct k_thread *thread)
{
	/* No-op on this architecture */
}

int arch_buffer_validate(void *addr, size_t size, int write)
{
	return arm_core_mpu_buffer_validate(addr, size, write);
+2 −0
Original line number Diff line number Diff line
@@ -540,6 +540,7 @@ int arch_mem_domain_max_partitions_get(void);
int arch_mem_domain_init(struct k_mem_domain *domain);
#endif /* CONFIG_ARCH_MEM_DOMAIN_DATA */

#ifdef CONFIG_ARCH_MEM_DOMAIN_SYNCHRONOUS_API
/**
 * @brief Add a thread to a memory domain (arch-specific)
 *
@@ -606,6 +607,7 @@ void arch_mem_domain_partition_add(struct k_mem_domain *domain,
 * @param domain The memory domain structure which needs to be deleted.
 */
void arch_mem_domain_destroy(struct k_mem_domain *domain);
#endif /* CONFIG_ARCH_MEM_DOMAIN_SYNCHRONOUS_API */

/**
 * @brief Check memory region permissions
+29 −0
Original line number Diff line number Diff line
@@ -709,6 +709,35 @@ config ARCH_MEM_DOMAIN_DATA

	  Typical uses might be a set of page tables for that memory domain.

config ARCH_MEM_DOMAIN_SYNCHRONOUS_API
	bool
	depends on USERSPACE
	help
	  This hidden option is selected by the target architecture if
	  modifying a memory domain's partitions at runtime, or changing
	  a memory domain's thread membership requires synchronous calls
	  into the architecture layer.

	  If enabled, the architecture layer must implement the following
	  APIs:

	  arch_mem_domain_thread_add
	  arch_mem_domain_thread_remove
	  arch_mem_domain_partition_remove
	  arch_mem_domain_partition_add
	  arch_mem_domain_destroy

	  It's important to note that although supervisor threads can be
	  members of memory domains, they have no implications on supervisor
	  thread access to memory. Memory domain APIs may only be invoked from
	  supervisor mode.

	  For these reasons, on uniprocessor systems unless memory access
	  policy is managed in separate software constructions like page
	  tables, these APIs don't need to be implemented as the underlying
	  memory management hardware will be reprogrammed on context switch
	  anyway.

menu "SMP Options"

config USE_SWITCH
Loading