Skip to content

[patina::pi::hob] Adjust hob misc design - #1752

Open
yangrongwei wants to merge 1 commit into
OpenDevicePartnership:mainfrom
uefi-lab:adjust_hob_misc_design
Open

yangrongwei wants to merge 1 commit into
OpenDevicePartnership:mainfrom
uefi-lab:adjust_hob_misc_design

Conversation

@yangrongwei

@yangrongwei yangrongwei commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Refactor the Hob::Misc design.

Introduce hob::GenericHob to hold the HOB generic header for Hob::Misc.

Per the PI spec, HOB is an open design, and all HOBs share a common header. Binding to a generic header is more intuitive than using a heterogeneous integer representation.

Bug Fix:
Introduce hob::EndOfHobList for unit tests, this is the correct struct for end-of-hob per PI Spec.
Correct related unit tests to use hob::EndOfHobList

Code Enhancement:
Add align(8) for hob::HobHeader. This is optional for consumers, but following PI Spec is not a bad choice.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Pass cargo make test

Integration Instructions

N/A

@patina-automation

Copy link
Copy Markdown
Contributor

⌛ QEMU Validation Pending

QEMU validation is pending on successful CI completion.

Note: Any previous results are available in this comment's edit history.

This comment was automatically generated by the Patina QEMU PR Validation workflow.

@github-actions github-actions Bot added impact:non-functional Does not have a functional impact impact:testing Affects testing labels Aug 21, 2026
@yangrongwei

Copy link
Copy Markdown
Contributor Author

Original bug, #1748

@os-d os-d linked an issue Aug 21, 2026 that may be closed by this pull request
1 task done
@os-d
os-d self-requested a review August 21, 2026 17:34
Comment thread sdk/patina/src/pi/hob/hob_list.rs Resolved
Comment thread sdk/patina/src/pi/hob/hob_list.rs Resolved
Comment thread sdk/patina/src/pi/hob/hob_list.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob/hob_list.rs Resolved
Comment thread sdk/patina/src/pi/hob/hob_list.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob/hob_list.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
Comment thread sdk/patina/src/pi/hob.rs Resolved
@github-actions github-actions Bot added the type:documentation Improvements or additions to documentation label Aug 28, 2026
Comment thread sdk/patina/src/pi/hob.rs
/// - MEMORY_POOL
/// - UNUSED
/// - LOAD_PEIM_UNUSED
Misc(&'a GenericHob),

@Javagedes Javagedes Aug 31, 2026 •

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.

There may have been conversation around this, so let me know if so, but If I'm understanding correctly, the Misc hob is incredibly close to the GuidHob. Due to this, I'm not a fan of the fact that we just give the user the header, and it is up to the caller to unsafe-ly extract any bytes after the header if the length exceeds the length of a header. I also don't think we should be using GenericHob. In my opinion it should just be a HobHeader.

I personally think it makes more sense for this enum variable to be below, where our code takes on the burden of extracting the bytes after the header:

Misc(&'a Hobheader, &'a [u8])

Comment thread sdk/patina/src/pi/hob.rs
}
END_OF_HOB_LIST => return None,
hob_type => Hob::Misc(hob_type),
MEMORY_POOL | LOAD_PEIM_UNUSED | UNUSED => {

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.

Here we would do something similar to GUID_EXTENSION and call the slice::from_raw_parts(data_ptr, data_len for the user.

Comment thread sdk/patina/src/pi/hob.rs
///
#[repr(C)]
#[derive(Debug)]
pub struct GenericHob {

@Javagedes Javagedes Aug 31, 2026 •

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.

I don't see a need for GenericHob. It feels like we should just use the HobHeader directly - via the usage I described above.

@yangrongwei
yangrongwei force-pushed the adjust_hob_misc_design branch 3 times, most recently from 5e18cfd to ba08e3e Compare October 29, 2026 10:45
@yangrongwei
yangrongwei force-pushed the adjust_hob_misc_design branch from ba08e3e to e8e79d5 Compare October 29, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:non-functional Does not have a functional impact impact:testing Affects testing type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Question for patina::pi::hob::Hob

5 participants