-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Labels
StalebugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug
Description
Describe the bug
The calculation of the stack bounds is wrong according to the riscv's arch.h
:
+------------+ <- thread.arch.priv_stack_start
| Guard | } Z_RISCV_STACK_GUARD_SIZE
+------------+
| Priv Stack | } CONFIG_PRIVILEGED_STACK_SIZE
+------------+ <- thread.arch.priv_stack_start +
CONFIG_PRIVILEGED_STACK_SIZE +
Z_RISCV_STACK_GUARD_SIZE
The start of the privilege stack should be:
thread.arch.priv_stack_start + Z_RISCV_STACK_GUARD_SIZE
Instead of
thread.arch.priv_stack_start - CONFIG_PRIVILEGED_STACK_SIZE
This resulted in empty call trace when the exception happens in a userspace thread.
To Reproduce
Steps to reproduce the behavior:
- Check out v3.7.0
west build -b qemu_riscv64 -p auto -t run -T zephyr/tests/kernel/mem_protect/userspace/kernel.memory_protection.userspace
- Exception message of
test_unimplemented_syscall
doesn't contain call traces:
START - test_unimplemented_syscall
E: Unimplemented system call
E: call trace:
E:
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Current thread: 0x80020ba8 (test_unimplemented_syscall)
Caught system error -- reason 3
System error was expected
PASS - test_unimplemented_syscall in 0.004 seconds
Expected behavior
There should be call traces:
START - test_unimplemented_syscall
E: Unimplemented system call
E: call trace:
E: 0: ra: 00000000800034b6
E: 1: ra: 00000000800005d0
E: 2: ra: 0000000080003660
E: 3: ra: 00000000800029e0
E: 4: ra: 00000000800029fa
E: 5: ra: 0000000080002b08
E: 6: ra: 0000000080002b16
E: 7: ra: 000000008000d51e
E:
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Current thread: 0x80020ba8 (test_unimplemented_syscall)
Caught system error -- reason 3
System error was expected
PASS - test_unimplemented_syscall in 0.006 seconds
Impact
No call traces in userspace
Environment (please complete the following information):
- Commit SHA or Version used: Zephyr v3.7.0
Metadata
Metadata
Assignees
Labels
StalebugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug