VirtualBox

source: vbox/trunk/include/VBox/vmm/iem-x86-amd64.h@ 99897

Last change on this file since 99897 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: 15.9 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_x86_amd64_h
37#define VBOX_INCLUDED_vmm_iem_x86_amd64_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
43# include <VBox/vmm/hm_vmx.h>
44#endif
45
46
47RT_C_DECLS_BEGIN
48
49/** @addtogroup grp_iem
50 * @{ */
51
52/** @name Operand or addressing mode.
53 * @{ */
54typedef uint8_t IEMMODE;
55#define IEMMODE_16BIT 0
56#define IEMMODE_32BIT 1
57#define IEMMODE_64BIT 2
58/** @} */
59
60
61/** @name IEMTARGETCPU_XXX - IEM target CPU specification.
62 *
63 * This is a gross simpliciation of CPUMMICROARCH for dealing with really old
64 * CPUs which didn't have much in the way of hinting at supported instructions
65 * and features. This slowly changes with the introduction of CPUID with the
66 * Intel Pentium.
67 *
68 * @{
69 */
70/** The dynamic target CPU mode is for getting thru the BIOS and then use
71 * the debugger or modifying instruction behaviour (e.g. HLT) to switch to a
72 * different target CPU. */
73#define IEMTARGETCPU_DYNAMIC UINT32_C(0)
74/** Intel 8086/8088. */
75#define IEMTARGETCPU_8086 UINT32_C(1)
76/** NEC V20/V30.
77 * @remarks must be between 8086 and 80186. */
78#define IEMTARGETCPU_V20 UINT32_C(2)
79/** Intel 80186/80188. */
80#define IEMTARGETCPU_186 UINT32_C(3)
81/** Intel 80286. */
82#define IEMTARGETCPU_286 UINT32_C(4)
83/** Intel 80386. */
84#define IEMTARGETCPU_386 UINT32_C(5)
85/** Intel 80486. */
86#define IEMTARGETCPU_486 UINT32_C(6)
87/** Intel Pentium . */
88#define IEMTARGETCPU_PENTIUM UINT32_C(7)
89/** Intel PentiumPro. */
90#define IEMTARGETCPU_PPRO UINT32_C(8)
91/** A reasonably current CPU, probably newer than the pentium pro when it comes
92 * to the feature set and behaviour. Generally the CPUID info and CPU vendor
93 * dicates the behaviour here. */
94#define IEMTARGETCPU_CURRENT UINT32_C(9)
95/** @} */
96
97
98/** The CPUMCTX_EXTRN_XXX mask required to be cleared when interpreting anything.
99 * IEM will ASSUME the caller of IEM APIs has ensured these are already present. */
100#define IEM_CPUMCTX_EXTRN_MUST_MASK ( CPUMCTX_EXTRN_GPRS_MASK \
101 | CPUMCTX_EXTRN_RIP \
102 | CPUMCTX_EXTRN_RFLAGS \
103 | CPUMCTX_EXTRN_SS \
104 | CPUMCTX_EXTRN_CS \
105 | CPUMCTX_EXTRN_CR0 \
106 | CPUMCTX_EXTRN_CR3 \
107 | CPUMCTX_EXTRN_CR4 \
108 | CPUMCTX_EXTRN_APIC_TPR \
109 | CPUMCTX_EXTRN_EFER \
110 | CPUMCTX_EXTRN_DR7 )
111/** The CPUMCTX_EXTRN_XXX mask needed when injecting an exception/interrupt.
112 * IEM will import missing bits, callers are encouraged to make these registers
113 * available prior to injection calls if fetching state anyway. */
114#define IEM_CPUMCTX_EXTRN_XCPT_MASK ( IEM_CPUMCTX_EXTRN_MUST_MASK \
115 | CPUMCTX_EXTRN_CR2 \
116 | CPUMCTX_EXTRN_SREG_MASK \
117 | CPUMCTX_EXTRN_TABLE_MASK )
118/** The CPUMCTX_EXTRN_XXX mask required to be cleared when calling any
119 * IEMExecDecoded API not using memory. IEM will ASSUME the caller of IEM
120 * APIs has ensured these are already present.
121 * @note ASSUMES execution engine has checked for instruction breakpoints
122 * during decoding. */
123#define IEM_CPUMCTX_EXTRN_EXEC_DECODED_NO_MEM_MASK ( CPUMCTX_EXTRN_RIP \
124 | CPUMCTX_EXTRN_RFLAGS \
125 | CPUMCTX_EXTRN_SS /* for CPL */ \
126 | CPUMCTX_EXTRN_CS /* for mode */ \
127 | CPUMCTX_EXTRN_CR0 /* for mode */ \
128 | CPUMCTX_EXTRN_EFER /* for mode */ )
129/** The CPUMCTX_EXTRN_XXX mask required to be cleared when calling any
130 * IEMExecDecoded API using memory. IEM will ASSUME the caller of IEM
131 * APIs has ensured these are already present.
132 * @note ASSUMES execution engine has checked for instruction breakpoints
133 * during decoding. */
134#define IEM_CPUMCTX_EXTRN_EXEC_DECODED_MEM_MASK ( IEM_CPUMCTX_EXTRN_EXEC_DECODED_NO_MEM_MASK \
135 | CPUMCTX_EXTRN_CR3 /* for page tables */ \
136 | CPUMCTX_EXTRN_CR4 /* for mode paging mode */ \
137 | CPUMCTX_EXTRN_DR7 /* for memory breakpoints */ )
138
139#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
140/** The CPUMCTX_EXTRN_XXX mask needed when calling IEMExecDecodedVmlaunchVmresume().
141 * IEM will ASSUME the caller has ensured these are already present. */
142# define IEM_CPUMCTX_EXTRN_VMX_VMENTRY_MASK ( IEM_CPUMCTX_EXTRN_EXEC_DECODED_NO_MEM_MASK \
143 | CPUMCTX_EXTRN_CR2 \
144 | CPUMCTX_EXTRN_HWVIRT )
145
146/** The CPUMCTX_EXTRN_XXX mask that the IEM VM-exit code will import on-demand when
147 * needed, primarily because there are several IEM VM-exit interface functions and
148 * some of which may not cause a VM-exit at all.
149 *
150 * This is currently unused, but keeping it here in case we can get away a bit more
151 * fine-grained state handling.
152 *
153 * @note Update HM_CHANGED_VMX_VMEXIT_MASK if something here changes. */
154# define IEM_CPUMCTX_EXTRN_VMX_VMEXIT_MASK ( CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_CR3 | CPUMCTX_EXTRN_CR4 \
155 | CPUMCTX_EXTRN_DR7 | CPUMCTX_EXTRN_DR6 \
156 | CPUMCTX_EXTRN_EFER \
157 | CPUMCTX_EXTRN_SYSENTER_MSRS \
158 | CPUMCTX_EXTRN_OTHER_MSRS /* for PAT MSR */ \
159 | CPUMCTX_EXTRN_RIP | CPUMCTX_EXTRN_RSP | CPUMCTX_EXTRN_RFLAGS \
160 | CPUMCTX_EXTRN_SREG_MASK \
161 | CPUMCTX_EXTRN_TR \
162 | CPUMCTX_EXTRN_LDTR | CPUMCTX_EXTRN_GDTR | CPUMCTX_EXTRN_IDTR \
163 | CPUMCTX_EXTRN_HWVIRT )
164#endif
165
166#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
167/** The CPUMCTX_EXTRN_XXX mask needed when calling IEMExecSvmVmexit().
168 * IEM will ASSUME the caller has ensured these are already present. */
169# define IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK ( CPUMCTX_EXTRN_RSP \
170 | CPUMCTX_EXTRN_RAX \
171 | CPUMCTX_EXTRN_RIP \
172 | CPUMCTX_EXTRN_RFLAGS \
173 | CPUMCTX_EXTRN_CS \
174 | CPUMCTX_EXTRN_SS \
175 | CPUMCTX_EXTRN_DS \
176 | CPUMCTX_EXTRN_ES \
177 | CPUMCTX_EXTRN_GDTR \
178 | CPUMCTX_EXTRN_IDTR \
179 | CPUMCTX_EXTRN_CR_MASK \
180 | CPUMCTX_EXTRN_EFER \
181 | CPUMCTX_EXTRN_DR6 \
182 | CPUMCTX_EXTRN_DR7 \
183 | CPUMCTX_EXTRN_OTHER_MSRS \
184 | CPUMCTX_EXTRN_HWVIRT \
185 | CPUMCTX_EXTRN_APIC_TPR \
186 | CPUMCTX_EXTRN_HM_SVM_HWVIRT_VIRQ)
187
188/** The CPUMCTX_EXTRN_XXX mask needed when calling IEMExecDecodedVmrun().
189 * IEM will ASSUME the caller has ensured these are already present. */
190# define IEM_CPUMCTX_EXTRN_SVM_VMRUN_MASK IEM_CPUMCTX_EXTRN_SVM_VMEXIT_MASK
191#endif
192
193/** @name Given Instruction Interpreters
194 * @{ */
195VMM_INT_DECL(VBOXSTRICTRC) IEMExecStringIoWrite(PVMCPUCC pVCpu, uint8_t cbValue, IEMMODE enmAddrMode,
196 bool fRepPrefix, uint8_t cbInstr, uint8_t iEffSeg, bool fIoChecked);
197VMM_INT_DECL(VBOXSTRICTRC) IEMExecStringIoRead(PVMCPUCC pVCpu, uint8_t cbValue, IEMMODE enmAddrMode,
198 bool fRepPrefix, uint8_t cbInstr, bool fIoChecked);
199VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedOut(PVMCPUCC pVCpu, uint8_t cbInstr, uint16_t u16Port, bool fImm, uint8_t cbReg);
200VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedIn(PVMCPUCC pVCpu, uint8_t cbInstr, uint16_t u16Port, bool fImm, uint8_t cbReg);
201VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedMovCRxWrite(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iCrReg, uint8_t iGReg);
202VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedMovCRxRead(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iGReg, uint8_t iCrReg);
203VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedMovDRxWrite(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iDrReg, uint8_t iGReg);
204VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedMovDRxRead(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iGReg, uint8_t iDrReg);
205VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedClts(PVMCPUCC pVCpu, uint8_t cbInstr);
206VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedLmsw(PVMCPUCC pVCpu, uint8_t cbInstr, uint16_t uValue, RTGCPTR GCPtrEffDst);
207VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedXsetbv(PVMCPUCC pVCpu, uint8_t cbInstr);
208VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedWbinvd(PVMCPUCC pVCpu, uint8_t cbInstr);
209VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedInvd(PVMCPUCC pVCpu, uint8_t cbInstr);
210VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedInvlpg(PVMCPUCC pVCpu, uint8_t cbInstr, RTGCPTR GCPtrPage);
211VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedInvpcid(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrDesc,
212 uint64_t uType);
213VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedCpuid(PVMCPUCC pVCpu, uint8_t cbInstr);
214VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedRdpmc(PVMCPUCC pVCpu, uint8_t cbInstr);
215VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedRdtsc(PVMCPUCC pVCpu, uint8_t cbInstr);
216VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedRdtscp(PVMCPUCC pVCpu, uint8_t cbInstr);
217VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedRdmsr(PVMCPUCC pVCpu, uint8_t cbInstr);
218VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedWrmsr(PVMCPUCC pVCpu, uint8_t cbInstr);
219VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedMonitor(PVMCPUCC pVCpu, uint8_t cbInstr);
220VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedMwait(PVMCPUCC pVCpu, uint8_t cbInstr);
221VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedHlt(PVMCPUCC pVCpu, uint8_t cbInstr);
222
223#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
224VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedClgi(PVMCPUCC pVCpu, uint8_t cbInstr);
225VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedStgi(PVMCPUCC pVCpu, uint8_t cbInstr);
226VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmload(PVMCPUCC pVCpu, uint8_t cbInstr);
227VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmsave(PVMCPUCC pVCpu, uint8_t cbInstr);
228VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedInvlpga(PVMCPUCC pVCpu, uint8_t cbInstr);
229VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmrun(PVMCPUCC pVCpu, uint8_t cbInstr);
230VMM_INT_DECL(VBOXSTRICTRC) IEMExecSvmVmexit(PVMCPUCC pVCpu, uint64_t uExitCode, uint64_t uExitInfo1, uint64_t uExitInfo2);
231#endif
232
233#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
234VMM_INT_DECL(void) IEMReadVmxVmcsField(PCVMXVVMCS pVmcs, uint64_t u64VmcsField, uint64_t *pu64Dst);
235VMM_INT_DECL(void) IEMWriteVmxVmcsField(PVMXVVMCS pVmcs, uint64_t u64VmcsField, uint64_t u64Val);
236VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVirtApicAccessMsr(PVMCPUCC pVCpu, uint32_t idMsr, uint64_t *pu64Val, bool fWrite);
237VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitApicWrite(PVMCPUCC pVCpu);
238VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitPreemptTimer(PVMCPUCC pVCpu);
239VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitExtInt(PVMCPUCC pVCpu, uint8_t uVector, bool fIntPending);
240VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitXcpt(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo, PCVMXVEXITEVENTINFO pExitEventInfo);
241VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitXcptNmi(PVMCPUCC pVCpu);
242VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitTripleFault(PVMCPUCC pVCpu);
243VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitStartupIpi(PVMCPUCC pVCpu, uint8_t uVector);
244VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitInstrWithInfo(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
245VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitInstr(PVMCPUCC pVCpu, uint32_t uExitReason, uint8_t cbInstr);
246VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitTrapLike(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
247VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitTaskSwitch(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo, PCVMXVEXITEVENTINFO pExitEventInfo);
248VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitApicAccess(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo, PCVMXVEXITEVENTINFO pExitEventInfo);
249VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexit(PVMCPUCC pVCpu, uint32_t uExitReason, uint64_t uExitQual);
250VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmread(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
251VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmwrite(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
252VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmptrld(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
253VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmptrst(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
254VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmclear(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
255VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmlaunchVmresume(PVMCPUCC pVCpu, uint8_t cbInstr, VMXINSTRID uInstrId);
256VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmxon(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
257VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedVmxoff(PVMCPUCC pVCpu, uint8_t cbInstr);
258VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedInvvpid(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
259# ifdef VBOX_WITH_NESTED_HWVIRT_VMX_EPT
260VMM_INT_DECL(VBOXSTRICTRC) IEMExecDecodedInvept(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo);
261VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitEptViolation(PVMCPUCC pVCpu, PCVMXVEXITINFO pExitInfo, PCVMXVEXITEVENTINFO pExitEventInfo);
262VMM_INT_DECL(VBOXSTRICTRC) IEMExecVmxVmexitEptMisconfig(PVMCPUCC pVCpu, RTGCPHYS GCPhysAddr, PCVMXVEXITEVENTINFO pExitEventInfo);
263# endif
264#endif
265/** @} */
266
267/** @defgroup grp_iem_r0 The IEM Host Context Ring-0 API.
268 * @{
269 */
270VMMR0_INT_DECL(int) IEMR0InitVM(PGVM pGVM);
271/** @} */
272
273/** @} */
274
275RT_C_DECLS_END
276
277#endif /* !VBOX_INCLUDED_vmm_iem_x86_amd64_h */
278
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