Skip to main content

Module memory

Module memory 

Source
Expand description

Routines to prepare VTL2 memory for launching the kernel.

StructsΒ§

BitmapHex πŸ”’
core::fmt::Display adapter 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.
DiagChunkHash πŸ”’
DiagPerPageState πŸ”’
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.
DiagSavedBadPage πŸ”’
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::Display adapter that prints a byte slice as lowercase hex, no separators. Convenient for hashes in log lines.
RleRanges πŸ”’
core::fmt::Display adapter that walks a page-bitmap and emits corrupt page-index ranges in the form 0x8-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_a and reported in diag_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_a can compare each 4 KB page against them. Must be called once, before the acceptance loop in setup_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 and diag_record_phase_a silently 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 against imported_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 (if diag_init_expected_hashes cached one) – mismatches are recorded in a bitmap plus a small buffer of the first N bad pages’ full contents so diag_report_per_page_expected can 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_PAGES corrupt pages. Called from diag_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_hash when 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