This is similar to emulator.c, that does not run on 32-bit systems. This bug happens (due to kvm_mmu_page_fault's call to the emulator) during Windows 7 boot. Reported-by: Erik Rull <erik.rull@xxxxxxxxxxxxx> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> --- v1->v2: go through kvm_mmu_page_fault like Windows 7 does. Emulation of locked operations on MMIO does not go through the cmpxchg path, gva_to_gpa fails. --- config/config-i386.mak | 4 +++- x86/cmpxchg8b.c | 27 +++++++++++++++++++++++++++ x86/run | 2 +- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 x86/cmpxchg8b.c diff --git a/config/config-i386.mak b/config/config-i386.mak index 503a3be..691381c 100644 --- a/config/config-i386.mak +++ b/config/config-i386.mak @@ -3,9 +3,11 @@ bits = 32 ldarch = elf32-i386 CFLAGS += -I $(KERNELDIR)/include -tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat +tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat \ + $(TEST_DIR)/cmpxchg8b.flat include config/config-x86-common.mak +$(TEST_DIR)/cmpxchg8b.elf: $(cstart.o) $(TEST_DIR)/cmpxchg8b.o $(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o $(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o diff --git a/x86/cmpxchg8b.c b/x86/cmpxchg8b.c new file mode 100644 index 0000000..2e5a8e6 --- /dev/null +++ b/x86/cmpxchg8b.c @@ -0,0 +1,27 @@ +#include "ioram.h" +#include "vm.h" +#include "libcflat.h" +#include "desc.h" +#include "types.h" +#include "processor.h" + +static void test_cmpxchg8b(u32 *mem) +{ + mem[1] = 2; + mem[0] = 1; + asm("push %%ebx\n" + "mov %[ebx_val], %%ebx\n" + "lock cmpxchg8b (%0)\n" + "pop %%ebx" : : "D" (mem), + "d" (2), "a" (1), "c" (4), [ebx_val] "i" (3) : "memory"); + report("cmpxchg8b", mem[0] == 3 && mem[1] == 4); +} + +int main() +{ + setup_vm(); + setup_idt(); + + test_cmpxchg8b(phys_to_virt(read_cr3()) + 4088); + return report_summary(); +} diff --git a/x86/run b/x86/run index 646c577..af37eb4 100755 --- a/x86/run +++ b/x86/run @@ -33,7 +33,7 @@ else pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out" fi -command="${qemu} -enable-kvm $pc_testdev -display none -serial stdio $pci_testdev -kernel" +command="${qemu} -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev -kernel" echo ${command} "$@" ${command} "$@" ret=$? -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html