From: Avi Kivity Subject: [PATCH kvm-unit-tests 02/12] emulator: test leave Date: Wed, 27 Jun 2012 11:36:31 +0300 Message-ID: <1340786201-27881-3-git-send-email-avi@redhat.com> References: <1340786201-27881-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42008 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753831Ab2F0Igt (ORCPT ); Wed, 27 Jun 2012 04:36:49 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5R8anif007594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Jun 2012 04:36:49 -0400 In-Reply-To: <1340786201-27881-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Avi Kivity --- x86/emulator.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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_push(void *mem) 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 @@ void test_pop(void *mem) : [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) -- 1.7.11