Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boot with ram drive not working #7

Closed
rick-masters opened this issue Nov 14, 2022 · 1 comment
Closed

Boot with ram drive not working #7

rick-masters opened this issue Nov 14, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@rick-masters
Copy link
Contributor

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);
 }
@mikaku mikaku self-assigned this Nov 14, 2022
@mikaku mikaku added the bug Something isn't working label Nov 14, 2022
@mikaku
Copy link
Owner

mikaku commented Nov 15, 2022

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants