Skip to content

Commit 5f105cc

Browse files
committed
libcpu: riscv: fixed ARCH_RISCV_VECTOR issue
description: Using the vector instruction set to trigger an illegal instruction exception when ARCH_SISCV_VECTOR=y. analysis: When initializing the thread stack, the rt_cw_stack_init function did not enable VS for SSTATUS. Solution: When ARCH_SISCV_VECTOR=y, increment the initial value of sstatus by 0x600(SSTATUS_VS). Signed-off-by: Liu Gui <[email protected]>
1 parent 7432b0a commit 5f105cc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

libcpu/risc-v/common64/cpuport.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@
1919
#include <encoding.h>
2020

2121
#ifdef ARCH_RISCV_FPU
22-
#define K_SSTATUS_DEFAULT (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM | SSTATUS_FS)
22+
#define K_SSTATUS_DEFAULT_BASE (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM | SSTATUS_FS)
2323
#else
24-
#define K_SSTATUS_DEFAULT (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM)
24+
#define K_SSTATUS_DEFAULT_BASE (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM)
25+
#endif
26+
27+
#ifdef ARCH_RISCV_VECTOR
28+
#define K_SSTATUS_DEFAULT (K_SSTATUS_DEFAULT_BASE | SSTATUS_VS)
29+
#else
30+
#define K_SSTATUS_DEFAULT K_SSTATUS_DEFAULT_BASE
2531
#endif
2632
#ifdef RT_USING_SMART
2733
#include <lwp_arch.h>

0 commit comments

Comments
 (0)