From e19b4af344791ef46d0bd4b766aa57ab26c71370 Mon Sep 17 00:00:00 2001 From: wangxiaoyao Date: Tue, 27 Sep 2022 16:25:50 +0800 Subject: [PATCH 1/2] [lwp/arch/rv64] fixed pthread_self() --- components/lwp/arch/risc-v/rv64/lwp_arch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/lwp/arch/risc-v/rv64/lwp_arch.c b/components/lwp/arch/risc-v/rv64/lwp_arch.c index 118e173105..ef3fc3c17c 100644 --- a/components/lwp/arch/risc-v/rv64/lwp_arch.c +++ b/components/lwp/arch/risc-v/rv64/lwp_arch.c @@ -190,6 +190,10 @@ void lwp_set_thread_context(void *exit_addr, void *new_thread_stack, void *user_ syscall_frame->a0 = 0; syscall_frame->a1 = 0; + /* reset thread area */ + rt_thread_t thread = rt_container_of((unsigned long)thread_sp, struct rt_thread, sp); + syscall_frame->tp = (rt_ubase_t)thread->thread_idr; + /* build temp thread context */ stk -= sizeof(struct rt_hw_stack_frame); -- Gitee From 8e1da833dad4970ea5e552a1c7490bdce9e60b80 Mon Sep 17 00:00:00 2001 From: wangxiaoyao Date: Tue, 27 Sep 2022 18:20:53 +0800 Subject: [PATCH 2/2] [lwp/arch/rv] remove useless code for rv64 --- components/lwp/lwp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index d7de0e0d9a..488619250f 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -1333,7 +1333,10 @@ void lwp_user_setting_restore(rt_thread_t thread) { return; } +#if !defined(ARCH_RISCV64) + /* tidr will be set in RESTORE_ALL in risc-v */ rt_cpu_set_thread_idr(thread->thread_idr); +#endif if (rt_dbg_ops) { -- Gitee