Skip to content

Commit 3a53c80

Browse files
authored
Merge pull request #1591 from YenHaoChen/pr-sstc-stce
Teach Sstc to respect xenvcfg.STCE
2 parents d4726e1 + 928743b commit 3a53c80

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

riscv/csrs.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,8 @@ void time_counter_csr_t::sync(const reg_t val) noexcept {
10791079
if (proc->extension_enabled(EXT_SSTC)) {
10801080
const reg_t mip_val = (shadow_val >= state->stimecmp->read() ? MIP_STIP : 0) |
10811081
(shadow_val + state->htimedelta->read() >= state->vstimecmp->read() ? MIP_VSTIP : 0);
1082-
state->mip->backdoor_write_with_mask(MIP_STIP | MIP_VSTIP, mip_val);
1082+
const reg_t mask = ((state->menvcfg->read() & MENVCFG_STCE) ? MIP_STIP : 0) | ((state->henvcfg->read() & HENVCFG_STCE) ? MIP_VSTIP : 0);
1083+
state->mip->backdoor_write_with_mask(mask, mip_val);
10831084
}
10841085
}
10851086

@@ -1537,7 +1538,8 @@ stimecmp_csr_t::stimecmp_csr_t(processor_t* const proc, const reg_t addr, const
15371538
}
15381539

15391540
bool stimecmp_csr_t::unlogged_write(const reg_t val) noexcept {
1540-
state->mip->backdoor_write_with_mask(intr_mask, state->time->read() >= val ? intr_mask : 0);
1541+
const reg_t mask = ((state->menvcfg->read() & MENVCFG_STCE) ? MIP_STIP : 0) | ((state->henvcfg->read() & HENVCFG_STCE) ? MIP_VSTIP : 0);
1542+
state->mip->backdoor_write_with_mask(mask, state->time->read() >= val ? intr_mask : 0);
15411543
return basic_csr_t::unlogged_write(val);
15421544
}
15431545

0 commit comments

Comments
 (0)