Skip to contentSkip to conversation

uvesafb doesn't work with seabios

Qemu-devel Bernhard Walle 3 participants 15 messages May 9, 2014 – May 14, 2014

lore
Share & tools
lore
#0 lore raw

Hello,

I'm using QEmu 2.0.0 on a Linux host (x86-64) with a quite special target system that uses uvesafb ('video=uvesafb:1024x768-32'). I get following errors in the target system:

    uvesafb: Getting mode info block for mode 0x2 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x3 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x4 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x5 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x6 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x7 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0xd failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0xe failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0xf failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x10 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x11 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x12 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x13 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x6a failed (eax=0x4f01, err=1)
    uvesafb: vbe_init() failed with -22
    uvesafb: probe of uvesafb.0 failed with error -22

With QEmu 1.6, it worked. I bisected that down to following commit:

commit 6eefccc0bb9c34051b1e21880fc3a1c1c8686edd
Author: Gerd Hoffmann <[email protected]>
Date: Mon Dec 2 13:01:20 2013 +0100

roms: update vgabios binaries

And indeed, when I switch 'vgabios-stdvga.bin' to the old variant, it works.

What can I do to track down the problem? I tried to build the svga bios inside the QEMU tree, but I didn't succeed. Building it in the current seabios git tree worked, but I got a different error...

Regards,
Bernhard

#1 lore raw
Quoted 29 lines · Bernhard Walle

Hello,

I'm using QEmu 2.0.0 on a Linux host (x86-64) with a quite special target system that uses uvesafb ('video=uvesafb:1024x768-32'). I get following errors in the target system:

    uvesafb: Getting mode info block for mode 0x2 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x3 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x4 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x5 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x6 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x7 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0xd failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0xe failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0xf failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x10 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x11 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x12 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x13 failed (eax=0x4f01, err=1)
    uvesafb: Getting mode info block for mode 0x6a failed (eax=0x4f01, err=1)
    uvesafb: vbe_init() failed with -22
    uvesafb: probe of uvesafb.0 failed with error -22

With QEmu 1.6, it worked. I bisected that down to following commit:

commit 6eefccc0bb9c34051b1e21880fc3a1c1c8686edd
Author: Gerd Hoffmann <[email protected]>
Date: Mon Dec 2 13:01:20 2013 +0100

Quoted 7 lines

roms: update vgabios binaries

And indeed, when I switch 'vgabios-stdvga.bin' to the old variant, it works.

What can I do to track down the problem? I tried to build the svga bios inside the QEMU tree, but I didn't succeed. Building it in the current seabios git tree worked, but I got a different error...

Can you run the original SeaVGABIOS image and provide the output with the following added to the qemu command line:

-chardev stdio,id=seabios -device isa-debugcon,iobase=0x402,chardev=seabios

Also, it looks like uvesafb can call x86emu. Older versions of x86emu are known to not emulate some instructions properly, and it has caused problems for SeaVGABIOS. The most recent version of SeaVGABIOS from SeaBIOS git has additional checks for this - can you grab the seabios git, set CONFIG_DEBUG_LEVEL to 8, build SeaVGABIOS (set CONFIG_VGA_BOCHS), and post the logs from both Linux and QEMU with the above options?

-Kevin

#2 lore raw

Am 10.05.14 17:07, schrieb Kevin O'Connor:

Quoted 5 lines

Can you run the original SeaVGABIOS image and provide the output with the following added to the qemu command line:

-chardev stdio,id=seabios -device isa-debugcon,iobase=0x402,chardev=seabios

Since it's quite much debugging info, I uploaded it to
http://bwalle.de/tmp/debugoutput-unmodified

Basically it's

set VGA mode 12
set VGA mode 3
VBE mode info request: 100
VBE mode info request: 101
...
VBE mode info request: 6a
set VGA mode 3
VBE mode info request: 100

Quoted 7 lines

Also, it looks like uvesafb can call x86emu. Older versions of x86emu are known to not emulate some instructions properly, and it has caused problems for SeaVGABIOS. The most recent version of SeaVGABIOS from SeaBIOS git has additional checks for this - can you grab the seabios git, set CONFIG_DEBUG_LEVEL to 8, build SeaVGABIOS (set CONFIG_VGA_BOCHS), and post the logs from both Linux and QEMU with the above options?

It doesn't change the result (that it doesn't work). It only makes the kernel failing much faster and of course there's much more debugging
output: http://bwalle.de/tmp/debugoutput (250k).

Regards,
Bernhard

#3 lore raw
Quoted 9 lines · Bernhard Walle

Am 10.05.14 17:07, schrieb Kevin O'Connor:

Quoted 7 lines

Also, it looks like uvesafb can call x86emu. Older versions of x86emu are known to not emulate some instructions properly, and it has caused problems for SeaVGABIOS. The most recent version of SeaVGABIOS from SeaBIOS git has additional checks for this - can you grab the seabios git, set CONFIG_DEBUG_LEVEL to 8, build SeaVGABIOS (set CONFIG_VGA_BOCHS), and post the logs from both Linux and QEMU with the above options?

Quoted 3 lines

It doesn't change the result (that it doesn't work). It only makes the kernel failing much faster and of course there's much more debugging
output: http://bwalle.de/tmp/debugoutput (250k).

Were there any Linux or userspace messages with the above?

-Kevin

#4 lore raw

Am 2014-05-11 14:37, schrieb Kevin O'Connor:

Quoted 10 lines · Bernhard Walle
Quoted 9 lines

Am 10.05.14 17:07, schrieb Kevin O'Connor:

Quoted 7 lines

Also, it looks like uvesafb can call x86emu. Older versions of x86emu are known to not emulate some instructions properly, and it has caused problems for SeaVGABIOS. The most recent version of SeaVGABIOS from SeaBIOS git has additional checks for this - can you grab the seabios git, set CONFIG_DEBUG_LEVEL to 8, build SeaVGABIOS (set CONFIG_VGA_BOCHS), and post the logs from both Linux and QEMU with the above options?

Quoted 5 lines
Quoted 3 lines

It doesn't change the result (that it doesn't work). It only makes the kernel failing much faster and of course there's much more debugging
output: http://bwalle.de/tmp/debugoutput (250k).

Were there any Linux or userspace messages with the above?

Yes:

uvesafb: Getting VBE info block failed (eax=0x1d2, err=0)
uvesafb: vbe_init() failed with -22
uvesafb: probe of uvesafb.0 failed with error -22

Regards,
Bernhard

#5 lore raw
Quoted 15 lines · Bernhard Walle

Am 2014-05-11 14:37, schrieb Kevin O'Connor:

Quoted 14 lines · Bernhard Walle
Quoted 12 lines

Am 10.05.14 17:07, schrieb Kevin O'Connor:

Quoted 7 lines

Also, it looks like uvesafb can call x86emu. Older versions of x86emu are known to not emulate some instructions properly, and it has caused problems for SeaVGABIOS. The most recent version of SeaVGABIOS from SeaBIOS git has additional checks for this - can you grab the seabios git, set CONFIG_DEBUG_LEVEL to 8, build SeaVGABIOS (set CONFIG_VGA_BOCHS), and post the logs from both Linux and QEMU with the above options?

It doesn't change the result (that it doesn't work). It only makes the kernel failing much faster and of course there's much more debugging
output: http://bwalle.de/tmp/debugoutput (250k).

Quoted 8 lines
Quoted 1 line

Were there any Linux or userspace messages with the above?

Yes:

uvesafb: Getting VBE info block failed (eax=0x1d2, err=0)
uvesafb: vbe_init() failed with -22
uvesafb: probe of uvesafb.0 failed with error -22

It does look like the x86emu issue. You can try applying the SeaVGABIOS patch below to confirm it.

-Kevin

vgasrc/vgaentry.S +7 -0
@@ -47,7 +47,14 @@ _rom_header_signature:
 
         // Force a fault if found to be running on broken x86emu versions.
         DECLFUNC x86emu_fault
+msg:    .ascii "SeaVGABIOS: x86emu leal trap!\n"
 x86emu_fault:
+#if CONFIG_DEBUG_IO
+        movw %cs:DebugOutputPort, %dx
+        movl $30, %ecx
+        movl $msg, %esi
+        rep outsb %cs:(%esi), (%dx)
+#endif
 1:      hlt
         jmp 1b
 
#6 lore raw

Am 2014-05-12 07:29, schrieb Kevin O'Connor:

Quoted 3 lines

It does look like the x86emu issue. You can try applying the SeaVGABIOS patch below to confirm it.

The output doesn't appear. But I'm sure that I copied the correct files because modifications of other strings worked.

Regards,
Bernhard

Quoted 21 lines
(quoted diff) +0 -1
-Kevin
vgasrc/vgaentry.S +0 -0
@@ -47,7 +47,14 @@ _rom_header_signature:
 
         // Force a fault if found to be running on broken x86emu 

versions.
DECLFUNC x86emu_fault

vgasrc/vgaentry.S +7 -0
+msg:    .ascii "SeaVGABIOS: x86emu leal trap!\n"
 x86emu_fault:
+#if CONFIG_DEBUG_IO
+        movw %cs:DebugOutputPort, %dx
+        movl $30, %ecx
+        movl $msg, %esi
+        rep outsb %cs:(%esi), (%dx)
+#endif
 1:      hlt
         jmp 1b
#7 lore raw
Quoted 7 lines · Bernhard Walle

Am 2014-05-12 07:29, schrieb Kevin O'Connor:

Quoted 3 lines

It does look like the x86emu issue. You can try applying the SeaVGABIOS patch below to confirm it.

The output doesn't appear. But I'm sure that I copied the correct files because modifications of other strings worked.

Heh - old versions of x86emu apparently don't support "rep outsb" either. Can you test the patch below instead?

-Kevin

vgasrc/vgaentry.S +10 -0
@@ -47,7 +47,17 @@ _rom_header_signature:
 
         // Force a fault if found to be running on broken x86emu versions.
         DECLFUNC x86emu_fault
+msg:    .ascii "SeaVGABIOS: x86emu leal trap!\n"
 x86emu_fault:
+#if CONFIG_DEBUG_IO
+        movw %cs:DebugOutputPort, %dx
+        movw $msg, %si
+1:      movb %cs:(%si), %al
+        outb %al, (%dx)
+        incw %si
+        cmpw $x86emu_fault, %si
+        jl 1b
+#endif
 1:      hlt
         jmp 1b
 
#8 lore raw

Hi,

Quoted 11 lines · Kevin O'Connor
Quoted 7 lines · Bernhard Walle

Am 2014-05-12 07:29, schrieb Kevin O'Connor:

Quoted 3 lines

It does look like the x86emu issue. You can try applying the SeaVGABIOS patch below to confirm it.

The output doesn't appear. But I'm sure that I copied the correct files because modifications of other strings worked.

Heh - old versions of x86emu apparently don't support "rep outsb" either. Can you test the patch below instead?

Okay, the output appears. So that means that I should update v86d (the x86emu lib included there is okay?)?

Regards,
Bernhard

#9 lore raw

Am 2014-05-13 07:52, schrieb Bernhard Walle:

Quoted 9 lines

Hi,

Quoted 6 lines · Kevin O'Connor
Quoted 5 lines · Bernhard Walle

Am 2014-05-12 07:29, schrieb Kevin O'Connor:

Quoted 3 lines

It does look like the x86emu issue. You can try applying the SeaVGABIOS patch below to confirm it.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

The output doesn't appear. But I'm sure that I copied the correct files because modifications of other strings worked.

Heh - old versions of x86emu apparently don't support "rep outsb" either. Can you test the patch below instead?

Okay, the output appears. So that means that I should update v86d (the x86emu lib included there is okay?)?

I already have the latest version of x86d from
https://github.com/mjanusz/v86d/commits/master.

Regards,
Bernhard

#10 lore raw
Quoted 11 lines · Bernhard Walle

Am 2014-05-13 07:52, schrieb Bernhard Walle:

Quoted 10 lines · Kevin O'Connor
Quoted 9 lines · Bernhard Walle
Quoted 7 lines

Am 2014-05-12 07:29, schrieb Kevin O'Connor:

Quoted 3 lines

It does look like the x86emu issue. You can try applying the SeaVGABIOS patch below to confirm it.

The output doesn't appear. But I'm sure that I copied the correct files because modifications of other strings worked.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Heh - old versions of x86emu apparently don't support "rep outsb" either. Can you test the patch below instead?

Okay, the output appears. So that means that I should update v86d (the x86emu lib included there is okay?)?

I already have the latest version of x86d from
https://github.com/mjanusz/v86d/commits/master.

Thanks for running further tests.

Unfortunately, I don't know enough about v86d or x86emu to really help here. I do know that the version of x86emu that ships with Xorg was updated several years back and no longer has trouble with the leal instruction.

As background, the root of the problem is that SeaVGABIOS is compiled with gcc, and gcc can emit the "leal" instruction. The old "lgpl VGA BIOS" uses a really old compiler (bcc) which doesn't emit that x86 instruction. The x86emu code does not properly emulate "leal" (as near as I can tell it treats it as a "leaw" instead), which leads to all sorts of bizarre behavior when it tries to interpret the code. This type of issue has occurred for a bunch of instructions (on both x86emu and on an emulator Windows uses) and we've worked around it in SeaVGABIOS with a combination of gcc compiler flags and by post processing gcc's assembler to remove some troublesome instructions. Unfortunately, I don't know of any way to convince gcc to not emit the "leal" instruction and the instruction appears too complex to readily patch out of the assembler.

So, my advice would be to either avoid x86emu (eg, maybe by trying the vm86 mode of v86d, or maybe by not using uvesafb), try compiling v86d with a newer version of x86emu, or stick with the "lgpl VGA BIOS".

-Kevin

#11 lore raw
Quoted 2 lines · Kevin O'Connor

The x86emu code does not properly emulate "leal" (as near as I can
tell it treats it as a "leaw" instead), which leads to all sorts of bizarre behavior when it tries to interpret the code. This type of issue has occurred for a bunch of instructions (on both x86emu and on an emulator Windows uses) and we've worked around it in SeaVGABIOS with a combination of gcc compiler flags and by post processing gcc's assembler to remove some troublesome instructions. Unfortunately, I don't know of any way to convince gcc to not emit the "leal" instruction and the instruction appears too complex to readily patch out of the assembler.

Can't that wrong behaviour of "leal" instruction be fixed in qemu?

Ciao,
Gerhard

#12 lore raw
Quoted 11 lines · Gerhard Wiesinger
Quoted 9 lines · Kevin O'Connor

The x86emu code does not properly emulate "leal" (as near as I can tell it treats it as a "leaw" instead), which leads to all sorts of bizarre behavior when it tries to interpret the code. This type of issue has occurred for a bunch of instructions (on both x86emu and on an emulator Windows uses) and we've worked around it in SeaVGABIOS with a combination of gcc compiler flags and by post processing gcc's assembler to remove some troublesome instructions. Unfortunately, I don't know of any way to convince gcc to not emit the "leal" instruction and the instruction appears too complex to readily patch out of the assembler.

Quoted 1 line

Can't that wrong behaviour of "leal" instruction be fixed in qemu?

QEMU doesn't have any issue with leal. x86emu is a separate program that implements a (partial) x86 interpretter.

The issue being reported is when QEMU runs a guest which uses x86emu to interpret SeaVGABIOS - QEMU is correctly emulating what a real machine would do (random faults) and thus it can't be fixed in QEMU itself.

-Kevin

#13 lore raw
In reply to Kevin O'Connor

Am 13.05.14 17:41, schrieb Kevin O'Connor:

Quoted 4 lines

So, my advice would be to either avoid x86emu (eg, maybe by trying the vm86 mode of v86d, or maybe by not using uvesafb), try compiling v86d with a newer version of x86emu, or stick with the "lgpl VGA BIOS".

Unfortunately I cannot use vm86 mode because it's a x86-64 image (and I really want to avoid kernel patches that seem to provide vm86 on 64 bit kernels).

However, I took the step to update the x86emu code from X.org. That seems to work! At least with my test VM that is based on Arch Linux. I'll try the original Gentoo-based VM tomorrow.

For the meanwhile, I uploaded my patch at
https://bitbucket.org/bwalle/v86d/commits/all. Maybe someone else can use it.

I'll try to push the fix to the original v86d repo, but the project seem to be a bit unmaintained. Unfortunately, there seem to be three independent versions of x86emu out there that even have different APIs (luckily the X.org copy still has the same API as the "original" x86emu).

Thanks for your advise and debugging help!

Regards,
Bernhard

#14 lore raw

Am 13.05.14 21:48, schrieb Bernhard Walle:

Quoted 3 lines

However, I took the step to update the x86emu code from X.org. That seems to work! At least with my test VM that is based on Arch Linux. I'll try the original Gentoo-based VM tomorrow.

That worked, too. :)

I sent a pull request via https://github.com/bwalle/v86d to
https://github.com/mjanusz/v86d.

Regards,
Bernhard