Skip to content

Commit

Permalink
bitmap/GuestMemory:fix false positive in read_from
Browse files Browse the repository at this point in the history
Before, if we didn't succeed to read all `len` bytes, we would've
marked as dirty more bytes than needed.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
  • Loading branch information
lauralt committed Jun 9, 2021
1 parent 5bd7138 commit a1c13d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion coverage_config_x86_64.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"coverage_score": 87.5,
"coverage_score": 87.6,
"exclude_path": "mmap_windows.rs",
"crate_features": "backend-mmap,backend-atomic,backend-bitmap"
}
10 changes: 5 additions & 5 deletions src/guest_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,16 @@ impl<T: GuestMemory> Bytes<GuestAddress> for T {
// record the dirty status of the written range below.
let start = caddr.raw_value() as usize;
let end = start + len;
let result = loop {
let bytes_read = loop {
match src.read(&mut dst[start..end]) {
Ok(n) => break Ok(n),
Ok(n) => break n,
Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => continue,
Err(e) => break Err(Error::IOError(e)),
Err(e) => return Err(Error::IOError(e)),
}
};

region.bitmap().mark_dirty(start, len);
result
region.bitmap().mark_dirty(start, bytes_read);
Ok(bytes_read)
} else {
let len = std::cmp::min(len, MAX_ACCESS_CHUNK);
let mut buf = vec![0u8; len].into_boxed_slice();
Expand Down

0 comments on commit a1c13d2

Please sign in to comment.