diff --git a/arch/Kconfig b/arch/Kconfig index 18a8e1a4950..c93fb026331 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -95,6 +95,7 @@ config X86 && !SOC_HAS_TIMING_FUNCTIONS select ARCH_HAS_STACK_CANARIES_TLS select ARCH_SUPPORTS_MEM_MAPPED_STACKS if X86_MMU && !DEMAND_PAGING + select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE help x86 architecture diff --git a/arch/x86/core/userspace.c b/arch/x86/core/userspace.c index 4dc09d71ab4..436bc18edb7 100644 --- a/arch/x86/core/userspace.c +++ b/arch/x86/core/userspace.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include #include #include @@ -183,3 +185,19 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry, _current->stack_info.start); CODE_UNREACHABLE; } + +int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size, + size_t *unused_ptr) +{ + struct z_x86_thread_stack_header *hdr_stack_obj; + + if ((thread->base.user_options & K_USER) != K_USER) { + return -EINVAL; + } + + hdr_stack_obj = (struct z_x86_thread_stack_header *)thread->stack_obj; + + return z_stack_space_get(&hdr_stack_obj->privilege_stack[0], + sizeof(hdr_stack_obj->privilege_stack), + unused_ptr); +}