VirtualBox

source: vbox/trunk/include/VBox/vmm/iem.h@ 98982

Last change on this file since 98982 was 98982, checked in by vboxsync, 21 months ago

VMM: More ARMv8 x86/amd64 separation work, get past IEM, bugref:10385 [build fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
1/** @file
2 * IEM - Interpreted Execution Manager.
3 */
4
5/*
6 * Copyright (C) 2011-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_iem_h
37#define VBOX_INCLUDED_vmm_iem_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <VBox/vmm/trpm.h>
44#include <iprt/assert.h>
45
46#ifdef VBOX_VMM_TARGET_ARMV8
47# include <VBox/vmm/iem-armv8.h>
48#else
49# include <VBox/vmm/iem-x86-amd64.h>
50#endif
51
52
53RT_C_DECLS_BEGIN
54
55/** @defgroup grp_iem The Interpreted Execution Manager API.
56 * @ingroup grp_vmm
57 * @{
58 */
59
60/** @name IEMXCPTRAISEINFO_XXX - Extra info. on a recursive exception situation.
61 *
62 * This is primarily used by HM for working around a PGM limitation (see
63 * @bugref{6607}) and special NMI/IRET handling. In the future, this may be
64 * used for diagnostics.
65 *
66 * @{
67 */
68typedef uint32_t IEMXCPTRAISEINFO;
69/** Pointer to a IEMXCPTINFO type. */
70typedef IEMXCPTRAISEINFO *PIEMXCPTRAISEINFO;
71/** No addition info. available. */
72#define IEMXCPTRAISEINFO_NONE RT_BIT_32(0)
73/** Delivery of a \#AC caused another \#AC. */
74#define IEMXCPTRAISEINFO_AC_AC RT_BIT_32(1)
75/** Delivery of a \#PF caused another \#PF. */
76#define IEMXCPTRAISEINFO_PF_PF RT_BIT_32(2)
77/** Delivery of a \#PF caused some contributory exception. */
78#define IEMXCPTRAISEINFO_PF_CONTRIBUTORY_XCPT RT_BIT_32(3)
79/** Delivery of an external interrupt caused an exception. */
80#define IEMXCPTRAISEINFO_EXT_INT_XCPT RT_BIT_32(4)
81/** Delivery of an external interrupt caused an \#PF. */
82#define IEMXCPTRAISEINFO_EXT_INT_PF RT_BIT_32(5)
83/** Delivery of a software interrupt caused an exception. */
84#define IEMXCPTRAISEINFO_SOFT_INT_XCPT RT_BIT_32(6)
85/** Delivery of an NMI caused an exception. */
86#define IEMXCPTRAISEINFO_NMI_XCPT RT_BIT_32(7)
87/** Delivery of an NMI caused a \#PF. */
88#define IEMXCPTRAISEINFO_NMI_PF RT_BIT_32(8)
89/** Can re-execute the instruction at CS:RIP. */
90#define IEMXCPTRAISEINFO_CAN_REEXEC_INSTR RT_BIT_32(9)
91/** @} */
92
93
94/** @name IEMXCPTRAISE_XXX - Ways to handle a recursive exception condition.
95 * @{ */
96typedef enum IEMXCPTRAISE
97{
98 /** Raise the current (second) exception. */
99 IEMXCPTRAISE_CURRENT_XCPT = 0,
100 /** Re-raise the previous (first) event (for HM, unused by IEM). */
101 IEMXCPTRAISE_PREV_EVENT,
102 /** Re-execute instruction at CS:RIP (for HM, unused by IEM). */
103 IEMXCPTRAISE_REEXEC_INSTR,
104 /** Raise a \#DF exception. */
105 IEMXCPTRAISE_DOUBLE_FAULT,
106 /** Raise a triple fault. */
107 IEMXCPTRAISE_TRIPLE_FAULT,
108 /** Cause a CPU hang. */
109 IEMXCPTRAISE_CPU_HANG,
110 /** Invalid sequence of events. */
111 IEMXCPTRAISE_INVALID = 0x7fffffff
112} IEMXCPTRAISE;
113/** Pointer to a IEMXCPTRAISE type. */
114typedef IEMXCPTRAISE *PIEMXCPTRAISE;
115/** @} */
116
117
118/** @name IEM_XCPT_FLAGS_XXX - flags for iemRaiseXcptOrInt.
119 * @{ */
120/** CPU exception. */
121#define IEM_XCPT_FLAGS_T_CPU_XCPT RT_BIT_32(0)
122/** External interrupt (from PIC, APIC, whatever). */
123#define IEM_XCPT_FLAGS_T_EXT_INT RT_BIT_32(1)
124/** Software interrupt (int or into, not bound).
125 * Returns to the following instruction */
126#define IEM_XCPT_FLAGS_T_SOFT_INT RT_BIT_32(2)
127/** Takes an error code. */
128#define IEM_XCPT_FLAGS_ERR RT_BIT_32(3)
129/** Takes a CR2. */
130#define IEM_XCPT_FLAGS_CR2 RT_BIT_32(4)
131/** Generated by the breakpoint instruction. */
132#define IEM_XCPT_FLAGS_BP_INSTR RT_BIT_32(5)
133/** Generated by a DRx instruction breakpoint and RF should be cleared. */
134#define IEM_XCPT_FLAGS_DRx_INSTR_BP RT_BIT_32(6)
135/** Generated by the icebp instruction. */
136#define IEM_XCPT_FLAGS_ICEBP_INSTR RT_BIT_32(7)
137/** Generated by the overflow instruction. */
138#define IEM_XCPT_FLAGS_OF_INSTR RT_BIT_32(8)
139/** @} */
140
141
142/** @name IEM status codes.
143 *
144 * Not quite sure how this will play out in the end, just aliasing safe status
145 * codes for now.
146 *
147 * @{ */
148#define VINF_IEM_RAISED_XCPT VINF_EM_RESCHEDULE
149/** @} */
150
151
152VMMDECL(VBOXSTRICTRC) IEMExecOne(PVMCPUCC pVCpu);
153VMMDECL(VBOXSTRICTRC) IEMExecOneEx(PVMCPUCC pVCpu, uint32_t *pcbWritten);
154VMMDECL(VBOXSTRICTRC) IEMExecOneWithPrefetchedByPC(PVMCPUCC pVCpu, uint64_t OpcodeBytesPC,
155 const void *pvOpcodeBytes, size_t cbOpcodeBytes);
156VMMDECL(VBOXSTRICTRC) IEMExecOneBypassEx(PVMCPUCC pVCpu, uint32_t *pcbWritten);
157VMMDECL(VBOXSTRICTRC) IEMExecOneBypassWithPrefetchedByPC(PVMCPUCC pVCpu, uint64_t OpcodeBytesPC,
158 const void *pvOpcodeBytes, size_t cbOpcodeBytes);
159VMMDECL(VBOXSTRICTRC) IEMExecOneIgnoreLock(PVMCPUCC pVCpu);
160VMMDECL(VBOXSTRICTRC) IEMExecLots(PVMCPUCC pVCpu, uint32_t cMaxInstructions, uint32_t cPollRate, uint32_t *pcInstructions);
161/** Statistics returned by IEMExecForExits. */
162typedef struct IEMEXECFOREXITSTATS
163{
164 uint32_t cInstructions;
165 uint32_t cExits;
166 uint32_t cMaxExitDistance;
167 uint32_t cReserved;
168} IEMEXECFOREXITSTATS;
169/** Pointer to statistics returned by IEMExecForExits. */
170typedef IEMEXECFOREXITSTATS *PIEMEXECFOREXITSTATS;
171VMMDECL(VBOXSTRICTRC) IEMExecForExits(PVMCPUCC pVCpu, uint32_t fWillExit, uint32_t cMinInstructions, uint32_t cMaxInstructions,
172 uint32_t cMaxInstructionsWithoutExits, PIEMEXECFOREXITSTATS pStats);
173VMMDECL(VBOXSTRICTRC) IEMInjectTrpmEvent(PVMCPUCC pVCpu);
174VMM_INT_DECL(VBOXSTRICTRC) IEMInjectTrap(PVMCPUCC pVCpu, uint8_t u8TrapNo, TRPMEVENT enmType, uint16_t uErrCode, RTGCPTR uCr2,
175 uint8_t cbInstr);
176
177VMM_INT_DECL(int) IEMBreakpointSet(PVM pVM, RTGCPTR GCPtrBp);
178VMM_INT_DECL(int) IEMBreakpointClear(PVM pVM, RTGCPTR GCPtrBp);
179
180VMM_INT_DECL(void) IEMTlbInvalidateAll(PVMCPUCC pVCpu);
181VMM_INT_DECL(void) IEMTlbInvalidatePage(PVMCPUCC pVCpu, RTGCPTR GCPtr);
182VMM_INT_DECL(void) IEMTlbInvalidateAllPhysical(PVMCPUCC pVCpu);
183VMM_INT_DECL(void) IEMTlbInvalidateAllPhysicalAllCpus(PVMCC pVM, VMCPUID idCpuCaller);
184VMM_INT_DECL(bool) IEMGetCurrentXcpt(PVMCPUCC pVCpu, uint8_t *puVector, uint32_t *pfFlags, uint32_t *puErr,
185 uint64_t *puCr2);
186VMM_INT_DECL(IEMXCPTRAISE) IEMEvaluateRecursiveXcpt(PVMCPUCC pVCpu, uint32_t fPrevFlags, uint8_t uPrevVector, uint32_t fCurFlags,
187 uint8_t uCurVector, PIEMXCPTRAISEINFO pXcptRaiseInfo);
188
189/** @defgroup grp_iem_r3 The IEM Host Context Ring-3 API.
190 * @{
191 */
192VMMR3DECL(int) IEMR3Init(PVM pVM);
193VMMR3DECL(int) IEMR3Term(PVM pVM);
194VMMR3DECL(void) IEMR3Relocate(PVM pVM);
195VMMR3_INT_DECL(VBOXSTRICTRC) IEMR3ProcessForceFlag(PVM pVM, PVMCPUCC pVCpu, VBOXSTRICTRC rcStrict);
196/** @} */
197
198/** @} */
199
200RT_C_DECLS_END
201
202#endif /* !VBOX_INCLUDED_vmm_iem_h */
203
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