repository: /home/avi/kvm
branch: master
commit b0137bceca1e25f47f5fc83796d639f3fc6ab75c
Author: Avi Kivity <[EMAIL PROTECTED]>
Date:   Thu Dec 6 19:03:11 2007 +0200

    kvm: testsuite: test push instruction emulation
    
    Signed-off-by: Avi Kivity <[EMAIL PROTECTED]>

diff --git a/user/test/x86/emulator.c b/user/test/x86/emulator.c
index 830e7dc..626e02b 100644
--- a/user/test/x86/emulator.c
+++ b/user/test/x86/emulator.c
@@ -2,6 +2,8 @@
 #include "vm.h"
 #include "printf.h"
 
+#define memset __builtin_memset
+
 int fails, tests;
 
 void report(const char *name, int result)
@@ -90,6 +92,32 @@ void test_cmps(void *mem)
 
 }
 
+void test_push(void *mem)
+{
+       unsigned long tmp;
+       unsigned long *stack_top = mem + 4096;
+       unsigned long *new_stack_top;
+       unsigned long memw = 0x123456789abcdeful;
+
+       memset(mem, 0x55, (void *)stack_top - mem);
+
+       asm volatile("mov %%rsp, %[tmp] \n\t"
+                    "mov %[stack_top], %%rsp \n\t"
+                    "pushq $-7 \n\t"
+                    "pushq %[reg] \n\t"
+                    "pushq (%[mem]) \n\t"
+                    "mov %%rsp, %[new_stack_top] \n\t"
+                    "mov %[tmp], %%rsp"
+                    : [new_stack_top]"=r"(new_stack_top)
+                    : [tmp]"r"(tmp), [stack_top]"r"(stack_top),
+                      [reg]"r"(-17l), [mem]"r"(&memw)
+                    : "memory");
+
+       report("push $imm8", stack_top[-1] == -7ul);
+       report("push %reg", stack_top[-2] == -17ul);
+       report("push mem", stack_top[-3] == 0x123456789abcdeful);
+}
+
 int main()
 {
        void *mem;
@@ -109,6 +137,8 @@ int main()
 
        test_cmps(mem);
 
+       test_push(mem);
+
        printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
        return fails ? 1 : 0;
 }

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
kvm-commits mailing list
kvm-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-commits

Reply via email to