Booting with the initrd.img ram drive from media_setup does not work. The screen output after the startup messages is:
PANIC: in init_init()
can't find /sbin/init
Fiwix version: current git code a542c56
How to reproduce:
qemu-system-x86_64 \
-kernel fiwix \
-initrd initrd.img \
-append "root=/dev/ram0 ramdisksize=1024 initrd=initrd.img"
Qemu places the initrd image right after the kernel, as a multiboot module. The problem is that get_last_boot_addr is not accounting for the initrd module. Well it is, but then some newer code from April 29th can move the last address back down to right after the kernel, just below the initrd module. Then, kernel stack and data structures will overwrite the initrd image.
If I move that code above the multiboot module adjustments, the kernel boots ok:
--- a/kernel/multiboot.c
+++ b/kernel/multiboot.c
@@ -177,6 +177,11 @@ unsigned int get_last_boot_addr(unsigned int info)
addr = strtab->sh_addr + strtab->sh_size;
+ /* no ELF header tables */
+ if(!(mbi->flags & MULTIBOOT_INFO_ELF_SHDR)) {
+ addr = (unsigned int)_end + PAGE_SIZE;
+ }
+
/*
* https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
*
@@ -190,11 +195,6 @@ unsigned int get_last_boot_addr(unsigned int info)
}
}
- /* no ELF header tables */
- if(!(mbi->flags & MULTIBOOT_INFO_ELF_SHDR)) {
- addr = (unsigned int)_end + PAGE_SIZE;
- }
-
return P2V(addr);
}
Booting with the initrd.img ram drive from media_setup does not work. The screen output after the startup messages is:
Fiwix version: current git code a542c56
How to reproduce:
Qemu places the initrd image right after the kernel, as a multiboot module. The problem is that get_last_boot_addr is not accounting for the initrd module. Well it is, but then some newer code from April 29th can move the last address back down to right after the kernel, just below the initrd module. Then, kernel stack and data structures will overwrite the initrd image.
If I move that code above the multiboot module adjustments, the kernel boots ok: