Il 03/09/2013 15:41, Laszlo Ersek ha scritto:
> Short summary for Gleb and Paolo:
> 
> - qemu master + kvm_intel (3.10) run both OVMF/master and
>   OVMF/master+SeaBIOS/master CSM well, including booting a legacy OS
> 
> - qemu master + TCG spirals into an endless loop when trying to boot a
>   legacy OS with OVMF+CSM -- I'm not focusing on this right now,
> 
> - qemu master + kvm_amd (3.10) throws an emulation failure with pure
>   OVMF immediately at startup:
> 
> On 09/03/13 11:56, Laszlo Ersek wrote:
>> On 09/03/13 01:05, Rod Smith wrote:
>>> On 09/02/2013 05:32 PM, Laszlo Ersek wrote:
>>
>>>> Maybe -enable-kvm would make a difference...
>>>
>>> It causes it to crash with a new set of error messages:
>>>
>>> KVM internal error. Suberror: 1
>>> emulation failure
>>> EAX=c0000033 EBX=fffcc0e4 ECX=c0000080 EDX=00000000
>>> ESI=fffcc2c4 EDI=00005042 EBP=fffcc000 ESP=00000000
>>> EIP=ffffff26 EFL=00000082 [--S----] CPL=0 II=0 A20=1 SMM=0 HLT=0
>>> ES =0008 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
>>> CS =0010 00000000 ffffffff 00c09b00 DPL=0 CS32 [-RA]
>>> SS =0008 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
>>> DS =0008 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
>>> FS =0008 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
>>> GS =0008 00000000 ffffffff 00c09300 DPL=0 DS   [-WA]
>>> LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
>>> TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS64-busy
>>> GDT=     00000000ffffff80 0000001f
>>> IDT=     0000000000000000 0000ffff
>>> CR0=c0000033 CR2=0000000000000000 CR3=00000000ffffe000 CR4=00000660
>>> DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000
>>> DR3=0000000000000000
>>> DR6=00000000ffff0ff0 DR7=0000000000000400
>>> EFER=0000000000000500
>>> Code=00 c0 0f 32 0f ba e8 08 0f 30 0f 20 c0 0f ba e8 1f 0f 22 c0 <ea>
>>> 2d ff ff ff 18 00 e9 93 00 00 00 fa bb 00 f0 8e db bb 6c ff 2e 66 0f
>>> 01 17 66 b8 23 00
>>> Connected to RFB server, using protocol version 3.8
>>>
>>> the kvm and kvm_amd modules are loaded on my system when this
>>> happens.
> 
> In the qemu monitor:
> 
> (qemu) x /20i 0xffffffefd
> 0x0000000ffffffefd:  mov    $0xffffe000,%eax
> 0x0000000fffffff02:  mov    %eax,%cr3
> 0x0000000fffffff05:  mov    %cr4,%eax
> 0x0000000fffffff08:  bts    $0x5,%eax
> 0x0000000fffffff0c:  mov    %eax,%cr4
> 0x0000000fffffff0f:  mov    $0xc0000080,%ecx
> 0x0000000fffffff14:  rdmsr
> 0x0000000fffffff16:  bts    $0x8,%eax
> 0x0000000fffffff1a:  wrmsr
> 0x0000000fffffff1c:  mov    %cr0,%eax
> 0x0000000fffffff1f:  bts    $0x1f,%eax
> 0x0000000fffffff23:  mov    %eax,%cr0
> 0x0000000fffffff26:  ljmp   $0x18,$0xffffff2d <------ emul. failure here

This is probably a failure to fetch the first instruction after paging
is enabled.

This instruction is not emulated usually.  It is emulated here only as
part of "fixing" a nested page fault.

> This is what trace-cmd has to say:
> 
> qemu-system-x86-29149 [002] 12270.789910: kvm_update_master_clock: 
> masterclock 0 hostclock tsc offsetmatched 0
> qemu-system-x86-29149 [002] 12270.789977: kvm_fpu:              load
> qemu-system-x86-29149 [002] 12270.789979: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.789987: kvm_exit:             reason 
> EXIT_NPF rip 0xfff0 info 100000014 fffffff0
> qemu-system-x86-29149 [002] 12270.789992: kvm_page_fault:       address 
> fffffff0 error_code 14
> qemu-system-x86-29149 [002] 12270.790022: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790025: kvm_exit:             reason 
> EXIT_WRITE_CR0 rip 0xff46 info 0 0
> qemu-system-x86-29149 [002] 12270.790042: kvm_emulate_insn:     
> ffff0000:ff46: 0f 22 c0
> qemu-system-x86-29149 [002] 12270.790060: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790063: kvm_exit:             reason 
> EXIT_WRITE_CR4 rip 0xffffff56 info 0 0
> qemu-system-x86-29149 [002] 12270.790065: kvm_emulate_insn:     0:ffffff56: 
> 0f 22 e0
> qemu-system-x86-29149 [002] 12270.790069: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790076: kvm_exit:             reason 
> EXIT_READ_CR4 rip 0xffffff05 info 0 0
> qemu-system-x86-29149 [002] 12270.790079: kvm_emulate_insn:     0:ffffff05: 
> 0f 20 e0
> qemu-system-x86-29149 [002] 12270.790082: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790084: kvm_exit:             reason 
> EXIT_WRITE_CR4 rip 0xffffff0c info 0 0
> qemu-system-x86-29149 [002] 12270.790086: kvm_emulate_insn:     0:ffffff0c: 
> 0f 22 e0
> qemu-system-x86-29149 [002] 12270.790092: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790095: kvm_exit:             reason 
> EXIT_MSR rip 0xffffff14 info 0 0
> qemu-system-x86-29149 [002] 12270.790097: kvm_msr:              msr_read 
> c0000080 = 0x0
> qemu-system-x86-29149 [002] 12270.790098: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790100: kvm_exit:             reason 
> EXIT_MSR rip 0xffffff1a info 1 0
> qemu-system-x86-29149 [002] 12270.790102: kvm_msr:              msr_write 
> c0000080 = 0x100
> qemu-system-x86-29149 [002] 12270.790103: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790105: kvm_exit:             reason 
> EXIT_READ_CR0 rip 0xffffff1c info 0 0
> qemu-system-x86-29149 [002] 12270.790108: kvm_emulate_insn:     0:ffffff1c: 
> 0f 20 c0
> qemu-system-x86-29149 [002] 12270.790109: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790112: kvm_exit:             reason 
> EXIT_WRITE_CR0 rip 0xffffff23 info 0 0
> qemu-system-x86-29149 [002] 12270.790113: kvm_emulate_insn:     0:ffffff23: 
> 0f 22 c0
> qemu-system-x86-29149 [002] 12270.790121: kvm_entry:            vcpu 0
> qemu-system-x86-29149 [002] 12270.790124: kvm_exit:             reason 
> EXIT_NPF rip 0xffffff26 info 200000007 ffffe000
> qemu-system-x86-29149 [002] 12270.790125: kvm_page_fault:       address 
> ffffe000 error_code 7

This is an NPT page fault at 0xffffe000 which is the page table.  In
fact, bit 33 says that the "nested page fault occurred while translating
the guest page tables"

AMD manuals say "host table walks for guest page tables are always
treated as data writes", and that "the page must be writable by user at
the nested page table level, or else a #VMEXIT(NPF) is
raised".  This may be a problem for OVMF: we might have to forget
altogether about pagetables in ROM, which I fixed last week for Intel. :(

> qemu-system-x86-29149 [002] 12270.790129: kvm_emulate_insn:     0:ffffff26: 
> 0f 22 c0
> qemu-system-x86-29149 [002] 12270.790131: kvm_emulate_insn:     0:ffffff26: 
> 0f 22 c0 FAIL
> qemu-system-x86-29149 [002] 12270.790134: kvm_userspace_exit:   reason 
> KVM_EXIT_INTERNAL_ERROR (17)
> qemu-system-x86-29149 [002] 12270.790137: kvm_fpu:              unload

> So, what's going on here? Perhaps, does this mov-to-cr0 *not* exit on
> Intel, but unexpectedly exits on AMD, and the instruction emulator is
> not prepared to handle it?
> 
> In x86_decode_insn():
> 
>       /* Opcode byte(s). */
>       opcode = opcode_table[ctxt->b];
>       /* Two-byte opcode? */
>       if (ctxt->b == 0x0f) {
>               ctxt->twobyte = 1;
>               ctxt->b = insn_fetch(u8, ctxt);
>               opcode = twobyte_table[ctxt->b];
>       }
>       ctxt->d = opcode.flags;
> 
> twobyte_table[0x22] is
> 
>       IIP(ModRM | SrcMem | Priv | Op3264, em_cr_write, cr_write, 
> check_cr_write),
> 
> which at least appears to match mov-to-cr0.
> 
> I guess Rod is the first user who tried OVMF on SVM...

Probably...

Paolo

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to