Skip to content

firmware_uefi: add diagnostics service for uefi logs #1209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

maheeraeron
Copy link

@maheeraeron maheeraeron commented Apr 19, 2025

This PR focuses on a new diagnostics service for firmware_uefi.

UEFI will write the GPA of the advanced logger buffer (which we formally call EFI Diagnostics here) to an Io port intercept called SET_EFI_DIAGNOSTICS_GPA.

UEFI will also write to a different Io port intercept called PROCESS_EFI_DIAGNOSTICS, which signals us to process the EFI Diagnostics buffer.

The diagnostics subsystem's role is to read into guest memory from the specified GPA, collect advanced logger entries and log them to our tracing facilities. This will get triggered by the following conditions:

  • UEFI encounters a failure (guest driven via PROCESS_EFI_DIAGNOSTICS)
  • UEFI fails to boot any device (guest driven via PROCESS_EFI_DIAGNOSTICS)
  • UEFI reaches exit boot services

@maheeraeron maheeraeron marked this pull request as ready for review April 20, 2025 03:02
@maheeraeron maheeraeron requested review from a team as code owners April 20, 2025 03:02
@maheeraeron maheeraeron changed the title [WIP] Parse and Log the EFI Diagnostics Buffer Parse and Log the EFI Diagnostics Buffer Apr 20, 2025
@maheeraeron maheeraeron changed the title Parse and Log the EFI Diagnostics Buffer [WIP] Parse and Log the EFI Diagnostics Buffer Apr 20, 2025
use zerocopy::Immutable;
use zerocopy::KnownLayout;

// Advanced Logger Info signature
Copy link
Member

Choose a reason for hiding this comment

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

use /// doc comments here, please. Also, can we require doc comments?

@maheeraeron maheeraeron requested a review from jstarks May 13, 2025 23:16
return Err(EntryParseError::Timestamp(entry.time_stamp));
}

// Validate the message length
Copy link
Member

Choose a reason for hiding this comment

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

I suggest leaving out comments that don't say anything more than what the code is obviously doing.

/// UEFI Advanced Logger Info Header, which is shared
/// with the Advanced Logger Package in UEFI. The entries
/// live right after.
#[repr(C, packed)]
Copy link
Member

Choose a reason for hiding this comment

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

Why is this packed? It looks like it has natural alignment for all fields. Marking it packed just makes more work for yourself since you can't take references to fields inside it.

}

// Process any remaining accumulated message
if is_accumulating && !accumulated_message.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

This chunk of code is duplicated. Find a way to avoid this duplication (e.g., define a closure and call that closure in the two places).

@maheeraeron maheeraeron requested a review from jstarks May 16, 2025 20:32
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.

5 participants