Skip to content

Add Hypervisor test macros for VS and VU mode - #53

Open
Nadime Barhoumi (nadime15) wants to merge 3 commits into
riscv:masterfrom
nadime15:add/expand-hypervisor-infrastructure
Open

Add Hypervisor test macros for VS and VU mode#53
Nadime Barhoumi (nadime15) wants to merge 3 commits into
riscv:masterfrom
nadime15:add/expand-hypervisor-infrastructure

Conversation

@nadime15

@nadime15 Nadime Barhoumi (nadime15) commented Mar 24, 2026

Copy link
Copy Markdown

Add support for running tests in virtual supervisor (VS) and virtual user (VU) modes by extending the test environment with H-extension infrastructure.

Changes:

  • Add RVTEST_RV32VS, RVTEST_RV64VS, RVTEST_RV32VU and RVTEST_RV64VU top-level test macros
  • Add INIT_HGATP to initialize hgatp to bare mode at reset
  • Extend DELEGATE_NO_TRAPS to also clear hedeleg, hideleg, and hie
  • Add RVTEST_ENABLE_VIRTUAL_SUPERVISOR and RVTEST_ENABLE_VIRTUAL_USER for transitioning from M-mode to VS/VU mode via MRET
  • Add RVTEST_ENABLE_VIRTUAL_SUPERVISOR_FROM_HS and RVTEST_ENABLE_VIRTUAL_USER_FROM_HS for transitioning from HS-mode to VS/VU mode via SRET
  • Add RVTEST_ENABLE_USER and RVTEST_ENABLE_USER_FROM_SUPERVISOR
  • Add CAUSE_VIRTUAL_SUPERVISOR_ECALL to trap vector so VS-mode tests can pass/fail via ecall
  • Delegate guest-page-fault causes (load, store, fetch) to HS-mode in the default medeleg setup

user (VU) modes by extending the test environment with H-extension
infrastructure.

Changes:
- Add RVTEST_RV64VS and RVTEST_RV64VU top-level test macros
- Add INIT_HGATP to initialize hgatp to bare mode at reset
- Extend DELEGATE_NO_TRAPS to also clear hedeleg, hideleg, and hie
- Add RVTEST_ENABLE_VIRTUAL_SUPERVISOR and RVTEST_ENABLE_VIRTUAL_USER
  for transitioning from M-mode to VS/VU mode via MRET
- Add RVTEST_ENABLE_VIRTUAL_SUPERVISOR_FROM_HS and
  RVTEST_ENABLE_VIRTUAL_USER_FROM_HS for transitioning from HS-mode
  to VS/VU mode via SRET
- Add RVTEST_ENABLE_USER and RVTEST_ENABLE_USER_FROM_SUPERVISOR
- Add CAUSE_VIRTUAL_SUPERVISOR_ECALL to trap vector so VS-mode tests
  can pass/fail via ecall
- Delegate guest-page-fault causes (load, store, fetch) to HS-mode
  in the default medeleg setup
@aswaterman

Copy link
Copy Markdown
Member

Have you written tests that successfully make use of these macros?

@nadime15

Copy link
Copy Markdown
Author

Yes, I tested them. I'm just unsure about the following macro names:

* RVTEST_ENABLE_USER_FROM_SUPERVISOR
* RVTEST_ENABLE_VIRTUAL_SUPERVISOR_FROM_HS
* RVTEST_ENABLE_VIRTUAL_USER_FROM_HS

What do you think about these names? Do they seem clear and consistent, or would you suggest something different?

On RV32, MPV lives in mstatush not mstatus. Use SET_MPV helper macro
to write the correct CSR based on XLEN.
@aswaterman

Copy link
Copy Markdown
Member

I think so. Maybe we could get some more feedback from others if you also make a PR that contributes your new tests.

@nadime15

Copy link
Copy Markdown
Author

Ok sure, will do.

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 this pull request may close these issues.

2 participants