QEMU Crashes When Loading Kernel

16,683

The suggestion made by Ben Voigt is not your problem. I have the exact same output when I run my kernel and it doesn't cause any problems.

The reason QEMU aborts is the following:

qemu: fatal: Trying to execute code outside RAM or ROM at 0x000a0000

This means your kernel tries to execute code from an invalid memory location. Thus, it's a bug in your kernel and has nothing to do with QEMU.

Edit: Just a hint on where your bug may be. Looking at your register dump, it is clear that the last executed instruction is just below 640K (at 0x9fffb). On my machine, QEMU reports all memory between 637K and 1M as unavailable. You always have to be careful not to use unavailable memory. A safe bet is to just stay below 637K until you are able to get a memory map and know what memory you can use.

Share:
16,683
Daniel Lopez
Author by

Daniel Lopez

Updated on June 26, 2022

Comments

  • Daniel Lopez
    Daniel Lopez almost 2 years

    I've created a C kernel, and I'm loading the kernel in the QEMU emulator. But when I load the kernel, it seems to crash QEMU and it complains that it can't access the kvm folder. Does it mean that kvm is missing, or that I'm not as an administrator; because I logged in as a root administrator. Here is the error information, that originated from the Terminal:

    danny@ubuntu:~/Desktop$ sudo qemu -kernel os.bin
    open /dev/kvm: No such file or directory
    Could not initialize KVM, will disable KVM support
    pci_add_option_rom: failed to find romfile "pxe-rtl8139.bin"
    qemu: fatal: Trying to execute code outside RAM or ROM at 0x000a0000
    
    EAX=00004500 EBX=00000000 ECX=00000000 EDX=00000000
    ESI=00000000 EDI=00000000 EBP=00000000 ESP=00009fe0
    EIP=0000fdfb EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
    ES =9000 00090000 ffffffff 00cf9300
    CS =9020 00090200 0000ffff 00009b0f
    SS =9000 00090000 0000ffff 00009300
    DS =9000 00090000 0000ffff 00009300
    FS =9000 00090000 0000ffff 00009300
    GS =9000 00090000 0000ffff 00009300
    LDT=0000 00000000 0000ffff 00008200
    TR =0000 00000000 0000ffff 00008b00
    GDT=     000cba40 00000017
    IDT=     00000000 000003ff
    CR0=00000010 CR2=00000000 CR3=00000000 CR4=00000000
    DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000 
    DR6=ffff0ff0 DR7=00000400
    CCS=00004500 CCD=00004546 CCO=ADDB    
    FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80
    FPR0=0000000000000000 0000 FPR1=0000000000000000 0000
    FPR2=0000000000000000 0000 FPR3=0000000000000000 0000
    FPR4=0000000000000000 0000 FPR5=0000000000000000 0000
    FPR6=0000000000000000 0000 FPR7=0000000000000000 0000
    XMM00=00000000000000000000000000000000 XMM01=00000000000000000000000000000000
    XMM02=00000000000000000000000000000000 XMM03=00000000000000000000000000000000
    XMM04=00000000000000000000000000000000 XMM05=00000000000000000000000000000000
    XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000
    Aborted
    

    The error also seems to show information, that seems to be NASM registers, and it complains that it couldn't find a ROM file. So could anyone please tell me what I'm doing wrong, I'd appreciate your time, and effort.

  • Daniel Lopez
    Daniel Lopez over 13 years
    Hi, thanks for the reply, so how can I be able to remove the network card?
  • Matthew Iselin
    Matthew Iselin over 13 years
    @Daniel: -net none works. I believe by default QEMU emulates an RTL8139 with the usermode stack.
  • Matthew Iselin
    Matthew Iselin over 13 years
    Addendum: in my experience QEMU has only ever crashed in a situation that would've been a "triple fault" on real hardware. Something to think about.
  • Ben Voigt
    Ben Voigt over 13 years
    You're overlooking the vital detail, which is that address -- A000:0000 is in the space where boot ROMs load. The reason that the address is outside ROM, is that the ROM which was supposed to exist at that address isn't there because of the missing firmware file. The kernel isn't even involved, qemu's emulated BIOS is still searching for a boot device and hasn't handed off control to the OS yet. And I don't see where you're getting 0x9fffb from, are you looking at the dump in the question or on your own qemu system?
  • mtvec
    mtvec over 13 years
    @Ben: While I'm not completely sure what QEMU does with loaded ROM files, this is not the problem here. Like I said, I see this warning all the time and it doesn't cause any problems. I calculated the physical address as follows: the code was running in real mode (CR0[0] == 0) so segmentation is in use => physical address = 0x10 * CS + EIP = 0x10 * 0x9020 + 0xfdfb = 0x9fffb.
  • Ezio
    Ezio almost 9 years
    I've faced the same problem.But I runned u-boot for powerpc. The same u-boot I tried ok in develop board but failed in qemu-system-ppc.Details in stackoverflow.com/questions/30609694/…
  • Ezio
    Ezio almost 9 years
    I faced the same error but I use qemu emulats powerpc.Details in stackoverflow.com/questions/30609694/… please help me .
  • wlnirvana
    wlnirvana about 6 years
    @Job I know this is a very late followup, but I came across exactly the same problem and think this might be the root cause. Could you please add relevant reference, doc or source code? And is there any workaround for the issue QEMU limiting memory below 637K?