diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-23 19:25:58 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-23 19:43:44 +0100 |
commit | 5100dabb9682bb021bb85beeae1c0fa23a5a6db5 (patch) | |
tree | bd10797e6b512aa825f87670785ff4df8ba50787 /Kernel/Arch | |
parent | 4172a46fb5d56dae53346728522ad4b8acbf9660 (diff) | |
download | serenity-5100dabb9682bb021bb85beeae1c0fa23a5a6db5.zip |
Kernel: Copy the kernel command line to a good location at boot
When building the kernel with -O2, we somehow ended up with the kernel
command line outside of the lower 8MB of physical memory. Since we don't
map that area in our initial page table setup, we would triple fault
when trying to parse the command line.
This patch sidesteps the issue by copying the (first 4KB of) the kernel
command line to a buffer in a known safe location at boot.
Diffstat (limited to 'Kernel/Arch')
-rw-r--r-- | Kernel/Arch/i386/Boot/boot.S | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Kernel/Arch/i386/Boot/boot.S b/Kernel/Arch/i386/Boot/boot.S index 717b3fd00a..e068815a60 100644 --- a/Kernel/Arch/i386/Boot/boot.S +++ b/Kernel/Arch/i386/Boot/boot.S @@ -31,6 +31,10 @@ stack_bottom: .skip 32768 stack_top: +.global kernel_cmdline +kernel_cmdline: +.skip 4096 + .section .page_tables, "aw", @nobits .align 4096 .global boot_pdpt @@ -93,6 +97,19 @@ start: cli cld + /* We don't know where the bootloader might have put the command line. + * It might be at an inconvenient location that we're not about to map, + * so let's just copy it to a convenient location while we have the whole + * memory space identity-mapped anyway. :^) + */ + + movl %ebx, %esi + addl $16, %esi + movl (%esi), %esi + movl $1024, %ecx + movl $(kernel_cmdline - 0xc0000000), %edi + rep movsl + /* clear pdpt */ movl $(boot_pdpt - 0xc0000000), %edi movl $1024, %ecx |