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

[BUG] Incorrect stval value after illegal instruction exception while mstatus.TVM flag is activated in HS-mode #2688

Open
1 task done
riscv914 opened this issue Jan 7, 2025 · 0 comments
Labels
notCV32A65X It is not an CV32A65X issue Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system

Comments

@riscv914
Copy link

riscv914 commented Jan 7, 2025

Is there an existing CVA6 bug for this?

  • I have searched the existing bug issues

Bug Description

In HS-mode, when mstatus.TVM flag is activated executing the HFENCE.GVMA instruction should trigger an illegal instruction exception. While this behavior is correct on CVA6 cores, after the trap is triggered, the stval register value should be set to the instruction value.

"The stval register can optionally also be used to return the faulting instruction bits on an illegal instruction exception (sepc points to the faulting instruction in memory). If stval is written with a nonzero value when an illegal-instruction exception occurs, then stval will contain the shortest of:
the actual faulting instruction
the first ILEN bits of the faulting instruction
the first SXLEN bits of the faulting instruction
"

However, in the case of the HFENCE.GVMA instruction, the CVA6 core erroneously sets stval to 0x1 instead of the instruction value.


Code for Reproducing the Bug:

int main() {
    asm volatile ("li t0, (1 << 20)"); 
    asm volatile ("csrs mstatus, t0"); // set TVM
    /// Switch to HS-mode
    asm volatile ("hfence.gvma zero, zero");
}

Expected Behavior:

When the HFENCE.GVMA instruction causes the trap, the stval register should hold the value of the HFENCE.GVMA instruction.


Observed Behavior:

The stval register is incorrectly set to 0x1 instead of the correct value of the HFENCE.GVMA instruction 0x62000073.


CVA6 commit: 2155d0e
Build config : cv64a6_imafdch_sv39_wb

@riscv914 riscv914 added the Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system label Jan 7, 2025
@JeanRochCoulon JeanRochCoulon added the notCV32A65X It is not an CV32A65X issue label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notCV32A65X It is not an CV32A65X issue Type:Bug For bugs in the RTL, Documentation, Verification environment or Tool and Build system
Projects
None yet
Development

No branches or pull requests

2 participants