Skip to content
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

Add support for a LoadOpt Hive #678

Open
hughsie opened this issue Aug 9, 2024 · 2 comments
Open

Add support for a LoadOpt Hive #678

hughsie opened this issue Aug 9, 2024 · 2 comments
Assignees

Comments

@hughsie
Copy link

hughsie commented Aug 9, 2024

Right now we can only store a UCS2-LE path in the loadopt data for Shim to consume. We now also need to provide that, and a way for customers to add and remove options for kernel command line if we want to remove grub with a 1st stage switchroot/kexec-able kernel like shim.

The other problem is that real-world broken firmware sometimes pads or offsets the loadopt data meaning that we can’t parse strings reliably. We should also make sure that the data inside the hive has not been corrupted, but do not need to cryptographically sign it.

We could create a hive, similar to the BCD hive found in Windows, that includes an extensible and robust key value store:

struct ShimHive {
    magic: [u8; 4],      // “HIVE”
    header_version: u8,  // 0x01
    items_count: u8,     // number of items to parse
    items_offset: u8,    // for forwards and backwards compatibility
    crc32: u32,          // of the entire hive (excluding padding)
    items: [ShimHiveItems; items_count]
}
struct ShimHiveItem {
    key_length: u8,
    value_length: u32,
    // key string, no trailing NUL
    // value string, no trailing NUL
}
  • We should start parsing ShimHiveItem from offset ShimHive.items_offset to allow us to add more header items to ShimHive in the future without breaking ABI.
  • The ShimHive should normally be padded out to 512 bytes to ensure that SetVariable writes are as atomic as possible. The padding should be NUL characters.
  • If the hive is not present in the loadopt then it is loaded from the ESP, if it exists – perhaps in /EFI/$x/shim.env (normal path mangling like for second stage etc). This allows us to workaround hardware bugs and still boot an installer.
@hughsie hughsie self-assigned this Aug 9, 2024
@hughsie
Copy link
Author

hughsie commented Sep 10, 2024

@vathpela what did you call the key for the path? i.e. the UCS-2 thing we store already? i.e. Path, PATH etc?

@vathpela
Copy link
Contributor

path and cmdline are the two I've got defined so far.

hughsie added a commit to fwupd/fwupd that referenced this issue Sep 10, 2024
hughsie added a commit to fwupd/fwupd that referenced this issue Sep 10, 2024
hughsie added a commit to fwupd/fwupd that referenced this issue Oct 1, 2024
hughsie added a commit to fwupd/fwupd that referenced this issue Oct 1, 2024
hughsie added a commit to fwupd/fwupd that referenced this issue Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants