Skip to content

Commit

Permalink
libcpu: riscv: fixed ARCH_RISCV_VECTOR issue
Browse files Browse the repository at this point in the history
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 <kenneth.liu@sophgo.com>
  • Loading branch information
KennethLiu61 authored and mysterywolf committed Feb 22, 2025
1 parent b3225ec commit 2be83d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libcpu/risc-v/common64/cpuport.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
#include <encoding.h>

#ifdef ARCH_RISCV_FPU
#define K_SSTATUS_DEFAULT (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM | SSTATUS_FS)
#define K_SSTATUS_DEFAULT_BASE (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM | SSTATUS_FS)
#else
#define K_SSTATUS_DEFAULT (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM)
#define K_SSTATUS_DEFAULT_BASE (SSTATUS_SPP | SSTATUS_SPIE | SSTATUS_SUM)
#endif

#ifdef ARCH_RISCV_VECTOR
#define K_SSTATUS_DEFAULT (K_SSTATUS_DEFAULT_BASE | SSTATUS_VS)
#else
#define K_SSTATUS_DEFAULT K_SSTATUS_DEFAULT_BASE
#endif
#ifdef RT_USING_SMART
#include <lwp_arch.h>
Expand Down

0 comments on commit 2be83d5

Please sign in to comment.