pussuw opened a new pull request, #9485:
URL: https://github.com/apache/nuttx/pull/9485
## Summary
If a kernel stack exists, use that whenever the user process is in
privileged mode, i.e. running an exception or in system call. Previously
the exception context was stored into the user's stack, which is not ideal.
Why?
1. Because the exception entry status (REG_INT_CTX) is needed by the
kernel, and this is now in user memory which requires that the correct
user mappings are active when it is accessed.
2. The user must currently account for the exception stack frame (which
is BIG) in its own stack allocation. Moving the exception context save
to the kernel stack offloads this responsibility from the user to the
kernel, which is IMO the correct behavior.
3. The kernel access to user memory is currently allowed without condition,
however this is not ideal either. The privileged mode status CSR
(MSTATUS/SSTATUS) allows
blocking access to user memory via the STATUS_SUM-bit, which should be
disabled by default and only enabled when access to user space is really
needed. This patch allows implementing such features.
Also had to fix arm_initialstate due to execution ordering: the allocated
kstack pointer in xcptcontext is wiped by memset if
it is allocated before call to arm_initialstate.
## Impact
Significant, changes the kernel stack functionality entirely, but affects
risc-v targets that define:
CONFIG_ARCH_ADDRENV=y
CONFIG_ARCH_KERNEL_STACK=y
Others are not affected by this.
## Testing
icicle:knsh
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]