-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch: riscv: stacktrace: fix user thread stack bound check #75564
arch: riscv: stacktrace: fix user thread stack bound check #75564
Conversation
It might be better not to rely too much on |
Thanks for the insights
Should it be Z_STACK_PTR_ALIGN(_current->arch.priv_stack_start + K_KERNEL_STACK_RESERVED + CONFIG_PRIVILEGED_STACK_SIZE); instead? According to zephyr/arch/riscv/core/thread.c Lines 143 to 145 in 80ce7d2
|
If it is the privileged/exception stack for user threads that you need then |
So yes, that's pretty much equivalent. |
Maybe this ought to be abstracted in a single location eventually. |
what if we store it somewhere, just like what we did with the stack_info? |
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` For the `end`, use the same equation of `top_of_priv_stack` in the `arch_user_mode_enter()` Signed-off-by: Yong Cong Sin <ycsin@meta.com>
292a6c7
to
4557fe0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
According to the riscv's
arch.h
: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
For the
end
, use the same equation oftop_of_priv_stack
in thearch_user_mode_enter()