-
Notifications
You must be signed in to change notification settings - Fork 161
guest_mem: Add support for guest memory access wrappers for PagedRanges #2444
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1900,6 +1900,23 @@ impl GuestMemory { | |||||||||||
| }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /// Check if a given PagedRange is readable or not. | ||||||||||||
| pub fn probe_gpn_readable_range(&self, range: &PagedRange<'_>) -> Result<(), GuestMemoryError> { | ||||||||||||
| self.op_range(GuestMemoryOperation::Probe, range, move |addr, _r| { | ||||||||||||
| let mut b = [0]; | ||||||||||||
| self.read_at_inner(addr, &mut b) | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||||||||||||
| }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /// Check if a given PagedRange is writable or not. | ||||||||||||
|
||||||||||||
| /// Check if a given PagedRange is writable or not. | |
| /// Check if a given PagedRange is writable or not. | |
| /// | |
| /// This checks writability by attempting a compare-exchange operation at each address in the range. | |
| /// If the compare-exchange succeeds, the page is considered writable; otherwise, an error is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The documentation could be more descriptive. Consider expanding it to clarify what "readable" means in this context and what errors might be returned. For example:
The same applies to
probe_gpn_writable_range.