VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstInstrEmul.cpp@ 52066

Last change on this file since 52066 was 50694, checked in by vboxsync, 11 years ago

a few unimportant format string fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.0 KB
Line 
1/* $Id: tstInstrEmul.cpp 50694 2014-03-05 10:03:03Z vboxsync $ */
2/** @file
3 * Micro Testcase, checking emulation of certain instructions
4 */
5
6/*
7 * Copyright (C) 2006-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/*******************************************************************************
19* Header Files *
20*******************************************************************************/
21#include <stdio.h>
22#include <VBox/vmm/vm.h>
23#include <VBox/err.h>
24#include <VBox/vmm/em.h>
25
26#include <VBox/log.h>
27#include <iprt/assert.h>
28#include <iprt/initterm.h>
29#include <iprt/stream.h>
30#include <iprt/string.h>
31#include <iprt/semaphore.h>
32
33
34int main(int argc, char **argv)
35{
36 int rcRet = 0; /* error count. */
37
38 RTR3InitExe(argc, &argv, 0);
39 RTPrintf("tstInstrEmul: TESTING...\n");
40
41 uint32_t eax, edx, ebx, ecx, eflags;
42 uint64_t val;
43
44 val = UINT64_C(0xffffffffffff);
45 eax = 0xffffffff;
46 edx = 0xffff;
47 ebx = 0x1;
48 ecx = 0x2;
49 eflags = EMEmulateLockCmpXchg8b(&val, &eax, &edx, ebx, ecx);
50 if ( !(eflags & X86_EFL_ZF)
51 || val != UINT64_C(0x200000001))
52 {
53 RTPrintf("tstInstrEmul: FAILURE - Lock cmpxchg8b failed the equal case! (val=%RX64)\n", val);
54 return 1;
55 }
56 val = UINT64_C(0x123456789);
57 eflags = EMEmulateLockCmpXchg8b(&val, &eax, &edx, ebx, ecx);
58 if ( (eflags & X86_EFL_ZF)
59 || eax != 0x23456789
60 || edx != 0x1)
61 {
62 RTPrintf("tstInstrEmul: FAILURE - Lock cmpxchg8b failed the non-equal case! (val=%RX64)\n", val);
63 return 1;
64 }
65 RTPrintf("tstInstrEmul: Testing lock cmpxchg instruction emulation - SUCCESS\n");
66
67 val = UINT64_C(0xffffffffffff);
68 eax = 0xffffffff;
69 edx = 0xffff;
70 ebx = 0x1;
71 ecx = 0x2;
72 eflags = EMEmulateCmpXchg8b(&val, &eax, &edx, ebx, ecx);
73 if ( !(eflags & X86_EFL_ZF)
74 || val != UINT64_C(0x200000001))
75 {
76 RTPrintf("tstInstrEmul: FAILURE - Cmpxchg8b failed the equal case! (val=%RX64)\n", val);
77 return 1;
78 }
79 val = UINT64_C(0x123456789);
80 eflags = EMEmulateCmpXchg8b(&val, &eax, &edx, ebx, ecx);
81 if ( (eflags & X86_EFL_ZF)
82 || eax != 0x23456789
83 || edx != 0x1)
84 {
85 RTPrintf("tstInstrEmul: FAILURE - Cmpxchg8b failed the non-equal case! (val=%RX64)\n", val);
86 return 1;
87 }
88 RTPrintf("tstInstrEmul: Testing cmpxchg instruction emulation - SUCCESS\n");
89
90
91 /*
92 * Summary.
93 */
94 if (!rcRet)
95 RTPrintf("tstInstrEmul: SUCCESS\n");
96 else
97 RTPrintf("tstInstrEmul: FAILURE - %d errors\n", rcRet);
98 return rcRet ? 1 : 0;
99}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette