Skip to content

WIP: crash_log: Dump encrypted log on panic - #1711

Draft
Femi Adeyemi (femiatl) wants to merge 1 commit into
mainfrom
femia/wip/crashlog
Draft

Femi Adeyemi (femiatl) wants to merge 1 commit into
mainfrom
femia/wip/crashlog

Conversation

@femiatl

@femiatl Femi Adeyemi (femiatl) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor
  1. Replace HOST_LOGGER with CRASH_LOGGER. It logs to VTL1 allocated
    memory and mirrors to the serial port, only dumping to the VTL0
    ringbuffer on a panic. This replaces HOST_LOGGER writing to serial
    port and the VTL0 ringbugffer. When a crash dump key is set,
    release builds will turn serial mirroring off.

  2. VTL0 uses a new SetCrashDumpKey API to send LiteBox a public key
    for crash dump envelope encryption. Key verification is a TODO, so
    this API must be called before EndofBoot flag is set. Only DER
    encoded RSA-(2048,3072,4096 bit) keys are supported.

  3. On panic, VTL1 logs are encrypted in place with a symmetric key
    (AES-256-GCM), and that key is wrapped by the public key sent
    via SetCrashDumpKey API. The crash dump envelope is then written to
    VTL0 ringbuffer in the following format:
    CrashDumpHeader | Wrapped Key | Log Ciphertext | Tag

  4. The panic path uses locks with bounded wait times and avoids
    allocation. Writes to VTL0 wingbuffer are the exception. TODOs have
    been added to simplify that path.

Signed-off-by: Femi Adeyemi femiadeyemi@microsoft.com

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved provisioning, log retention, serialization, key-trust, and panic-coordination issues prevent reliable and secure crash dumping.

8 open issues
What changed in this PR

This PR introduces encrypted crash logging for LVBS, keeping logs in VTL1 memory and preparing an encrypted envelope for export to VTL0 on panic.

Changes:

  • Replaces the host logger with a fixed-size crash logger and optional debug serial mirroring.
  • Adds crash-dump key provisioning interfaces and RSA-wrapped AES-256-GCM encryption.
  • Connects panic handling to dump generation and updates dependencies and global-count limits.
File Description
litebox_runner_lvbs/​src/​main.rs Installs the crash logger and configures serial mirroring.
litebox_runner_lvbs/​src/​lib.rs Adds the dispatch arm and invokes dumping on panic.
litebox_platform_lvbs/​src/​mshv/​vsm.rs Implements public-key loading and envelope preparation.
litebox_platform_lvbs/​src/​mshv/​ringbuffer.rs Adds a TODO about buffer alignment requirements.
litebox_platform_lvbs/​src/​lib.rs Exposes the crash-log module.
litebox_platform_lvbs/​src/​host/​lvbs_impl.rs Makes the hardware seed helper crate-visible.
litebox_platform_lvbs/​src/​crash_log.rs Implements buffered logging, encryption, and dump serialization.
litebox_platform_lvbs/​src/​arch/​x86/​ioport.rs Removes ring-buffer forwarding and adds nonblocking panic serial output.
litebox_platform_lvbs/​Cargo.toml Adds logging and encryption dependencies.
litebox_common_lvbs/​src/​lib.rs Defines the crash-key call, gate method, and error.
dev_tests/​src/​ratchet.rs Adjusts global-count limits for logger relocation.
Cargo.lock Records the added cryptographic dependency graph.

Review effort: Balanced

Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/mshv/vsm.rs Resolved
Comment thread litebox_runner_lvbs/src/lib.rs Resolved
Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/mshv/vsm.rs Resolved
Comment thread litebox_runner_lvbs/src/lib.rs Resolved
Comment thread litebox_platform_lvbs/src/mshv/vsm.rs Resolved
Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/crash_log.rs Resolved
Comment thread litebox_platform_lvbs/src/mshv/vsm.rs Resolved
Comment thread litebox_service_heki/src/handlers.rs Resolved
@femiatl
Femi Adeyemi (femiatl) force-pushed the femia/wip/crashlog branch 5 times, most recently from ff955ac to 19b78ed Compare November 5, 2026 23:09
Replace HOST_LOGGER with CRASH_LOGGER. It logs to VTL1 allocated
memory and mirrors to the serial port, only dumping to the VTL0
ringbuffer on a panic. It replaces HOST_LOGGER writing to serial
port and the VTL0 ringbuffer.

VTL0 can use the SetCrashDumpKey API to send LiteBox a public RSA
key for crash dump envelope encryption. Keys are not verified,
so this API must be called before EndofBoot flag is set. Only DER
encoded RSA-(2048,3072,4096 bit) keys in SPKI or PKCS#1 format are
supported. When a crash dump key is set, release builds will turn
serial port mirroring off.

On panic, if a crash dump key is found, VTL1 logs are encrypted
in-place with a symmetric (AES-256-GCM) key and that key is wrapped
by the public RSA key. The optionally encrypted logs are copied to
VTL0 in the format:
   CrashDumpHeader | Wrapped Key | (Cipher)Text | Tag

Signed-off-by: Femi Adeyemi <femiadeyemi@microsoft.com>
@github-actions

Copy link
Copy Markdown

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_variant_added.ron

Failed in:
  variant VsmFunction:SetCrashDumpKey in /home/runner/work/litebox/litebox/litebox_common_lvbs/src/lib.rs:86
  variant VsmFunction:RunLvbsTest in /home/runner/work/litebox/litebox/litebox_common_lvbs/src/lib.rs:87

--- failure trait_method_added: pub trait method added ---

Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/trait_method_added.ron

Failed in:
  trait method litebox_common_lvbs::Vtl1Gate::set_crash_dump_key in file /home/runner/work/litebox/litebox/litebox_common_lvbs/src/lib.rs:919

--- failure trait_method_return_value_added: pub trait method return value added ---

Description:
A trait method that previously returned `()` now returns a value. Since the trait is not sealed, downstream implementations of the trait will get compile errors.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-item-signature
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/trait_method_return_value_added.ron

Failed in:
  litebox_common_lvbs::Vtl0Gate::install_ringbuffer in file /home/runner/work/litebox/litebox/litebox_common_lvbs/src/lib.rs:826

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants