firmware_uefi: Allow inspect or ohcldiag to reprocess UEFI logs with an increased log level#2802
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the UEFI diagnostics inspection capability by allowing dynamic log level overrides at runtime. The UEFI diagnostics buffer contains all logs up to the VERBOSE level, but by default only ERROR and WARN logs are projected. This change enables users to reprocess the buffer with increased verbosity (INFO or VERBOSE) via the inspect interface without requiring a restart.
Changes:
- Added
log_level_override: Option<LogLevel>parameter to diagnostics processing methods - Enhanced inspect_mut handler to accept "default", "info", or "full" values for runtime log level control
- Updated all existing call sites to pass
None, preserving default behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
vm/devices/firmware/firmware_uefi/src/service/diagnostics/mod.rs |
Added log_level_override parameter to both DiagnosticsServices::process_diagnostics and UefiDevice::process_diagnostics methods with documentation updates |
vm/devices/firmware/firmware_uefi/src/lib.rs |
Enhanced inspect_mut handler to parse log level values ("default"/"info"/"full") and updated all call sites to pass None for the new parameter |
vm/devices/firmware/firmware_uefi/fuzz/fuzz_diagnostics.rs |
Updated fuzz test to pass None for the new log_level_override parameter |
| match value { | ||
| Ok(node) => println!("{:#}", node), | ||
| Ok(node) => match &node.kind { | ||
| inspect::ValueKind::String(s) => println!("{s}"), |
There was a problem hiding this comment.
This was necessary because otherwise printing the return value of inspect didn't break up each log into their own line
| |log| { | ||
| let _ = writeln!( | ||
| output, | ||
| "[{}] [{}] (ticks: {}) {}", |
There was a problem hiding this comment.
so currently the output looks like:
PS C:\maa> .\ohcldiag-dev.exe UHVM1 inspect -u default vm/uefi/efi_diagnostics_dump
"[ERROR] [PEI_CORE] (ticks: 7709416) InstallPermanentMemoryBuffer: - New Info=42FF000, Buffer Offset=50, Current Offset=1000, Size=4194224, Discarded=5464\n[ERROR] [PEI_CORE] (ticks: 7797332) SyncPcrAllocationsAndPcrMask!\n[ERROR] [PEI_CORE] (ticks: 8166883) PeiDelayedDispatchOnEndOfPei Count of dispatch cycles is 0\n[WARNING] [DXE] (ticks: 8290957) VmbusRootIsChannelAllowed: Channel not allowed during boot (525074DC-8985-46E2-8057-A307DC18A502).\n[WARNING] [DXE] (ticks: 8291028) VmbusRootIsChannelAllowed: Channel not allowed during boot (F8E65716-3CB3-4A06-9A60-1889C5CCCAB5).\n[WARNING] [DXE] (ticks: 8291088) VmbusRootIsChannelAllowed: Channel not allowed during boot (CFA8B69E-5B4A-4CC0-B98B-8BA1A1F3F95A).\n[WARNING] [DXE] (ticks: 8291400) VmbusRootIsChannelAllowed: Channel not allowed during boot (3375BAF4-9E15-4B30-B765-67ACB10D607B).\n[WARNING] [DXE] (ticks: 8291460) VmbusRootIsChannelAllowed: Channel not allowed during boot (57164F39-9115-4E78-AB55-382F3BD5422D).\n[WARNING] [DXE] (ticks: 8291519) VmbusRootIsChannelAllowed: Channel not allowed during boot (A9A0F4E7-5A45-4D96-B827-8A841E8C03E6).\n[WARNING] [DXE] (ticks: 8291578) VmbusRootIsChannelAllowed: Channel not allowed during boot (0E0B6031-5213-4934-818B-38D90CED39DB).\n[WARNING] [DXE] (ticks: 8291637) VmbusRootIsChannelAllowed: Channel not allowed during boot (9527E630-D0AE-497B-ADCE-E80AB0175CAF).\n[WARNING] [DXE] (ticks: 8291697) VmbusRootIsChannelAllowed: Channel not allowed during boot (35FA2E29-EA23-4236-96AE-3A6EBACBA440).\n[WARNING] [DXE] (ticks: 8291756) VmbusRootIsChannelAllowed: Channel not allowed during boot (276AACF4-AC15-426C-98DD-7521AD3F01FE).\n[WARNING] [DXE] (ticks: 8294702) FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n[ERROR] [DXE] (ticks: 8295776) OnVariablePolicyNotification: - Unable to locate variable policy protocol - Status=Not Found\n[ERROR] [DXE] (ticks: 9426410) OnVariablePolicyNotification: - Unable to locate variable policy protocol - Status=Not Found\n[WARNING] [DXE] (ticks: 10480382) AziHsm: Seal command size: 87 bytes, data size: 32 bytes\n[WARNING] [DXE] (ticks: 10480392) AziHsm: Parent handle: 0x80000000, command tag: 0x8002\n[ERROR] [DXE] (ticks: 11565269) Error: Image at 000F7BA9000 start failed: Unsupported\n[ERROR] [DXE] (ticks: 13690878) MnpStart: MnpStartSnp failed, Already started.\n[WARNING] [DXE] (ticks: 13816412) WARN [DE]: Failed to locate on-screen keyboard protocol (Not Found).\n[ERROR] [DXE] (ticks: 13828070) [Bds] Unable to boot!\n[WARNING] [DXE] (ticks: 13828347) Boot order is empty\n[ERROR] [DXE] (ticks: 13874746) Unable to locate any 964E5B22-6459-11D2-8E39-00A0C969723B handles - code=Not Found\n[WARNING] [DXE] (ticks: 13874760) Attempted to boot from HDD with FilterOnlyMedia, SelectAndBootDevice returned Not Found\n[ERROR] [DXE] (ticks: 13874809) AziHsm: Unable to Boot event triggered - clearing sensitive data\n[ERROR] [DXE] (ticks: 14112965) OnVariablePolicyNotification: - Unable to locate variable policy protocol - Status=Not Found\n[WARNING] [DXE] (ticks: 14207143) WARN [FP]: Failed to find the on-screen keyboard protocol (Not Found).\n[ERROR] [DXE] (ticks: 14223643) RenderTitlebar Parameter = B - LoadOption=0\n[WARNING] [DXE] (ticks: 14679545) MnpSyncSendPacket: No network cable detected.\n[WARNING] [DXE] (ticks: 21679726) MnpSyncSendPacket: No network cable detected.\n[WARNING] [DXE] (ticks: 113679353) MnpSyncSendPacket: No network cable detected.\n\n(0xb91 entries processed, 0x657d8 bytes read)"
PS C:\maa> .\ohcldiag-dev.exe UHVM1 efi-diagnostics default
[ERROR] [PEI_CORE] (ticks: 7709416) InstallPermanentMemoryBuffer: - New Info=42FF000, Buffer Offset=50, Current Offset=1000, Size=4194224, Discarded=5464
[ERROR] [PEI_CORE] (ticks: 7797332) SyncPcrAllocationsAndPcrMask!
[ERROR] [PEI_CORE] (ticks: 8166883) PeiDelayedDispatchOnEndOfPei Count of dispatch cycles is 0
[WARNING] [DXE] (ticks: 8290957) VmbusRootIsChannelAllowed: Channel not allowed during boot (525074DC-8985-46E2-8057-A307DC18A502).
[WARNING] [DXE] (ticks: 8291028) VmbusRootIsChannelAllowed: Channel not allowed during boot (F8E65716-3CB3-4A06-9A60-1889C5CCCAB5).
[WARNING] [DXE] (ticks: 8291088) VmbusRootIsChannelAllowed: Channel not allowed during boot (CFA8B69E-5B4A-4CC0-B98B-8BA1A1F3F95A).
[WARNING] [DXE] (ticks: 8291400) VmbusRootIsChannelAllowed: Channel not allowed during boot (3375BAF4-9E15-4B30-B765-67ACB10D607B).
[WARNING] [DXE] (ticks: 8291460) VmbusRootIsChannelAllowed: Channel not allowed during boot (57164F39-9115-4E78-AB55-382F3BD5422D).
[WARNING] [DXE] (ticks: 8291519) VmbusRootIsChannelAllowed: Channel not allowed during boot (A9A0F4E7-5A45-4D96-B827-8A841E8C03E6).
[WARNING] [DXE] (ticks: 8291578) VmbusRootIsChannelAllowed: Channel not allowed during boot (0E0B6031-5213-4934-818B-38D90CED39DB).
[WARNING] [DXE] (ticks: 8291637) VmbusRootIsChannelAllowed: Channel not allowed during boot (9527E630-D0AE-497B-ADCE-E80AB0175CAF).
[WARNING] [DXE] (ticks: 8291697) VmbusRootIsChannelAllowed: Channel not allowed during boot (35FA2E29-EA23-4236-96AE-3A6EBACBA440).
[WARNING] [DXE] (ticks: 8291756) VmbusRootIsChannelAllowed: Channel not allowed during boot (276AACF4-AC15-426C-98DD-7521AD3F01FE).
[WARNING] [DXE] (ticks: 8294702) FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!
[ERROR] [DXE] (ticks: 8295776) OnVariablePolicyNotification: - Unable to locate variable policy protocol - Status=Not Found
[ERROR] [DXE] (ticks: 9426410) OnVariablePolicyNotification: - Unable to locate variable policy protocol - Status=Not Found
[WARNING] [DXE] (ticks: 10480382) AziHsm: Seal command size: 87 bytes, data size: 32 bytes
[WARNING] [DXE] (ticks: 10480392) AziHsm: Parent handle: 0x80000000, command tag: 0x8002
[ERROR] [DXE] (ticks: 11565269) Error: Image at 000F7BA9000 start failed: Unsupported
[ERROR] [DXE] (ticks: 13690878) MnpStart: MnpStartSnp failed, Already started.
[WARNING] [DXE] (ticks: 13816412) WARN [DE]: Failed to locate on-screen keyboard protocol (Not Found).
[ERROR] [DXE] (ticks: 13828070) [Bds] Unable to boot!
[WARNING] [DXE] (ticks: 13828347) Boot order is empty
[ERROR] [DXE] (ticks: 13874746) Unable to locate any 964E5B22-6459-11D2-8E39-00A0C969723B handles - code=Not Found
[WARNING] [DXE] (ticks: 13874760) Attempted to boot from HDD with FilterOnlyMedia, SelectAndBootDevice returned Not Found
[ERROR] [DXE] (ticks: 13874809) AziHsm: Unable to Boot event triggered - clearing sensitive data
[ERROR] [DXE] (ticks: 14112965) OnVariablePolicyNotification: - Unable to locate variable policy protocol - Status=Not Found
[WARNING] [DXE] (ticks: 14207143) WARN [FP]: Failed to find the on-screen keyboard protocol (Not Found).
[ERROR] [DXE] (ticks: 14223643) RenderTitlebar Parameter = B - LoadOption=0
[WARNING] [DXE] (ticks: 14679545) MnpSyncSendPacket: No network cable detected.
[WARNING] [DXE] (ticks: 21679726) MnpSyncSendPacket: No network cable detected.
[WARNING] [DXE] (ticks: 113679353) MnpSyncSendPacket: No network cable detected.
(and if you pass info or full, you get more logs)
Any preference on what the output format should look like?
Maybe we go:
[14679545 ticks] [WARNING] [DXE] MnpSyncSendPacket: No network cable detected.
instead?
| let value = client.update(path, value).await?; | ||
| println!("{value}"); | ||
| match value.kind { | ||
| inspect::ValueKind::String(s) => println!("{s}"), |
There was a problem hiding this comment.
similarly, needed to do this so that output renders newlines correctly
Enhances the inspect_mut on the UefiDevice such that you can now provide a log level to reprocess the UEFI diagnostics buffer with more verbosity. You can also choose to output this through tracing or stdout. The stdout option is used when issuing this same command through ohcldiag.
This works because the in-memory buffer for UEFI logs technically contains all logs up to the VERBOSE level.
By default we only project ERROR and WARN logs, but now we can get INFO and VERBOSE logs at runtime via inspect or ohcldiag