Skip to content

Commit 9014a3f

Browse files
committed
Bump version to v1.1.1
- Fix .vmsn hang: use mmap instead of fs::read for metadata parsing, avoiding multi-GB allocation on embedded memory snapshots - Reduce EPT scan budget (4GB cap, 1GB gap limit) for faster bail-out on non-VBS VMs (70s → 10s on 16GB snapshot)
1 parent f6001f8 commit 9014a3f

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vmkatz"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
edition = "2021"
55
license = "MIT"
66

‎src/paging/ept.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,16 @@ pub fn find_ept_candidates<P: PhysicalMemory>(l1: &P) -> Result<Vec<EptCandidate
340340
// Scan budget: if no candidates found after scanning a portion of L1, give up.
341341
// EPT PML4 tables are placed by the hypervisor in the lower portion of L1 memory.
342342
// For genuine VBS VMs, candidates appear within the first few GB.
343-
// Small VMs (<2GB) can't run VBS, so reduce budget to 25%.
343+
// Cap at 4GB — scanning more is wasteful since EPTs live in low memory.
344+
const MAX_SCAN_BUDGET: u64 = 4 * 1024 * 1024 * 1024;
344345
let scan_budget = if l1_size < 2 * 1024 * 1024 * 1024 {
345346
l1_size / 4
346347
} else {
347-
l1_size / 2
348+
(l1_size / 4).min(MAX_SCAN_BUDGET)
348349
};
349350
let mut pages_since_last_candidate: u64 = 0;
350-
// Also give up if we've scanned 2M pages (8GB) without finding a candidate.
351-
const PAGES_WITHOUT_CANDIDATE_LIMIT: u64 = 2_000_000;
351+
// Give up if we've scanned 256K pages (1GB) without finding a candidate.
352+
const PAGES_WITHOUT_CANDIDATE_LIMIT: u64 = 256_000;
352353

353354
let mut addr: u64 = 0;
354355
while addr < l1_size {

‎src/vmware/layer.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ impl VmwareLayer {
166166

167167
/// Parse a .vmsn file and return (regions, tags).
168168
fn parse_vmsn_metadata(vmsn_path: &Path) -> Result<(Vec<MemoryRegion>, Vec<Tag>)> {
169-
let vmsn_data = fs::read(vmsn_path)?;
169+
// Memory-map instead of fs::read to avoid loading the entire multi-GB
170+
// snapshot into memory — only the header/tag pages get paged in.
171+
let vmsn_file = fs::File::open(vmsn_path)?;
172+
let vmsn_data = unsafe { Mmap::map(&vmsn_file)? };
170173

171174
let (hdr, groups) = header::parse_vmsn(&vmsn_data)?;
172175
log::info!(

0 commit comments

Comments
 (0)