VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/target-x86/IEMInlineExec-x86.h@ 108898

Last change on this file since 108898 was 108898, checked in by vboxsync, 2 weeks ago

VMM/IEM: Working on the ARM bsd/opensource spec reader & decoder generator. Still work in progress. jiraref:VBP-1598

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/* $Id: IEMInlineExec-x86.h 108898 2025-04-08 18:09:19Z vboxsync $ */
2/** @file
3 * IEM - Interpreted Execution Manager - X86 target, Inline Exec/Decoder routines.
4 *
5 * Target specific stuff for IEMAll.cpp.
6 */
7
8/*
9 * Copyright (C) 2011-2025 Oracle and/or its affiliates.
10 *
11 * This file is part of VirtualBox base platform packages, as
12 * available from https://www.virtualbox.org.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation, in version 3 of the
17 * License.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see <https://www.gnu.org/licenses>.
26 *
27 * SPDX-License-Identifier: GPL-3.0-only
28 */
29
30
31#ifndef VMM_INCLUDED_SRC_VMMAll_target_x86_IEMInlineExec_x86_h
32#define VMM_INCLUDED_SRC_VMMAll_target_x86_IEMInlineExec_x86_h
33#ifndef RT_WITHOUT_PRAGMA_ONCE
34# pragma once
35#endif
36
37
38#ifdef IEM_OPCODE_GET_FIRST_U8
39DECL_FORCE_INLINE_THROW(VBOXSTRICTRC) iemExecDecodeAndInterpretTargetInstruction(PVMCPUCC pVCpu)
40{
41 uint8_t b; IEM_OPCODE_GET_FIRST_U8(&b);
42 return FNIEMOP_CALL(g_apfnIemInterpretOnlyOneByteMap[b]);
43}
44#endif
45
46
47DECL_FORCE_INLINE(uint64_t) iemRegGetPC(PVMCPUCC pVCpu)
48{
49 return pVCpu->cpum.GstCtx.rip;
50}
51
52
53DECL_FORCE_INLINE(bool) iemExecLoopTargetCheckMaskedCpuFFs(PVMCPUCC pVCpu, uint64_t fCpuForceFlags)
54{
55 /* No FFs (irrelevant ones have already been masked out): */
56 if (!fCpuForceFlags)
57 return true;
58
59 /* We can continue loop if only APIC or/and PIC FFs are pending and
60 interrupts are masked (IF=0): */
61 return !(fCpuForceFlags & ~(VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_INTERRUPT_PIC))
62 && !pVCpu->cpum.GstCtx.rflags.Bits.u1IF;
63}
64
65#ifdef VBOX_STRICT
66
67DECLINLINE(void) iemInitDecoderStrictTarget(PVMCPUCC pVCpu)
68{
69 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.cs));
70 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.ss));
71 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.es));
72 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.ds));
73 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.fs));
74 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.gs));
75 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.ldtr));
76 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.tr));
77 RT_NOREF(pVCpu);
78}
79
80
81DECLINLINE(void) iemInitExecTailStrictTarget(PVMCPUCC pVCpu)
82{
83 /*
84 * Assert hidden register sanity (also done in iemInitDecoder and iemReInitDecoder).
85 */
86 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.cs));
87 Assert(CPUMSELREG_ARE_HIDDEN_PARTS_VALID(pVCpu, &pVCpu->cpum.GstCtx.ss));
88 RT_NOREF(pVCpu);
89}
90
91
92DECLINLINE(void) iemInitExecTargetStrict(PVMCPUCC pVCpu) RT_NOEXCEPT
93{
94 iemInitDecoderStrictTarget(pVCpu);
95
96 pVCpu->iem.s.enmDefAddrMode = (IEMMODE)0xfe;
97 pVCpu->iem.s.enmEffAddrMode = (IEMMODE)0xfe;
98 pVCpu->iem.s.enmDefOpSize = (IEMMODE)0xfe;
99 pVCpu->iem.s.enmEffOpSize = (IEMMODE)0xfe;
100 pVCpu->iem.s.fPrefixes = 0xfeedbeef;
101 pVCpu->iem.s.uRexReg = 127;
102 pVCpu->iem.s.uRexB = 127;
103 pVCpu->iem.s.offModRm = 127;
104 pVCpu->iem.s.uRexIndex = 127;
105 pVCpu->iem.s.iEffSeg = 127;
106 pVCpu->iem.s.idxPrefix = 127;
107 pVCpu->iem.s.uVex3rdReg = 127;
108 pVCpu->iem.s.uVexLength = 127;
109 pVCpu->iem.s.fEvexStuff = 127;
110 pVCpu->iem.s.uFpuOpcode = UINT16_MAX;
111# ifdef IEM_WITH_CODE_TLB
112 pVCpu->iem.s.offInstrNextByte = UINT16_MAX;
113 pVCpu->iem.s.pbInstrBuf = NULL;
114 pVCpu->iem.s.cbInstrBuf = UINT16_MAX;
115 pVCpu->iem.s.cbInstrBufTotal = UINT16_MAX;
116 pVCpu->iem.s.offCurInstrStart = INT16_MAX;
117 pVCpu->iem.s.uInstrBufPc = UINT64_C(0xc0ffc0ffcff0c0ff);
118# ifdef IEM_WITH_CODE_TLB_AND_OPCODE_BUF
119 pVCpu->iem.s.offOpcode = 127;
120# endif
121# else
122 pVCpu->iem.s.offOpcode = 127;
123 pVCpu->iem.s.cbOpcode = 127;
124# endif
125}
126
127#endif /* VBOX_STRICT */
128
129
130#ifdef DBGFTRACE_ENABLED
131DECLINLINE(void) iemInitDecoderTraceTargetPc(PVMCPUCC pVCpu, uint32_t fExec)
132{
133 switch (fExec & IEM_F_MODE_X86_CPUMODE_MASK)
134 {
135 case IEMMODE_64BIT:
136 RTTraceBufAddMsgF(pVCpu->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf), "I64/%u %08llx", IEM_GET_CPL(pVCpu), pVCpu->cpum.GstCtx.rip);
137 break;
138 case IEMMODE_32BIT:
139 RTTraceBufAddMsgF(pVCpu->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf), "I32/%u %04x:%08x", IEM_GET_CPL(pVCpu), pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip);
140 break;
141 case IEMMODE_16BIT:
142 RTTraceBufAddMsgF(pVCpu->CTX_SUFF(pVM)->CTX_SUFF(hTraceBuf), "I16/%u %04x:%04x", IEM_GET_CPL(pVCpu), pVCpu->cpum.GstCtx.cs.Sel, pVCpu->cpum.GstCtx.eip);
143 break;
144 case 3:
145 AssertFailedBreak();
146 }
147}
148#endif /* DBGFTRACE_ENABLED */
149
150#endif /* !VMM_INCLUDED_SRC_VMMAll_target_x86_IEMInlineExec_x86_h */
151
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette