VirtualBox

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

Last change on this file since 62478 was 62478, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.2 KB
Line 
1/* $Id: tstInstrEmul.cpp 62478 2016-07-22 18:29:06Z vboxsync $ */
2/** @file
3 * Micro Testcase, checking emulation of certain instructions
4 */
5
6/*
7 * Copyright (C) 2006-2016 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/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#include <stdio.h>
23#include <VBox/vmm/vm.h>
24#include <VBox/err.h>
25#include <VBox/vmm/em.h>
26
27#include <VBox/log.h>
28#include <iprt/assert.h>
29#include <iprt/initterm.h>
30#include <iprt/stream.h>
31#include <iprt/string.h>
32#include <iprt/semaphore.h>
33
34
35int main(int argc, char **argv)
36{
37 int rcRet = 0; /* error count. */
38
39 RTR3InitExe(argc, &argv, 0);
40 RTPrintf("tstInstrEmul: TESTING...\n");
41
42 uint32_t eax, edx, ebx, ecx, eflags;
43 uint64_t val;
44
45 val = UINT64_C(0xffffffffffff);
46 eax = 0xffffffff;
47 edx = 0xffff;
48 ebx = 0x1;
49 ecx = 0x2;
50 eflags = EMEmulateLockCmpXchg8b(&val, &eax, &edx, ebx, ecx);
51 if ( !(eflags & X86_EFL_ZF)
52 || val != UINT64_C(0x200000001))
53 {
54 RTPrintf("tstInstrEmul: FAILURE - Lock cmpxchg8b failed the equal case! (val=%RX64)\n", val);
55 return 1;
56 }
57 val = UINT64_C(0x123456789);
58 eflags = EMEmulateLockCmpXchg8b(&val, &eax, &edx, ebx, ecx);
59 if ( (eflags & X86_EFL_ZF)
60 || eax != 0x23456789
61 || edx != 0x1)
62 {
63 RTPrintf("tstInstrEmul: FAILURE - Lock cmpxchg8b failed the non-equal case! (val=%RX64)\n", val);
64 return 1;
65 }
66 RTPrintf("tstInstrEmul: Testing lock cmpxchg instruction emulation - SUCCESS\n");
67
68 val = UINT64_C(0xffffffffffff);
69 eax = 0xffffffff;
70 edx = 0xffff;
71 ebx = 0x1;
72 ecx = 0x2;
73 eflags = EMEmulateCmpXchg8b(&val, &eax, &edx, ebx, ecx);
74 if ( !(eflags & X86_EFL_ZF)
75 || val != UINT64_C(0x200000001))
76 {
77 RTPrintf("tstInstrEmul: FAILURE - Cmpxchg8b failed the equal case! (val=%RX64)\n", val);
78 return 1;
79 }
80 val = UINT64_C(0x123456789);
81 eflags = EMEmulateCmpXchg8b(&val, &eax, &edx, ebx, ecx);
82 if ( (eflags & X86_EFL_ZF)
83 || eax != 0x23456789
84 || edx != 0x1)
85 {
86 RTPrintf("tstInstrEmul: FAILURE - Cmpxchg8b failed the non-equal case! (val=%RX64)\n", val);
87 return 1;
88 }
89 RTPrintf("tstInstrEmul: Testing cmpxchg instruction emulation - SUCCESS\n");
90
91
92 /*
93 * Summary.
94 */
95 if (!rcRet)
96 RTPrintf("tstInstrEmul: SUCCESS\n");
97 else
98 RTPrintf("tstInstrEmul: FAILURE - %d errors\n", rcRet);
99 return rcRet ? 1 : 0;
100}
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