Expand description
Routines to prepare VTL2 memory for launching the kernel.
StructsΒ§
- Bitmap
Hex π core::fmt::Displayadapter that prints a page-bitmap (little-endian per byte within each u64 word) as a compact hex string. One hex char per 4 pages, so a full 2 MB / 4 KB = 512-page chunk fits in 128 hex chars.- Diag
Chunk πHash - Diag
PerPage πState - Per-page expected-hash tracking state. Populated during Phase A capture as each 4 KB shared page is compared against the loaderβs per-page SHA-384 baked into the measured expected-page-hashes region.
- Diag
Saved πBadPage - One corrupt pageβs full 4 KB contents plus the shim vs loader hashes, captured during Phase A when we first noticed the mismatch.
- HexBytes π
core::fmt::Displayadapter that prints a byte slice as lowercase hex, no separators. Convenient for hashes in log lines.- RleRanges π
core::fmt::Displayadapter that walks a page-bitmap and emits corrupt page-index ranges in the form0x8-0xa,0x11,0x20-0x21. Human-readable alternative to the raw hex bitmap.
ConstantsΒ§
- DIAG_
BITMAP_ πWORDS - Bitmap word count (u64s) for one 2 MB chunk.
- DIAG_
EMPTY_ πSAVED_ PAGE - DIAG_
HASH_ πBITMAP_ WORDS - DIAG_
MAX_ πBAD_ PAGE_ HASHES - Cap on how many per-bad-page SHA-384 lines we emit per Phase B mismatch, so a wholly-corrupt chunk doesnβt spam thousands of log lines.
- DIAG_
MAX_ πCHUNKS - Maximum number of 2 MB chunks we track. Debug builds hash roughly kernel + initrd (~80 MB), giving ~40 chunks; leave generous headroom.
- DIAG_
MAX_ πHASH_ PAGES - Maximum number of individual 4 KB pages we can track for per-page expected-hash comparison. Sized with headroom over the current shared-page count observed in soaks (~20 K pages = 40 x 2 MB chunks).
- DIAG_
MAX_ πPAGES_ PER_ CHUNK - Max pages we can bitmap in a single 2 MB accept chunk (2 MB / 4 KB = 512).
- DIAG_
MAX_ πSAVED_ BAD_ PAGES - Number of corrupt pages for which we save the full 4 KB contents so we can hex-dump them on final report.
- DIAG_
PAGE_ πSIZE - Diagnostic page size == HV page size (4 KB).
StaticsΒ§
- DIAG_
CHUNK_ πHASHES - DIAG_
FULL_ πPAGE_ DUMPED - One-shot latch guarding the full 4 KB hex dump of a corrupted page. Whichever phase (B or C) trips a mismatch first gets to dump; every subsequent detection just logs the header/bitmap/hashes and skips the full dump. Keeps COM3 quiet even when many chunks are corrupted.
- DIAG_
PER_ πPAGE - Per-page expected-hash tracking (populated in
diag_record_phase_aand reported indiag_report_per_page_expected). - DIAG_
RUNNING_ πA
FunctionsΒ§
- accept_
pending_ πvtl2_ memory - Accepts VTL2 memory in the specified range that is currently marked as pending, i.e. not yet assigned as exclusive and private.
- accept_
vtl2_ πmemory - Accepts VTL2 memory in the specified gpa range.
- diag_
claim_ πfull_ page_ dump - Returns true and latches on the first call; returns false thereafter.
- diag_
dump_ πfull_ page_ diff - Emit a full 4 KB page as hex, one log line per 64-byte cache line, with pre and post side by side. Used when we have both Phase-A and Phase-C bytes for the first corrupted page.
- diag_
dump_ πfull_ page_ single - Emit a full 4 KB page as hex, one log line per 64-byte cache line. Used when only the current (Phase-D) bytes are available for the first bad page and there is no pre-image to compare side by side.
- diag_
dump_ πsaved_ page - Emit a saved corrupt page (captured in Phase A) as hex, one log line per 64-byte cache line, along with the shim vs loader hashes.
- diag_
init_ πexpected_ hashes - Cache the loader-emitted per-page expected hashes so
diag_record_phase_acan compare each 4 KB page against them. Must be called once, before the acceptance loop insetup_vtl2_memory. If the IGVM doesnβt have the expected-page-hashes region (older loader) or the region magic/version mismatched, per-page compare is left disabled anddiag_record_phase_asilently skips the per-page work. - diag_
record_ πphase_ a - Record the Phase-A hash of a chunk that was just copied out of a shared
page into
ram_buffer. Also feeds the bytes into a running combined Phase-A hasher so it can be compared againstimported_regions_hash()on final mismatch. Additionally walks the chunk at 4 KB page granularity and compares each pageβs SHA-384 against the loader-emitted per-page expected hash (ifdiag_init_expected_hashescached one) β mismatches are recorded in a bitmap plus a small buffer of the first N bad pagesβ full contents sodiag_report_per_page_expectedcan dump them on final panic. - diag_
report_ πper_ page_ expected - Emit the per-page expected-hash comparison summary, corrupt-page bitmap,
RLE ranges, and full 4 KB dumps of the first
DIAG_MAX_SAVED_BAD_PAGEScorrupt pages. Called fromdiag_report_phase_c(i.e. after the combined hash mismatch has been detected and just before panic). - diag_
report_ πphase_ c - Called from
verify_imported_regions_hashwhen the combined Phase-C hash does not match the expected measured value. Reports: - diag_
verify_ πphase_ b - Immediately after the shared -> private transition and copy-back, compare the same chunk (via the identity map) against the Phase-A bytes we captured before the transition, at 4 KB PAGE granularity. On mismatch, emits:
- setup_
vtl2_ memory - On isolated systems, transitions all VTL2 RAM to be private and accepted, with the appropriate VTL permissions applied.
- verify_
imported_ regions_ hash