Self-Compiled Bochs failing before execution of any code

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Qeroq
Member
Member
Posts: 52
Joined: Wed Aug 25, 2010 6:35 am
Location: Bonn, Germany

Self-Compiled Bochs failing before execution of any code

Post by Qeroq »

Hello,
to debug an issue I'm having with SMP (faulting when setting PM bit in CR0 in RM after STARTUP IPI), I decided to switch over from qemu to bochs for the sake of its great debugging features.

Unfortunately, the precompiled bochs version that ships with my linux distro (Ubuntu 10.10) has no support for ACPI which is required for my kernel to run (doing LAPIC discovery etc.), so I decided to compile bochs by myself, loaded the source from SVN and compiled with the following configuration on my X86_64-linux-unknown-gnu machine:

Code: Select all

./configure --enable-smp \
    --enable-cpu-level=6 \
    --enable-acpi \
    --enable-x86-64 \
    --enable-pci \
    --enable-vmx \
    --enable-debugger \
    --enable-disasm \
    --enable-debugger-gui \
    --enable-logging \
    --enable-vbe \
    --enable-fpu \
    --enable-3dnow \
    --enable-sb16=dummy \
    --enable-cdrom \
    --enable-x86-debugger \
    --enable-iodebug \
    --disable-plugins \
    --disable-docbook \
    --enable-magic-breakpoint \
    --with-x --with-x11 --with-term
Now, everything compiles fine and as expected, installing bochs with sudo make install, and trying to execute my kernel (bootloader: GRUB legacy, image: ISO9660) using the following bochsrc.txt:

Code: Select all

megs: 32
romimage: file=/usr/local/share/bochs/BIOS-bochs-latest, address=0xe0000
vgaromimage: file=/usr/local/share/bochs/VGABIOS-lgpl-latest
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=cdrom, path="boot.iso", status=inserted
boot: cdrom
log: bochsout.txt
mouse: enabled=0
clock: sync=realtime
Now, when I'm trying to run my kernel (with one CPU, for the beginning), the emulator windows stays black and bochs reports me:

Code: Select all

Next at t=0
(0) [0x00000000fffffff0] f000:fff0 (unk. ctxt): (invalid)                 ; ffff
Okay, what's happening there? To me, it looks like bochs is trying to start execution on 0xF000:0xFFF0, but actually finds no valid instruction to execute, but I could be wrong and I don't see any reason why it should do that. I attached my bochsout.txt to this post below and my OS's code (except for the latest one that does the SMP initialization and some half-way-done, but not integrated scheduler) is available on Github, if it helps (see the link below).
Attachments
bochsout.txt
(9.18 KiB) Downloaded 68 times
https://github.com/qero/Hydrogen (Loader for AMD64 kernels running on top of GRUB2)
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Self-Compiled Bochs failing before execution of any code

Post by thepowersgang »

The bochsout file posted looks OK, so I'd blame a bug from SVN, have you tried compiling a release version?
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Self-Compiled Bochs failing before execution of any code

Post by Combuster »

several observations:
1) you start up in debugger mode, which means you have to manually start the simulation (so you can set breakpoints ahead of time, press c to continue).
2) You don't seem to run your custom bochs build as specified - the 3dnow and soundblaster arguments in the log differ from the posted configure line.
3) execution starts at 0xfffffff0, not 0x000ffff0 where you configured bochs to load the bios. Check the bios and sample bochsrc that came with the relevant bochs version.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Qeroq
Member
Member
Posts: 52
Joined: Wed Aug 25, 2010 6:35 am
Location: Bonn, Germany

Re: Self-Compiled Bochs failing before execution of any code

Post by Qeroq »

Hm, same error for 2.4.6 release, trying with 2.4.5 now...

Edit: Oh, ok I'll check on that one.
https://github.com/qero/Hydrogen (Loader for AMD64 kernels running on top of GRUB2)
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Self-Compiled Bochs failing before execution of any code

Post by bewing »

Yes, as Combuster said, the BIOS should be loaded at just under 4G, not just under 1M. So the address for "romimage" should be 0xfffe0000 -- and that should completely fix your problem.

I am working on a replacement for bochs, and I am working on supporting APIC at this moment. So I would be very interested in a copy of your disk image at some point, if you are willing. :wink:

Especially since the GUI debugger has been significantly improved over what Bochs has.
Qeroq
Member
Member
Posts: 52
Joined: Wed Aug 25, 2010 6:35 am
Location: Bonn, Germany

Re: Self-Compiled Bochs failing before execution of any code

Post by Qeroq »

Yeah, 0xfffe0000 works fine, just figured that out before reading your post.

A replacement for bochs sounds nice, but is a lot of work, I guess. I would be glad to help you by sending you an image once I finished SMP.

Thanks for your help.
https://github.com/qero/Hydrogen (Loader for AMD64 kernels running on top of GRUB2)
Post Reply