This repository was archived by the owner on Feb 27, 2026. It is now read-only.
Guest console read support via Debug Console Read SBI function#333
Merged
dgreid merged 4 commits intorivosinc:mainfrom Jun 6, 2025
Merged
Guest console read support via Debug Console Read SBI function#333dgreid merged 4 commits intorivosinc:mainfrom
dgreid merged 4 commits intorivosinc:mainfrom
Conversation
This adds the infrastructure to support reading bytes from the console by renaming `ConsoleWriter` trait to `ConsoleDriver` and adding a function to read bytes. A default implementation that never returns any bytes is provided. Read implementations in individual console drivers are left for subsequent changes.
Member
Author
|
@atishp04 FYI |
Member
Author
|
Note that this depends on rivosinc/sbi-rs#23 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds guest console read support to the Debug Console Read SBI function by implementing a handle_read function in the host VM and updating the console driver abstraction throughout the code.
- Added a new DebugConsoleFunction::Read branch in src/host_vm.rs with a corresponding handle_read function.
- Refactored pinning of guest console buffers and updated error mapping.
- Updated console trait naming from ConsoleWriter to ConsoleDriver and augmented the UART driver with a read_bytes method.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/host_vm.rs | Added Debug Console read handling and refactored buffer pinning logic |
| sbi-rs | Updated subproject commit |
| s-mode-utils/src/sbi_console.rs | Updated console abstraction to use the new ConsoleDriver trait |
| s-mode-utils/src/print.rs | Refactored print module to adopt the updated ConsoleDriver trait |
| drivers/src/uart.rs | Introduced UartRegister enum and implemented read_bytes for console read support |
Comments suppressed due to low confidence (1)
src/host_vm.rs:598
- Mapping all errors from pin_console_buffer to 0 may be ambiguous because 0 is conventionally a success code. Consider returning a more descriptive or distinct error code to clearly differentiate failure cases.
let (_pinned, mut hyp_addr) = self.pin_console_buffer(vm, addr, len).map_err(|_| 0u64)?;
dgreid
reviewed
Jun 5, 2025
Contributor
dgreid
left a comment
There was a problem hiding this comment.
lgtm, just one comment nit. and you'll have to reset the sbi uprev after a rebased merge.
Contributor
|
lgtm. Thanks for pushing the console changes separately! |
dgreid
approved these changes
Jun 6, 2025
This change adds minimal logic to the UART driver for reading bytes. As is already the case with the write code path, the driver assumes that the UART is already set up correctly.
Bump the version to bring in a fix to Debug Console.
A basic implementation analogous to the write implementation that reads characters from the UART. This has been tested successfully against with the Linux SBI hvc driver. While at it wrap access to the buffer in a `PinnedBuffer` helper that isolates the business logic from safety considerations by exposing the buffer as a `VolatileSlice`.
68654c2 to
acdf9ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fills in a Debug Console Read implementation for use by guests. This is achieved by adding read support to the console abstraction, which is then used in the added SBI function handler.