@@ -411,6 +411,7 @@ static RISCVException read_timeh(CPURISCVState *env, int csrno,
static const target_ulong delegable_ints = S_MODE_INTERRUPTS |
VS_MODE_INTERRUPTS;
+static const target_ulong vs_delegable_ints = VS_MODE_INTERRUPTS;
static const target_ulong all_ints = M_MODE_INTERRUPTS | S_MODE_INTERRUPTS |
VS_MODE_INTERRUPTS;
static const target_ulong delegable_excps =
@@ -433,6 +434,14 @@ static const target_ulong delegable_excps =
(1ULL << (RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT)) |
(1ULL << (RISCV_EXCP_VIRT_INSTRUCTION_FAULT)) |
(1ULL << (RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT));
+static const target_ulong vs_delegable_excps = delegable_excps &
+ ~((1ULL << (RISCV_EXCP_S_ECALL)) |
+ (1ULL << (RISCV_EXCP_VS_ECALL)) |
+ (1ULL << (RISCV_EXCP_M_ECALL)) |
+ (1ULL << (RISCV_EXCP_INST_GUEST_PAGE_FAULT)) |
+ (1ULL << (RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT)) |
+ (1ULL << (RISCV_EXCP_VIRT_INSTRUCTION_FAULT)) |
+ (1ULL << (RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT)));
static const target_ulong sstatus_v1_10_mask = SSTATUS_SIE | SSTATUS_SPIE |
SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS |
SSTATUS_SUM | SSTATUS_MXR;
@@ -1039,7 +1048,7 @@ static RISCVException read_hedeleg(CPURISCVState *env, int csrno,
static RISCVException write_hedeleg(CPURISCVState *env, int csrno,
target_ulong val)
{
- env->hedeleg = val;
+ env->hedeleg = val & vs_delegable_excps;
return RISCV_EXCP_NONE;
}
@@ -1053,7 +1062,7 @@ static RISCVException read_hideleg(CPURISCVState *env, int csrno,
static RISCVException write_hideleg(CPURISCVState *env, int csrno,
target_ulong val)
{
- env->hideleg = val;
+ env->hideleg = val & vs_delegable_ints;
return RISCV_EXCP_NONE;
}