riscvarchive / riscv-smcdeleg-ssccfg

Supervisor Counter Delegation Architecture Extension
https://jira.riscv.org/browse/RVG-59
Creative Commons Attribution 4.0 International
2 stars 2 forks source link

Type of exception for write access to read-only scounovf from VS/VU-modes via Ssccfg #8

Open oolegoon opened 2 months ago

oolegoon commented 2 months ago

According to the H extension of the Privileged ISA, write access to a read-only register from VS/VU mode causes an illegal instruction exception according to the rules of the HS-qualified instruction.

Ssccfg is based on Sscsrind, which states that this rule does not apply and exceptions on access are determined by the spec for which the window is used.

For alias CSRs sireg* and vsireg*, the hypervisor extension’s usual rules for when to raise a virtual
instruction exception (based on whether an instruction is HS-qualified) are not applicable. The
rules given in this section for sireg and vsireg apply instead, unless overridden by the
requirements specified in the section below, which take precedence over this section when
extension Smstateen is also implemented.

The Ssccfg spec says that access to scountovf generates a virtual instruction exception.

For implementations that support Smcdeleg/Ssccfg, Sscofpmf, and the H extension, when
menvcfg.CDE=1, attempts to access scountovf from VS-mode or VU-mode raise a virtual instruction
exception.

Could you please clarify: does both read and write access generate a virtual instruction exception?

On the one hand, the behavior is described quite clearly, on the other hand, the dualism in terms of different types of exceptions for writing to read-only from VS/VU-modes is a bit confusing.

bcstrongx commented 2 months ago

Good catch, I think this may be an oversight. Certainly reads of scountovf from VS/VU-mode should raise virtual-instruction exceptions. Writes should probably raise an illegal instruction exception, as normal. However, this spec is ratified, so let me check with ARC.

bcstrongx commented 2 months ago

We are hoping to fix the spec, see https://lists.riscv.org/g/tech-privileged/message/2094.

oolegoon commented 1 month ago

Thanks for clarification!