Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Does hip.VSTIP revert to defined behavior when menvcfg.STCE=henvcfg.STCE=0? #5

Open
YenHaoChen opened this issue Jan 26, 2024 · 5 comments

Comments

@YenHaoChen
Copy link

The spec says that hip.VSTIP reverts to its defined behavior (as if unsupporting Sstc extension) when menvcfg.STCE=1 and henvcfg.STCE=0.
Does hip.VSTIP reverts to its defined behavior (as if unsupporting Sstc extension) when menvcfg.STCE=henvcfg.STCE=0?

image

@YenHaoChen
Copy link
Author

@jscheid-ventana Would you share some words on this question? Thank you.

@jscheid-ventana
Copy link
Collaborator

I suspect so, but I agree that it deserves clarification. Up to @aswaterman or @gfavor , but is the more clear intent presented if the initial qualifying term in the second paragraph was removed, so that it's just:

When STCE in henvcfg is zero, an attempt to access stimecmp (really vstimecmp) when V = 1 raises a virtual instruction exception, and VSTIP in hip reverts to its defined behavior as if this extension is not implemented.

There are other ways, by adding more terms.

@gfavor
Copy link
Collaborator

gfavor commented Feb 1, 2024

Saying just "When STCE in henvcfg is zero" in the spec would result in defining different arch semantics than the current text. In particular it would create two conflicting arch statements. One that says accesses when menvcfg.STCE=0 raise an illegal instruction exception in non-M modes. And one that says accesses when henvcfg.STCE=0 raise a virtual instruction exception in a subset of non-M modes (i.e VS/VU modes).

To the original question: When menvcfg.STCE=0, then henvcfg.STCE is a don't care. Although this doesn't explicitly say what then happens with VSTIP. So the clarification to make in the spec is that when menvcfg.STCE=0 and if the H extension is implemented, then hip.VSTIP also reverts to its defined behavior as if this extension is not implemented.

After review and approval by the ARC, this clarification can be incorporated into the rewritten version of the spec that will soon be integrated into the new adoc Priv spec document.

@YenHaoChen
Copy link
Author

@jscheid-ventana @gfavor Thank you for the detailed clarification.

@jscheid-ventana
Copy link
Collaborator

Ah, right. I was missing the different exception types.

This should stay open to track the spec update.

YenHaoChen added a commit to YenHaoChen/riscv-isa-sim that referenced this issue Feb 4, 2024
When menvcfg.STCE=0, mip.STIP reverts to its defined behavior as if
unsupporting Sstc extension. When henvcfg.STCE=0, mip.VSTIP reverts
to its defined behavior as if unsupporting Sstc extension. [riscvarchive/riscv-time-compare#5]

The previous Sstc implementation does not respect the xenvcfg.STCE.
In other words, the Sstc may assert mip.STIP (mip.VSTIP) when
menvcfg.STCE=0 (henvcfg.STCE=0), which is a misbehaving.

This commit presents a proposal that respects the xenvcf.STCE by
utilizing the write mask of mip_csr_t::backdoor_write_with_mask()
function. If menvcfg.STCE=0 (henvcfg.STCE=0), the corresponding
bit of mip.STIP (mip.VSTIP) in the write mask should be 0 to revert
the behavior as if unsupporting Sstec extension.
YenHaoChen added a commit to YenHaoChen/riscv-isa-sim that referenced this issue Feb 6, 2024
When menvcfg.STCE=0, mip.STIP reverts to its defined behavior as if
unsupporting Sstc extension. When henvcfg.STCE=0, mip.VSTIP reverts
to its defined behavior as if unsupporting Sstc extension. [riscvarchive/riscv-time-compare#5]

The previous Sstc implementation does not respect the xenvcfg.STCE.
In other words, the Sstc may assert mip.STIP (mip.VSTIP) when
menvcfg.STCE=0 (henvcfg.STCE=0), which is a misbehaving.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants