fix(initrd): pad each chained initrd to a 4-byte boundary

Chained initrds were concatenated back to back. Linux only finds a cpio
archive at a 4-byte aligned offset when it unpacks concatenated
initrds, so a compressed initramfs with an odd length followed by
another archive, like a microcode or overlay cpio, failed to unpack.
Pad each initrd with zeros to a 4-byte boundary, as GRUB and
systemd-boot do.
This commit is contained in:
alex authored and Alex Zenla committed 2026-09-26 20:52:15 -07:00
1 parent cd38f0271d
commit e96a5a64c9
3 files changed
+37 -4

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ use alloc::rc::Rc;
use alloc::vec::Vec;
use anyhow::{Context, Result, bail};
use edera_sprout_config::actions::chainload::ChainloadConfiguration;
use edera_sprout_parsing::{combine_options, empty_is_none};
use edera_sprout_parsing::{append_initrd, combine_options, empty_is_none};
use eficore::bootloader_interface::BootloaderInterface;
use eficore::loader::source::ImageSource;
use eficore::loader::{ImageLoadRequest, ImageLoader};
@@ -112,7 +112,7 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
continue;
};
match initrd.as_mut() {
Some(initrd) => initrd.extend_from_slice(&content),
Some(initrd) => append_initrd(initrd, &content),
None => initrd = Some(content),
}
}
+5 -2
View File
@@ -5,7 +5,7 @@ use alloc::{format, vec};
use anyhow::{Context, Result, bail};
use edera_sprout_config::actions::chainload::ChainloadConfiguration;
use edera_sprout_config::actions::edera::EderaConfiguration;
use edera_sprout_parsing::{build_xen_config, combine_options, empty_is_none};
use edera_sprout_parsing::{append_initrd, build_xen_config, combine_options, empty_is_none};
use eficore::media_loader::{
MediaLoaderHandle,
constants::xen::{
@@ -94,7 +94,10 @@ pub fn edera(context: Rc<SproutContext>, configuration: &EderaConfiguration) ->
.chain(configuration.initrd_chain.iter())
{
if let Some(p) = empty_is_none(Some(p)) {
initrd_bytes.extend(read_loader_payload(&context, "initrd", p)?);
append_initrd(
&mut initrd_bytes,
&read_loader_payload(&context, "initrd", p)?,
);
}
}
PlatformTpm::log_event(