Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach Sstc to respect xenvcfg.STCE #1591

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions riscv/csrs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,8 @@ void time_counter_csr_t::sync(const reg_t val) noexcept {
if (proc->extension_enabled(EXT_SSTC)) {
const reg_t mip_val = (shadow_val >= state->stimecmp->read() ? MIP_STIP : 0) |
(shadow_val + state->htimedelta->read() >= state->vstimecmp->read() ? MIP_VSTIP : 0);
state->mip->backdoor_write_with_mask(MIP_STIP | MIP_VSTIP, mip_val);
const reg_t mask = ((state->menvcfg->read() & MENVCFG_STCE) ? MIP_STIP : 0) | ((state->henvcfg->read() & HENVCFG_STCE) ? MIP_VSTIP : 0);
state->mip->backdoor_write_with_mask(mask, mip_val);
}
}

Expand Down Expand Up @@ -1533,7 +1534,8 @@ stimecmp_csr_t::stimecmp_csr_t(processor_t* const proc, const reg_t addr, const
}

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

Expand Down
Loading