1 | /* $Id: tstMicro.h 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Micro Testcase, profiling special CPU operations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VMM_INCLUDED_SRC_testcase_tstMicro_h
|
---|
29 | #define VMM_INCLUDED_SRC_testcase_tstMicro_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * The testcase identifier.
|
---|
36 | */
|
---|
37 | typedef enum TSTMICROTEST
|
---|
38 | {
|
---|
39 | TSTMICROTEST_OVERHEAD = 0,
|
---|
40 | TSTMICROTEST_INVLPG_0,
|
---|
41 | TSTMICROTEST_INVLPG_EIP,
|
---|
42 | TSTMICROTEST_INVLPG_ESP,
|
---|
43 | TSTMICROTEST_CR3_RELOAD,
|
---|
44 | TSTMICROTEST_WP_DISABLE,
|
---|
45 | TSTMICROTEST_WP_ENABLE,
|
---|
46 |
|
---|
47 | TSTMICROTEST_TRAP_FIRST,
|
---|
48 | TSTMICROTEST_PF_R0 = TSTMICROTEST_TRAP_FIRST,
|
---|
49 | TSTMICROTEST_PF_R1,
|
---|
50 | TSTMICROTEST_PF_R2,
|
---|
51 | TSTMICROTEST_PF_R3,
|
---|
52 |
|
---|
53 | /** The max testcase. */
|
---|
54 | TSTMICROTEST_MAX
|
---|
55 | } TSTMICROTEST;
|
---|
56 |
|
---|
57 |
|
---|
58 | /**
|
---|
59 | *
|
---|
60 | */
|
---|
61 | typedef struct TSTMICRORESULT
|
---|
62 | {
|
---|
63 | /** The total number of ticks spent executing the testcase.
|
---|
64 | * This may include extra overhead stuff if we're weird stuff during trap handler. */
|
---|
65 | uint64_t cTotalTicks;
|
---|
66 | /** Number of ticks spent getting into Rx from R0.
|
---|
67 | * This will include time spent setting up the testcase in R3. */
|
---|
68 | uint64_t cToRxFirstTicks;
|
---|
69 | /** Number of ticks spent executing the trap.
|
---|
70 | * I.e. from right before trapping instruction to the start of the trap handler.
|
---|
71 | * This does not apply to testcases which doesn't trap. */
|
---|
72 | uint64_t cTrapTicks;
|
---|
73 | /** Number of ticks spent resuming Rx executing after a trap.
|
---|
74 | * This does not apply to testcases which doesn't trap. */
|
---|
75 | uint64_t cToRxTrapTicks;
|
---|
76 | /** Number of ticks to get to back to r0 after resuming the trapped code.
|
---|
77 | * This does not apply to testcases which doesn't trap. */
|
---|
78 | uint64_t cToR0Ticks;
|
---|
79 | } TSTMICRORESULT, *PTSTMICRORESULT;
|
---|
80 |
|
---|
81 | /**
|
---|
82 | * Micro profiling testcase
|
---|
83 | */
|
---|
84 | typedef struct TSTMICRO
|
---|
85 | {
|
---|
86 | /** The RC address of this structure. */
|
---|
87 | RTRCPTR RCPtr;
|
---|
88 | /** Just for proper alignment. */
|
---|
89 | RTRCPTR RCPtrStack;
|
---|
90 |
|
---|
91 | /** TSC sampled right before leaving R0. */
|
---|
92 | uint64_t u64TSCR0Start;
|
---|
93 | /** TSC sampled right before the exception. */
|
---|
94 | uint64_t u64TSCRxStart;
|
---|
95 | /** TSC sampled right after entering the trap handler. */
|
---|
96 | uint64_t u64TSCR0Enter;
|
---|
97 | /** TSC sampled right before exitting the trap handler. */
|
---|
98 | uint64_t u64TSCR0Exit;
|
---|
99 | /** TSC sampled right after resuming guest trap. */
|
---|
100 | uint64_t u64TSCRxEnd;
|
---|
101 | /** TSC sampled right after re-entering R0. */
|
---|
102 | uint64_t u64TSCR0End;
|
---|
103 | /** Number of times entered (should be one). */
|
---|
104 | uint32_t cHits;
|
---|
105 | /** Advance EIP. */
|
---|
106 | int32_t offEIPAdd;
|
---|
107 | /** The last CR3 code. */
|
---|
108 | uint32_t u32CR2;
|
---|
109 | /** The last error code. */
|
---|
110 | uint32_t u32ErrCd;
|
---|
111 | /** The last trap eip. */
|
---|
112 | uint32_t u32EIP;
|
---|
113 | /** The original IDT address and limit. */
|
---|
114 | VBOXIDTR OriginalIDTR;
|
---|
115 | /** Our IDT. */
|
---|
116 | VBOXIDTE aIDT[256];
|
---|
117 |
|
---|
118 | /** The overhead for the rdtsc + 2 xchg instr. */
|
---|
119 | uint64_t u64Overhead;
|
---|
120 |
|
---|
121 | /** The testresults. */
|
---|
122 | TSTMICRORESULT aResults[TSTMICROTEST_MAX];
|
---|
123 | /** Ring-3 stack. */
|
---|
124 | uint8_t au8Stack[4096];
|
---|
125 |
|
---|
126 | } TSTMICRO, *PTSTMICRO;
|
---|
127 |
|
---|
128 |
|
---|
129 | RT_C_DECLS_BEGIN
|
---|
130 |
|
---|
131 | DECLASM(void) idtOnly42(PTSTMICRO pTst);
|
---|
132 |
|
---|
133 |
|
---|
134 | DECLASM(void) tstOverhead(PTSTMICRO pTst);
|
---|
135 | DECLASM(void) tstInvlpg0(PTSTMICRO pTst);
|
---|
136 | DECLASM(void) tstInvlpgEIP(PTSTMICRO pTst);
|
---|
137 | DECLASM(void) tstInvlpgESP(PTSTMICRO pTst);
|
---|
138 | DECLASM(void) tstCR3Reload(PTSTMICRO pTst);
|
---|
139 | DECLASM(void) tstWPEnable(PTSTMICRO pTst);
|
---|
140 | DECLASM(void) tstWPDisable(PTSTMICRO pTst);
|
---|
141 |
|
---|
142 |
|
---|
143 | DECLASM(int) tstPFR0(PTSTMICRO pTst);
|
---|
144 | DECLASM(int) tstPFR1(PTSTMICRO pTst);
|
---|
145 | DECLASM(int) tstPFR2(PTSTMICRO pTst);
|
---|
146 | DECLASM(int) tstPFR3(PTSTMICRO pTst);
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 | DECLASM(void) tstTrapHandlerNoErr(void);
|
---|
151 | DECLASM(void) tstTrapHandler(void);
|
---|
152 | DECLASM(void) tstInterrupt42(void);
|
---|
153 |
|
---|
154 | RT_C_DECLS_END
|
---|
155 |
|
---|
156 | #endif /* !VMM_INCLUDED_SRC_testcase_tstMicro_h */
|
---|