You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/08/31 01:20:42 UTC
[incubator-nuttx] branch master updated: arch: risc-v: Fix up_check_tcbstack() for CONFIG_ARCH_ADDRENV=y
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b7063427c8 arch: risc-v: Fix up_check_tcbstack() for CONFIG_ARCH_ADDRENV=y
b7063427c8 is described below
commit b7063427c8b79c1021c2dc47cf794e389565d0da
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Wed Aug 31 08:39:15 2022 +0900
arch: risc-v: Fix up_check_tcbstack() for CONFIG_ARCH_ADDRENV=y
Summary:
- I noticed that ps shows incorrect stack usage when running
getprime in the background.
- With CONFIG_ARCH_ADDRENV=y, a user task including pthread
allocates its stack in the user space that needs to be
accessed with a correct address environment.
- This commit fixes this issue.
Impact:
- CONFIG_ARCH_ADDRENV=y only
Testing:
- Tested with rv-virt:knsh64 on qemu-6.2
Signed-off-by: Masayuki Ishikawa <Ma...@jp.sony.com>
---
arch/risc-v/src/common/riscv_checkstack.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/arch/risc-v/src/common/riscv_checkstack.c b/arch/risc-v/src/common/riscv_checkstack.c
index c3160c9a9a..71db7a5e06 100644
--- a/arch/risc-v/src/common/riscv_checkstack.c
+++ b/arch/risc-v/src/common/riscv_checkstack.c
@@ -155,8 +155,30 @@ size_t riscv_stack_check(uintptr_t alloc, size_t size)
size_t up_check_tcbstack(struct tcb_s *tcb)
{
- return riscv_stack_check((uintptr_t)tcb->stack_base_ptr,
+ size_t size;
+
+#ifdef CONFIG_ARCH_ADDRENV
+ save_addrenv_t oldenv;
+ bool saved = false;
+
+ if ((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
+ {
+ up_addrenv_select(&tcb->group->tg_addrenv, &oldenv);
+ saved = true;
+ }
+#endif
+
+ size = riscv_stack_check((uintptr_t)tcb->stack_base_ptr,
tcb->adj_stack_size);
+
+#ifdef CONFIG_ARCH_ADDRENV
+ if (saved)
+ {
+ up_addrenv_restore(&oldenv);
+ }
+#endif
+
+ return size;
}
ssize_t up_check_tcbstack_remain(struct tcb_s *tcb)