From cbdfff91290d96c539c1d3d6f96c1cb64bd58c8f Mon Sep 17 00:00:00 2001 From: Alvin Chang Date: Sat, 7 Oct 2023 13:09:54 +0800 Subject: [PATCH] core: riscv: Support fault mitigations in non-threaded code The commit ce56605a0ede ("core: support fault mitigations in non-threaded code) supports fault mitigations in non-threaded code for ARM architecture. This commit adds the related modification for RISC-V architecture to support it too. Also the indentation in __ftmn_get_tsd_func_arg_pp() is fixed. Signed-off-by: Alvin Chang --- core/arch/riscv/include/kernel/thread_arch.h | 3 +++ lib/libutils/ext/include/fault_mitigation.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/arch/riscv/include/kernel/thread_arch.h b/core/arch/riscv/include/kernel/thread_arch.h index e150fa10e86..1e2da17b726 100644 --- a/core/arch/riscv/include/kernel/thread_arch.h +++ b/core/arch/riscv/include/kernel/thread_arch.h @@ -32,6 +32,9 @@ struct thread_core_local { #ifdef CFG_CORE_DEBUG_CHECK_STACKS bool stackcheck_recursion; #endif +#ifdef CFG_FAULT_MITIGATION + struct ftmn_func_arg *ftmn_arg; +#endif } THREAD_CORE_LOCAL_ALIGNED; struct thread_user_vfp_state { diff --git a/lib/libutils/ext/include/fault_mitigation.h b/lib/libutils/ext/include/fault_mitigation.h index b0610ba22a5..06a6f7f017b 100644 --- a/lib/libutils/ext/include/fault_mitigation.h +++ b/lib/libutils/ext/include/fault_mitigation.h @@ -250,7 +250,7 @@ extern struct ftmn_func_arg *__ftmn_global_func_arg; static inline struct ftmn_func_arg **__ftmn_get_tsd_func_arg_pp(void) { #if defined(CFG_FAULT_MITIGATION) && defined(__KERNEL__) - if (thread_get_id_may_fail() >= 0) + if (thread_get_id_may_fail() >= 0) return &thread_get_tsd()->ftmn_arg; else return &thread_get_core_local()->ftmn_arg;