Bug 307194

Summary: unable to install openSUSE in kvm, workaround needed in gfxboot
Product: [openSUSE] openSUSE 10.3 Reporter: Christoph Thiel <cthiel>
Component: KernelAssignee: Bernhard Kaindl <bk>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: forgotten_vLQ3atphDQ, peter, snwint
Version: Beta 2   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Christoph Thiel 2007-09-03 15:06:18 UTC
# qemu-kvm -hda vdisk.img -cdrom /mounts/machcd2/iso/openSUSE-10.3-Beta2-GNOME-i386-Build20070903-CD1.iso -m 386
exception 6 (0)
rax 00000000000029c0 rbx 0000000000250000 rcx 0000000000008100 rdx 000000000000009c
rsi 0000000000042204 rdi 0000000000042204 rsp 00000000fffc1dd6 rbp 000000000000200c
r8  0000000000000000 r9  0000000000000000 r10 0000000000000000 r11 0000000000000000
r12 0000000000000000 r13 0000000000000000 r14 0000000000000000 r15 0000000000000000
rip 000000000000b030 rflags 00033096
cs 2cbc (0002cbc0/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ds 2cbc (0002cbc0/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
es 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ss 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
fs 3002 (00030020/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
gs 0000 (00000000/0000ffff p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
tr 0000 (18a50000/00002088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
ldt 0000 (00000000/0000ffff p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
gdt 2d4a0/47
idt 0/ffff
cr0 60000010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0
code: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 --> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Aborted
#

We need a way to dectect kvm in gfxboot (graphical boot menu), to be able to workaround missing features or bugs in kvm, which currently isn't able to handle gfxboot and fails with the above exception.

Does anyone have any input on this?
Comment 1 Steffen Winterfeldt 2007-09-03 17:04:29 UTC
The problem seems to be after the switch to pm. I've added some debug code
(the full code is in the gfxboot package, bincode.asm::switch_to_pm):

                or al,1
                o32 lgdt [cs:pm_gdt]
                o32 lidt [cs:pm_idt]

                mov cr0,eax
                jmp pm_seg.prog_c32:switch_to_pm_20
switch_to_pm_20:
                bits 32

                mov ax,pm_seg.prog_d16
                mov ds,ax

                mov eax,ss
                and esp,0ffffh
                shl eax,4
                add esp,eax
                mov ax,pm_seg.4gb_d32
                mov ss,ax

; DEBUG START
                mov ebx,ss 
                mov dx,ss 
                mov esi,ss 
                mov edi,esp
                mov cr7,eax
; DEBUG END
                mov es,ax
                mov fs,ax
                mov gs,ax

'mov cr7,eax' is an illegal op, which kills the kvm session. Now, the
registers it _should_ print are these:

ebx 00000008, edx 00000008, esi 00000008, edi 00055e14

but it shows:
ebx 00000017, edx 00000014, esi 00003c00, edi 00002004

in other words, completely messed up.

It sees that segment register accesses are all wrong (not only ss - others
as well). This leads to a wrong esp calculation and kvm normally dies when
returning from that function.

Note, however, that this happens the *SECOND* time that function is called.
It survives the first call, but if only by chance, I can't say.
Comment 2 Steffen Winterfeldt 2007-09-03 17:17:18 UTC
BTW, I was using qemu-kvm and kvm breaks right after setting
the PM bit (in 'mov cr0,eax' at the top of the code).
Comment 3 peter czanik 2007-09-03 19:12:56 UTC
http://kvm.qumranet.com/kvmwiki/Guest_Support_Status says, that:

" OpenSuse 10.2
	

32/64
	

kvm-28/29
	

Intel
	

64
	

Crashes, Workaround exists
	

sans gfxmenu, start kvm with -no-acpi -no-kvm for installation "

I can't find the explanation right now, but was something like Intel hw virtualisation does not support some instructions used by gfxmenu.
Comment 4 Forgotten User vLQ3atphDQ 2007-09-04 07:26:56 UTC
VT doesn't do real mode in hardware, and the emulation is incomplete.
With SVM (aka AMD hardware) it should work fine.

Also I've seen a bunch of real mode emulation fixes go over the kvm-devel list last weeks, so someone is busy fixing that, try the latest bits.  kvm-35 boots sles10sp1 install iso (including gfxmenu) just fine for me.  Didn't try latest opensuse though.
Comment 5 Steffen Winterfeldt 2007-09-04 09:11:51 UTC
Note this isn't about breaking in real mode but in protected mode.
Comment 6 Steffen Winterfeldt 2007-10-08 12:05:34 UTC
Fixed gfxboot in FACTORY. For details, see:

https://sourceforge.net/mailarchive/forum.php?thread_name=46FF262C.9000900%40codemonkey.ws&forum_name=kvm-devel