Skip to content

Commit 55ee97c

Browse files
dcpleungnashif
authored andcommitted
xtensa: implements arch_thread_priv_stack_space_get
This implements arch_thread_priv_stack_space_get() so this can be used to figure out how much privileged stack space is used. Signed-off-by: Daniel Leung <[email protected]>
1 parent 1dc02fc commit 55ee97c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

arch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ config XTENSA
136136
select ARCH_MEM_DOMAIN_DATA if USERSPACE
137137
select ARCH_HAS_DIRECTED_IPIS
138138
select THREAD_STACK_INFO
139+
select ARCH_HAS_THREAD_PRIV_STACK_SPACE_GET if USERSPACE
139140
help
140141
Xtensa architecture
141142

arch/xtensa/core/thread.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <errno.h>
78
#include <string.h>
89

910
#include <zephyr/kernel.h>
@@ -170,4 +171,20 @@ FUNC_NORETURN void arch_user_mode_enter(k_thread_entry_t user_entry,
170171

171172
CODE_UNREACHABLE;
172173
}
174+
175+
int arch_thread_priv_stack_space_get(const struct k_thread *thread, size_t *stack_size,
176+
size_t *unused_ptr)
177+
{
178+
struct xtensa_thread_stack_header *hdr_stack_obj;
179+
180+
if ((thread->base.user_options & K_USER) != K_USER) {
181+
return -EINVAL;
182+
}
183+
184+
hdr_stack_obj = (struct xtensa_thread_stack_header *)thread->stack_obj;
185+
186+
return z_stack_space_get(&hdr_stack_obj->privilege_stack[0],
187+
sizeof(hdr_stack_obj->privilege_stack),
188+
unused_ptr);
189+
}
173190
#endif /* CONFIG_USERSPACE */

0 commit comments

Comments
 (0)