0

With QEMU, I can use either use -initrd '${images_dir}/rootfs.cpio for the initrd, or pass the initramfs image directly to -kernel Image.

But if I try the initramfs image with gem5 fs.py --kernel Image it fails with:

fatal: Could not load kernel file

with the exact same initramfs kernel image that QEMU was able to consume.

And I don't see an analogue to -initrd.

The only method that I got to work was to pass an ext2 disk image to --disk-image with the raw vmlinux.

https://www.mail-archive.com/gem5-users@gem5.org/msg15198.html

Ciro Santilli
  • 3,693
  • 1
  • 18
  • 44

1 Answers1

0

initrd appears unimplemented on arm and x86 at least, since gem5 must know how to load it and inform the kernel about it's location, and grepping initrdonly shows some ARM hits under:

src/arch/arm/linux/atag.hh

but they are commented out.

Communicating the initrd to the kernel now appears to be simply doable via the DTB chosen node linux,initrd-start and linux,initrd-end properties, so it might be very easy to implement: https://www.kernel.org/doc/Documentation/devicetree/bindings/chosen.txt (and gem5's existing DTB auto generation) + reusing the infrastructure to load arbitrary bytes to a memory location: How to preload memory with given raw bytes in gem5 from the command line in addition to the main ELF executable?

Initramfs doesn't work because gem5 can only boot from vmlinux which is the raw ELF file, and the initramfs images only gets attached by the kernel build to a more final image type like Image or bzImage which QEMU can use to boot, see also: https://unix.stackexchange.com/questions/5518/what-is-the-difference-between-the-following-kernel-makefile-terms-vmlinux-vml/482978#482978

Edit: the following is not needed anymore after the patch mentioned at: How to attach multiple disk images in a simulation with gem5 fs.py? To do this test, I also had to pass a dummy disk image as of gem5 7fa4c946386e7207ad5859e8ade0bbfc14000d91 since the scripts don't handle a missing --disk-image well, you can just dump some random 512 bytes and use them:

dd if=/dev/zero of=dummy.iso bs=512 count=1
Ciro Santilli
  • 3,693
  • 1
  • 18
  • 44