Conversation
Add `handle_hvc` to the `Platform` trait, enabling custom EL2 HVC calls for specific platforms. Unhandled HVCs are properly trapped and routed to this method. If a platform doesn't handle the HVC, it now returns SMCCC_NOT_SUPPORTED (-1) to the guest instead of panicking. Added a dummy HVC (0xFF00_0000) to the QEMU platform implementation for testing purposes. The `integration_test` (formerly called `isolation_test`) validates both successful dummy HVC execution and expected failure for unknown HVCs.
qwandor
reviewed
Mar 27, 2026
src/platform/qemu.rs
Outdated
| if function_id == 0xFF00_0000 { | ||
| // SAFETY: We only modify the state of the x0 register as an answer to the | ||
| // guest call. | ||
| let regs = unsafe { register_state.get_mut() }; |
Collaborator
There was a problem hiding this comment.
It would be nice to provide a safe abstraction for platforms to handle HVCs. Maybe rather than passing the RegisterStateRef you could pass a mutable reference to the subset of registers which the SMCCC allows to be changed by an HVC call? I guess this handler shouldn't need to change the FP, SP, ELR or SPSR, right?
Collaborator
Author
There was a problem hiding this comment.
Fair - I changed the API so that handle_hvc now return a custom error. The nice part is that some of the logic can be shared with the PSCI proxy code.
Let me know if this makes sense.
qwandor
approved these changes
Mar 30, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
handle_hvcto thePlatformtrait, enabling custom EL2 HVC calls for specific platforms. Unhandled HVCs are properly trapped and routed to this method. If a platform doesn't handle the HVC, it now returns SMCCC_NOT_SUPPORTED (-1) to the guest instead of panicking.Added a dummy HVC (0xFF00_0000) to the QEMU platform implementation for testing purposes. The
integration_test(formerly calledisolation_test) validates both successful dummy HVC execution and expected failure for unknown HVCs.