Page 1 of 1

Self-Compiled Bochs failing before execution of any code

Posted: Thu Mar 03, 2011 5:13 am
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).

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

Posted: Thu Mar 03, 2011 5:19 am
by thepowersgang
The bochsout file posted looks OK, so I'd blame a bug from SVN, have you tried compiling a release version?

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

Posted: Thu Mar 03, 2011 5:28 am
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.

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

Posted: Thu Mar 03, 2011 5:32 am
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.

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

Posted: Thu Mar 03, 2011 6:42 am
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.

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

Posted: Thu Mar 03, 2011 6:50 am
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.