QEMU crashes when the kernel boots

I created the C core, and I load the kernel into the QEMU emulator. But when I boot the kernel, it seems to crash QEMU and complains that it cannot access the kvm folder. Does this mean that kvm is missing, or that I am not an administrator; because i logged in as root admin. Here is the error information that came 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 a NASM register, and it complains that it cannot find the ROM file. So can someone please tell me what I'm doing wrong, I will be grateful for your time and efforts.

+7
source share
4 answers

The proposal made by Ben Voigt is not your problem. I have the same result when I start my kernel and this does not cause any problems.

The reason for the failure of QEMU is as follows:

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

This means that your kernel is trying to execute code from an invalid memory location. So this is a bug in your kernel and has nothing to do with QEMU.

Edit: Just tell me where your error might be. Looking at the registry dump, it is clear that the last instruction executed is just below 640K (at 0x9fffb). On my machine, QEMU reports all memory between 637K and 1M as inaccessible. You should always be careful not to use inaccessible memory. A safe bet is simply to stay below 637K until you can get a memory card and know what memory you can use.

+5
source

Firstly, if there is no kvm, that is, u must "modprobe kvm" and "modprobe kvm_intel" (or modprobe kvm_amd "if you are running on an AMD processor) in order to load the kvm kernel module before using qemu. Qemu found that there is no kvm loaded, i.e. / dev / kvm no, then it will continue to execute anyway, except that there is no hardware virtualization (see http://en.wikipedia.org/wiki/X86_virtualization ).

There is also no showstopper rom ("pxe-rtl8139.bin") option. I think that ’s why it continues to work (see Qemu source code):

 ./hw/pci.c: error_report("%s: failed to find romfile \"%s\"", 

But the main error in your case is the address 0xa000:

"Attempting to execute code outside RAM or ROM at 0x000a0000"

And this is illegal - since an address exceeding 0xa0000 is called a memory hole. See the chart in:

http://www.cs.cmu.edu/~410-s07/p4/p4-boot.pdf

which describe the task needed to write the bootloader (see page 15 for a description of the memory hole).

  static inline tb_page_addr_t get_page_addr_code(CPUState *env1, target_ulong addr) { int mmu_idx, page_index, pd; void *p; page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = cpu_mmu_index(env1); if (unlikely(env1->tlb_table[mmu_idx][page_index].addr_code != (addr & TARGET_PAGE_MASK))) { ldub_code(addr); } pd = env1->tlb_table[mmu_idx][page_index].addr_code & ~TARGET_PAGE_MASK; if (pd > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) { cpu_abort(env1, "Trying to execute code outside RAM or ROM at 0x" TARGET_FMT_lx "\n", addr); } p = (void *)((uintptr_t)addr + env1->tlb_table[mmu_idx][page_index].addend); return qemu_ram_addr_from_host_nofail(p); } 

And as you can see, the error is a serious serious error of "cpu_abort ()". Essentially, on page 5 of the article, the CMU is higher than the higher. 0xa0000 is the highest address that you can access at boot time in real time.

0
source

You need to fix this:

pci_add_option_rom: could not find romfile "pxe-rtl8139.bin"

Either provide the necessary file (reinstall qemu?), Or change the configuration of the virtual machine and remove the network card. A virtual network cannot work without this file.

-one
source

I think you should point to a valid bzImage instead of os.bin. Personally, I use kvm -kernel arch / x86 / boot / bzImage.

There are two good tutorials

http://softperience.eu/wiki/Wiki.jsp?page=Developing%20Linux%20Kernel%20with%20Netbeans

http://softperience.eu/wiki/Wiki.jsp?page=Advanced%20Linux%20Kernel%20Developing%20with%20Netbeansw

with a few good tricks

-3
source

All Articles