@@ -302,13 +302,12 @@ impl SnapshotModule {
302
302
}
303
303
304
304
pub fn access ( & mut self , addr : GuestAddr , size : usize ) {
305
- // ASSUMPTION: the access can only cross 2 pages
306
- debug_assert ! ( size <= SNAPSHOT_PAGE_SIZE ) ;
307
- let page = addr & SNAPSHOT_PAGE_MASK ;
308
- self . page_access ( page) ;
309
- let second_page = ( addr + size as GuestAddr - 1 ) & SNAPSHOT_PAGE_MASK ;
310
- if page != second_page {
311
- self . page_access ( second_page) ;
305
+ let start = addr & SNAPSHOT_PAGE_MASK ;
306
+ let end = ( addr + size as GuestAddr - 1 ) & SNAPSHOT_PAGE_MASK ;
307
+ /* Apparently there is a performance hit to using an inclusive range */
308
+ #[ allow( clippy:: range_plus_one) ]
309
+ for page in ( start..end + 1 ) . step_by ( SNAPSHOT_PAGE_SIZE ) {
310
+ self . page_access ( page) ;
312
311
}
313
312
}
314
313
@@ -920,7 +919,13 @@ where
920
919
match i64:: from ( sys_num) {
921
920
SYS_read | SYS_pread64 => {
922
921
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
923
- h. access ( a1, a2 as usize ) ;
922
+ /*
923
+ * Only note the access if the call is successful. And only mark the
924
+ * portion of the buffer which has actually been modified.
925
+ */
926
+ if result != GuestAddr :: MAX {
927
+ h. access ( a1, result as usize ) ;
928
+ }
924
929
}
925
930
SYS_readlinkat => {
926
931
let h = emulator_modules. get_mut :: < SnapshotModule > ( ) . unwrap ( ) ;
0 commit comments