[SeaBIOS] SeaBIOS not fully working when compiled on FreeBSD
kevin at koconnor.net
Mon Apr 20 17:20:17 CEST 2015
On Mon, Apr 20, 2015 at 04:28:03PM +0200, Roger Pau Monné wrote:
> El 16/04/15 a les 19.51, Kevin O'Connor ha escrit:
> > On Thu, Apr 16, 2015 at 06:37:29PM +0200, Roger Pau Monné wrote:
> >> El 16/04/15 a les 17.52, Kevin O'Connor ha escrit:
> >>> Seems like the same problem. You wont be able to set a gdb breakpoint
> >>> for the freebsd call because freebsd isn't calling the bios - it's
> >>> attempting to interpret the bios code.
> >>> Does the seabios patch below fix the problem for you?
> >> Seems to kind of fix it, but it's hard to tell.
> >> Most of the time the original SeaBIOS binary works without problems.
> >> There's sometimes were the int 0x15 call with ah=0xc0 returns what seem
> >> to be valid values in ah and flg, but the values in es and bx are
> >> corrupted so when freebsd tries to access this region (es << 4 + bx) it
> >> gets a page fault.
> >> This is what I see now with the patch applied:
> >> atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
> >> atkbd0: <AT Keyboard> irq 1 on atkbdc0
> >> Calling INT 0x15 (ax=0xc000 bx=0x0000 cx=0x0000 dx=0x0000 es=0x0000 di=0x0000)
> >> Exiting INT 0x15 (ax=0xf9c0 bx=0xf9c0 cx=0xf99e dx=0xdf80 es=0x0000 di=0x0000)
> >> kbd0 at atkbd0
> >> atkbd0: [GIANT-LOCKED]
> > Ah, looks like the freebsd code isn't even checking if x86emu exited
> > abnormally.
> Yes, this is something that can be solved without much work AFAICT, so
> that we know if the emulator exited correctly or not. However this is
> only a side-effect of what's actually happening.
If changing freebsd code, I would change it to set the repeat rate to
a standard default irrespective of what the bios uses, and thus not
call the bios at all.
> > To summarize, this looks to be the same problem that I investigated
> > two years ago:
> > http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg01311.html
> > Basically, freebsd is attempting to interpret the x86 bios code, but
> > it is using an incomplete interpreter that misinterprets some x86
> > instructions. That broken interpreter could cause page faults, loop
> > forever, or return bogus values.
> I've added a little bit more debug to the FreeBSD kernel and x86emu in
> order to see what's going on. It seems like SeaBIOS contains VERR/VERW
> instructions (or x86emu in FreeBSD thinks so, but maybe this is just
> the fail over of some badly emulated instructions), which x86emu
> doesn't know how to handle, can this be the case?
Yes. It is known that x86emu does not properly emulate the calll,
retl, leavel, and leal instructions (32bit forms of call, ret, leave
and lea). There are other unsupported instructions as well (eg,
smsww, outsb, enterl), but these are less problamatic because gcc
doesn't emit them.
Because x86emu is used so frequently with vga bios, SeaVGABIOS has
code to fixup the gcc assembler to avoid the above instructions - see
More information about the SeaBIOS