userspace: deprecate k_mem_domain_remove_thread()
This is just equivalent to calling k_mem_domain_add_thread() on the default memory domain now. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
ed938d18b1
commit
f1d12aa45b
5 changed files with 4 additions and 112 deletions
|
@ -189,10 +189,12 @@ extern void k_mem_domain_add_thread(struct k_mem_domain *domain,
|
|||
/**
|
||||
* @brief Remove a thread from its memory domain.
|
||||
*
|
||||
* Remove a thread from its memory domain.
|
||||
* Remove a thread from its memory domain. It will be reassigned to the
|
||||
* default memory domain.
|
||||
*
|
||||
* @param thread ID of thread going to be removed from its memory domain.
|
||||
*/
|
||||
__deprecated
|
||||
extern void k_mem_domain_remove_thread(k_tid_t thread);
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -104,7 +104,6 @@ void test_permission_inheritance(void *p1, void *p2, void *p3)
|
|||
ARRAY_SIZE(inherit_memory_partition_array),
|
||||
inherit_memory_partition_array);
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
parent_tid = k_current_get();
|
||||
k_mem_domain_add_thread(&inherit_mem_domain, parent_tid);
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ extern void test_mem_domain_add_partitions_invalid(void);
|
|||
extern void test_mem_domain_add_partitions_simple(void);
|
||||
extern void test_mem_domain_remove_partitions_simple(void);
|
||||
extern void test_mem_domain_remove_partitions(void);
|
||||
extern void test_mem_domain_remove_thread(void);
|
||||
extern void test_kobject_access_grant(void);
|
||||
extern void test_syscall_invalid_kobject(void);
|
||||
extern void test_thread_without_kobject_permission(void);
|
||||
|
@ -66,7 +65,6 @@ void test_main(void)
|
|||
ztest_unit_test(test_mem_domain_add_partitions_simple),
|
||||
ztest_unit_test(test_mem_domain_remove_partitions_simple),
|
||||
ztest_unit_test(test_mem_domain_remove_partitions),
|
||||
ztest_unit_test(test_mem_domain_remove_thread),
|
||||
ztest_unit_test(test_mark_thread_exit_uninitialized),
|
||||
ztest_unit_test(test_kobject_access_grant),
|
||||
ztest_unit_test(test_syscall_invalid_kobject),
|
||||
|
|
|
@ -104,7 +104,6 @@ static void mem_domain_test_1(void *tc_number, void *p2, void *p3)
|
|||
{
|
||||
if ((uintptr_t)tc_number == 1U) {
|
||||
mem_domain_buf[0] = 10U;
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&mem_domain_mem_domain,
|
||||
k_current_get());
|
||||
}
|
||||
|
@ -189,7 +188,6 @@ void test_mem_domain_partitions_user_rw(void)
|
|||
ARRAY_SIZE(mem_domain_memory_partition_array),
|
||||
mem_domain_memory_partition_array);
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&mem_domain_mem_domain,
|
||||
k_current_get());
|
||||
|
||||
|
@ -230,7 +228,6 @@ void test_mem_domain_partitions_user_ro(void)
|
|||
k_mem_domain_init(&mem_domain1,
|
||||
ARRAY_SIZE(mem_domain_memory_partition_array1),
|
||||
mem_domain_memory_partition_array1);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
k_mem_domain_add_thread(&mem_domain1, k_current_get());
|
||||
|
||||
|
@ -248,7 +245,6 @@ void test_mem_domain_partitions_supervisor_rw(void)
|
|||
k_mem_domain_init(&mem_domain_mem_domain,
|
||||
ARRAY_SIZE(mem_domain_memory_partition_array1),
|
||||
mem_domain_memory_partition_array1);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
k_mem_domain_add_thread(&mem_domain_mem_domain, k_current_get());
|
||||
|
||||
|
@ -354,8 +350,6 @@ void test_mem_domain_add_partitions_invalid(void *p1, void *p2, void *p3)
|
|||
uint8_t max_partitions = (uint8_t)arch_mem_domain_max_partitions_get() - 1;
|
||||
uint8_t index;
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
mem_domain_init();
|
||||
k_mem_domain_init(&mem_domain_tc3_mem_domain,
|
||||
1,
|
||||
|
@ -367,7 +361,7 @@ void test_mem_domain_add_partitions_invalid(void *p1, void *p2, void *p3)
|
|||
[index]);
|
||||
|
||||
}
|
||||
/* The next add_thread and remove_thread is done so that the
|
||||
/* The next add_thread is done so that the
|
||||
* memory domain for mem_domain_tc3_mem_domain partitions are
|
||||
* initialized. Because the pages/regions will not be configuired for
|
||||
* the partitions in mem_domain_tc3_mem_domain when do a add_partition.
|
||||
|
@ -375,8 +369,6 @@ void test_mem_domain_add_partitions_invalid(void *p1, void *p2, void *p3)
|
|||
k_mem_domain_add_thread(&mem_domain_tc3_mem_domain,
|
||||
k_current_get());
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
/* configure a different memory domain for the current thread. */
|
||||
k_mem_domain_add_thread(&mem_domain_mem_domain,
|
||||
k_current_get());
|
||||
|
@ -429,7 +421,6 @@ void test_mem_domain_add_partitions_simple(void *p1, void *p2, void *p3)
|
|||
|
||||
}
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&mem_domain_tc3_mem_domain,
|
||||
k_current_get());
|
||||
|
||||
|
@ -460,7 +451,6 @@ static void mem_domain_for_user_tc5(void *p1, void *p2, void *p3)
|
|||
*/
|
||||
void test_mem_domain_remove_partitions_simple(void *p1, void *p2, void *p3)
|
||||
{
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&mem_domain_tc3_mem_domain,
|
||||
k_current_get());
|
||||
|
||||
|
@ -502,7 +492,6 @@ static void mem_domain_test_6_2(void *p1, void *p2, void *p3)
|
|||
*/
|
||||
void test_mem_domain_remove_partitions(void *p1, void *p2, void *p3)
|
||||
{
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&mem_domain_tc3_mem_domain,
|
||||
k_current_get());
|
||||
|
||||
|
@ -529,39 +518,3 @@ void test_mem_domain_remove_partitions(void *p1, void *p2, void *p3)
|
|||
|
||||
k_thread_join(&mem_domain_6_tid, K_FOREVER);
|
||||
}
|
||||
/****************************************************************************/
|
||||
|
||||
static void mem_domain_for_user_tc7(void *p1, void *p2, void *p3)
|
||||
{
|
||||
set_fault_valid(true);
|
||||
|
||||
/* will generate a fault */
|
||||
mem_domain_tc3_part4[0] = 10U;
|
||||
zassert_unreachable(ERROR_STR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Test removal of a thread from the memory domain.
|
||||
*
|
||||
* @details Till now all the test suite would have tested add thread.
|
||||
* this ensures that remove is working correctly.
|
||||
*
|
||||
* @ingroup kernel_memprotect_tests
|
||||
*
|
||||
* @see k_mem_domain_remove_thread()
|
||||
*/
|
||||
void test_mem_domain_remove_thread(void *p1, void *p2, void *p3)
|
||||
{
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
k_mem_domain_add_thread(&mem_domain_tc3_mem_domain,
|
||||
k_current_get());
|
||||
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&k_mem_domain_default, k_current_get());
|
||||
|
||||
k_thread_user_mode_enter(mem_domain_for_user_tc7,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
}
|
||||
|
|
|
@ -651,9 +651,6 @@ static void test_access_other_memdomain(void)
|
|||
*/
|
||||
|
||||
k_mem_domain_init(&dom1, ARRAY_SIZE(parts), parts);
|
||||
|
||||
/* remove current thread from domain dom0 and add to dom1 */
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&dom1, k_current_get());
|
||||
|
||||
/* Create user mode thread */
|
||||
|
@ -708,9 +705,6 @@ static void test_domain_add_thread_drop_to_user(void)
|
|||
|
||||
expect_fault = false;
|
||||
k_mem_domain_init(&add_thread_drop_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
k_mem_domain_add_thread(&add_thread_drop_dom, k_current_get());
|
||||
|
||||
k_thread_user_mode_enter(user_half, NULL, NULL, NULL);
|
||||
|
@ -729,7 +723,6 @@ static void test_domain_add_part_drop_to_user(void)
|
|||
|
||||
expect_fault = false;
|
||||
k_mem_domain_init(&add_part_drop_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&add_part_drop_dom, k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
|
@ -738,28 +731,6 @@ static void test_domain_add_part_drop_to_user(void)
|
|||
k_thread_user_mode_enter(user_half, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Show that self-removing from a memory domain and then dropping to user
|
||||
* mode faults as expected.
|
||||
*
|
||||
* @ingroup kernel_memprotect_tests
|
||||
*/
|
||||
static void test_domain_remove_thread_drop_to_user(void)
|
||||
{
|
||||
struct k_mem_partition *parts[] = {&part0, &access_part,
|
||||
&ztest_mem_partition};
|
||||
|
||||
expect_fault = true;
|
||||
expected_reason = K_ERR_CPU_EXCEPTION;
|
||||
k_mem_domain_init(&remove_thread_drop_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&remove_thread_drop_dom, k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
k_thread_user_mode_enter(user_half, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show that self-removing a partition from a domain we are a member of,
|
||||
* and then dropping to user mode faults as expected.
|
||||
|
@ -774,7 +745,6 @@ static void test_domain_remove_part_drop_to_user(void)
|
|||
expect_fault = true;
|
||||
expected_reason = K_ERR_CPU_EXCEPTION;
|
||||
k_mem_domain_init(&remove_part_drop_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&remove_part_drop_dom, k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
|
@ -820,9 +790,6 @@ static void test_domain_add_thread_context_switch(void)
|
|||
|
||||
expect_fault = false;
|
||||
k_mem_domain_init(&add_thread_ctx_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
k_mem_domain_add_thread(&add_thread_ctx_dom, k_current_get());
|
||||
|
||||
spawn_user();
|
||||
|
@ -839,7 +806,6 @@ static void test_domain_add_part_context_switch(void)
|
|||
|
||||
expect_fault = false;
|
||||
k_mem_domain_init(&add_part_ctx_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&add_part_ctx_dom, k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
|
@ -848,28 +814,6 @@ static void test_domain_add_part_context_switch(void)
|
|||
spawn_user();
|
||||
}
|
||||
|
||||
/* Show that self-removing from a memory domain and then switching to another
|
||||
* user thread in the same domain faults as expected.
|
||||
*
|
||||
* @ingroup kernel_memprotect_tests
|
||||
*/
|
||||
static void test_domain_remove_thread_context_switch(void)
|
||||
{
|
||||
struct k_mem_partition *parts[] = {&part0, &access_part,
|
||||
&ztest_mem_partition};
|
||||
|
||||
expect_fault = true;
|
||||
expected_reason = K_ERR_CPU_EXCEPTION;
|
||||
k_mem_domain_init(&remove_thread_ctx_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&remove_thread_ctx_dom, k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
|
||||
spawn_user();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show that self-removing a partition from a domain we are a member of,
|
||||
* and then switching to another user thread in the same domain faults as
|
||||
|
@ -885,7 +829,6 @@ static void test_domain_remove_part_context_switch(void)
|
|||
expect_fault = true;
|
||||
expected_reason = K_ERR_CPU_EXCEPTION;
|
||||
k_mem_domain_init(&remove_part_ctx_dom, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_add_thread(&remove_part_ctx_dom, k_current_get());
|
||||
|
||||
k_sleep(K_MSEC(1));
|
||||
|
@ -1087,7 +1030,6 @@ void test_main(void)
|
|||
struct k_mem_partition *parts[] = {&part0, &part1,
|
||||
&ztest_mem_partition};
|
||||
|
||||
k_mem_domain_remove_thread(k_current_get());
|
||||
k_mem_domain_init(&dom0, ARRAY_SIZE(parts), parts);
|
||||
k_mem_domain_add_thread(&dom0, k_current_get());
|
||||
|
||||
|
@ -1131,11 +1073,9 @@ void test_main(void)
|
|||
ztest_unit_test(test_domain_add_thread_drop_to_user),
|
||||
ztest_unit_test(test_domain_add_part_drop_to_user),
|
||||
ztest_unit_test(test_domain_remove_part_drop_to_user),
|
||||
ztest_unit_test(test_domain_remove_thread_drop_to_user),
|
||||
ztest_unit_test(test_domain_add_thread_context_switch),
|
||||
ztest_unit_test(test_domain_add_part_context_switch),
|
||||
ztest_unit_test(test_domain_remove_part_context_switch),
|
||||
ztest_unit_test(test_domain_remove_thread_context_switch),
|
||||
ztest_user_unit_test(test_unimplemented_syscall),
|
||||
ztest_user_unit_test(test_bad_syscall),
|
||||
ztest_user_unit_test(test_oops_panic),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue