Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Macros | |
#define | PARTS_USED 2 |
#define | NUM_RW_PARTS (CONFIG_MAX_DOMAIN_PARTITIONS - PARTS_USED) |
#define | PRIO K_PRIO_PREEMPT(1) |
Show that moving a thread from one domain to another works. More... | |
Functions | |
static | K_THREAD_STACK_DEFINE (child_stack, 512+CONFIG_TEST_EXTRA_STACKSIZE) |
K_MEM_PARTITION_DEFINE (ro_part, ro_buf, sizeof(ro_buf), K_MEM_PARTITION_P_RO_U_RO) | |
K_MEM_PARTITION_DEFINE (overlap_part, ro_buf, sizeof(ro_buf), K_MEM_PARTITION_P_RW_U_RW) | |
static void | zzz_entry (void *p1, void *p2, void *p3) |
static | K_THREAD_DEFINE (zzz_thread, 256+CONFIG_TEST_EXTRA_STACKSIZE, zzz_entry, NULL, NULL, NULL, 0, 0, 0) |
void | test_mem_domain_setup (void) |
static void | spawn_child_thread (k_thread_entry_t entry, struct k_mem_domain *domain, bool should_fault) |
static void | rw_part_access (void *p1, void *p2, void *p3) |
static void | ro_part_access (void *p1, void *p2, void *p3) |
static void | ro_write_entry (void *p1, void *p2, void *p3) |
void | test_mem_domain_valid_access (void) |
Check if the mem_domain is configured and accessible for userspace. More... | |
void | test_mem_domain_invalid_access (void) |
Show that a user thread can't touch partitions not in its domain. More... | |
void | test_mem_domain_no_writes_to_ro (void) |
Show that a read-only partition can't be written to. More... | |
void | test_mem_domain_remove_add_partition (void) |
Show that adding/removing partitions works. More... | |
K_MEM_PARTITION_DEFINE (no_access_part, no_access_buf, sizeof(no_access_buf), K_MEM_PARTITION_P_RW_U_RW) | |
static void | mem_domain_init_entry (void *p1, void *p2, void *p3) |
static void | mem_domain_add_partition_entry (void *p1, void *p2, void *p3) |
static void | mem_domain_remove_partition_entry (void *p1, void *p2, void *p3) |
static void | mem_domain_add_thread_entry (void *p1, void *p2, void *p3) |
void | test_mem_domain_api_supervisor_only (void) |
Test access memory domain APIs allowed to supervisor threads only. More... | |
void | test_mem_domain_boot_threads (void) |
Show that boot threads belong to the default memory domain. More... | |
static | K_SEM_DEFINE (spin_sem, 0, 1) |
static void | spin_entry (void *p1, void *p2, void *p3) |
void | test_mem_domain_migration (void) |
void | test_mem_part_overlap (void) |
Test system assert when new partition overlaps the existing partition. More... | |
void | post_fatal_error_handler (unsigned int reason, const z_arch_esf_t *pEsf) |
K_MEM_PARTITION_DEFINE (exceed_part, exceed_buf, sizeof(exceed_buf), K_MEM_PARTITION_P_RW_U_RW) | |
void | test_mem_part_assert_add_overmax (void) |
Test system assert when adding memory partitions more than possible. More... | |
void | test_mem_domain_remove_part_fail (void) |
void | test_mem_domain_init_fail (void) |
Test error case of initializing memory domain fail. More... | |
Variables | |
static struct k_thread | child_thread |
static struct k_mem_domain | test_domain |
ZTEST_BMEM int | num_rw_parts |
static volatile uint8_t | rw_bufs [(CONFIG_MAX_DOMAIN_PARTITIONS - 2)][MEM_REGION_ALLOC] |
static struct k_mem_partition | rw_parts [(CONFIG_MAX_DOMAIN_PARTITIONS - 2)] |
static volatile uint8_t | ro_buf [MEM_REGION_ALLOC] |
static struct k_mem_domain | no_access_domain |
static volatile uint8_t | no_access_buf [MEM_REGION_ALLOC] |
static ZTEST_BMEM volatile bool | spin_done |
static ZTEST_BMEM bool | need_recover_spinlock |
static struct k_mem_domain | test_domain_fail |
static volatile uint8_t | exceed_buf [MEM_REGION_ALLOC] |
#define NUM_RW_PARTS (CONFIG_MAX_DOMAIN_PARTITIONS - PARTS_USED) |
#define PARTS_USED 2 |
#define PRIO K_PRIO_PREEMPT(1) |
Show that moving a thread from one domain to another works.
Start a thread and have it spin. Then while it is spinning, show that adding it to another memory domain doesn't cause any faults.
This test is of particular importance on SMP systems where the child thread is spinning on a different CPU concurrently with the migration operation.
K_MEM_PARTITION_DEFINE | ( | exceed_part | , |
exceed_buf | , | ||
sizeof(exceed_buf) | , | ||
K_MEM_PARTITION_P_RW_U_RW | |||
) |
K_MEM_PARTITION_DEFINE | ( | no_access_part | , |
no_access_buf | , | ||
sizeof(no_access_buf) | , | ||
K_MEM_PARTITION_P_RW_U_RW | |||
) |
K_MEM_PARTITION_DEFINE | ( | overlap_part | , |
ro_buf | , | ||
sizeof(ro_buf) | , | ||
K_MEM_PARTITION_P_RW_U_RW | |||
) |
K_MEM_PARTITION_DEFINE | ( | ro_part | , |
ro_buf | , | ||
sizeof(ro_buf) | , | ||
K_MEM_PARTITION_P_RO_U_RO | |||
) |
|
static |
|
static |
|
static |
|
static |
Test access memory domain APIs allowed to supervisor threads only.
Show that invoking any of the memory domain APIs from user mode leads to a fault.
Show that boot threads belong to the default memory domain.
Static threads and the main thread are supposed to start as members of the default memory domain. Prove this is the case by examining the memory domain membership of z_main_thread and a static thread.
Test error case of initializing memory domain fail.
Try to initialize a domain with invalid partition, then see if an expected fatal error happens. And while the fatal error happened, the memory domain spinlock is held, we need to release them to make other follow test case.
Show that a user thread can't touch partitions not in its domain.
Show that adding/removing partitions works.
Show that removing a partition doesn't affect access to other partitions. Show that removing a partition generates a fault if its data is accessed. Show that adding a partition back restores access from a user thread.
Check if the mem_domain is configured and accessible for userspace.
Join a memory domain with a read-write memory partition and a read-only partition within it, and show that the data in the partition is accessible as expected by the permissions provided.
Test system assert when adding memory partitions more than possible.
Test system assert when new partition overlaps the existing partition.
Test Objective:
Testing techniques:
Prerequisite Conditions:
Input Specifications:
Test Procedure:
Expected Test Result:
Pass/Fail Criteria:
Assumptions and Constraints:
|
static |
|
static |
|
static |
|
static |
|
static |
ZTEST_BMEM int num_rw_parts |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |