xref: /kvm-unit-tests/x86/cmpxchg8b.c (revision cd5f2fb4ad641c51fe0f1a85264dc3f6ede6e131)
1 #include "ioram.h"
2 #include "vm.h"
3 #include "libcflat.h"
4 #include "desc.h"
5 #include "processor.h"
6 
test_cmpxchg8b(u32 * mem)7 static void test_cmpxchg8b(u32 *mem)
8 {
9     mem[1] = 2;
10     mem[0] = 1;
11     asm("push %%ebx\n"
12         "mov %[ebx_val], %%ebx\n"
13         "lock cmpxchg8b (%0)\n"
14         "pop %%ebx" : : "D" (mem),
15         "d" (2), "a" (1), "c" (4), [ebx_val] "i" (3) : "memory");
16     report(mem[0] == 3 && mem[1] == 4, "cmpxchg8b");
17 }
18 
main(void)19 int main(void)
20 {
21 	setup_vm();
22 
23 	test_cmpxchg8b(phys_to_virt(read_cr3()) + 4088);
24 	return report_summary();
25 }
26