Conversation
Add initramfs_filepath and initramfs_load_paddr JSON fields to zone_start_from_json. When both fields are present, the initramfs image is loaded to the specified physical address using the existing HVISOR_LOAD_IMAGE ioctl, similar to how kernel and dtb are loaded. This is architecture-independent and does not require changes to zone_config_t or CONFIG_MAGIC_VERSION.
Remove anonymous block, fix line breaking and indentation to match the project's LLVM-based clang-format style (4-space indent).
|
Thank you for this contribution! I took a close look at the existing code, and I believe the current The "modules": [
{
"name": "initramfs",
"filepath": "./initramfs.cpio.gz",
"load_paddr": "0x87e00000"
}
]This approach is more flexible - you can load multiple initramfs images or other firmware files - and it avoids adding redundant configuration keys that might confuse users about which method to use. I'd suggest closing this PR and, if needed, documenting or adding an example showing how to load an initramfs via On a related note, I think we might also consider moving Thanks again for your interest in improving hvisor, and I hope this feedback is helpful! |
|
Thank you for the detailed review! You're absolutely right - the I'll close this PR and update the hvisor-side configuration to use "modules": [
{
"name": "initramfs",
"filepath": "./initramfs.cpio.gz",
"load_paddr": "0x87e00000"
}
]The suggestion to eventually move Thanks again for the guidance! |
|
Thank you for the review! You're absolutely right - the existing Example usage: "modules": [
{
"name": "initramfs",
"filepath": "./initramfs.cpio.gz",
"load_paddr": "0x87e00000"
}
]Thanks for the guidance! |
Overview
Add initramfs loading support to hvisor-tool, enabling zones to load initramfs images via the
HVISOR_LOAD_IMAGEioctl, similar to how kernel and DTB images are currently loaded.Changes
tools/hvisor.cAdded
initramfs_filepathandinitramfs_load_paddrJSON field parsing inzone_start_from_json(). When both fields are present, the initramfs image is loaded to the specified physical address using the existingload_image_to_memory()function (which callsHVISOR_LOAD_IMAGEioctl).Key Design Decisions
Architecture-independent: The initramfs loading is not in
arch_configbut at the top level of the JSON config, making it work for all architectures (ARM64, RISC-V, x86_64, LoongArch64).No struct changes: No changes to
zone_config_torCONFIG_MAGIC_VERSION. The initramfs is loaded separately to memory, and the guest discovers it via the DTBchosennode (linux,initrd-start/linux,initrd-end).Inspired by x86_64: The x86_64 architecture already has initrd loading in
arch_config. This PR makes the feature available to all architectures.Usage
Add the following fields to your zone JSON config:
{ "kernel_filepath": "./asterinas.bin", "dtb_filepath": "./zone1.dtb", "initramfs_filepath": "./initramfs.cpio.gz", "initramfs_load_paddr": "0x87e00000", "kernel_load_paddr": "0x84000000", "dtb_load_paddr": "0x83000000", "entry_point": "0x84000000" }Testing
The initramfs loading has been tested with Asterinas OS as zone1 on hvisor RISC-V (qemu-plic). The initramfs was successfully loaded to memory and the guest OS was able to access it via the DTB chosen node.
Related
-device loaderparameters.