Commit e06e5259c3226f1e2408eb8bb940ee4fe5697f4c

Authored by bellard
1 parent aba9d61e

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
tests/test-i386-code16.S
... ... @@ -77,21 +77,3 @@ myfunc2:
77 77  
78 78  
79 79 code16_end:
80   -
81   -
82   -/* other 32 bits tests */
83   - .code32
84   -
85   - .globl func_lret32
86   -func_lret32:
87   - movl $0x87654321, %eax
88   - lret
89   -
90   - .globl func_iret32
91   -func_iret32:
92   - movl $0xabcd4321, %eax
93   - iret
94   -
95   -
96   -
97   -
98 80 \ No newline at end of file
... ...
tests/test-i386.c
... ... @@ -1321,8 +1321,25 @@ void test_code16(void)
1321 1321 }
1322 1322 #endif
1323 1323  
1324   -extern char func_lret32;
1325   -extern char func_iret32;
  1324 +#if defined(__x86_64__)
  1325 +asm(".globl func_lret\n"
  1326 + "func_lret:\n"
  1327 + "movl $0x87654641, %eax\n"
  1328 + "lretq\n");
  1329 +#else
  1330 +asm(".globl func_lret\n"
  1331 + "func_lret:\n"
  1332 + "movl $0x87654321, %eax\n"
  1333 + "lret\n"
  1334 +
  1335 + ".globl func_iret\n"
  1336 + "func_iret:\n"
  1337 + "movl $0xabcd4321, %eax\n"
  1338 + "iret\n");
  1339 +#endif
  1340 +
  1341 +extern char func_lret;
  1342 +extern char func_iret;
1326 1343  
1327 1344 void test_misc(void)
1328 1345 {
... ... @@ -1334,16 +1351,53 @@ void test_misc(void)
1334 1351 asm ("xlat" : "=a" (res) : "b" (table), "0" (res));
1335 1352 printf("xlat: EAX=" FMTLX "\n", res);
1336 1353  
1337   -#if !defined(__x86_64__)
  1354 +#if defined(__x86_64__)
  1355 + {
  1356 + static struct __attribute__((packed)) {
  1357 + uint32_t offset;
  1358 + uint16_t seg;
  1359 + } desc;
  1360 + long cs_sel;
  1361 +
  1362 + asm volatile ("mov %%cs, %0" : "=r" (cs_sel));
  1363 +
  1364 + asm volatile ("push %1\n"
  1365 + "call func_lret\n"
  1366 + : "=a" (res)
  1367 + : "r" (cs_sel) : "memory", "cc");
  1368 + printf("func_lret=" FMTLX "\n", res);
  1369 +
  1370 + /* NOTE: we assume that &func_lret < 4GB */
  1371 + desc.offset = (long)&func_lret;
  1372 + desc.seg = cs_sel;
  1373 +
  1374 + asm volatile ("xor %%rax, %%rax\n"
  1375 + "rex64 lcall %1\n"
  1376 + : "=a" (res)
  1377 + : "m" (desc)
  1378 + : "memory", "cc");
  1379 + printf("func_lret2=" FMTLX "\n", res);
  1380 +
  1381 + asm volatile ("push %2\n"
  1382 + "mov $ 1f, %%rax\n"
  1383 + "push %%rax\n"
  1384 + "ljmp %1\n"
  1385 + "1:\n"
  1386 + : "=a" (res)
  1387 + : "m" (desc), "b" (cs_sel)
  1388 + : "memory", "cc");
  1389 + printf("func_lret3=" FMTLX "\n", res);
  1390 + }
  1391 +#else
1338 1392 asm volatile ("push %%cs ; call %1"
1339 1393 : "=a" (res)
1340   - : "m" (func_lret32): "memory", "cc");
1341   - printf("func_lret32=" FMTLX "\n", res);
  1394 + : "m" (func_lret): "memory", "cc");
  1395 + printf("func_lret=" FMTLX "\n", res);
1342 1396  
1343 1397 asm volatile ("pushf ; push %%cs ; call %1"
1344 1398 : "=a" (res)
1345   - : "m" (func_iret32): "memory", "cc");
1346   - printf("func_iret32=" FMTLX "\n", res);
  1399 + : "m" (func_iret): "memory", "cc");
  1400 + printf("func_iret=" FMTLX "\n", res);
1347 1401 #endif
1348 1402  
1349 1403 #if defined(__x86_64__)
... ...