Skip to contentSkip to conversation

target-i386/kvm: vmx realization

Qemu-devel Dmitry Poletaev 2 participants 3 messages May 26, 2016 – May 27, 2016

lore
Share & tools
lore
#0 lore raw

Hello.

In my diploma project I'm trying to add VMX to qemu. It is first vmx incarnation, without ept, unrestricted guest and other improvements.
It seems working in some way. Virtual Box can execute few hundreds of instructions until crash, but it's tricky for me to build it completely to add some logging features for debug.
Because of it I begun debug with kvm. But with kvm problems started in very beginning.
I am doing my experiments simultaneously on qemu, modified by me, and real intel machine, artificially restricted to support only first vmx version.
When kvm configures guest and enters in it, #PF with 0xfe05b address happens. Kvm on both platforms goes to handle #PF.
kvm_mmu_page_fault goes to nonpaging_page_fault, which don't find page in cache and calls nonpaging_map. nonpaging_map exits after critical section before out_unlock label. For me reaction is normal and looks the same on both platforms, but I think problem may be here deeper. After #PF handling kvm enters to guest again and here difference begins. Real machine have new #PF far away from this address, but qemu falls to kvm again with #PF on 0xfe05b.
This situation repeats infinitely. Qemu vmcs fields after exit to kvm don't have important differencies (on my view) with Intel vmcs.
Some more info I received after logging qemu's address translation.
Qemu rises first #PF on first entry to guest (pml4e = 0x3d9fe001 pdpe = 0x0). On second entry to guest, after kvm handling, it rise #PF again (pml4e = 0x3d9fe021 pdpe = 0x3d9fa027 pde = 0x0). Next entries to guest is the same (PF and pml4e = 0x3d9fe021 pdpe = 0x3d9fa027 pde = 0x0). May be someone know, why it is happens and how I can fix my vmx realization, or where I should look.

Thank you.

#1 lore raw
Quoted 8 lines · Dmitry Poletaev

kvm_mmu_page_fault goes to nonpaging_page_fault, which don't find page in cache and calls nonpaging_map. nonpaging_map exits after critical section before out_unlock label. For me reaction is normal and looks the same on both platforms, but I think problem may be here deeper. After #PF handling kvm enters to guest again and here difference begins. Real machine have new #PF far away from this address, but qemu falls to kvm again with #PF on 0xfe05b.
This situation repeats infinitely. Qemu vmcs fields after exit to kvm don't have important differencies (on my view) with Intel vmcs.
Some more info I received after logging qemu's address translation.
Qemu rises first #PF on first entry to guest (pml4e = 0x3d9fe001 pdpe
= 0x0). On second entry to guest, after kvm handling, it rise #PF again
(pml4e = 0x3d9fe021 pdpe = 0x3d9fa027 pde = 0x0). Next entries to guest
is the same (PF and pml4e = 0x3d9fe021 pdpe = 0x3d9fa027 pde = 0x0).

I think the PDE and PTE should have become non-zero, but I'm not sure.

You can use the kvm_flightrecorder script (scripts/kvm/kvm_flightrecorder in the QEMU git tree) to find where the differences start exactly.

You can also compare QEMU and Bochs.

BTW, have you tried running the VMX testcases from kvm-unit-tests.git?

Thanks,

Paolo

Quoted 1 line

May be someone know, why it is happens and how I can fix my vmx realization, or where I should look.

#2 lore raw

Thanks for answer.

I think it should be non zero too. Because of guest state is defined by vmcs fields, it is unclear for me, why kvm handle same situation in different way.

I didn't see this script and tests. Unit tests end by timeout (I've increased it 15 times, all the same) and kvm script prints almost different traces. Anyway, it is nice tools for futher debugging.

May be you could give some more advises?

Thank you.

26.05.2016, 13:09, "Paolo Bonzini" <[email protected]>:

Quoted 25 lines · Dmitry Poletaev
Quoted 8 lines

 kvm_mmu_page_fault goes to nonpaging_page_fault, which don't find page in cache and calls nonpaging_map. nonpaging_map exits after critical section before out_unlock label. For me reaction is normal and looks the same on both platforms, but I think problem may be here deeper. After #PF handling kvm enters to guest again and here difference begins. Real machine have new #PF far away from this address, but qemu falls to kvm again with #PF on 0xfe05b.
 This situation repeats infinitely. Qemu vmcs fields after exit to kvm don't have important differencies (on my view) with Intel vmcs.
 Some more info I received after logging qemu's address translation.
 Qemu rises first #PF on first entry to guest (pml4e = 0x3d9fe001 pdpe
 = 0x0). On second entry to guest, after kvm handling, it rise #PF again
 (pml4e = 0x3d9fe021 pdpe = 0x3d9fa027 pde = 0x0). Next entries to guest
 is the same (PF and pml4e = 0x3d9fe021 pdpe = 0x3d9fa027 pde = 0x0).

I think the PDE and PTE should have become non-zero, but I'm not sure.

You can use the kvm_flightrecorder script (scripts/kvm/kvm_flightrecorder in the QEMU git tree) to find where the differences start exactly.

You can also compare QEMU and Bochs.

BTW, have you tried running the VMX testcases from kvm-unit-tests.git?

Thanks,

Paolo

Quoted 1 line

 May be someone know, why it is happens and how I can fix my vmx realization, or where I should look.