VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/cpu/xmmsaving.cpp@ 90780

Last change on this file since 90780 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: xmmsaving.cpp 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * xmmsaving - Test that all XMM register state is handled correctly and
4 * not corrupted the VMM.
5 */
6
7/*
8 * Copyright (C) 2009-2020 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include <iprt/test.h>
33#include <iprt/x86.h>
34
35
36/*********************************************************************************************************************************
37* Structures and Typedefs *
38*********************************************************************************************************************************/
39typedef struct MYXMMREGSET
40{
41 RTUINT128U aRegs[16];
42} MYXMMREGSET;
43
44
45DECLASM(int) XmmSavingTestLoadSet(const MYXMMREGSET *pSet, const MYXMMREGSET *pPrevSet, PRTUINT128U pBadVal);
46
47
48static void XmmSavingTest(void)
49{
50 RTTestISub("xmm saving and restoring");
51
52 /* Create the test sets. */
53 static MYXMMREGSET s_aSets[256];
54 for (unsigned s = 0; s < RT_ELEMENTS(s_aSets); s++)
55 {
56 for (unsigned r = 0; r < RT_ELEMENTS(s_aSets[s].aRegs); r++)
57 {
58 unsigned x = (s << 4) | r;
59 s_aSets[s].aRegs[r].au32[0] = x | UINT32_C(0x12345000);
60 s_aSets[s].aRegs[r].au32[1] = (x << 8) | UINT32_C(0x88700011);
61 s_aSets[s].aRegs[r].au32[2] = (x << 16) | UINT32_C(0xe000dcba);
62 s_aSets[s].aRegs[r].au32[3] = (x << 20) | UINT32_C(0x00087654);
63 }
64 }
65
66 /* Do the actual testing. */
67 const MYXMMREGSET *pPrev2 = NULL;
68 const MYXMMREGSET *pPrev = NULL;
69 for (int i = 0; i < 1000000; i++)
70 {
71 if ((i % 50000) == 0)
72 {
73 RTTestIPrintf(RTTESTLVL_ALWAYS, ".");
74 pPrev = pPrev2 = NULL; /* May be trashed by the above call. */
75 }
76 for (unsigned s = 0; s < RT_ELEMENTS(s_aSets); s++)
77 {
78 RTUINT128U BadVal;
79 const MYXMMREGSET *pSet = &s_aSets[s];
80 int r = XmmSavingTestLoadSet(pSet, pPrev, &BadVal);
81 if (r-- != 0)
82 {
83 RTTestIFailed("i=%d s=%d r=%d", i, s, r);
84 RTTestIFailureDetails("XMM%-2d = %08x,%08x,%08x,%08x\n",
85 r,
86 BadVal.au32[0],
87 BadVal.au32[1],
88 BadVal.au32[2],
89 BadVal.au32[3]);
90 RTTestIFailureDetails("Expected %08x,%08x,%08x,%08x\n",
91 pPrev->aRegs[r].au32[0],
92 pPrev->aRegs[r].au32[1],
93 pPrev->aRegs[r].au32[2],
94 pPrev->aRegs[r].au32[3]);
95 if (pPrev2)
96 RTTestIFailureDetails("PrevPrev %08x,%08x,%08x,%08x\n",
97 pPrev2->aRegs[r].au32[0],
98 pPrev2->aRegs[r].au32[1],
99 pPrev2->aRegs[r].au32[2],
100 pPrev2->aRegs[r].au32[3]);
101 return;
102 }
103 pPrev2 = pPrev;
104 pPrev = pSet;
105 }
106 }
107 RTTestISubDone();
108}
109
110
111int main()
112{
113 RTTEST hTest;
114 int rc = RTTestInitAndCreate("xmmsaving", &hTest);
115 if (rc)
116 return rc;
117 XmmSavingTest();
118 return RTTestSummaryAndDestroy(hTest);
119}
120
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