emulator: test leave
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/x86/emulator.c b/x86/emulator.c
index 969944a..4867f58 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -213,7 +213,7 @@
void test_pop(void *mem)
{
- unsigned long tmp;
+ unsigned long tmp, tmp3;
unsigned long *stack_top = mem + 4096;
unsigned long memw = 0x123456789abcdeful;
static unsigned long tmp2;
@@ -256,6 +256,17 @@
: [tmp]"=&r"(tmp) : [stack_top]"r"(stack_top)
: "memory");
report("ret", 1);
+
+ stack_top[-1] = 0x778899;
+ asm volatile("mov %%rsp, %[tmp] \n\t"
+ "mov %%rbp, %[tmp3] \n\t"
+ "mov %[stack_top], %%rbp \n\t"
+ "leave \n\t"
+ "xchg %%rsp, %[tmp] \n\t"
+ "xchg %%rbp, %[tmp3]"
+ : [tmp]"=&r"(tmp), [tmp3]"=&r"(tmp3) : [stack_top]"r"(stack_top-1)
+ : "memory");
+ report("leave", tmp == (ulong)stack_top && tmp3 == 0x778899);
}
void test_ljmp(void *mem)