SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.75k stars 3.18k forks source link

Kernel: Boot fails when built with -O0 #8951

Open gunnarbeutner opened 3 years ago

gunnarbeutner commented 3 years ago
[#0 init_stage2(1:1)]: VirtIOConsole: Found @ PCI [0000:00:03:00]
[#0 init_stage2(1:1)]: Trying to unregister unused handler (?)
[#0 init_stage2(1:1)]: VirtIOConsole: cols: 0, rows: 0, max nr ports 2
qemu-system-i386: Guest says index 60672 is available
[#0 init_stage2(1:1)]: VirtIOConsole: Handle device config change
[#0 init_stage2(1:1)]: Invalid queue_index 0
[#0 init_stage2(1:1)]: VirtIORNG: Found @ PCI [0000:00:04:00]
qemu-system-i386: Guest moved used index from 0 to 49483
[init_stage2(1:1)]: ASSERTION FAILED: false
[init_stage2(1:1)]: ../../Kernel/VirtIO/VirtIORNG.cpp:38 in virtual bool Kernel::VirtIORNG::handle_device_config_change()
[#0 init_stage2(1:1)]: 0xc0adebe1  abort +0x5c
[#0 init_stage2(1:1)]: 0xc0adeb85  abort +0x0
[#0 init_stage2(1:1)]: 0xc0a1d447  non-virtual thunk to Kernel::VirtIORNG::handle_device_config_change() +0x0
[#0 init_stage2(1:1)]: 0xc09fd4a1  Kernel::VirtIODevice::handle_irq(Kernel::RegisterState const&) +0x129
[#0 init_stage2(1:1)]: 0xc03011b1  Kernel::IRQHandler::handle_interrupt(Kernel::RegisterState const&) +0xaf
[#0 init_stage2(1:1)]: 0xc0663f8a  Kernel::SharedIRQHandler::handle_interrupt(Kernel::RegisterState const&) +0x1fa
[#0 init_stage2(1:1)]: 0xc0ae40fe  handle_interrupt +0x447
[#0 init_stage2(1:1)]: 0xc0e3e62b  interrupt_common_asm_entry +0x2b
[#0 init_stage2(1:1)]: 0xc09fa39c  Kernel::VirtIODevice::config_write8(Kernel::Configuration const&, unsigned int, unsigned char) +0x122
[#0 init_stage2(1:1)]: 0xc09fadd3  Kernel::VirtIODevice::set_status_bit(unsigned char) +0x2ab
[#0 init_stage2(1:1)]: 0xc09fd228  Kernel::VirtIODevice::finish_init() +0x1b8
[#0 init_stage2(1:1)]: 0xc0c93560  Kernel::VirtIORNG::VirtIORNG(Kernel::PCI::Address) +0x4a4
[#0 init_stage2(1:1)]: 0xc09f8d05  Kernel::VirtIO::detect()::{lambda(Kernel::PCI::Address const&, Kernel::PCI::ID)#1}::operator()(Kernel::PCI::Address const&, Kernel::PCI::ID) const +0x83d
[#0 init_stage2(1:1)]: 0xc09fe118  AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>::CallableWrapper<Kernel::VirtIO::detect()::{lambda(Kernel::PCI::Address const&, Kernel::PCI::ID)#1}>::call(Kernel::PCI::Address, Kernel::PCI::ID) +0xee
[#0 init_stage2(1:1)]: 0xc033214d  AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>::operator()(Kernel::PCI::Address, Kernel::PCI::ID) const +0x295
[#0 init_stage2(1:1)]: 0xc032a7de  Kernel::PCI::Access::enumerate(AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>&) const +0x394
[#0 init_stage2(1:1)]: 0xc032a871  Kernel::PCI::enumerate(AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>) +0x45
[#0 init_stage2(1:1)]: 0xc0c9001c  Kernel::VirtIO::detect() +0x78
[#0 init_stage2(1:1)]: 0xc0ac51f0  Kernel::init_stage2(void*) +0x1bd3
[#0 init_stage2(1:1)]: 0xc0ae9fa0  exit_kernel_thread +0x0

And after commenting that out:

[#0 init_stage2(1:1)]: VirtIOConsole: cols: 0, rows: 0, max nr ports 2
qemu-system-i386: Guest says index 60672 is available
[#0 init_stage2(1:1)]: VirtIOConsole: Handle device config change
[#0 init_stage2(1:1)]: Invalid queue_index 0
[#0 init_stage2(1:1)]: VirtIORNG: Found @ PCI [0000:00:04:00]
qemu-system-i386: Guest moved used index from 0 to 49483
[#0 init_stage2(1:1)]: CPU[0] BUG! Page fault while handling IRQ! code=0, vaddr=V0xd8bee00c, irq level: 1
[#0 init_stage2(1:1)]: Kernel regions:
[#0 init_stage2(1:1)]: BEGIN         END        SIZE       ACCESS NAME
[#0 init_stage2(1:1)]: 0xc2c03000 -- 0xc2d02fff 0x00100000 RW     kmalloc subheap
[#0 init_stage2(1:1)]: 0xc2d06000 -- 0xc2d06fff 0x00001000 RW     HPET MMIO
[#0 init_stage2(1:1)]: 0xc2d08000 -- 0xc2d08fff 0x00001000 R    C Signal trampolines
[#0 init_stage2(1:1)]: 0xc2d0a000 -- 0xc2d19fff 0x00010000 RW  T  Kernel stack (thread 0)
[#0 init_stage2(1:1)]: 0xc2d1b000 -- 0xc2d2afff 0x00010000 RW  T  Kernel stack (thread 1)
[#0 init_stage2(1:1)]: 0xc2d2c000 -- 0xc2d3bfff 0x00010000 RW  T  Kernel stack (thread 2)
[#0 init_stage2(1:1)]: 0xc2d3d000 -- 0xc2d3dfff 0x00001000 RW     VGA font
[#0 init_stage2(1:1)]: 0xc2d3f000 -- 0xc2d3ffff 0x00001000 RW     
[#0 init_stage2(1:1)]: 0xc3042000 -- 0xc3341fff 0x00300000 RW     Framebuffer Console
[#0 init_stage2(1:1)]: 0xc3343000 -- 0xc3942fff 0x00600000 RW     Framebuffer
[#0 init_stage2(1:1)]: 0xc3944000 -- 0xc3f43fff 0x00600000 RW     Framebuffer Swap (Blank)
[#0 init_stage2(1:1)]: 0xc2d41000 -- 0xc2dd0fff 0x00090000 RW     Virtual Console Cells
[#0 init_stage2(1:1)]: 0xc2dd2000 -- 0xc2e61fff 0x00090000 RW     Virtual Console Cells
[#0 init_stage2(1:1)]: 0xc2e63000 -- 0xc2ef2fff 0x00090000 RW     Virtual Console Cells
[#0 init_stage2(1:1)]: 0xc2ef4000 -- 0xc2f83fff 0x00090000 RW     Virtual Console Cells
[#0 init_stage2(1:1)]: 0xc2f85000 -- 0xc3014fff 0x00090000 RW     Virtual Console Cells
[#0 init_stage2(1:1)]: 0xc3f45000 -- 0xc3fd4fff 0x00090000 RW     Virtual Console Cells
[#0 init_stage2(1:1)]: 0xc3016000 -- 0xc3025fff 0x00010000 RW  T  Kernel stack (thread 3)
[#0 init_stage2(1:1)]: 0xc3027000 -- 0xc3036fff 0x00010000 RW  T  Kernel stack (thread 4)
[#0 init_stage2(1:1)]: 0xc3038000 -- 0xc3038fff 0x00001000  W     UHCI Framelist
[#0 init_stage2(1:1)]: 0xc303a000 -- 0xc303bfff 0x00002000  W     UHCI Queue Head Pool
[#0 init_stage2(1:1)]: 0xc303d000 -- 0xc303efff 0x00002000  W     UHCI Transfer Descriptor Pool
[#0 init_stage2(1:1)]: 0xc3fd6000 -- 0xc3fe5fff 0x00010000 RW  T  Kernel stack (thread 5)
[#0 init_stage2(1:1)]: 0xc3fe7000 -- 0xc3feafff 0x00004000 RW     VirtIO MMIO
[#0 init_stage2(1:1)]: 0xc3fec000 -- 0xc3fecfff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: 0xc3fee000 -- 0xc3feefff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: 0xc3ff0000 -- 0xc3ff0fff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: 0xc3ff2000 -- 0xc3ff2fff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: 0xc3ff4000 -- 0xc3ff4fff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: 0xc3ff6000 -- 0xc3ff6fff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: 0xc3ff8000 -- 0xc3ff8fff 0x00001000 RW     VirtIOConsole control receive queue
[#0 init_stage2(1:1)]: 0xc3ffa000 -- 0xc3ffafff 0x00001000 RW     VirtIOConsole control transmit queue
[#0 init_stage2(1:1)]: 0xc3ffc000 -- 0xc3ffffff 0x00004000 RW     VirtIO MMIO
[#0 init_stage2(1:1)]: 0xc4001000 -- 0xc4001fff 0x00001000 RW     VirtIO Queue
[#0 init_stage2(1:1)]: Unrecoverable page fault, read from address V0xd8bee00c
[init_stage2(1:1)]: CRASH: CPU #0 Page Fault in ring 0
[#0 init_stage2(1:1)]: Exception code: 0000 (isr: 0000)
[#0 init_stage2(1:1)]:     pc=0x0008:0xc0a1730d eflags=0x00010097
[#0 init_stage2(1:1)]:  stack=0x0010:0xc2d2a544
[#0 init_stage2(1:1)]:     ds=0x0010 es=0x0010 fs=0x0000 gs=0x0030
[#0 init_stage2(1:1)]:    eax=0xc14bed00 ebx=0xc14bed00 ecx=0x00000001 edx=0xd8bee000
[#0 init_stage2(1:1)]:    ebp=0xc2d2a58c esp=0xc2d2a544 esi=0xd8bee000 edi=0x14bed000
[#0 init_stage2(1:1)]:    cr0=0x80010013 cr2=0xd8bee00c cr3=0x039b3000 cr4=0x00340ee4
[init_stage2(1:1)]: KERNEL PANIC! :^(
[init_stage2(1:1)]: Crash in ring 0
[init_stage2(1:1)]: at ../../Kernel/Arch/x86/common/Interrupts.cpp:228 in void Kernel::handle_crash(const Kernel::RegisterState&, const char*, int, bool)
[#0 init_stage2(1:1)]: 0xc0773aec  Kernel::__panic(char const*, unsigned int, char const*) +0x7b
[#0 init_stage2(1:1)]: 0xc0ae0e3f  Kernel::handle_crash(Kernel::RegisterState const&, char const*, int, bool) +0x306
[#0 init_stage2(1:1)]: 0xc0ae2479  page_fault_handler +0x126f
[#0 init_stage2(1:1)]: 0xc0ae1161  page_fault_asm_entry +0x30
[#0 init_stage2(1:1)]: 0xc0a1d5cd  Kernel::VirtIORNG::handle_queue_update(unsigned short) +0x12f
[#0 init_stage2(1:1)]: 0xc09fd716  Kernel::VirtIODevice::handle_irq(Kernel::RegisterState const&) +0x39e
[#0 init_stage2(1:1)]: 0xc03011b1  Kernel::IRQHandler::handle_interrupt(Kernel::RegisterState const&) +0xaf
[#0 init_stage2(1:1)]: 0xc0663f8a  Kernel::SharedIRQHandler::handle_interrupt(Kernel::RegisterState const&) +0x1fa
[#0 init_stage2(1:1)]: 0xc0ae40e2  handle_interrupt +0x447
[#0 init_stage2(1:1)]: 0xc0e3e5eb  interrupt_common_asm_entry +0x2b
[#0 init_stage2(1:1)]: 0xc09fa39c  Kernel::VirtIODevice::config_write8(Kernel::Configuration const&, unsigned int, unsigned char) +0x122
[#0 init_stage2(1:1)]: 0xc09fadd3  Kernel::VirtIODevice::set_status_bit(unsigned char) +0x2ab
[#0 init_stage2(1:1)]: 0xc09fd228  Kernel::VirtIODevice::finish_init() +0x1b8
[#0 init_stage2(1:1)]: 0xc0c93560  Kernel::VirtIORNG::VirtIORNG(Kernel::PCI::Address) +0x4a4
[#0 init_stage2(1:1)]: 0xc09f8d05  Kernel::VirtIO::detect()::{lambda(Kernel::PCI::Address const&, Kernel::PCI::ID)#1}::operator()(Kernel::PCI::Address const&, Kernel::PCI::ID) const +0x83d
[#0 init_stage2(1:1)]: 0xc09fe118  AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>::CallableWrapper<Kernel::VirtIO::detect()::{lambda(Kernel::PCI::Address const&, Kernel::PCI::ID)#1}>::call(Kernel::PCI::Address, Kernel::PCI::ID) +0xee
[#0 init_stage2(1:1)]: 0xc033214d  AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>::operator()(Kernel::PCI::Address, Kernel::PCI::ID) const +0x295
[#0 init_stage2(1:1)]: 0xc032a7de  Kernel::PCI::Access::enumerate(AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>&) const +0x394
[#0 init_stage2(1:1)]: 0xc032a871  Kernel::PCI::enumerate(AK::Function<void (Kernel::PCI::Address, Kernel::PCI::ID)>) +0x45
[#0 init_stage2(1:1)]: 0xc0c9001c  Kernel::VirtIO::detect() +0x78
[#0 init_stage2(1:1)]: 0xc0ac51d6  Kernel::init_stage2(void*) +0x1bd3
[#0 init_stage2(1:1)]: 0xc0ae9f84  exit_kernel_thread +0x0

And with disable_virtio:

[init_stage2(1:1)]: AHCI Port 6: Device not detected, Phy not enabled
[#0 init_stage2(1:1)]: Master Boot Record: invalid signature
[init_stage2(1:1)]: VirtualFileSystem: mounted root from Ext2FS (/dev/hda)
[init_stage2(1:1)]: Unmapped 892 KiB of kernel text after init! :^)
[init_stage2(1:1)]: Unmapped 5120 KiB of kernel symbols after init! :^)
[#0 IO WorkQueue(2:2)]: Exception code: 0003 (isr: 0000)
[#0 IO WorkQueue(2:2)]:     pc=0x0008:0xc06703b4 eflags=0x00010016
[#0 IO WorkQueue(2:2)]:  stack=0x0010:0xc2d3bac8
[#0 IO WorkQueue(2:2)]:     ds=0x0010 es=0x0010 fs=0x0000 gs=0x0030
[#0 IO WorkQueue(2:2)]:    eax=0xc14bed00 ebx=0xc14bed00 ecx=0x00000340 edx=0xc14bed00
[#0 IO WorkQueue(2:2)]:    ebp=0xc2d3baf0 esp=0xc2d3bac8 esi=0xc40d7300 edi=0xc14bf000
[#0 IO WorkQueue(2:2)]:    cr0=0x80010013 cr2=0xc14bf000 cr3=0x0399f000 cr4=0x00340ee4
[IO WorkQueue(2:2)]: KERNEL PANIC! :^(
[IO WorkQueue(2:2)]: Attempt to write into READONLY_AFTER_INIT section
[IO WorkQueue(2:2)]: at ../../Kernel/Arch/x86/common/Interrupts.cpp:321 in void Kernel::page_fault_handler(Kernel::TrapFrame*)
[#0 IO WorkQueue(2:2)]: 0xc0773aec  Kernel::__panic(char const*, unsigned int, char const*) +0x7b
[#0 IO WorkQueue(2:2)]: 0xc0ae1729  page_fault_handler +0x51f
[#0 IO WorkQueue(2:2)]: 0xc0ae1161  page_fault_asm_entry +0x30
[#0 IO WorkQueue(2:2)]: 0xc09f7fdc  Kernel::UserOrKernelBuffer::write(void const*, unsigned long, unsigned long) +0x1c4
[#0 IO WorkQueue(2:2)]: 0xc0315c1f  Kernel::UserOrKernelBuffer::write(void const*, unsigned long) +0x47
[#0 IO WorkQueue(2:2)]: 0xc04b3210  bool Kernel::AsyncDeviceRequest::write_to_buffer<unsigned char*, unsigned int>(Kernel::UserOrKernelBuffer&, unsigned char*, unsigned int) +0x132
[#0 IO WorkQueue(2:2)]: 0xc04aaafe  Kernel::BMIDEChannel::complete_current_request(Kernel::AsyncDeviceRequest::RequestResult)::{lambda()#1}::operator()() const +0xde2
[#0 IO WorkQueue(2:2)]: 0xc04b204b  AK::Function<void ()>::CallableWrapper<Kernel::BMIDEChannel::complete_current_request(Kernel::AsyncDeviceRequest::RequestResult)::{lambda()#1}>::call() +0x87
[#0 IO WorkQueue(2:2)]: 0xc04dab0b  AK::Function<void ()>::operator()() const +0x209
[#0 IO WorkQueue(2:2)]: 0xc0ac1f6b  Kernel::WorkQueue::WorkQueue(char const*)::{lambda()#1}::operator()() const +0x28b
[#0 IO WorkQueue(2:2)]: 0xc0ac2462  void Kernel::Process::kernel_process_trampoline<Kernel::WorkQueue::WorkQueue(char const*)::{lambda()#1}>(void*) +0x47
[#0 IO WorkQueue(2:2)]: 0xc0ae9f84  exit_kernel_thread +0x0
BertalanD commented 3 years ago

Crashes with Clang too, but at an unrelated place:

[NetworkTask(7:7)]: NetworkTask: E1000NetworkAdapter network adapter found: hw=52:54:00:12:34:56
[NetworkTask(7:7)]: NetworkTask: E1000NetworkAdapter network adapter found: hw=52:54:00:12:34:57
[NetworkTask(7:7)]: NetworkTask: LoopbackAdapter network adapter found: hw=13:55:02:09:55:aa
[#0 colonel(0:0)]: Unrecoverable page fault, write to address V0x01119bd0
[colonel(0:0)]: CRASH: CPU #0 Page Fault in ring 0
[#0 colonel(0:0)]: Exception code: 0002 (isr: 0000)
[#0 colonel(0:0)]:     pc=0x0008:0xc0dca958 eflags=0x00015082
[#0 colonel(0:0)]:  stack=0x0010:0xc3119ba0
[#0 colonel(0:0)]:     ds=0x0010 es=0x0010 fs=0x0000 gs=0x0030
[#0 colonel(0:0)]:    eax=0xc21cc870 ebx=0xc3119bd0 ecx=0xc1fd86e4 edx=0x01119bd0
[#0 colonel(0:0)]:    ebp=0xc3119bd0 esp=0xc3119ba0 esi=0xc2003ba4 edi=0xc200cfe4
[#0 colonel(0:0)]:    cr0=0x80010013 cr2=0x01119bd0 cr3=0x03dcf000 cr4=0x00340ee4
[colonel(0:0)]: KERNEL PANIC! :^(
[colonel(0:0)]: Crash in ring 0
[colonel(0:0)]: at ./Kernel/Arch/x86/common/Interrupts.cpp:229 in void Kernel::handle_crash(const Kernel::RegisterState &, const char *, int, bool)