cmpxchg8b.c 554 B

123456789101112131415161718192021222324252627
  1. #include "ioram.h"
  2. #include "vm.h"
  3. #include "libcflat.h"
  4. #include "desc.h"
  5. #include "types.h"
  6. #include "processor.h"
  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("cmpxchg8b", mem[0] == 3 && mem[1] == 4);
  17. }
  18. int main()
  19. {
  20. setup_vm();
  21. setup_idt();
  22. test_cmpxchg8b(phys_to_virt(read_cr3()) + 4088);
  23. return report_summary();
  24. }