Skip to content

Commit 1a6a1bf

Browse files
dcpleungcfriedt
authored andcommitted
tests: mem_protect/userspace: fix privilege stack ptr for Xtensa
The priv_stack_ptr for reading and writing tests was not set correctly on Xtensa, and was always 0. Test would pass since the NULL page should always generate access faults on most Xtensa platforms. However, those tests are supposed to test reading and writing to the privilege stack. So fix that by populating the priv_stack_ptr correctly. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
1 parent 95d260e commit 1a6a1bf

File tree

1 file changed

+6
-0
lines changed
  • tests/kernel/mem_protect/userspace/src

1 file changed

+6
-0
lines changed

tests/kernel/mem_protect/userspace/src/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,12 @@ void *userspace_setup(void)
11911191
priv_stack_ptr = (char *)((uintptr_t)ztest_thread_stack +
11921192
Z_RISCV_STACK_GUARD_SIZE);
11931193
#endif
1194+
#elif defined(CONFIG_XTENSA)
1195+
struct xtensa_thread_stack_header *hdr;
1196+
void *vhdr = ((struct xtensa_thread_stack_header *)ztest_thread_stack);
1197+
1198+
hdr = vhdr;
1199+
priv_stack_ptr = (((char *)&hdr->privilege_stack) + (sizeof(hdr->privilege_stack) - 1));
11941200
#endif
11951201
k_thread_access_grant(k_current_get(),
11961202
&test_thread, &test_stack,

0 commit comments

Comments
 (0)