Hello coreboot community,

For our work on POWER9 coreboot port we were using Skiboot [1] packed into
FIT payload. While it worked fine, we wanted to provide users with easier
way of testing it on hardware. I believe it may be possible to modify only
one of PNOR (fancy name for flash given by POWER people) partitions.
In order to do this, we would have to fit whole CBFS into 512k (actually
1M including ECC, but that would require non-power-of-2 size), which
should be doable with LTO and compressed payload.

According to [2], whole file compression is not available for FIT payloads.
I understand that this makes sense, thanks to this we can decompress/load
individual parts of payload (e.g. kernel and initramfs) once, otherwise we
would have to decompress it to read metadata first and then move code
around in memory.

However, FIT format doesn't hold information about uncompressed sizes of
its components, required by decompressing functions in coreboot. Instead,
their compressed sizes [3] are used to initialize output region sizes [4]
and those are then passed to decompressors [5]. Only FDT has a workaround
to this problem [6], and kernel's size is calculated in an arm64-specific
way in [7]. On other architectures components (other than FDT) are
partially decompressed until they run of of space, silently ignoring the
rest.

What should be "the proper way" of getting uncompressed size? I can think
of the following options, listed in no particular order:

1. Extend hack used for FDT to other components, use it for all compressed
   parts. Arbitrary size multiplier may either waste some space potentially
   overlapping other component's memory range or not be enough in edge
   cases (e.g. mostly zeroed file).

2. For LZMA you may get decompressed size from the header, unfortunately
   this is not possible with LZ4.

3. Dry decompression just to check proper size - sounds too costly.

4. New properties for components' nodes in ITS file. May need changes in
   mkimage, haven't looked yet. Preferably shouldn't have to be manually
   written to ITS as that would be prone to error. While playing with
   mkimage, may add automatic compression, right now it expects already
   compressed files in ITS, although this can also be scripted.

5. Add more arch- and payload-specific parsing of images, as was done for
   arm64. This may require some kind of mark that a payload needs special
   handling (new CBFS attribute maybe?)

6. Enable whole file compression of FIT payloads, which results in juggling
   in RAM.

7. Mix of the above.

For our current issue we can also load Skiboot from another PNOR partition
(from where it is normally loaded by Hostboot [8] which we are basically
substituting with coreboot) and manually create FDT for it. This would
however break normal coreboot boot flow and we would like to avoid that.

[1] https://github.com/open-power/skiboot
[2] https://doc.coreboot.org/lib/payloads/fit.html#supported-compression
[3] https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/lib/fit.c#122 [4] https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/lib/fit_payload.c#211 [5] https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/lib/fit_payload.c#67 [6] https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/lib/fit_payload.c#96 [7] https://review.coreboot.org/plugins/gitiles/coreboot/+/refs/heads/master/src/arch/arm64/fit_payload.c#84
[8] https://github.com/open-power/hostboot

--
Krystian Hebel
Firmware Engineer
https://3mdeb.com | @3mdeb_com

_______________________________________________
coreboot mailing list -- coreboot@coreboot.org
To unsubscribe send an email to coreboot-le...@coreboot.org

Reply via email to