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

Incorrect GVA setting in mstatus #640

Closed
youzi27 opened this issue Nov 6, 2024 · 1 comment · Fixed by #642
Closed

Incorrect GVA setting in mstatus #640

youzi27 opened this issue Nov 6, 2024 · 1 comment · Fixed by #642

Comments

@youzi27
Copy link

youzi27 commented Nov 6, 2024

Describe the bug

In M-mode, mstatus's GVA value is incorrectly set when a trap is thrown during ebreak.

To Reproduce

.section .text
.globl _start
_start:

    nop
    li x26, 0x800000ca007e7a8a
    csrw mstatus, x26
    ebreak      
    
    nop

Expected behavior

Field GVA (Guest Virtual Address) is written by the implementation whenever a trap is taken into M-mode. For any trap (breakpoint, address misaligned, access fault, page fault, or guest-page fault) that writes a guest virtual address to mtval, GVA is set to 1. For any other trap into M-mode, GVA is set to 0.

Error log or Screenshots

image

Necessary information on versions
ready-to-run's NEMU commit: c9c1451

@NewPaulWalker
Copy link
Contributor

Thank you for your issue.
You wrote 1 to mprv, 1 to mpv, and 3 to mpp in mstatus, but after executing the ebreak instruction, the gva in mstatus is still 1 in NEMU.
This is indeed a bug in NEMU, and I have fixed the set/clear logic for gva, which should have fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants