You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2024/07/24 11:03:29 UTC
(nuttx) branch releases/12.6 updated (14da04e988 -> 2fa7b9cc34)
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a change to branch releases/12.6
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 14da04e988 sched/tcb: fix 12320 regression
new 11ddd00470 riscv/fork: fix tp for PROTECTED
new 2fa7b9cc34 riscv/trap: fix sp restore logic
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/risc-v/src/common/riscv_exception_common.S | 4 ++++
arch/risc-v/src/common/riscv_fork.c | 8 ++++++++
2 files changed, 12 insertions(+)
(nuttx) 01/02: riscv/fork: fix tp for PROTECTED
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch releases/12.6
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 11ddd0047071425abbac324df33d2b931fb5da72
Author: Yanfeng Liu <yf...@qq.com>
AuthorDate: Fri Jul 5 10:25:55 2024 +0800
riscv/fork: fix tp for PROTECTED
This fixes `tp` value of forked child in PROTECTED build to support
vfork. Why? the optimized `dispatch_syscall` requires `tp` to hold
the task TCB since commit e6973c764c.
Signed-off-by: Yanfeng Liu <yf...@qq.com>
---
arch/risc-v/src/common/riscv_fork.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/risc-v/src/common/riscv_fork.c b/arch/risc-v/src/common/riscv_fork.c
index 16f6225297..6b7705028c 100644
--- a/arch/risc-v/src/common/riscv_fork.c
+++ b/arch/risc-v/src/common/riscv_fork.c
@@ -246,6 +246,14 @@ pid_t riscv_fork(const struct fork_s *context)
fregs[REG_FS11] = context->fs11; /* Saved register fs11 */
#endif
+#ifdef CONFIG_BUILD_PROTECTED
+ /* Forked task starts at `dispatch_syscall()`, which requires TP holding
+ * TCB pointer as per e6973c764c, so we please it here to support vfork.
+ */
+
+ child->cmn.xcp.regs[REG_TP] = (uintptr_t)child;
+#endif
+
/* And, finally, start the child task. On a failure, nxtask_start_fork()
* will discard the TCB by calling nxtask_abort_fork().
*/
(nuttx) 02/02: riscv/trap: fix sp restore logic
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch releases/12.6
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2fa7b9cc34e62ce23d00a32af21e325b807f2d98
Author: Yanfeng Liu <yf...@qq.com>
AuthorDate: Tue Jul 16 14:41:04 2024 +0800
riscv/trap: fix sp restore logic
This fixes stack pointer restore logic to avoid parent stack corruption
by forked child in PROTECTED build.
Signed-off-by: Yanfeng Liu <yf...@qq.com>
---
arch/risc-v/src/common/riscv_exception_common.S | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/risc-v/src/common/riscv_exception_common.S b/arch/risc-v/src/common/riscv_exception_common.S
index 9035947031..7bcf2d2d72 100644
--- a/arch/risc-v/src/common/riscv_exception_common.S
+++ b/arch/risc-v/src/common/riscv_exception_common.S
@@ -231,7 +231,11 @@ return_from_exception:
load_ctx sp
+#ifdef CONFIG_ARCH_KERNEL_STACK
REGLOAD sp, REG_SP(sp) /* restore original sp */
+#else
+ addi sp, sp, XCPTCONTEXT_SIZE
+#endif
/* Return from exception */