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

Add DCSR.MPRVEN support #1882

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fk-sc
Copy link

@fk-sc fk-sc commented Dec 20, 2024

Adds DCSR.MPRVEN bit support, as specified in RISC-V External Debug Support Version 1.0.0-rc4 (https://github.com/riscv/riscv-debug-spec/releases/tag/1.0.0-rc4, see 4.9.1 Debug Control and Status).

This bit allows to enable hardware virtual address translation when memory access is initiated by the debugger (see 4.1 Debug Mode, clause 2).

This change:

  • Increases debug specification coverage, allows more detailed testing of external debuggers with Spike.
  • DCSR.MPRVEN decreases the number of required abstract commands to read virtual memory.

Commit's changes:

  • Added MPRVEN field to DCSR register
  • Updated debug_rom.S to turn off MPRVEN while executing ROM

To avoid unwanted address translation while debug_rom.S executed DCSR.MPRVEN bit has to be cleared on entry and restored on exit.

Updated version of debug_rom.S does the following:

  • On _entry: clears DCSR.MPRVEN bit, stores previous DCSR value to S1 and stores previous S1 value to DSCRATCH01
  • On _exception: restores S1 value from DSCRATCH01
  • On _resume/going: restores S1 and DCSR values

@fk-sc
Copy link
Author

fk-sc commented Dec 20, 2024

I've also added tests targeting this feature: riscv-software-src/riscv-tests#599

Adds DCSR.MPRVEN bit support, as specified in RISC-V External Debug Support Version 1.0.0-rc4
(https://github.com/riscv/riscv-debug-spec/releases/tag/1.0.0-rc4, see 4.9.1 Debug Control and Status).

This bit allows to enable hardware virtual address translation when memory access
is initiated by the debugger (see 4.1 Debug Mode, clause 2).

This change:
* Increases debug specification coverage, allows more detailed testing of external debuggers with Spike.
* Decreases the number of required abstract commands to read virtual memory thus improving the user experience.

Commit's changes:
* Added MPRVEN field to DCSR register
* Updated debug_rom.S to turn off MPRVEN while executing ROM

To avoid unwanted address translation in while debug_rom.S executed
DCSR.MPRVEN bit has to be cleared on entry and restored on exit.

Updated version of debug_rom.S does the following:
* On _entry: clears DCSR.MPRVEN bit, stores previous DCSR value to S1
  and stores previous S1 value to DSCRATCH01
* On _exception: restores S1 value from DSCRATCH01
* On _resume/going: restores S1 and DCSR values

Signed-off-by: Farid Khaydari <f.khaydari@syntacore.com>
@fk-sc fk-sc force-pushed the fk-sc/mprven-support branch from 372448d to 95af514 Compare December 20, 2024 12:52
@fk-sc
Copy link
Author

fk-sc commented Dec 20, 2024

@aswaterman, @rtwfroody, would you kindly take a look?

Copy link
Collaborator

@aswaterman aswaterman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had thought that not using dscratch1 was a goal of this sample debug ROM, but I'll defer to @rtwfroody

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