Is there an easy way for a running payload to extract additional files from its CBFS image in ROM? I'd like to have a reproducible kernel and initrd as the primary payload, with user data (and keys) stored in a separate payload section of the CBFS.
On the build host I can use cbfstool to add/extract them from the file, but I'm not seeing an easy way to do it on the running machine short of 'dd if=/dev/mem' at the correct address.
On Wed, Apr 12, 2017 at 08:51:11AM -0600, Trammell Hudson wrote:
[...] On the build host I can use cbfstool to add/extract them from the file, but I'm not seeing an easy way to do it on the running machine short of 'dd if=/dev/mem' at the correct address.
Which works on real hardware, but fails with "bad address" on qemu. So even that work-around doesn't work for testing purposes.
On 2017-04-12 07:51, Trammell Hudson wrote:
Is there an easy way for a running payload to extract additional files from its CBFS image in ROM? I'd like to have a reproducible kernel and initrd as the primary payload, with user data (and keys) stored in a separate payload section of the CBFS.
On the build host I can use cbfstool to add/extract them from the file, but I'm not seeing an easy way to do it on the running machine short of 'dd if=/dev/mem' at the correct address.
-- Trammell
I have always wondered why payload_load() has a hard-wired payload filename.
For internal test-purposes we have created cbfs containers with multiple payload files. payload_load() can either be parameterized or cloned and renamed for each payload.
The simple solution that I would try is in ramstage load the secondary files and add them to the coreboot tables passed to depthcharge. Depthcharge has access to the payload data without having to actually load them because they are already loaded.
If you are using another payload, I assume they use similar mechanism to receive the coreboot tables.
Of course if this is production code parameterizing payload_load() would have to be discussed on the list... Cheers, T.mike
Is there an easy way for a running payload to extract additional files from its CBFS image in ROM? I'd like to have a reproducible kernel and initrd as the primary payload, with user data (and keys) stored in a separate payload section of the CBFS.
On the build host I can use cbfstool to add/extract them from the file, but I'm not seeing an easy way to do it on the running machine short of 'dd if=/dev/mem' at the correct address.
If you were talking about a "normal" payload (linking libpayload) that would be easy... there's plenty of CBFS APIs in libpayload (cbfs_find_file() would be the simplest for this case).
But it sounds like you're using a Linux kernel as payload? Then I'm afraid you're restricted to the normal ways that Linux can use to access the firmware flash... flashrom it out and use cbfstool extract (which should work on a real system, not so sure about qemu). Depending on what exactly you're trying to do, it may be easier to just include your data in an initramfs instead.