Skip to content

Commit

Permalink
fix: Remove 4096B chunk restriction of read/write_volatile
Browse files Browse the repository at this point in the history
Fixes a bug where GuestMemory::read_volatile_from and
GuestMemory::write_volatile_into would only copy data in chunks of at
most 4096 bytes from/into the underlying stream. The check removed in
this commit was errorneously copied from the read_from/write_into
functions, which use a temporary buffer to transfer data (and this
temporary buffer was capped to 4096 bytes).

Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
  • Loading branch information
roypat committed Jan 8, 2024
1 parent b8bf1db commit 6b58497
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
### Added
### Changed
### Fixed
- [[#279](https://github.com/rust-vmm/vm-memory/pull/279)] Remove restriction from `read_volatile_from` and `write_volatile_into`
that made it copy data it chunks of 4096.

### Removed
### Deprecated

Expand Down
3 changes: 0 additions & 3 deletions src/guest_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,6 @@ pub trait GuestMemory {
// Check if something bad happened before doing unsafe things.
assert!(offset <= count);

let len = std::cmp::min(len, MAX_ACCESS_CHUNK);

let mut vslice = region.get_slice(caddr, len)?;

src.read_volatile(&mut vslice)
Expand All @@ -749,7 +747,6 @@ pub trait GuestMemory {
// Check if something bad happened before doing unsafe things.
assert!(offset <= count);

let len = std::cmp::min(len, MAX_ACCESS_CHUNK);
let vslice = region.get_slice(caddr, len)?;

// For a non-RAM region, reading could have side effects, so we
Expand Down

0 comments on commit 6b58497

Please sign in to comment.