summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-04-23 17:54:59 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2005-04-23 17:54:59 +0000
commite06e5259c3226f1e2408eb8bb940ee4fe5697f4c (patch)
tree64f67b548793221475c1b1c8e2d203060281f81a
parentaba9d61e34b9d43b856fd758d70f38e99e026cab (diff)
downloadqemu-e06e5259c3226f1e2408eb8bb940ee4fe5697f4c.tar.gz
lretq, lcall and ljmp tests in 64 bit mode
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1376 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--tests/test-i386-code16.S18
-rw-r--r--tests/test-i386.c68
2 files changed, 61 insertions, 25 deletions
diff --git a/tests/test-i386-code16.S b/tests/test-i386-code16.S
index 78ecc1f77e..e400e73fd9 100644
--- a/tests/test-i386-code16.S
+++ b/tests/test-i386-code16.S
@@ -77,21 +77,3 @@ myfunc2:
code16_end:
-
-
-/* other 32 bits tests */
- .code32
-
- .globl func_lret32
-func_lret32:
- movl $0x87654321, %eax
- lret
-
- .globl func_iret32
-func_iret32:
- movl $0xabcd4321, %eax
- iret
-
-
-
- \ No newline at end of file
diff --git a/tests/test-i386.c b/tests/test-i386.c
index 5e6e6c624c..310a93aebe 100644
--- a/tests/test-i386.c
+++ b/tests/test-i386.c
@@ -1321,8 +1321,25 @@ void test_code16(void)
}
#endif
-extern char func_lret32;
-extern char func_iret32;
+#if defined(__x86_64__)
+asm(".globl func_lret\n"
+ "func_lret:\n"
+ "movl $0x87654641, %eax\n"
+ "lretq\n");
+#else
+asm(".globl func_lret\n"
+ "func_lret:\n"
+ "movl $0x87654321, %eax\n"
+ "lret\n"
+
+ ".globl func_iret\n"
+ "func_iret:\n"
+ "movl $0xabcd4321, %eax\n"
+ "iret\n");
+#endif
+
+extern char func_lret;
+extern char func_iret;
void test_misc(void)
{
@@ -1334,16 +1351,53 @@ void test_misc(void)
asm ("xlat" : "=a" (res) : "b" (table), "0" (res));
printf("xlat: EAX=" FMTLX "\n", res);
-#if !defined(__x86_64__)
+#if defined(__x86_64__)
+ {
+ static struct __attribute__((packed)) {
+ uint32_t offset;
+ uint16_t seg;
+ } desc;
+ long cs_sel;
+
+ asm volatile ("mov %%cs, %0" : "=r" (cs_sel));
+
+ asm volatile ("push %1\n"
+ "call func_lret\n"
+ : "=a" (res)
+ : "r" (cs_sel) : "memory", "cc");
+ printf("func_lret=" FMTLX "\n", res);
+
+ /* NOTE: we assume that &func_lret < 4GB */
+ desc.offset = (long)&func_lret;
+ desc.seg = cs_sel;
+
+ asm volatile ("xor %%rax, %%rax\n"
+ "rex64 lcall %1\n"
+ : "=a" (res)
+ : "m" (desc)
+ : "memory", "cc");
+ printf("func_lret2=" FMTLX "\n", res);
+
+ asm volatile ("push %2\n"
+ "mov $ 1f, %%rax\n"
+ "push %%rax\n"
+ "ljmp %1\n"
+ "1:\n"
+ : "=a" (res)
+ : "m" (desc), "b" (cs_sel)
+ : "memory", "cc");
+ printf("func_lret3=" FMTLX "\n", res);
+ }
+#else
asm volatile ("push %%cs ; call %1"
: "=a" (res)
- : "m" (func_lret32): "memory", "cc");
- printf("func_lret32=" FMTLX "\n", res);
+ : "m" (func_lret): "memory", "cc");
+ printf("func_lret=" FMTLX "\n", res);
asm volatile ("pushf ; push %%cs ; call %1"
: "=a" (res)
- : "m" (func_iret32): "memory", "cc");
- printf("func_iret32=" FMTLX "\n", res);
+ : "m" (func_iret): "memory", "cc");
+ printf("func_iret=" FMTLX "\n", res);
#endif
#if defined(__x86_64__)