Repository navigation
WIP: crash_log: Dump encrypted log on panic - #1711
Draft
Femi Adeyemi (femiatl) wants to merge 1 commit into
Draft
Femi Adeyemi (femiatl) wants to merge 1 commit into
Femi Adeyemi (femiatl) wants to merge 1 commit into
Conversation
Femi Adeyemi (femiatl)
force-pushed
the
femia/wip/crashlog
branch
3 times, most recently
from
October 23, 2026 23:23
ad38bbc to
578f890
Compare
1. Replace HOST_LOGGER with CRASH_LOGGER. It logs to VTL1 allocated
memory instead of serial port and VTL0 ringbuffer. On debug builds,
it optionally mirrors to the serial port.
2. VTL0 will a use a new SetCrashDumpKey API to send LiteBox a public
key that will be used for crash dump envelope encryption.
3. On panic, the VTL1 logs are encrypted with a symmetric AES-256-GCM
key, and that key itself is encrypted by the public key sent by VTL0.
The crash dump envelope is then written to VTL0 ringbuffer in the
following format (see CrashDumpHeader for details):
CrashDumpHeader(AEAD) | Encrypted Key | Log Ciphertext | Tag
4. Design Choices:
- VTL1 logs are stored in a const-size ringbuffer available at
boot. This implies some space in .bss/.data section.
- Envelope cipher is prepared on public key provision to avoid
RNG availability in panic path.
5. TODOS:
- On vault panic, what can be dumped, if any.
- Test exceptions (div/0,... ), VTL0 panic paths.
- VTL0 ringbuffer writes can be simplified if we insist on
a page aligned buffer.
Femi Adeyemi (femiatl)
force-pushed
the
femia/wip/crashlog
branch
from
October 23, 2026 23:37
578f890 to
b8df8aa
Compare
|
🤖 SemverChecks 🤖 Click for details |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved provisioning, log retention, serialization, key-trust, and panic-coordination issues prevent reliable and secure crash dumping.
8 open issues
Advance ring buffer head only for overwritten bytes · New Park concurrent panics during crash dump collection · New Remove duplicate crash dump key ID · New Reject dump key provisioning after boot trust window · New Route SetCrashDumpKey dispatch to the gate method · New Include panic information in encrypted crash artifact · New Preserve formatted prefix for oversized records · New Use the CRNG-produced seed for dump key generation · New
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
| self.buf[tail..tail + first_len].copy_from_slice(&data[..first_len]); | ||
| self.buf[..data.len() - first_len].copy_from_slice(&data[first_len..]); | ||
|
|
||
| self.head = (self.head + data.len()) % N; |
Comment on lines
+215
to
+217
| if self.panic_dump_started.swap(true, Ordering::SeqCst) { | ||
| serial_print_panic_string("Crash dump already progress"); | ||
| return Err(VsmError::OutOfMemory); |
| let mut vtl0_buf = vtl0_buf.lock(); | ||
| vtl0_buf.write(aead.as_bytes()); | ||
| vtl0_buf.write(&envelope.wrapped_data_key); | ||
| vtl0_buf.write(&envelope.crash_dump_key_id); |
Comment on lines
+806
to
+807
| fn set_crash_dump_key(&self, key_pa: u64, key_len: u64) -> Result<(), VsmError> { | ||
| let key_pa = PhysAddr::try_new(key_pa).map_err(|_| VsmError::InvalidPhysicalAddress)?; |
| Err(VsmError::OperationNotSupported("Identity key generation")) | ||
| } | ||
| VsmFunction::OpteeMessage => Err(VsmError::OperationNotSupported("OP-TEE communication")), | ||
| VsmFunction::SetCrashDumpKey => Err(VsmError::OperationNotSupported("Set Crash Dump Key")), |
Comment on lines
+214
to
+224
| pub fn dump_on_panic(&self, _info: &PanicInfo) -> Result<(), VsmError> { | ||
| if self.panic_dump_started.swap(true, Ordering::SeqCst) { | ||
| serial_print_panic_string("Crash dump already progress"); | ||
| return Err(VsmError::OutOfMemory); | ||
| } | ||
|
|
||
| let Some(envelope) = &*self.envelope.lock() else { | ||
| return Err(VsmError::InvalidKey); | ||
| }; | ||
|
|
||
| let ring_buffer = &mut *self.ring_buf.lock(); |
Comment on lines
+263
to
+265
| if litebox_util_log::format_record(&mut buf, record).is_ok() { | ||
| self.ring_buf.lock().write(buf.as_bytes()); | ||
| } |
Comment on lines
+818
to
+819
| let seed = crate::host::lvbs_impl::rdrand_seed().ok_or(VsmError::InvalidKey)?; | ||
| let mut rng = rand_chacha::ChaCha20Rng::from_seed(seed); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Replace HOST_LOGGER with CRASH_LOGGER. It logs to VTL1 allocated memory instead of serial port and VTL0 ringbuffer. On debug builds, it optionally mirrors to the serial port.
VTL0 will a use a new SetCrashDumpKey API to send LiteBox a public key that will be used for crash dump envelope encryption.
On panic, the VTL1 logs are encrypted with a symmetric AES-256-GCM key, and that key itself is encrypted by the public key sent by VTL0. The crash dump envelope is then written to VTL0 ringbuffer in the following format (see CrashDumpHeader for details): CrashDumpHeader(AEAD) | Encrypted Key | Log Ciphertext | Tag
Design Choices:
TODOS: