VirtualBox

source: vbox/trunk/src/VBox/VMM/include/IEMInternal.h@ 94791

Last change on this file since 94791 was 94768, checked in by vboxsync, 3 years ago

VMM/IEM: Split up IEMAll.cpp into a few more compilation units. bugref:9898

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 145.7 KB
Line 
1/* $Id: IEMInternal.h 94768 2022-05-01 22:02:17Z vboxsync $ */
2/** @file
3 * IEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2011-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VMM_INCLUDED_SRC_include_IEMInternal_h
19#define VMM_INCLUDED_SRC_include_IEMInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/vmm/cpum.h>
25#include <VBox/vmm/iem.h>
26#include <VBox/vmm/pgm.h>
27#include <VBox/vmm/stam.h>
28#include <VBox/param.h>
29
30#include <setjmp.h>
31
32
33RT_C_DECLS_BEGIN
34
35
36/** @defgroup grp_iem_int Internals
37 * @ingroup grp_iem
38 * @internal
39 * @{
40 */
41
42/** For expanding symbol in slickedit and other products tagging and
43 * crossreferencing IEM symbols. */
44#ifndef IEM_STATIC
45# define IEM_STATIC static
46#endif
47
48/** @def IEM_WITH_SETJMP
49 * Enables alternative status code handling using setjmps.
50 *
51 * This adds a bit of expense via the setjmp() call since it saves all the
52 * non-volatile registers. However, it eliminates return code checks and allows
53 * for more optimal return value passing (return regs instead of stack buffer).
54 */
55#if defined(DOXYGEN_RUNNING) || defined(RT_OS_WINDOWS) || 1
56# define IEM_WITH_SETJMP
57#endif
58
59#define IEM_IMPLEMENTS_TASKSWITCH
60
61/** @def IEM_WITH_3DNOW
62 * Includes the 3DNow decoding. */
63#define IEM_WITH_3DNOW
64
65/** @def IEM_WITH_THREE_0F_38
66 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
67#define IEM_WITH_THREE_0F_38
68
69/** @def IEM_WITH_THREE_0F_3A
70 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
71#define IEM_WITH_THREE_0F_3A
72
73/** @def IEM_WITH_VEX
74 * Includes the VEX decoding. */
75#define IEM_WITH_VEX
76
77/** @def IEM_CFG_TARGET_CPU
78 * The minimum target CPU for the IEM emulation (IEMTARGETCPU_XXX value).
79 *
80 * By default we allow this to be configured by the user via the
81 * CPUM/GuestCpuName config string, but this comes at a slight cost during
82 * decoding. So, for applications of this code where there is no need to
83 * be dynamic wrt target CPU, just modify this define.
84 */
85#if !defined(IEM_CFG_TARGET_CPU) || defined(DOXYGEN_RUNNING)
86# define IEM_CFG_TARGET_CPU IEMTARGETCPU_DYNAMIC
87#endif
88
89//#define IEM_WITH_CODE_TLB // - work in progress
90//#define IEM_WITH_DATA_TLB // - incomplete in progress
91
92
93/** @def IEM_USE_UNALIGNED_DATA_ACCESS
94 * Use unaligned accesses instead of elaborate byte assembly. */
95#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(DOXYGEN_RUNNING)
96# define IEM_USE_UNALIGNED_DATA_ACCESS
97#endif
98
99//#define IEM_LOG_MEMORY_WRITES
100
101#if !defined(IN_TSTVMSTRUCT) && !defined(DOXYGEN_RUNNING)
102/** Instruction statistics. */
103typedef struct IEMINSTRSTATS
104{
105# define IEM_DO_INSTR_STAT(a_Name, a_szDesc) uint32_t a_Name;
106# include "IEMInstructionStatisticsTmpl.h"
107# undef IEM_DO_INSTR_STAT
108} IEMINSTRSTATS;
109#else
110struct IEMINSTRSTATS;
111typedef struct IEMINSTRSTATS IEMINSTRSTATS;
112#endif
113/** Pointer to IEM instruction statistics. */
114typedef IEMINSTRSTATS *PIEMINSTRSTATS;
115
116
117/** @name IEMTARGETCPU_EFL_BEHAVIOR_XXX - IEMCPU::idxTargetCpuEflFlavour
118 * @{ */
119#define IEMTARGETCPU_EFL_BEHAVIOR_NATIVE 0 /**< Native x86 EFLAGS result; Intel EFLAGS when on non-x86 hosts. */
120#define IEMTARGETCPU_EFL_BEHAVIOR_INTEL 1 /**< Intel EFLAGS result. */
121#define IEMTARGETCPU_EFL_BEHAVIOR_AMD 2 /**< AMD EFLAGS result */
122#define IEMTARGETCPU_EFL_BEHAVIOR_RESERVED 3 /**< Reserved/dummy entry slot that's the same as 0. */
123#define IEMTARGETCPU_EFL_BEHAVIOR_MASK 3 /**< For masking the index before use. */
124/** Selects the right variant from a_aArray.
125 * pVCpu is implicit in the caller context. */
126#define IEMTARGETCPU_EFL_BEHAVIOR_SELECT(a_aArray) \
127 (a_aArray[pVCpu->iem.s.idxTargetCpuEflFlavour & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
128/** @} */
129
130
131/**
132 * Extended operand mode that includes a representation of 8-bit.
133 *
134 * This is used for packing down modes when invoking some C instruction
135 * implementations.
136 */
137typedef enum IEMMODEX
138{
139 IEMMODEX_16BIT = IEMMODE_16BIT,
140 IEMMODEX_32BIT = IEMMODE_32BIT,
141 IEMMODEX_64BIT = IEMMODE_64BIT,
142 IEMMODEX_8BIT
143} IEMMODEX;
144AssertCompileSize(IEMMODEX, 4);
145
146
147/**
148 * Branch types.
149 */
150typedef enum IEMBRANCH
151{
152 IEMBRANCH_JUMP = 1,
153 IEMBRANCH_CALL,
154 IEMBRANCH_TRAP,
155 IEMBRANCH_SOFTWARE_INT,
156 IEMBRANCH_HARDWARE_INT
157} IEMBRANCH;
158AssertCompileSize(IEMBRANCH, 4);
159
160
161/**
162 * INT instruction types.
163 */
164typedef enum IEMINT
165{
166 /** INT n instruction (opcode 0xcd imm). */
167 IEMINT_INTN = 0,
168 /** Single byte INT3 instruction (opcode 0xcc). */
169 IEMINT_INT3 = IEM_XCPT_FLAGS_BP_INSTR,
170 /** Single byte INTO instruction (opcode 0xce). */
171 IEMINT_INTO = IEM_XCPT_FLAGS_OF_INSTR,
172 /** Single byte INT1 (ICEBP) instruction (opcode 0xf1). */
173 IEMINT_INT1 = IEM_XCPT_FLAGS_ICEBP_INSTR
174} IEMINT;
175AssertCompileSize(IEMINT, 4);
176
177
178/**
179 * A FPU result.
180 */
181typedef struct IEMFPURESULT
182{
183 /** The output value. */
184 RTFLOAT80U r80Result;
185 /** The output status. */
186 uint16_t FSW;
187} IEMFPURESULT;
188AssertCompileMemberOffset(IEMFPURESULT, FSW, 10);
189/** Pointer to a FPU result. */
190typedef IEMFPURESULT *PIEMFPURESULT;
191/** Pointer to a const FPU result. */
192typedef IEMFPURESULT const *PCIEMFPURESULT;
193
194
195/**
196 * A FPU result consisting of two output values and FSW.
197 */
198typedef struct IEMFPURESULTTWO
199{
200 /** The first output value. */
201 RTFLOAT80U r80Result1;
202 /** The output status. */
203 uint16_t FSW;
204 /** The second output value. */
205 RTFLOAT80U r80Result2;
206} IEMFPURESULTTWO;
207AssertCompileMemberOffset(IEMFPURESULTTWO, FSW, 10);
208AssertCompileMemberOffset(IEMFPURESULTTWO, r80Result2, 12);
209/** Pointer to a FPU result consisting of two output values and FSW. */
210typedef IEMFPURESULTTWO *PIEMFPURESULTTWO;
211/** Pointer to a const FPU result consisting of two output values and FSW. */
212typedef IEMFPURESULTTWO const *PCIEMFPURESULTTWO;
213
214
215/**
216 * IEM TLB entry.
217 *
218 * Lookup assembly:
219 * @code{.asm}
220 ; Calculate tag.
221 mov rax, [VA]
222 shl rax, 16
223 shr rax, 16 + X86_PAGE_SHIFT
224 or rax, [uTlbRevision]
225
226 ; Do indexing.
227 movzx ecx, al
228 lea rcx, [pTlbEntries + rcx]
229
230 ; Check tag.
231 cmp [rcx + IEMTLBENTRY.uTag], rax
232 jne .TlbMiss
233
234 ; Check access.
235 mov rax, ACCESS_FLAGS | MAPPING_R3_NOT_VALID | 0xffffff00
236 and rax, [rcx + IEMTLBENTRY.fFlagsAndPhysRev]
237 cmp rax, [uTlbPhysRev]
238 jne .TlbMiss
239
240 ; Calc address and we're done.
241 mov eax, X86_PAGE_OFFSET_MASK
242 and eax, [VA]
243 or rax, [rcx + IEMTLBENTRY.pMappingR3]
244 %ifdef VBOX_WITH_STATISTICS
245 inc qword [cTlbHits]
246 %endif
247 jmp .Done
248
249 .TlbMiss:
250 mov r8d, ACCESS_FLAGS
251 mov rdx, [VA]
252 mov rcx, [pVCpu]
253 call iemTlbTypeMiss
254 .Done:
255
256 @endcode
257 *
258 */
259typedef struct IEMTLBENTRY
260{
261 /** The TLB entry tag.
262 * Bits 35 thru 0 are made up of the virtual address shifted right 12 bits, this
263 * is ASSUMING a virtual address width of 48 bits.
264 *
265 * Bits 63 thru 36 are made up of the TLB revision (zero means invalid).
266 *
267 * The TLB lookup code uses the current TLB revision, which won't ever be zero,
268 * enabling an extremely cheap TLB invalidation most of the time. When the TLB
269 * revision wraps around though, the tags needs to be zeroed.
270 *
271 * @note Try use SHRD instruction? After seeing
272 * https://gmplib.org/~tege/x86-timing.pdf, maybe not.
273 *
274 * @todo This will need to be reorganized for 57-bit wide virtual address and
275 * PCID (currently 12 bits) and ASID (currently 6 bits) support. We'll
276 * have to move the TLB entry versioning entirely to the
277 * fFlagsAndPhysRev member then, 57 bit wide VAs means we'll only have
278 * 19 bits left (64 - 57 + 12 = 19) and they'll almost entire be
279 * consumed by PCID and ASID (12 + 6 = 18).
280 */
281 uint64_t uTag;
282 /** Access flags and physical TLB revision.
283 *
284 * - Bit 0 - page tables - not executable (X86_PTE_PAE_NX).
285 * - Bit 1 - page tables - not writable (complemented X86_PTE_RW).
286 * - Bit 2 - page tables - not user (complemented X86_PTE_US).
287 * - Bit 3 - pgm phys/virt - not directly writable.
288 * - Bit 4 - pgm phys page - not directly readable.
289 * - Bit 5 - currently unused.
290 * - Bit 6 - page tables - not dirty (complemented X86_PTE_D).
291 * - Bit 7 - tlb entry - pMappingR3 member not valid.
292 * - Bits 63 thru 8 are used for the physical TLB revision number.
293 *
294 * We're using complemented bit meanings here because it makes it easy to check
295 * whether special action is required. For instance a user mode write access
296 * would do a "TEST fFlags, (X86_PTE_RW | X86_PTE_US | X86_PTE_D)" and a
297 * non-zero result would mean special handling needed because either it wasn't
298 * writable, or it wasn't user, or the page wasn't dirty. A user mode read
299 * access would do "TEST fFlags, X86_PTE_US"; and a kernel mode read wouldn't
300 * need to check any PTE flag.
301 */
302 uint64_t fFlagsAndPhysRev;
303 /** The guest physical page address. */
304 uint64_t GCPhys;
305 /** Pointer to the ring-3 mapping (possibly also valid in ring-0). */
306 R3PTRTYPE(uint8_t *) pbMappingR3;
307#if HC_ARCH_BITS == 32
308 uint32_t u32Padding1;
309#endif
310} IEMTLBENTRY;
311AssertCompileSize(IEMTLBENTRY, 32);
312/** Pointer to an IEM TLB entry. */
313typedef IEMTLBENTRY *PIEMTLBENTRY;
314
315/** @name IEMTLBE_F_XXX - TLB entry flags (IEMTLBENTRY::fFlagsAndPhysRev)
316 * @{ */
317#define IEMTLBE_F_PT_NO_EXEC RT_BIT_64(0) /**< Page tables: Not executable. */
318#define IEMTLBE_F_PT_NO_WRITE RT_BIT_64(1) /**< Page tables: Not writable. */
319#define IEMTLBE_F_PT_NO_USER RT_BIT_64(2) /**< Page tables: Not user accessible (supervisor only). */
320#define IEMTLBE_F_PG_NO_WRITE RT_BIT_64(3) /**< Phys page: Not writable (access handler, ROM, whatever). */
321#define IEMTLBE_F_PG_NO_READ RT_BIT_64(4) /**< Phys page: Not readable (MMIO / access handler, ROM) */
322#define IEMTLBE_F_PT_NO_DIRTY RT_BIT_64(6) /**< Page tables: Not dirty (needs to be made dirty on write). */
323#define IEMTLBE_F_NO_MAPPINGR3 RT_BIT_64(7) /**< TLB entry: The IEMTLBENTRY::pMappingR3 member is invalid. */
324#define IEMTLBE_F_PHYS_REV UINT64_C(0xffffffffffffff00) /**< Physical revision mask. */
325/** @} */
326
327
328/**
329 * An IEM TLB.
330 *
331 * We've got two of these, one for data and one for instructions.
332 */
333typedef struct IEMTLB
334{
335 /** The TLB entries.
336 * We've choosen 256 because that way we can obtain the result directly from a
337 * 8-bit register without an additional AND instruction. */
338 IEMTLBENTRY aEntries[256];
339 /** The TLB revision.
340 * This is actually only 28 bits wide (see IEMTLBENTRY::uTag) and is incremented
341 * by adding RT_BIT_64(36) to it. When it wraps around and becomes zero, all
342 * the tags in the TLB must be zeroed and the revision set to RT_BIT_64(36).
343 * (The revision zero indicates an invalid TLB entry.)
344 *
345 * The initial value is choosen to cause an early wraparound. */
346 uint64_t uTlbRevision;
347 /** The TLB physical address revision - shadow of PGM variable.
348 *
349 * This is actually only 56 bits wide (see IEMTLBENTRY::fFlagsAndPhysRev) and is
350 * incremented by adding RT_BIT_64(8). When it wraps around and becomes zero,
351 * a rendezvous is called and each CPU wipe the IEMTLBENTRY::pMappingR3 as well
352 * as IEMTLBENTRY::fFlagsAndPhysRev bits 63 thru 8, 4, and 3.
353 *
354 * The initial value is choosen to cause an early wraparound. */
355 uint64_t volatile uTlbPhysRev;
356
357 /* Statistics: */
358
359 /** TLB hits (VBOX_WITH_STATISTICS only). */
360 uint64_t cTlbHits;
361 /** TLB misses. */
362 uint32_t cTlbMisses;
363 /** Slow read path. */
364 uint32_t cTlbSlowReadPath;
365#if 0
366 /** TLB misses because of tag mismatch. */
367 uint32_t cTlbMissesTag;
368 /** TLB misses because of virtual access violation. */
369 uint32_t cTlbMissesVirtAccess;
370 /** TLB misses because of dirty bit. */
371 uint32_t cTlbMissesDirty;
372 /** TLB misses because of MMIO */
373 uint32_t cTlbMissesMmio;
374 /** TLB misses because of write access handlers. */
375 uint32_t cTlbMissesWriteHandler;
376 /** TLB misses because no r3(/r0) mapping. */
377 uint32_t cTlbMissesMapping;
378#endif
379 /** Alignment padding. */
380 uint32_t au32Padding[3+5];
381} IEMTLB;
382AssertCompileSizeAlignment(IEMTLB, 64);
383/** IEMTLB::uTlbRevision increment. */
384#define IEMTLB_REVISION_INCR RT_BIT_64(36)
385/** IEMTLB::uTlbPhysRev increment. */
386#define IEMTLB_PHYS_REV_INCR RT_BIT_64(8)
387
388
389/**
390 * The per-CPU IEM state.
391 */
392typedef struct IEMCPU
393{
394 /** Info status code that needs to be propagated to the IEM caller.
395 * This cannot be passed internally, as it would complicate all success
396 * checks within the interpreter making the code larger and almost impossible
397 * to get right. Instead, we'll store status codes to pass on here. Each
398 * source of these codes will perform appropriate sanity checks. */
399 int32_t rcPassUp; /* 0x00 */
400
401 /** The current CPU execution mode (CS). */
402 IEMMODE enmCpuMode; /* 0x04 */
403 /** The CPL. */
404 uint8_t uCpl; /* 0x05 */
405
406 /** Whether to bypass access handlers or not. */
407 bool fBypassHandlers; /* 0x06 */
408 /** Whether to disregard the lock prefix (implied or not). */
409 bool fDisregardLock; /* 0x07 */
410
411 /** @name Decoder state.
412 * @{ */
413#ifdef IEM_WITH_CODE_TLB
414 /** The offset of the next instruction byte. */
415 uint32_t offInstrNextByte; /* 0x08 */
416 /** The number of bytes available at pbInstrBuf for the current instruction.
417 * This takes the max opcode length into account so that doesn't need to be
418 * checked separately. */
419 uint32_t cbInstrBuf; /* 0x0c */
420 /** Pointer to the page containing RIP, user specified buffer or abOpcode.
421 * This can be NULL if the page isn't mappable for some reason, in which
422 * case we'll do fallback stuff.
423 *
424 * If we're executing an instruction from a user specified buffer,
425 * IEMExecOneWithPrefetchedByPC and friends, this is not necessarily a page
426 * aligned pointer but pointer to the user data.
427 *
428 * For instructions crossing pages, this will start on the first page and be
429 * advanced to the next page by the time we've decoded the instruction. This
430 * therefore precludes stuff like <tt>pbInstrBuf[offInstrNextByte + cbInstrBuf - cbCurInstr]</tt>
431 */
432 uint8_t const *pbInstrBuf; /* 0x10 */
433# if ARCH_BITS == 32
434 uint32_t uInstrBufHigh; /** The high dword of the host context pbInstrBuf member. */
435# endif
436 /** The program counter corresponding to pbInstrBuf.
437 * This is set to a non-canonical address when we need to invalidate it. */
438 uint64_t uInstrBufPc; /* 0x18 */
439 /** The number of bytes available at pbInstrBuf in total (for IEMExecLots).
440 * This takes the CS segment limit into account. */
441 uint16_t cbInstrBufTotal; /* 0x20 */
442 /** Offset into pbInstrBuf of the first byte of the current instruction.
443 * Can be negative to efficiently handle cross page instructions. */
444 int16_t offCurInstrStart; /* 0x22 */
445
446 /** The prefix mask (IEM_OP_PRF_XXX). */
447 uint32_t fPrefixes; /* 0x24 */
448 /** The extra REX ModR/M register field bit (REX.R << 3). */
449 uint8_t uRexReg; /* 0x28 */
450 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
451 * (REX.B << 3). */
452 uint8_t uRexB; /* 0x29 */
453 /** The extra REX SIB index field bit (REX.X << 3). */
454 uint8_t uRexIndex; /* 0x2a */
455
456 /** The effective segment register (X86_SREG_XXX). */
457 uint8_t iEffSeg; /* 0x2b */
458
459 /** The offset of the ModR/M byte relative to the start of the instruction. */
460 uint8_t offModRm; /* 0x2c */
461#else
462 /** The size of what has currently been fetched into abOpcode. */
463 uint8_t cbOpcode; /* 0x08 */
464 /** The current offset into abOpcode. */
465 uint8_t offOpcode; /* 0x09 */
466 /** The offset of the ModR/M byte relative to the start of the instruction. */
467 uint8_t offModRm; /* 0x0a */
468
469 /** The effective segment register (X86_SREG_XXX). */
470 uint8_t iEffSeg; /* 0x0b */
471
472 /** The prefix mask (IEM_OP_PRF_XXX). */
473 uint32_t fPrefixes; /* 0x0c */
474 /** The extra REX ModR/M register field bit (REX.R << 3). */
475 uint8_t uRexReg; /* 0x10 */
476 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
477 * (REX.B << 3). */
478 uint8_t uRexB; /* 0x11 */
479 /** The extra REX SIB index field bit (REX.X << 3). */
480 uint8_t uRexIndex; /* 0x12 */
481
482#endif
483
484 /** The effective operand mode. */
485 IEMMODE enmEffOpSize; /* 0x2d, 0x13 */
486 /** The default addressing mode. */
487 IEMMODE enmDefAddrMode; /* 0x2e, 0x14 */
488 /** The effective addressing mode. */
489 IEMMODE enmEffAddrMode; /* 0x2f, 0x15 */
490 /** The default operand mode. */
491 IEMMODE enmDefOpSize; /* 0x30, 0x16 */
492
493 /** Prefix index (VEX.pp) for two byte and three byte tables. */
494 uint8_t idxPrefix; /* 0x31, 0x17 */
495 /** 3rd VEX/EVEX/XOP register.
496 * Please use IEM_GET_EFFECTIVE_VVVV to access. */
497 uint8_t uVex3rdReg; /* 0x32, 0x18 */
498 /** The VEX/EVEX/XOP length field. */
499 uint8_t uVexLength; /* 0x33, 0x19 */
500 /** Additional EVEX stuff. */
501 uint8_t fEvexStuff; /* 0x34, 0x1a */
502
503 /** Explicit alignment padding. */
504 uint8_t abAlignment2a[1]; /* 0x35, 0x1b */
505 /** The FPU opcode (FOP). */
506 uint16_t uFpuOpcode; /* 0x36, 0x1c */
507#ifndef IEM_WITH_CODE_TLB
508 /** Explicit alignment padding. */
509 uint8_t abAlignment2b[2]; /* 0x1e */
510#endif
511
512 /** The opcode bytes. */
513 uint8_t abOpcode[15]; /* 0x48, 0x20 */
514 /** Explicit alignment padding. */
515#ifdef IEM_WITH_CODE_TLB
516 uint8_t abAlignment2c[0x48 - 0x47]; /* 0x37 */
517#else
518 uint8_t abAlignment2c[0x48 - 0x2f]; /* 0x2f */
519#endif
520 /** @} */
521
522
523 /** The flags of the current exception / interrupt. */
524 uint32_t fCurXcpt; /* 0x48, 0x48 */
525 /** The current exception / interrupt. */
526 uint8_t uCurXcpt;
527 /** Exception / interrupt recursion depth. */
528 int8_t cXcptRecursions;
529
530 /** The number of active guest memory mappings. */
531 uint8_t cActiveMappings;
532 /** The next unused mapping index. */
533 uint8_t iNextMapping;
534 /** Records for tracking guest memory mappings. */
535 struct
536 {
537 /** The address of the mapped bytes. */
538 void *pv;
539 /** The access flags (IEM_ACCESS_XXX).
540 * IEM_ACCESS_INVALID if the entry is unused. */
541 uint32_t fAccess;
542#if HC_ARCH_BITS == 64
543 uint32_t u32Alignment4; /**< Alignment padding. */
544#endif
545 } aMemMappings[3];
546
547 /** Locking records for the mapped memory. */
548 union
549 {
550 PGMPAGEMAPLOCK Lock;
551 uint64_t au64Padding[2];
552 } aMemMappingLocks[3];
553
554 /** Bounce buffer info.
555 * This runs in parallel to aMemMappings. */
556 struct
557 {
558 /** The physical address of the first byte. */
559 RTGCPHYS GCPhysFirst;
560 /** The physical address of the second page. */
561 RTGCPHYS GCPhysSecond;
562 /** The number of bytes in the first page. */
563 uint16_t cbFirst;
564 /** The number of bytes in the second page. */
565 uint16_t cbSecond;
566 /** Whether it's unassigned memory. */
567 bool fUnassigned;
568 /** Explicit alignment padding. */
569 bool afAlignment5[3];
570 } aMemBbMappings[3];
571
572 /** Bounce buffer storage.
573 * This runs in parallel to aMemMappings and aMemBbMappings. */
574 struct
575 {
576 uint8_t ab[512];
577 } aBounceBuffers[3];
578
579
580 /** Pointer set jump buffer - ring-3 context. */
581 R3PTRTYPE(jmp_buf *) pJmpBufR3;
582 /** Pointer set jump buffer - ring-0 context. */
583 R0PTRTYPE(jmp_buf *) pJmpBufR0;
584
585 /** @todo Should move this near @a fCurXcpt later. */
586 /** The CR2 for the current exception / interrupt. */
587 uint64_t uCurXcptCr2;
588 /** The error code for the current exception / interrupt. */
589 uint32_t uCurXcptErr;
590
591 /** @name Statistics
592 * @{ */
593 /** The number of instructions we've executed. */
594 uint32_t cInstructions;
595 /** The number of potential exits. */
596 uint32_t cPotentialExits;
597 /** The number of bytes data or stack written (mostly for IEMExecOneEx).
598 * This may contain uncommitted writes. */
599 uint32_t cbWritten;
600 /** Counts the VERR_IEM_INSTR_NOT_IMPLEMENTED returns. */
601 uint32_t cRetInstrNotImplemented;
602 /** Counts the VERR_IEM_ASPECT_NOT_IMPLEMENTED returns. */
603 uint32_t cRetAspectNotImplemented;
604 /** Counts informational statuses returned (other than VINF_SUCCESS). */
605 uint32_t cRetInfStatuses;
606 /** Counts other error statuses returned. */
607 uint32_t cRetErrStatuses;
608 /** Number of times rcPassUp has been used. */
609 uint32_t cRetPassUpStatus;
610 /** Number of times RZ left with instruction commit pending for ring-3. */
611 uint32_t cPendingCommit;
612 /** Number of long jumps. */
613 uint32_t cLongJumps;
614 /** @} */
615
616 /** @name Target CPU information.
617 * @{ */
618#if IEM_CFG_TARGET_CPU == IEMTARGETCPU_DYNAMIC
619 /** The target CPU. */
620 uint8_t uTargetCpu;
621#else
622 uint8_t bTargetCpuPadding;
623#endif
624 /** For selecting assembly works matching the target CPU EFLAGS behaviour, see
625 * IEMTARGETCPU_EFL_BEHAVIOR_XXX for values. This is for instance used for the
626 * BSF & BSR instructions where AMD and Intel CPUs produce different EFLAGS. */
627 uint8_t idxTargetCpuEflFlavour;
628
629 /** The CPU vendor. */
630 CPUMCPUVENDOR enmCpuVendor;
631 /** @} */
632
633 /** @name Host CPU information.
634 * @{ */
635 /** The CPU vendor. */
636 CPUMCPUVENDOR enmHostCpuVendor;
637 /** @} */
638
639 /** Counts RDMSR \#GP(0) LogRel(). */
640 uint8_t cLogRelRdMsr;
641 /** Counts WRMSR \#GP(0) LogRel(). */
642 uint8_t cLogRelWrMsr;
643 /** Alignment padding. */
644 uint8_t abAlignment8[50];
645
646 /** Data TLB.
647 * @remarks Must be 64-byte aligned. */
648 IEMTLB DataTlb;
649 /** Instruction TLB.
650 * @remarks Must be 64-byte aligned. */
651 IEMTLB CodeTlb;
652
653#if defined(VBOX_WITH_STATISTICS) && !defined(IN_TSTVMSTRUCT) && !defined(DOXYGEN_RUNNING)
654 /** Instruction statistics for ring-0/raw-mode. */
655 IEMINSTRSTATS StatsRZ;
656 /** Instruction statistics for ring-3. */
657 IEMINSTRSTATS StatsR3;
658#endif
659} IEMCPU;
660AssertCompileMemberOffset(IEMCPU, fCurXcpt, 0x48);
661AssertCompileMemberAlignment(IEMCPU, DataTlb, 64);
662AssertCompileMemberAlignment(IEMCPU, CodeTlb, 64);
663/** Pointer to the per-CPU IEM state. */
664typedef IEMCPU *PIEMCPU;
665/** Pointer to the const per-CPU IEM state. */
666typedef IEMCPU const *PCIEMCPU;
667
668
669/** @def IEM_GET_CTX
670 * Gets the guest CPU context for the calling EMT.
671 * @returns PCPUMCTX
672 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
673 */
674#define IEM_GET_CTX(a_pVCpu) (&(a_pVCpu)->cpum.GstCtx)
675
676/** @def IEM_CTX_ASSERT
677 * Asserts that the @a a_fExtrnMbz is present in the CPU context.
678 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
679 * @param a_fExtrnMbz The mask of CPUMCTX_EXTRN_XXX flags that must be zero.
680 */
681#define IEM_CTX_ASSERT(a_pVCpu, a_fExtrnMbz) AssertMsg(!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz)), \
682 ("fExtrn=%#RX64 fExtrnMbz=%#RX64\n", (a_pVCpu)->cpum.GstCtx.fExtrn, \
683 (a_fExtrnMbz)))
684
685/** @def IEM_CTX_IMPORT_RET
686 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
687 *
688 * Will call the keep to import the bits as needed.
689 *
690 * Returns on import failure.
691 *
692 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
693 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
694 */
695#define IEM_CTX_IMPORT_RET(a_pVCpu, a_fExtrnImport) \
696 do { \
697 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
698 { /* likely */ } \
699 else \
700 { \
701 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
702 AssertRCReturn(rcCtxImport, rcCtxImport); \
703 } \
704 } while (0)
705
706/** @def IEM_CTX_IMPORT_NORET
707 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
708 *
709 * Will call the keep to import the bits as needed.
710 *
711 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
712 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
713 */
714#define IEM_CTX_IMPORT_NORET(a_pVCpu, a_fExtrnImport) \
715 do { \
716 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
717 { /* likely */ } \
718 else \
719 { \
720 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
721 AssertLogRelRC(rcCtxImport); \
722 } \
723 } while (0)
724
725/** @def IEM_CTX_IMPORT_JMP
726 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
727 *
728 * Will call the keep to import the bits as needed.
729 *
730 * Jumps on import failure.
731 *
732 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
733 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
734 */
735#define IEM_CTX_IMPORT_JMP(a_pVCpu, a_fExtrnImport) \
736 do { \
737 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
738 { /* likely */ } \
739 else \
740 { \
741 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
742 AssertRCStmt(rcCtxImport, longjmp(*pVCpu->iem.s.CTX_SUFF(pJmpBuf), rcCtxImport)); \
743 } \
744 } while (0)
745
746
747
748/** @def IEM_GET_TARGET_CPU
749 * Gets the current IEMTARGETCPU value.
750 * @returns IEMTARGETCPU value.
751 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
752 */
753#if IEM_CFG_TARGET_CPU != IEMTARGETCPU_DYNAMIC
754# define IEM_GET_TARGET_CPU(a_pVCpu) (IEM_CFG_TARGET_CPU)
755#else
756# define IEM_GET_TARGET_CPU(a_pVCpu) ((a_pVCpu)->iem.s.uTargetCpu)
757#endif
758
759/** @def IEM_GET_INSTR_LEN
760 * Gets the instruction length. */
761#ifdef IEM_WITH_CODE_TLB
762# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offInstrNextByte - (uint32_t)(int32_t)(a_pVCpu)->iem.s.offCurInstrStart)
763#else
764# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offOpcode)
765#endif
766
767
768/**
769 * Shared per-VM IEM data.
770 */
771typedef struct IEM
772{
773 /** The VMX APIC-access page handler type. */
774 PGMPHYSHANDLERTYPE hVmxApicAccessPage;
775} IEM;
776
777
778
779/** @name IEM_ACCESS_XXX - Access details.
780 * @{ */
781#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
782#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
783#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
784#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
785#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
786#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
787#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
788#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
789#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
790#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
791/** The writes are partial, so if initialize the bounce buffer with the
792 * orignal RAM content. */
793#define IEM_ACCESS_PARTIAL_WRITE UINT32_C(0x00000100)
794/** Used in aMemMappings to indicate that the entry is bounce buffered. */
795#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000200)
796/** Bounce buffer with ring-3 write pending, first page. */
797#define IEM_ACCESS_PENDING_R3_WRITE_1ST UINT32_C(0x00000400)
798/** Bounce buffer with ring-3 write pending, second page. */
799#define IEM_ACCESS_PENDING_R3_WRITE_2ND UINT32_C(0x00000800)
800/** Valid bit mask. */
801#define IEM_ACCESS_VALID_MASK UINT32_C(0x00000fff)
802/** Read+write data alias. */
803#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
804/** Write data alias. */
805#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
806/** Read data alias. */
807#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
808/** Instruction fetch alias. */
809#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
810/** Stack write alias. */
811#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
812/** Stack read alias. */
813#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
814/** Stack read+write alias. */
815#define IEM_ACCESS_STACK_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
816/** Read system table alias. */
817#define IEM_ACCESS_SYS_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_SYS)
818/** Read+write system table alias. */
819#define IEM_ACCESS_SYS_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_SYS)
820/** @} */
821
822/** @name Prefix constants (IEMCPU::fPrefixes)
823 * @{ */
824#define IEM_OP_PRF_SEG_CS RT_BIT_32(0) /**< CS segment prefix (0x2e). */
825#define IEM_OP_PRF_SEG_SS RT_BIT_32(1) /**< SS segment prefix (0x36). */
826#define IEM_OP_PRF_SEG_DS RT_BIT_32(2) /**< DS segment prefix (0x3e). */
827#define IEM_OP_PRF_SEG_ES RT_BIT_32(3) /**< ES segment prefix (0x26). */
828#define IEM_OP_PRF_SEG_FS RT_BIT_32(4) /**< FS segment prefix (0x64). */
829#define IEM_OP_PRF_SEG_GS RT_BIT_32(5) /**< GS segment prefix (0x65). */
830#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
831
832#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8) /**< Operand size prefix (0x66). */
833#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9) /**< REX.W prefix (0x48-0x4f). */
834#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10) /**< Address size prefix (0x67). */
835
836#define IEM_OP_PRF_LOCK RT_BIT_32(16) /**< Lock prefix (0xf0). */
837#define IEM_OP_PRF_REPNZ RT_BIT_32(17) /**< Repeat-not-zero prefix (0xf2). */
838#define IEM_OP_PRF_REPZ RT_BIT_32(18) /**< Repeat-if-zero prefix (0xf3). */
839
840#define IEM_OP_PRF_REX RT_BIT_32(24) /**< Any REX prefix (0x40-0x4f). */
841#define IEM_OP_PRF_REX_R RT_BIT_32(25) /**< REX.R prefix (0x44,0x45,0x46,0x47,0x4c,0x4d,0x4e,0x4f). */
842#define IEM_OP_PRF_REX_B RT_BIT_32(26) /**< REX.B prefix (0x41,0x43,0x45,0x47,0x49,0x4b,0x4d,0x4f). */
843#define IEM_OP_PRF_REX_X RT_BIT_32(27) /**< REX.X prefix (0x42,0x43,0x46,0x47,0x4a,0x4b,0x4e,0x4f). */
844/** Mask with all the REX prefix flags.
845 * This is generally for use when needing to undo the REX prefixes when they
846 * are followed legacy prefixes and therefore does not immediately preceed
847 * the first opcode byte.
848 * For testing whether any REX prefix is present, use IEM_OP_PRF_REX instead. */
849#define IEM_OP_PRF_REX_MASK (IEM_OP_PRF_REX | IEM_OP_PRF_REX_R | IEM_OP_PRF_REX_B | IEM_OP_PRF_REX_X | IEM_OP_PRF_SIZE_REX_W )
850
851#define IEM_OP_PRF_VEX RT_BIT_32(28) /**< Indiciates VEX prefix. */
852#define IEM_OP_PRF_EVEX RT_BIT_32(29) /**< Indiciates EVEX prefix. */
853#define IEM_OP_PRF_XOP RT_BIT_32(30) /**< Indiciates XOP prefix. */
854/** @} */
855
856/** @name IEMOPFORM_XXX - Opcode forms
857 * @note These are ORed together with IEMOPHINT_XXX.
858 * @{ */
859/** ModR/M: reg, r/m */
860#define IEMOPFORM_RM 0
861/** ModR/M: reg, r/m (register) */
862#define IEMOPFORM_RM_REG (IEMOPFORM_RM | IEMOPFORM_MOD3)
863/** ModR/M: reg, r/m (memory) */
864#define IEMOPFORM_RM_MEM (IEMOPFORM_RM | IEMOPFORM_NOT_MOD3)
865/** ModR/M: r/m, reg */
866#define IEMOPFORM_MR 1
867/** ModR/M: r/m (register), reg */
868#define IEMOPFORM_MR_REG (IEMOPFORM_MR | IEMOPFORM_MOD3)
869/** ModR/M: r/m (memory), reg */
870#define IEMOPFORM_MR_MEM (IEMOPFORM_MR | IEMOPFORM_NOT_MOD3)
871/** ModR/M: r/m only */
872#define IEMOPFORM_M 2
873/** ModR/M: r/m only (register). */
874#define IEMOPFORM_M_REG (IEMOPFORM_M | IEMOPFORM_MOD3)
875/** ModR/M: r/m only (memory). */
876#define IEMOPFORM_M_MEM (IEMOPFORM_M | IEMOPFORM_NOT_MOD3)
877/** ModR/M: reg only */
878#define IEMOPFORM_R 3
879
880/** VEX+ModR/M: reg, r/m */
881#define IEMOPFORM_VEX_RM 4
882/** VEX+ModR/M: reg, r/m (register) */
883#define IEMOPFORM_VEX_RM_REG (IEMOPFORM_VEX_RM | IEMOPFORM_MOD3)
884/** VEX+ModR/M: reg, r/m (memory) */
885#define IEMOPFORM_VEX_RM_MEM (IEMOPFORM_VEX_RM | IEMOPFORM_NOT_MOD3)
886/** VEX+ModR/M: r/m, reg */
887#define IEMOPFORM_VEX_MR 5
888/** VEX+ModR/M: r/m (register), reg */
889#define IEMOPFORM_VEX_MR_REG (IEMOPFORM_VEX_MR | IEMOPFORM_MOD3)
890/** VEX+ModR/M: r/m (memory), reg */
891#define IEMOPFORM_VEX_MR_MEM (IEMOPFORM_VEX_MR | IEMOPFORM_NOT_MOD3)
892/** VEX+ModR/M: r/m only */
893#define IEMOPFORM_VEX_M 6
894/** VEX+ModR/M: r/m only (register). */
895#define IEMOPFORM_VEX_M_REG (IEMOPFORM_VEX_M | IEMOPFORM_MOD3)
896/** VEX+ModR/M: r/m only (memory). */
897#define IEMOPFORM_VEX_M_MEM (IEMOPFORM_VEX_M | IEMOPFORM_NOT_MOD3)
898/** VEX+ModR/M: reg only */
899#define IEMOPFORM_VEX_R 7
900/** VEX+ModR/M: reg, vvvv, r/m */
901#define IEMOPFORM_VEX_RVM 8
902/** VEX+ModR/M: reg, vvvv, r/m (register). */
903#define IEMOPFORM_VEX_RVM_REG (IEMOPFORM_VEX_RVM | IEMOPFORM_MOD3)
904/** VEX+ModR/M: reg, vvvv, r/m (memory). */
905#define IEMOPFORM_VEX_RVM_MEM (IEMOPFORM_VEX_RVM | IEMOPFORM_NOT_MOD3)
906/** VEX+ModR/M: r/m, vvvv, reg */
907#define IEMOPFORM_VEX_MVR 9
908/** VEX+ModR/M: r/m, vvvv, reg (register) */
909#define IEMOPFORM_VEX_MVR_REG (IEMOPFORM_VEX_MVR | IEMOPFORM_MOD3)
910/** VEX+ModR/M: r/m, vvvv, reg (memory) */
911#define IEMOPFORM_VEX_MVR_MEM (IEMOPFORM_VEX_MVR | IEMOPFORM_NOT_MOD3)
912
913/** Fixed register instruction, no R/M. */
914#define IEMOPFORM_FIXED 16
915
916/** The r/m is a register. */
917#define IEMOPFORM_MOD3 RT_BIT_32(8)
918/** The r/m is a memory access. */
919#define IEMOPFORM_NOT_MOD3 RT_BIT_32(9)
920/** @} */
921
922/** @name IEMOPHINT_XXX - Additional Opcode Hints
923 * @note These are ORed together with IEMOPFORM_XXX.
924 * @{ */
925/** Ignores the operand size prefix (66h). */
926#define IEMOPHINT_IGNORES_OZ_PFX RT_BIT_32(10)
927/** Ignores REX.W (aka WIG). */
928#define IEMOPHINT_IGNORES_REXW RT_BIT_32(11)
929/** Both the operand size prefixes (66h + REX.W) are ignored. */
930#define IEMOPHINT_IGNORES_OP_SIZES (IEMOPHINT_IGNORES_OZ_PFX | IEMOPHINT_IGNORES_REXW)
931/** Allowed with the lock prefix. */
932#define IEMOPHINT_LOCK_ALLOWED RT_BIT_32(11)
933/** The VEX.L value is ignored (aka LIG). */
934#define IEMOPHINT_VEX_L_IGNORED RT_BIT_32(12)
935/** The VEX.L value must be zero (i.e. 128-bit width only). */
936#define IEMOPHINT_VEX_L_ZERO RT_BIT_32(13)
937
938/** Hint to IEMAllInstructionPython.py that this macro should be skipped. */
939#define IEMOPHINT_SKIP_PYTHON RT_BIT_32(31)
940/** @} */
941
942/**
943 * Possible hardware task switch sources.
944 */
945typedef enum IEMTASKSWITCH
946{
947 /** Task switch caused by an interrupt/exception. */
948 IEMTASKSWITCH_INT_XCPT = 1,
949 /** Task switch caused by a far CALL. */
950 IEMTASKSWITCH_CALL,
951 /** Task switch caused by a far JMP. */
952 IEMTASKSWITCH_JUMP,
953 /** Task switch caused by an IRET. */
954 IEMTASKSWITCH_IRET
955} IEMTASKSWITCH;
956AssertCompileSize(IEMTASKSWITCH, 4);
957
958/**
959 * Possible CrX load (write) sources.
960 */
961typedef enum IEMACCESSCRX
962{
963 /** CrX access caused by 'mov crX' instruction. */
964 IEMACCESSCRX_MOV_CRX,
965 /** CrX (CR0) write caused by 'lmsw' instruction. */
966 IEMACCESSCRX_LMSW,
967 /** CrX (CR0) write caused by 'clts' instruction. */
968 IEMACCESSCRX_CLTS,
969 /** CrX (CR0) read caused by 'smsw' instruction. */
970 IEMACCESSCRX_SMSW
971} IEMACCESSCRX;
972
973#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
974/** @name IEM_SLAT_FAIL_XXX - Second-level address translation failure information.
975 *
976 * These flags provide further context to SLAT page-walk failures that could not be
977 * determined by PGM (e.g, PGM is not privy to memory access permissions).
978 *
979 * @{
980 */
981/** Translating a nested-guest linear address failed accessing a nested-guest
982 * physical address. */
983# define IEM_SLAT_FAIL_LINEAR_TO_PHYS_ADDR RT_BIT_32(0)
984/** Translating a nested-guest linear address failed accessing a
985 * paging-structure entry or updating accessed/dirty bits. */
986# define IEM_SLAT_FAIL_LINEAR_TO_PAGE_TABLE RT_BIT_32(1)
987/** @} */
988
989PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER) iemVmxApicAccessPageHandler;
990# ifndef IN_RING3
991DECLCALLBACK(FNPGMRZPHYSPFHANDLER) iemVmxApicAccessPagePfHandler;
992# endif
993#endif
994
995/**
996 * Indicates to the verifier that the given flag set is undefined.
997 *
998 * Can be invoked again to add more flags.
999 *
1000 * This is a NOOP if the verifier isn't compiled in.
1001 *
1002 * @note We're temporarily keeping this until code is converted to new
1003 * disassembler style opcode handling.
1004 */
1005#define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { } while (0)
1006
1007
1008/** @def IEM_DECL_IMPL_TYPE
1009 * For typedef'ing an instruction implementation function.
1010 *
1011 * @param a_RetType The return type.
1012 * @param a_Name The name of the type.
1013 * @param a_ArgList The argument list enclosed in parentheses.
1014 */
1015
1016/** @def IEM_DECL_IMPL_DEF
1017 * For defining an instruction implementation function.
1018 *
1019 * @param a_RetType The return type.
1020 * @param a_Name The name of the type.
1021 * @param a_ArgList The argument list enclosed in parentheses.
1022 */
1023
1024#if defined(__GNUC__) && defined(RT_ARCH_X86)
1025# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
1026 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
1027# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
1028 __attribute__((__fastcall__, __nothrow__)) a_RetType a_Name a_ArgList
1029# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
1030 __attribute__((__fastcall__, __nothrow__)) a_RetType a_Name a_ArgList
1031
1032#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
1033# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
1034 a_RetType (__fastcall a_Name) a_ArgList
1035# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
1036 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
1037# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
1038 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
1039
1040#elif __cplusplus >= 201700 /* P0012R1 support */
1041# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
1042 a_RetType (VBOXCALL a_Name) a_ArgList RT_NOEXCEPT
1043# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
1044 a_RetType VBOXCALL a_Name a_ArgList RT_NOEXCEPT
1045# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
1046 a_RetType VBOXCALL a_Name a_ArgList RT_NOEXCEPT
1047
1048#else
1049# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
1050 a_RetType (VBOXCALL a_Name) a_ArgList
1051# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
1052 a_RetType VBOXCALL a_Name a_ArgList
1053# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
1054 a_RetType VBOXCALL a_Name a_ArgList
1055
1056#endif
1057
1058/** Defined in IEMAllAImplC.cpp but also used by IEMAllAImplA.asm. */
1059RT_C_DECLS_BEGIN
1060extern uint8_t const g_afParity[256];
1061RT_C_DECLS_END
1062
1063
1064/** @name Arithmetic assignment operations on bytes (binary).
1065 * @{ */
1066typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU8, (uint8_t *pu8Dst, uint8_t u8Src, uint32_t *pEFlags));
1067typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
1068FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
1069FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
1070FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
1071FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
1072FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
1073FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
1074FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
1075/** @} */
1076
1077/** @name Arithmetic assignment operations on words (binary).
1078 * @{ */
1079typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU16, (uint16_t *pu16Dst, uint16_t u16Src, uint32_t *pEFlags));
1080typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
1081FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
1082FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
1083FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
1084FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
1085FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
1086FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
1087FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
1088/** @} */
1089
1090/** @name Arithmetic assignment operations on double words (binary).
1091 * @{ */
1092typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU32, (uint32_t *pu32Dst, uint32_t u32Src, uint32_t *pEFlags));
1093typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
1094FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
1095FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
1096FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
1097FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
1098FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
1099FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
1100FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
1101/** @} */
1102
1103/** @name Arithmetic assignment operations on quad words (binary).
1104 * @{ */
1105typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINU64, (uint64_t *pu64Dst, uint64_t u64Src, uint32_t *pEFlags));
1106typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
1107FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
1108FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
1109FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
1110FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
1111FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
1112FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
1113FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
1114/** @} */
1115
1116/** @name Compare operations (thrown in with the binary ops).
1117 * @{ */
1118FNIEMAIMPLBINU8 iemAImpl_cmp_u8;
1119FNIEMAIMPLBINU16 iemAImpl_cmp_u16;
1120FNIEMAIMPLBINU32 iemAImpl_cmp_u32;
1121FNIEMAIMPLBINU64 iemAImpl_cmp_u64;
1122/** @} */
1123
1124/** @name Test operations (thrown in with the binary ops).
1125 * @{ */
1126FNIEMAIMPLBINU8 iemAImpl_test_u8;
1127FNIEMAIMPLBINU16 iemAImpl_test_u16;
1128FNIEMAIMPLBINU32 iemAImpl_test_u32;
1129FNIEMAIMPLBINU64 iemAImpl_test_u64;
1130/** @} */
1131
1132/** @name Bit operations operations (thrown in with the binary ops).
1133 * @{ */
1134FNIEMAIMPLBINU16 iemAImpl_bt_u16;
1135FNIEMAIMPLBINU32 iemAImpl_bt_u32;
1136FNIEMAIMPLBINU64 iemAImpl_bt_u64;
1137FNIEMAIMPLBINU16 iemAImpl_btc_u16, iemAImpl_btc_u16_locked;
1138FNIEMAIMPLBINU32 iemAImpl_btc_u32, iemAImpl_btc_u32_locked;
1139FNIEMAIMPLBINU64 iemAImpl_btc_u64, iemAImpl_btc_u64_locked;
1140FNIEMAIMPLBINU16 iemAImpl_btr_u16, iemAImpl_btr_u16_locked;
1141FNIEMAIMPLBINU32 iemAImpl_btr_u32, iemAImpl_btr_u32_locked;
1142FNIEMAIMPLBINU64 iemAImpl_btr_u64, iemAImpl_btr_u64_locked;
1143FNIEMAIMPLBINU16 iemAImpl_bts_u16, iemAImpl_bts_u16_locked;
1144FNIEMAIMPLBINU32 iemAImpl_bts_u32, iemAImpl_bts_u32_locked;
1145FNIEMAIMPLBINU64 iemAImpl_bts_u64, iemAImpl_bts_u64_locked;
1146/** @} */
1147
1148/** @name Exchange memory with register operations.
1149 * @{ */
1150IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_locked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
1151IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_locked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
1152IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_locked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
1153IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_locked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
1154IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_unlocked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
1155IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_unlocked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
1156IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_unlocked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
1157IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_unlocked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
1158/** @} */
1159
1160/** @name Exchange and add operations.
1161 * @{ */
1162IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
1163IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
1164IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
1165IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
1166IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8_locked, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
1167IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16_locked,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
1168IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32_locked,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
1169IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64_locked,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
1170/** @} */
1171
1172/** @name Compare and exchange.
1173 * @{ */
1174IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
1175IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8_locked, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
1176IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16, (uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
1177IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16_locked,(uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
1178IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32, (uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
1179IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32_locked,(uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
1180#if ARCH_BITS == 32
1181IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
1182IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
1183#else
1184IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
1185IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
1186#endif
1187IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
1188 uint32_t *pEFlags));
1189IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b_locked,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
1190 uint32_t *pEFlags));
1191IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
1192 uint32_t *pEFlags));
1193IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_locked,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
1194 uint32_t *pEFlags));
1195#ifndef RT_ARCH_ARM64
1196IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_fallback,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx,
1197 PRTUINT128U pu128RbxRcx, uint32_t *pEFlags));
1198#endif
1199/** @} */
1200
1201/** @name Memory ordering
1202 * @{ */
1203typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEMFENCE,(void));
1204typedef FNIEMAIMPLMEMFENCE *PFNIEMAIMPLMEMFENCE;
1205IEM_DECL_IMPL_DEF(void, iemAImpl_mfence,(void));
1206IEM_DECL_IMPL_DEF(void, iemAImpl_sfence,(void));
1207IEM_DECL_IMPL_DEF(void, iemAImpl_lfence,(void));
1208#ifndef RT_ARCH_ARM64
1209IEM_DECL_IMPL_DEF(void, iemAImpl_alt_mem_fence,(void));
1210#endif
1211/** @} */
1212
1213/** @name Double precision shifts
1214 * @{ */
1215typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU16,(uint16_t *pu16Dst, uint16_t u16Src, uint8_t cShift, uint32_t *pEFlags));
1216typedef FNIEMAIMPLSHIFTDBLU16 *PFNIEMAIMPLSHIFTDBLU16;
1217typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU32,(uint32_t *pu32Dst, uint32_t u32Src, uint8_t cShift, uint32_t *pEFlags));
1218typedef FNIEMAIMPLSHIFTDBLU32 *PFNIEMAIMPLSHIFTDBLU32;
1219typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t cShift, uint32_t *pEFlags));
1220typedef FNIEMAIMPLSHIFTDBLU64 *PFNIEMAIMPLSHIFTDBLU64;
1221FNIEMAIMPLSHIFTDBLU16 iemAImpl_shld_u16, iemAImpl_shld_u16_amd, iemAImpl_shld_u16_intel;
1222FNIEMAIMPLSHIFTDBLU32 iemAImpl_shld_u32, iemAImpl_shld_u32_amd, iemAImpl_shld_u32_intel;
1223FNIEMAIMPLSHIFTDBLU64 iemAImpl_shld_u64, iemAImpl_shld_u64_amd, iemAImpl_shld_u64_intel;
1224FNIEMAIMPLSHIFTDBLU16 iemAImpl_shrd_u16, iemAImpl_shrd_u16_amd, iemAImpl_shrd_u16_intel;
1225FNIEMAIMPLSHIFTDBLU32 iemAImpl_shrd_u32, iemAImpl_shrd_u32_amd, iemAImpl_shrd_u32_intel;
1226FNIEMAIMPLSHIFTDBLU64 iemAImpl_shrd_u64, iemAImpl_shrd_u64_amd, iemAImpl_shrd_u64_intel;
1227/** @} */
1228
1229
1230/** @name Bit search operations (thrown in with the binary ops).
1231 * @{ */
1232FNIEMAIMPLBINU16 iemAImpl_bsf_u16, iemAImpl_bsf_u16_amd, iemAImpl_bsf_u16_intel;
1233FNIEMAIMPLBINU32 iemAImpl_bsf_u32, iemAImpl_bsf_u32_amd, iemAImpl_bsf_u32_intel;
1234FNIEMAIMPLBINU64 iemAImpl_bsf_u64, iemAImpl_bsf_u64_amd, iemAImpl_bsf_u64_intel;
1235FNIEMAIMPLBINU16 iemAImpl_bsr_u16, iemAImpl_bsr_u16_amd, iemAImpl_bsr_u16_intel;
1236FNIEMAIMPLBINU32 iemAImpl_bsr_u32, iemAImpl_bsr_u32_amd, iemAImpl_bsr_u32_intel;
1237FNIEMAIMPLBINU64 iemAImpl_bsr_u64, iemAImpl_bsr_u64_amd, iemAImpl_bsr_u64_intel;
1238/** @} */
1239
1240/** @name Signed multiplication operations (thrown in with the binary ops).
1241 * @{ */
1242FNIEMAIMPLBINU16 iemAImpl_imul_two_u16, iemAImpl_imul_two_u16_amd, iemAImpl_imul_two_u16_intel;
1243FNIEMAIMPLBINU32 iemAImpl_imul_two_u32, iemAImpl_imul_two_u32_amd, iemAImpl_imul_two_u32_intel;
1244FNIEMAIMPLBINU64 iemAImpl_imul_two_u64, iemAImpl_imul_two_u64_amd, iemAImpl_imul_two_u64_intel;
1245/** @} */
1246
1247/** @name Arithmetic assignment operations on bytes (unary).
1248 * @{ */
1249typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
1250typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
1251FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
1252FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
1253FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
1254FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
1255/** @} */
1256
1257/** @name Arithmetic assignment operations on words (unary).
1258 * @{ */
1259typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
1260typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
1261FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
1262FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
1263FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
1264FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
1265/** @} */
1266
1267/** @name Arithmetic assignment operations on double words (unary).
1268 * @{ */
1269typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
1270typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
1271FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
1272FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
1273FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
1274FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
1275/** @} */
1276
1277/** @name Arithmetic assignment operations on quad words (unary).
1278 * @{ */
1279typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
1280typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
1281FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
1282FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
1283FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
1284FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
1285/** @} */
1286
1287
1288/** @name Shift operations on bytes (Group 2).
1289 * @{ */
1290typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU8,(uint8_t *pu8Dst, uint8_t cShift, uint32_t *pEFlags));
1291typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
1292FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8, iemAImpl_rol_u8_amd, iemAImpl_rol_u8_intel;
1293FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8, iemAImpl_ror_u8_amd, iemAImpl_ror_u8_intel;
1294FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8, iemAImpl_rcl_u8_amd, iemAImpl_rcl_u8_intel;
1295FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8, iemAImpl_rcr_u8_amd, iemAImpl_rcr_u8_intel;
1296FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8, iemAImpl_shl_u8_amd, iemAImpl_shl_u8_intel;
1297FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8, iemAImpl_shr_u8_amd, iemAImpl_shr_u8_intel;
1298FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8, iemAImpl_sar_u8_amd, iemAImpl_sar_u8_intel;
1299/** @} */
1300
1301/** @name Shift operations on words (Group 2).
1302 * @{ */
1303typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU16,(uint16_t *pu16Dst, uint8_t cShift, uint32_t *pEFlags));
1304typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
1305FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16, iemAImpl_rol_u16_amd, iemAImpl_rol_u16_intel;
1306FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16, iemAImpl_ror_u16_amd, iemAImpl_ror_u16_intel;
1307FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16, iemAImpl_rcl_u16_amd, iemAImpl_rcl_u16_intel;
1308FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16, iemAImpl_rcr_u16_amd, iemAImpl_rcr_u16_intel;
1309FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16, iemAImpl_shl_u16_amd, iemAImpl_shl_u16_intel;
1310FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16, iemAImpl_shr_u16_amd, iemAImpl_shr_u16_intel;
1311FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16, iemAImpl_sar_u16_amd, iemAImpl_sar_u16_intel;
1312/** @} */
1313
1314/** @name Shift operations on double words (Group 2).
1315 * @{ */
1316typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU32,(uint32_t *pu32Dst, uint8_t cShift, uint32_t *pEFlags));
1317typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
1318FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32, iemAImpl_rol_u32_amd, iemAImpl_rol_u32_intel;
1319FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32, iemAImpl_ror_u32_amd, iemAImpl_ror_u32_intel;
1320FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32, iemAImpl_rcl_u32_amd, iemAImpl_rcl_u32_intel;
1321FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32, iemAImpl_rcr_u32_amd, iemAImpl_rcr_u32_intel;
1322FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32, iemAImpl_shl_u32_amd, iemAImpl_shl_u32_intel;
1323FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32, iemAImpl_shr_u32_amd, iemAImpl_shr_u32_intel;
1324FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32, iemAImpl_sar_u32_amd, iemAImpl_sar_u32_intel;
1325/** @} */
1326
1327/** @name Shift operations on words (Group 2).
1328 * @{ */
1329typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTU64,(uint64_t *pu64Dst, uint8_t cShift, uint32_t *pEFlags));
1330typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
1331FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64, iemAImpl_rol_u64_amd, iemAImpl_rol_u64_intel;
1332FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64, iemAImpl_ror_u64_amd, iemAImpl_ror_u64_intel;
1333FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64, iemAImpl_rcl_u64_amd, iemAImpl_rcl_u64_intel;
1334FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64, iemAImpl_rcr_u64_amd, iemAImpl_rcr_u64_intel;
1335FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64, iemAImpl_shl_u64_amd, iemAImpl_shl_u64_intel;
1336FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64, iemAImpl_shr_u64_amd, iemAImpl_shr_u64_intel;
1337FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64, iemAImpl_sar_u64_amd, iemAImpl_sar_u64_intel;
1338/** @} */
1339
1340/** @name Multiplication and division operations.
1341 * @{ */
1342typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
1343typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
1344FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_mul_u8_amd, iemAImpl_mul_u8_intel;
1345FNIEMAIMPLMULDIVU8 iemAImpl_imul_u8, iemAImpl_imul_u8_amd, iemAImpl_imul_u8_intel;
1346FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_div_u8_amd, iemAImpl_div_u8_intel;
1347FNIEMAIMPLMULDIVU8 iemAImpl_idiv_u8, iemAImpl_idiv_u8_amd, iemAImpl_idiv_u8_intel;
1348
1349typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
1350typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
1351FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_mul_u16_amd, iemAImpl_mul_u16_intel;
1352FNIEMAIMPLMULDIVU16 iemAImpl_imul_u16, iemAImpl_imul_u16_amd, iemAImpl_imul_u16_intel;
1353FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_div_u16_amd, iemAImpl_div_u16_intel;
1354FNIEMAIMPLMULDIVU16 iemAImpl_idiv_u16, iemAImpl_idiv_u16_amd, iemAImpl_idiv_u16_intel;
1355
1356typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
1357typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
1358FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_mul_u32_amd, iemAImpl_mul_u32_intel;
1359FNIEMAIMPLMULDIVU32 iemAImpl_imul_u32, iemAImpl_imul_u32_amd, iemAImpl_imul_u32_intel;
1360FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_div_u32_amd, iemAImpl_div_u32_intel;
1361FNIEMAIMPLMULDIVU32 iemAImpl_idiv_u32, iemAImpl_idiv_u32_amd, iemAImpl_idiv_u32_intel;
1362
1363typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
1364typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
1365FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_mul_u64_amd, iemAImpl_mul_u64_intel;
1366FNIEMAIMPLMULDIVU64 iemAImpl_imul_u64, iemAImpl_imul_u64_amd, iemAImpl_imul_u64_intel;
1367FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_div_u64_amd, iemAImpl_div_u64_intel;
1368FNIEMAIMPLMULDIVU64 iemAImpl_idiv_u64, iemAImpl_idiv_u64_amd, iemAImpl_idiv_u64_intel;
1369/** @} */
1370
1371/** @name Byte Swap.
1372 * @{ */
1373IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u16,(uint32_t *pu32Dst)); /* Yes, 32-bit register access. */
1374IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u32,(uint32_t *pu32Dst));
1375IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u64,(uint64_t *pu64Dst));
1376/** @} */
1377
1378/** @name Misc.
1379 * @{ */
1380FNIEMAIMPLBINU16 iemAImpl_arpl;
1381/** @} */
1382
1383
1384/** @name FPU operations taking a 32-bit float argument
1385 * @{ */
1386typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1387 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
1388typedef FNIEMAIMPLFPUR32FSW *PFNIEMAIMPLFPUR32FSW;
1389
1390typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1391 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
1392typedef FNIEMAIMPLFPUR32 *PFNIEMAIMPLFPUR32;
1393
1394FNIEMAIMPLFPUR32FSW iemAImpl_fcom_r80_by_r32;
1395FNIEMAIMPLFPUR32 iemAImpl_fadd_r80_by_r32;
1396FNIEMAIMPLFPUR32 iemAImpl_fmul_r80_by_r32;
1397FNIEMAIMPLFPUR32 iemAImpl_fsub_r80_by_r32;
1398FNIEMAIMPLFPUR32 iemAImpl_fsubr_r80_by_r32;
1399FNIEMAIMPLFPUR32 iemAImpl_fdiv_r80_by_r32;
1400FNIEMAIMPLFPUR32 iemAImpl_fdivr_r80_by_r32;
1401
1402IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT32U pr32Val));
1403IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1404 PRTFLOAT32U pr32Val, PCRTFLOAT80U pr80Val));
1405/** @} */
1406
1407/** @name FPU operations taking a 64-bit float argument
1408 * @{ */
1409typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1410 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
1411typedef FNIEMAIMPLFPUR64FSW *PFNIEMAIMPLFPUR64FSW;
1412
1413typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1414 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
1415typedef FNIEMAIMPLFPUR64 *PFNIEMAIMPLFPUR64;
1416
1417FNIEMAIMPLFPUR64FSW iemAImpl_fcom_r80_by_r64;
1418FNIEMAIMPLFPUR64 iemAImpl_fadd_r80_by_r64;
1419FNIEMAIMPLFPUR64 iemAImpl_fmul_r80_by_r64;
1420FNIEMAIMPLFPUR64 iemAImpl_fsub_r80_by_r64;
1421FNIEMAIMPLFPUR64 iemAImpl_fsubr_r80_by_r64;
1422FNIEMAIMPLFPUR64 iemAImpl_fdiv_r80_by_r64;
1423FNIEMAIMPLFPUR64 iemAImpl_fdivr_r80_by_r64;
1424
1425IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT64U pr64Val));
1426IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1427 PRTFLOAT64U pr32Val, PCRTFLOAT80U pr80Val));
1428/** @} */
1429
1430/** @name FPU operations taking a 80-bit float argument
1431 * @{ */
1432typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1433 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
1434typedef FNIEMAIMPLFPUR80 *PFNIEMAIMPLFPUR80;
1435FNIEMAIMPLFPUR80 iemAImpl_fadd_r80_by_r80;
1436FNIEMAIMPLFPUR80 iemAImpl_fmul_r80_by_r80;
1437FNIEMAIMPLFPUR80 iemAImpl_fsub_r80_by_r80;
1438FNIEMAIMPLFPUR80 iemAImpl_fsubr_r80_by_r80;
1439FNIEMAIMPLFPUR80 iemAImpl_fdiv_r80_by_r80;
1440FNIEMAIMPLFPUR80 iemAImpl_fdivr_r80_by_r80;
1441FNIEMAIMPLFPUR80 iemAImpl_fprem_r80_by_r80;
1442FNIEMAIMPLFPUR80 iemAImpl_fprem1_r80_by_r80;
1443FNIEMAIMPLFPUR80 iemAImpl_fscale_r80_by_r80;
1444
1445FNIEMAIMPLFPUR80 iemAImpl_fpatan_r80_by_r80, iemAImpl_fpatan_r80_by_r80_amd, iemAImpl_fpatan_r80_by_r80_intel;
1446FNIEMAIMPLFPUR80 iemAImpl_fyl2x_r80_by_r80, iemAImpl_fyl2x_r80_by_r80_amd, iemAImpl_fyl2x_r80_by_r80_intel;
1447FNIEMAIMPLFPUR80 iemAImpl_fyl2xp1_r80_by_r80, iemAImpl_fyl2xp1_r80_by_r80_amd, iemAImpl_fyl2xp1_r80_by_r80_intel;
1448
1449typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1450 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
1451typedef FNIEMAIMPLFPUR80FSW *PFNIEMAIMPLFPUR80FSW;
1452FNIEMAIMPLFPUR80FSW iemAImpl_fcom_r80_by_r80;
1453FNIEMAIMPLFPUR80FSW iemAImpl_fucom_r80_by_r80;
1454
1455typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPUR80EFL,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
1456 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
1457typedef FNIEMAIMPLFPUR80EFL *PFNIEMAIMPLFPUR80EFL;
1458FNIEMAIMPLFPUR80EFL iemAImpl_fcomi_r80_by_r80;
1459FNIEMAIMPLFPUR80EFL iemAImpl_fucomi_r80_by_r80;
1460
1461typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARY,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
1462typedef FNIEMAIMPLFPUR80UNARY *PFNIEMAIMPLFPUR80UNARY;
1463FNIEMAIMPLFPUR80UNARY iemAImpl_fabs_r80;
1464FNIEMAIMPLFPUR80UNARY iemAImpl_fchs_r80;
1465FNIEMAIMPLFPUR80UNARY iemAImpl_f2xm1_r80, iemAImpl_f2xm1_r80_amd, iemAImpl_f2xm1_r80_intel;
1466FNIEMAIMPLFPUR80UNARY iemAImpl_fsqrt_r80;
1467FNIEMAIMPLFPUR80UNARY iemAImpl_frndint_r80;
1468FNIEMAIMPLFPUR80UNARY iemAImpl_fsin_r80, iemAImpl_fsin_r80_amd, iemAImpl_fsin_r80_intel;
1469FNIEMAIMPLFPUR80UNARY iemAImpl_fcos_r80, iemAImpl_fcos_r80_amd, iemAImpl_fcos_r80_intel;
1470
1471typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYFSW,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val));
1472typedef FNIEMAIMPLFPUR80UNARYFSW *PFNIEMAIMPLFPUR80UNARYFSW;
1473FNIEMAIMPLFPUR80UNARYFSW iemAImpl_ftst_r80;
1474FNIEMAIMPLFPUR80UNARYFSW iemAImpl_fxam_r80;
1475
1476typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80LDCONST,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes));
1477typedef FNIEMAIMPLFPUR80LDCONST *PFNIEMAIMPLFPUR80LDCONST;
1478FNIEMAIMPLFPUR80LDCONST iemAImpl_fld1;
1479FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2t;
1480FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2e;
1481FNIEMAIMPLFPUR80LDCONST iemAImpl_fldpi;
1482FNIEMAIMPLFPUR80LDCONST iemAImpl_fldlg2;
1483FNIEMAIMPLFPUR80LDCONST iemAImpl_fldln2;
1484FNIEMAIMPLFPUR80LDCONST iemAImpl_fldz;
1485
1486typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYTWO,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo,
1487 PCRTFLOAT80U pr80Val));
1488typedef FNIEMAIMPLFPUR80UNARYTWO *PFNIEMAIMPLFPUR80UNARYTWO;
1489FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fptan_r80_r80, iemAImpl_fptan_r80_r80_amd, iemAImpl_fptan_r80_r80_intel;
1490FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fxtract_r80_r80;
1491FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fsincos_r80_r80, iemAImpl_fsincos_r80_r80_amd, iemAImpl_fsincos_r80_r80_intel;
1492
1493IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
1494IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1495 PRTFLOAT80U pr80Dst, PCRTFLOAT80U pr80Src));
1496
1497IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_d80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTPBCD80U pd80Val));
1498IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_d80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
1499 PRTPBCD80U pd80Dst, PCRTFLOAT80U pr80Src));
1500
1501/** @} */
1502
1503/** @name FPU operations taking a 16-bit signed integer argument
1504 * @{ */
1505typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1506 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
1507typedef FNIEMAIMPLFPUI16 *PFNIEMAIMPLFPUI16;
1508typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI16,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
1509 int16_t *pi16Dst, PCRTFLOAT80U pr80Src));
1510typedef FNIEMAIMPLFPUSTR80TOI16 *PFNIEMAIMPLFPUSTR80TOI16;
1511
1512FNIEMAIMPLFPUI16 iemAImpl_fiadd_r80_by_i16;
1513FNIEMAIMPLFPUI16 iemAImpl_fimul_r80_by_i16;
1514FNIEMAIMPLFPUI16 iemAImpl_fisub_r80_by_i16;
1515FNIEMAIMPLFPUI16 iemAImpl_fisubr_r80_by_i16;
1516FNIEMAIMPLFPUI16 iemAImpl_fidiv_r80_by_i16;
1517FNIEMAIMPLFPUI16 iemAImpl_fidivr_r80_by_i16;
1518
1519typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1520 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
1521typedef FNIEMAIMPLFPUI16FSW *PFNIEMAIMPLFPUI16FSW;
1522FNIEMAIMPLFPUI16FSW iemAImpl_ficom_r80_by_i16;
1523
1524IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int16_t const *pi16Val));
1525FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fist_r80_to_i16;
1526FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fistt_r80_to_i16, iemAImpl_fistt_r80_to_i16_amd, iemAImpl_fistt_r80_to_i16_intel;
1527/** @} */
1528
1529/** @name FPU operations taking a 32-bit signed integer argument
1530 * @{ */
1531typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
1532 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
1533typedef FNIEMAIMPLFPUI32 *PFNIEMAIMPLFPUI32;
1534typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI32,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
1535 int32_t *pi32Dst, PCRTFLOAT80U pr80Src));
1536typedef FNIEMAIMPLFPUSTR80TOI32 *PFNIEMAIMPLFPUSTR80TOI32;
1537
1538FNIEMAIMPLFPUI32 iemAImpl_fiadd_r80_by_i32;
1539FNIEMAIMPLFPUI32 iemAImpl_fimul_r80_by_i32;
1540FNIEMAIMPLFPUI32 iemAImpl_fisub_r80_by_i32;
1541FNIEMAIMPLFPUI32 iemAImpl_fisubr_r80_by_i32;
1542FNIEMAIMPLFPUI32 iemAImpl_fidiv_r80_by_i32;
1543FNIEMAIMPLFPUI32 iemAImpl_fidivr_r80_by_i32;
1544
1545typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
1546 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
1547typedef FNIEMAIMPLFPUI32FSW *PFNIEMAIMPLFPUI32FSW;
1548FNIEMAIMPLFPUI32FSW iemAImpl_ficom_r80_by_i32;
1549
1550IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int32_t const *pi32Val));
1551FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fist_r80_to_i32;
1552FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fistt_r80_to_i32;
1553/** @} */
1554
1555/** @name FPU operations taking a 64-bit signed integer argument
1556 * @{ */
1557typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI64,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
1558 int64_t *pi64Dst, PCRTFLOAT80U pr80Src));
1559typedef FNIEMAIMPLFPUSTR80TOI64 *PFNIEMAIMPLFPUSTR80TOI64;
1560
1561IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int64_t const *pi64Val));
1562FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fist_r80_to_i64;
1563FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fistt_r80_to_i64;
1564/** @} */
1565
1566
1567/** Temporary type representing a 256-bit vector register. */
1568typedef struct { uint64_t au64[4]; } IEMVMM256;
1569/** Temporary type pointing to a 256-bit vector register. */
1570typedef IEMVMM256 *PIEMVMM256;
1571/** Temporary type pointing to a const 256-bit vector register. */
1572typedef IEMVMM256 *PCIEMVMM256;
1573
1574
1575/** @name Media (SSE/MMX/AVX) operations: full1 + full2 -> full1.
1576 * @{ */
1577typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src));
1578typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF2U64;
1579typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src));
1580typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF2U128;
1581FNIEMAIMPLMEDIAF2U64 iemAImpl_pxor_u64, iemAImpl_pcmpeqb_u64, iemAImpl_pcmpeqw_u64, iemAImpl_pcmpeqd_u64;
1582FNIEMAIMPLMEDIAF2U128 iemAImpl_pxor_u128, iemAImpl_pcmpeqb_u128, iemAImpl_pcmpeqw_u128, iemAImpl_pcmpeqd_u128;
1583/** @} */
1584
1585/** @name Media (SSE/MMX/AVX) operations: lowhalf1 + lowhalf1 -> full1.
1586 * @{ */
1587typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1L1U64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint32_t const *pu32Src));
1588typedef FNIEMAIMPLMEDIAF1L1U64 *PFNIEMAIMPLMEDIAF1L1U64;
1589typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1L1U128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, uint64_t const *pu64Src));
1590typedef FNIEMAIMPLMEDIAF1L1U128 *PFNIEMAIMPLMEDIAF1L1U128;
1591FNIEMAIMPLMEDIAF1L1U64 iemAImpl_punpcklbw_u64, iemAImpl_punpcklwd_u64, iemAImpl_punpckldq_u64;
1592FNIEMAIMPLMEDIAF1L1U128 iemAImpl_punpcklbw_u128, iemAImpl_punpcklwd_u128, iemAImpl_punpckldq_u128, iemAImpl_punpcklqdq_u128;
1593/** @} */
1594
1595/** @name Media (SSE/MMX/AVX) operations: hihalf1 + hihalf2 -> full1.
1596 * @{ */
1597typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1H1U64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src));
1598typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF1H1U64;
1599typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF1H1U128,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst, PCRTUINT128U pu128Src));
1600typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF1H1U128;
1601FNIEMAIMPLMEDIAF1H1U64 iemAImpl_punpckhbw_u64, iemAImpl_punpckhwd_u64, iemAImpl_punpckhdq_u64;
1602FNIEMAIMPLMEDIAF1H1U128 iemAImpl_punpckhbw_u128, iemAImpl_punpckhwd_u128, iemAImpl_punpckhdq_u128, iemAImpl_punpckhqdq_u128;
1603/** @} */
1604
1605/** @name Media (SSE/MMX/AVX) operation: Packed Shuffle Stuff (evil)
1606 * @{ */
1607typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUF,(PCX86FXSTATE pFpuState, PRTUINT128U pu128Dst,
1608 PCRTUINT128U pu128Src, uint8_t bEvil));
1609typedef FNIEMAIMPLMEDIAPSHUF *PFNIEMAIMPLMEDIAPSHUF;
1610FNIEMAIMPLMEDIAPSHUF iemAImpl_pshufhw, iemAImpl_pshuflw, iemAImpl_pshufd;
1611IEM_DECL_IMPL_DEF(void, iemAImpl_pshufw,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src, uint8_t bEvil));
1612/** @} */
1613
1614/** @name Media (SSE/MMX/AVX) operation: Move Byte Mask
1615 * @{ */
1616IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u64,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, uint64_t const *pu64Src));
1617IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u128,(PCX86FXSTATE pFpuState, uint64_t *pu64Dst, PCRTUINT128U pu128Src));
1618/** @} */
1619
1620/** @name Media (SSE/MMX/AVX) operation: Sort this later
1621 * @{ */
1622IEM_DECL_IMPL_DEF(void, iemAImpl_movsldup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc));
1623IEM_DECL_IMPL_DEF(void, iemAImpl_movshdup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc));
1624IEM_DECL_IMPL_DEF(void, iemAImpl_movddup,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, uint64_t uSrc));
1625
1626IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
1627IEM_DECL_IMPL_DEF(void, iemAImpl_vmovsldup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
1628IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rr,(PX86XSAVEAREA pXState, uint8_t iYRegDst, uint8_t iYRegSrc));
1629IEM_DECL_IMPL_DEF(void, iemAImpl_vmovddup_256_rm,(PX86XSAVEAREA pXState, uint8_t iYRegDst, PCRTUINT256U pSrc));
1630
1631/** @} */
1632
1633
1634/** @name Function tables.
1635 * @{
1636 */
1637
1638/**
1639 * Function table for a binary operator providing implementation based on
1640 * operand size.
1641 */
1642typedef struct IEMOPBINSIZES
1643{
1644 PFNIEMAIMPLBINU8 pfnNormalU8, pfnLockedU8;
1645 PFNIEMAIMPLBINU16 pfnNormalU16, pfnLockedU16;
1646 PFNIEMAIMPLBINU32 pfnNormalU32, pfnLockedU32;
1647 PFNIEMAIMPLBINU64 pfnNormalU64, pfnLockedU64;
1648} IEMOPBINSIZES;
1649/** Pointer to a binary operator function table. */
1650typedef IEMOPBINSIZES const *PCIEMOPBINSIZES;
1651
1652
1653/**
1654 * Function table for a unary operator providing implementation based on
1655 * operand size.
1656 */
1657typedef struct IEMOPUNARYSIZES
1658{
1659 PFNIEMAIMPLUNARYU8 pfnNormalU8, pfnLockedU8;
1660 PFNIEMAIMPLUNARYU16 pfnNormalU16, pfnLockedU16;
1661 PFNIEMAIMPLUNARYU32 pfnNormalU32, pfnLockedU32;
1662 PFNIEMAIMPLUNARYU64 pfnNormalU64, pfnLockedU64;
1663} IEMOPUNARYSIZES;
1664/** Pointer to a unary operator function table. */
1665typedef IEMOPUNARYSIZES const *PCIEMOPUNARYSIZES;
1666
1667
1668/**
1669 * Function table for a shift operator providing implementation based on
1670 * operand size.
1671 */
1672typedef struct IEMOPSHIFTSIZES
1673{
1674 PFNIEMAIMPLSHIFTU8 pfnNormalU8;
1675 PFNIEMAIMPLSHIFTU16 pfnNormalU16;
1676 PFNIEMAIMPLSHIFTU32 pfnNormalU32;
1677 PFNIEMAIMPLSHIFTU64 pfnNormalU64;
1678} IEMOPSHIFTSIZES;
1679/** Pointer to a shift operator function table. */
1680typedef IEMOPSHIFTSIZES const *PCIEMOPSHIFTSIZES;
1681
1682
1683/**
1684 * Function table for a multiplication or division operation.
1685 */
1686typedef struct IEMOPMULDIVSIZES
1687{
1688 PFNIEMAIMPLMULDIVU8 pfnU8;
1689 PFNIEMAIMPLMULDIVU16 pfnU16;
1690 PFNIEMAIMPLMULDIVU32 pfnU32;
1691 PFNIEMAIMPLMULDIVU64 pfnU64;
1692} IEMOPMULDIVSIZES;
1693/** Pointer to a multiplication or division operation function table. */
1694typedef IEMOPMULDIVSIZES const *PCIEMOPMULDIVSIZES;
1695
1696
1697/**
1698 * Function table for a double precision shift operator providing implementation
1699 * based on operand size.
1700 */
1701typedef struct IEMOPSHIFTDBLSIZES
1702{
1703 PFNIEMAIMPLSHIFTDBLU16 pfnNormalU16;
1704 PFNIEMAIMPLSHIFTDBLU32 pfnNormalU32;
1705 PFNIEMAIMPLSHIFTDBLU64 pfnNormalU64;
1706} IEMOPSHIFTDBLSIZES;
1707/** Pointer to a double precision shift function table. */
1708typedef IEMOPSHIFTDBLSIZES const *PCIEMOPSHIFTDBLSIZES;
1709
1710
1711/**
1712 * Function table for media instruction taking two full sized media registers,
1713 * optionally the 2nd being a memory reference (only modifying the first op.)
1714 */
1715typedef struct IEMOPMEDIAF2
1716{
1717 PFNIEMAIMPLMEDIAF2U64 pfnU64;
1718 PFNIEMAIMPLMEDIAF2U128 pfnU128;
1719} IEMOPMEDIAF2;
1720/** Pointer to a media operation function table for full sized ops. */
1721typedef IEMOPMEDIAF2 const *PCIEMOPMEDIAF2;
1722
1723/**
1724 * Function table for media instruction taking taking one full and one lower
1725 * half media register.
1726 */
1727typedef struct IEMOPMEDIAF1L1
1728{
1729 PFNIEMAIMPLMEDIAF1L1U64 pfnU64;
1730 PFNIEMAIMPLMEDIAF1L1U128 pfnU128;
1731} IEMOPMEDIAF1L1;
1732/** Pointer to a media operation function table for lowhalf+lowhalf -> full. */
1733typedef IEMOPMEDIAF1L1 const *PCIEMOPMEDIAF1L1;
1734
1735/**
1736 * Function table for media instruction taking taking one full and one high half
1737 * media register.
1738 */
1739typedef struct IEMOPMEDIAF1H1
1740{
1741 PFNIEMAIMPLMEDIAF1H1U64 pfnU64;
1742 PFNIEMAIMPLMEDIAF1H1U128 pfnU128;
1743} IEMOPMEDIAF1H1;
1744/** Pointer to a media operation function table for hihalf+hihalf -> full. */
1745typedef IEMOPMEDIAF1H1 const *PCIEMOPMEDIAF1H1;
1746
1747
1748/** @} */
1749
1750
1751/** @name C instruction implementations for anything slightly complicated.
1752 * @{ */
1753
1754/**
1755 * For typedef'ing or declaring a C instruction implementation function taking
1756 * no extra arguments.
1757 *
1758 * @param a_Name The name of the type.
1759 */
1760# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
1761 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
1762/**
1763 * For defining a C instruction implementation function taking no extra
1764 * arguments.
1765 *
1766 * @param a_Name The name of the function
1767 */
1768# define IEM_CIMPL_DEF_0(a_Name) \
1769 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
1770/**
1771 * Prototype version of IEM_CIMPL_DEF_0.
1772 */
1773# define IEM_CIMPL_PROTO_0(a_Name) \
1774 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
1775/**
1776 * For calling a C instruction implementation function taking no extra
1777 * arguments.
1778 *
1779 * This special call macro adds default arguments to the call and allow us to
1780 * change these later.
1781 *
1782 * @param a_fn The name of the function.
1783 */
1784# define IEM_CIMPL_CALL_0(a_fn) a_fn(pVCpu, cbInstr)
1785
1786/**
1787 * For typedef'ing or declaring a C instruction implementation function taking
1788 * one extra argument.
1789 *
1790 * @param a_Name The name of the type.
1791 * @param a_Type0 The argument type.
1792 * @param a_Arg0 The argument name.
1793 */
1794# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
1795 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
1796/**
1797 * For defining a C instruction implementation function taking one extra
1798 * argument.
1799 *
1800 * @param a_Name The name of the function
1801 * @param a_Type0 The argument type.
1802 * @param a_Arg0 The argument name.
1803 */
1804# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
1805 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
1806/**
1807 * Prototype version of IEM_CIMPL_DEF_1.
1808 */
1809# define IEM_CIMPL_PROTO_1(a_Name, a_Type0, a_Arg0) \
1810 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
1811/**
1812 * For calling a C instruction implementation function taking one extra
1813 * argument.
1814 *
1815 * This special call macro adds default arguments to the call and allow us to
1816 * change these later.
1817 *
1818 * @param a_fn The name of the function.
1819 * @param a0 The name of the 1st argument.
1820 */
1821# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pVCpu, cbInstr, (a0))
1822
1823/**
1824 * For typedef'ing or declaring a C instruction implementation function taking
1825 * two extra arguments.
1826 *
1827 * @param a_Name The name of the type.
1828 * @param a_Type0 The type of the 1st argument
1829 * @param a_Arg0 The name of the 1st argument.
1830 * @param a_Type1 The type of the 2nd argument.
1831 * @param a_Arg1 The name of the 2nd argument.
1832 */
1833# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
1834 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
1835/**
1836 * For defining a C instruction implementation function taking two extra
1837 * arguments.
1838 *
1839 * @param a_Name The name of the function.
1840 * @param a_Type0 The type of the 1st argument
1841 * @param a_Arg0 The name of the 1st argument.
1842 * @param a_Type1 The type of the 2nd argument.
1843 * @param a_Arg1 The name of the 2nd argument.
1844 */
1845# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
1846 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
1847/**
1848 * Prototype version of IEM_CIMPL_DEF_2.
1849 */
1850# define IEM_CIMPL_PROTO_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
1851 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
1852/**
1853 * For calling a C instruction implementation function taking two extra
1854 * arguments.
1855 *
1856 * This special call macro adds default arguments to the call and allow us to
1857 * change these later.
1858 *
1859 * @param a_fn The name of the function.
1860 * @param a0 The name of the 1st argument.
1861 * @param a1 The name of the 2nd argument.
1862 */
1863# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pVCpu, cbInstr, (a0), (a1))
1864
1865/**
1866 * For typedef'ing or declaring a C instruction implementation function taking
1867 * three extra arguments.
1868 *
1869 * @param a_Name The name of the type.
1870 * @param a_Type0 The type of the 1st argument
1871 * @param a_Arg0 The name of the 1st argument.
1872 * @param a_Type1 The type of the 2nd argument.
1873 * @param a_Arg1 The name of the 2nd argument.
1874 * @param a_Type2 The type of the 3rd argument.
1875 * @param a_Arg2 The name of the 3rd argument.
1876 */
1877# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
1878 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
1879/**
1880 * For defining a C instruction implementation function taking three extra
1881 * arguments.
1882 *
1883 * @param a_Name The name of the function.
1884 * @param a_Type0 The type of the 1st argument
1885 * @param a_Arg0 The name of the 1st argument.
1886 * @param a_Type1 The type of the 2nd argument.
1887 * @param a_Arg1 The name of the 2nd argument.
1888 * @param a_Type2 The type of the 3rd argument.
1889 * @param a_Arg2 The name of the 3rd argument.
1890 */
1891# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
1892 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
1893/**
1894 * Prototype version of IEM_CIMPL_DEF_3.
1895 */
1896# define IEM_CIMPL_PROTO_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
1897 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
1898/**
1899 * For calling a C instruction implementation function taking three extra
1900 * arguments.
1901 *
1902 * This special call macro adds default arguments to the call and allow us to
1903 * change these later.
1904 *
1905 * @param a_fn The name of the function.
1906 * @param a0 The name of the 1st argument.
1907 * @param a1 The name of the 2nd argument.
1908 * @param a2 The name of the 3rd argument.
1909 */
1910# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pVCpu, cbInstr, (a0), (a1), (a2))
1911
1912
1913/**
1914 * For typedef'ing or declaring a C instruction implementation function taking
1915 * four extra arguments.
1916 *
1917 * @param a_Name The name of the type.
1918 * @param a_Type0 The type of the 1st argument
1919 * @param a_Arg0 The name of the 1st argument.
1920 * @param a_Type1 The type of the 2nd argument.
1921 * @param a_Arg1 The name of the 2nd argument.
1922 * @param a_Type2 The type of the 3rd argument.
1923 * @param a_Arg2 The name of the 3rd argument.
1924 * @param a_Type3 The type of the 4th argument.
1925 * @param a_Arg3 The name of the 4th argument.
1926 */
1927# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
1928 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, a_Type3 a_Arg3))
1929/**
1930 * For defining a C instruction implementation function taking four extra
1931 * arguments.
1932 *
1933 * @param a_Name The name of the function.
1934 * @param a_Type0 The type of the 1st argument
1935 * @param a_Arg0 The name of the 1st argument.
1936 * @param a_Type1 The type of the 2nd argument.
1937 * @param a_Arg1 The name of the 2nd argument.
1938 * @param a_Type2 The type of the 3rd argument.
1939 * @param a_Arg2 The name of the 3rd argument.
1940 * @param a_Type3 The type of the 4th argument.
1941 * @param a_Arg3 The name of the 4th argument.
1942 */
1943# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
1944 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
1945 a_Type2 a_Arg2, a_Type3 a_Arg3))
1946/**
1947 * Prototype version of IEM_CIMPL_DEF_4.
1948 */
1949# define IEM_CIMPL_PROTO_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
1950 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
1951 a_Type2 a_Arg2, a_Type3 a_Arg3))
1952/**
1953 * For calling a C instruction implementation function taking four extra
1954 * arguments.
1955 *
1956 * This special call macro adds default arguments to the call and allow us to
1957 * change these later.
1958 *
1959 * @param a_fn The name of the function.
1960 * @param a0 The name of the 1st argument.
1961 * @param a1 The name of the 2nd argument.
1962 * @param a2 The name of the 3rd argument.
1963 * @param a3 The name of the 4th argument.
1964 */
1965# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3))
1966
1967
1968/**
1969 * For typedef'ing or declaring a C instruction implementation function taking
1970 * five extra arguments.
1971 *
1972 * @param a_Name The name of the type.
1973 * @param a_Type0 The type of the 1st argument
1974 * @param a_Arg0 The name of the 1st argument.
1975 * @param a_Type1 The type of the 2nd argument.
1976 * @param a_Arg1 The name of the 2nd argument.
1977 * @param a_Type2 The type of the 3rd argument.
1978 * @param a_Arg2 The name of the 3rd argument.
1979 * @param a_Type3 The type of the 4th argument.
1980 * @param a_Arg3 The name of the 4th argument.
1981 * @param a_Type4 The type of the 5th argument.
1982 * @param a_Arg4 The name of the 5th argument.
1983 */
1984# define IEM_CIMPL_DECL_TYPE_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
1985 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, \
1986 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
1987 a_Type3 a_Arg3, a_Type4 a_Arg4))
1988/**
1989 * For defining a C instruction implementation function taking five extra
1990 * arguments.
1991 *
1992 * @param a_Name The name of the function.
1993 * @param a_Type0 The type of the 1st argument
1994 * @param a_Arg0 The name of the 1st argument.
1995 * @param a_Type1 The type of the 2nd argument.
1996 * @param a_Arg1 The name of the 2nd argument.
1997 * @param a_Type2 The type of the 3rd argument.
1998 * @param a_Arg2 The name of the 3rd argument.
1999 * @param a_Type3 The type of the 4th argument.
2000 * @param a_Arg3 The name of the 4th argument.
2001 * @param a_Type4 The type of the 5th argument.
2002 * @param a_Arg4 The name of the 5th argument.
2003 */
2004# define IEM_CIMPL_DEF_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
2005 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
2006 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
2007/**
2008 * Prototype version of IEM_CIMPL_DEF_5.
2009 */
2010# define IEM_CIMPL_PROTO_5(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3, a_Type4, a_Arg4) \
2011 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
2012 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
2013/**
2014 * For calling a C instruction implementation function taking five extra
2015 * arguments.
2016 *
2017 * This special call macro adds default arguments to the call and allow us to
2018 * change these later.
2019 *
2020 * @param a_fn The name of the function.
2021 * @param a0 The name of the 1st argument.
2022 * @param a1 The name of the 2nd argument.
2023 * @param a2 The name of the 3rd argument.
2024 * @param a3 The name of the 4th argument.
2025 * @param a4 The name of the 5th argument.
2026 */
2027# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
2028
2029/** @} */
2030
2031
2032/** @name Opcode Decoder Function Types.
2033 * @{ */
2034
2035/** @typedef PFNIEMOP
2036 * Pointer to an opcode decoder function.
2037 */
2038
2039/** @def FNIEMOP_DEF
2040 * Define an opcode decoder function.
2041 *
2042 * We're using macors for this so that adding and removing parameters as well as
2043 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL
2044 *
2045 * @param a_Name The function name.
2046 */
2047
2048/** @typedef PFNIEMOPRM
2049 * Pointer to an opcode decoder function with RM byte.
2050 */
2051
2052/** @def FNIEMOPRM_DEF
2053 * Define an opcode decoder function with RM byte.
2054 *
2055 * We're using macors for this so that adding and removing parameters as well as
2056 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL_1
2057 *
2058 * @param a_Name The function name.
2059 */
2060
2061#if defined(__GNUC__) && defined(RT_ARCH_X86)
2062typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOP)(PVMCPUCC pVCpu);
2063typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
2064# define FNIEMOP_DEF(a_Name) \
2065 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu)
2066# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
2067 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
2068# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
2069 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
2070
2071#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
2072typedef VBOXSTRICTRC (__fastcall * PFNIEMOP)(PVMCPUCC pVCpu);
2073typedef VBOXSTRICTRC (__fastcall * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
2074# define FNIEMOP_DEF(a_Name) \
2075 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu) RT_NO_THROW_DEF
2076# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
2077 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) RT_NO_THROW_DEF
2078# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
2079 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) RT_NO_THROW_DEF
2080
2081#elif defined(__GNUC__)
2082typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
2083typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
2084# define FNIEMOP_DEF(a_Name) \
2085 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu)
2086# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
2087 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
2088# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
2089 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
2090
2091#else
2092typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
2093typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
2094# define FNIEMOP_DEF(a_Name) \
2095 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu) RT_NO_THROW_DEF
2096# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
2097 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) RT_NO_THROW_DEF
2098# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
2099 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) RT_NO_THROW_DEF
2100
2101#endif
2102#define FNIEMOPRM_DEF(a_Name) FNIEMOP_DEF_1(a_Name, uint8_t, bRm)
2103
2104/**
2105 * Call an opcode decoder function.
2106 *
2107 * We're using macors for this so that adding and removing parameters can be
2108 * done as we please. See FNIEMOP_DEF.
2109 */
2110#define FNIEMOP_CALL(a_pfn) (a_pfn)(pVCpu)
2111
2112/**
2113 * Call a common opcode decoder function taking one extra argument.
2114 *
2115 * We're using macors for this so that adding and removing parameters can be
2116 * done as we please. See FNIEMOP_DEF_1.
2117 */
2118#define FNIEMOP_CALL_1(a_pfn, a0) (a_pfn)(pVCpu, a0)
2119
2120/**
2121 * Call a common opcode decoder function taking one extra argument.
2122 *
2123 * We're using macors for this so that adding and removing parameters can be
2124 * done as we please. See FNIEMOP_DEF_1.
2125 */
2126#define FNIEMOP_CALL_2(a_pfn, a0, a1) (a_pfn)(pVCpu, a0, a1)
2127/** @} */
2128
2129
2130/** @name Misc Helpers
2131 * @{ */
2132
2133/** Used to shut up GCC warnings about variables that 'may be used uninitialized'
2134 * due to GCC lacking knowledge about the value range of a switch. */
2135#define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
2136
2137/** Variant of IEM_NOT_REACHED_DEFAULT_CASE_RET that returns a custom value. */
2138#define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: AssertFailedReturn(a_RetValue)
2139
2140/**
2141 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
2142 * occation.
2143 */
2144#ifdef LOG_ENABLED
2145# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
2146 do { \
2147 /*Log*/ LogAlways(("%s: returning IEM_RETURN_ASPECT_NOT_IMPLEMENTED (line %d)\n", __FUNCTION__, __LINE__)); \
2148 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
2149 } while (0)
2150#else
2151# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
2152 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
2153#endif
2154
2155/**
2156 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
2157 * occation using the supplied logger statement.
2158 *
2159 * @param a_LoggerArgs What to log on failure.
2160 */
2161#ifdef LOG_ENABLED
2162# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
2163 do { \
2164 LogAlways((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogAlways(a_LoggerArgs); \
2165 /*LogFunc(a_LoggerArgs);*/ \
2166 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
2167 } while (0)
2168#else
2169# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
2170 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
2171#endif
2172
2173/**
2174 * Check if we're currently executing in real or virtual 8086 mode.
2175 *
2176 * @returns @c true if it is, @c false if not.
2177 * @param a_pVCpu The IEM state of the current CPU.
2178 */
2179#define IEM_IS_REAL_OR_V86_MODE(a_pVCpu) (CPUMIsGuestInRealOrV86ModeEx(IEM_GET_CTX(a_pVCpu)))
2180
2181/**
2182 * Check if we're currently executing in virtual 8086 mode.
2183 *
2184 * @returns @c true if it is, @c false if not.
2185 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2186 */
2187#define IEM_IS_V86_MODE(a_pVCpu) (CPUMIsGuestInV86ModeEx(IEM_GET_CTX(a_pVCpu)))
2188
2189/**
2190 * Check if we're currently executing in long mode.
2191 *
2192 * @returns @c true if it is, @c false if not.
2193 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2194 */
2195#define IEM_IS_LONG_MODE(a_pVCpu) (CPUMIsGuestInLongModeEx(IEM_GET_CTX(a_pVCpu)))
2196
2197/**
2198 * Check if we're currently executing in a 64-bit code segment.
2199 *
2200 * @returns @c true if it is, @c false if not.
2201 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2202 */
2203#define IEM_IS_64BIT_CODE(a_pVCpu) (CPUMIsGuestIn64BitCodeEx(IEM_GET_CTX(a_pVCpu)))
2204
2205/**
2206 * Check if we're currently executing in real mode.
2207 *
2208 * @returns @c true if it is, @c false if not.
2209 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2210 */
2211#define IEM_IS_REAL_MODE(a_pVCpu) (CPUMIsGuestInRealModeEx(IEM_GET_CTX(a_pVCpu)))
2212
2213/**
2214 * Returns a (const) pointer to the CPUMFEATURES for the guest CPU.
2215 * @returns PCCPUMFEATURES
2216 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2217 */
2218#define IEM_GET_GUEST_CPU_FEATURES(a_pVCpu) (&((a_pVCpu)->CTX_SUFF(pVM)->cpum.ro.GuestFeatures))
2219
2220/**
2221 * Returns a (const) pointer to the CPUMFEATURES for the host CPU.
2222 * @returns PCCPUMFEATURES
2223 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2224 */
2225#define IEM_GET_HOST_CPU_FEATURES(a_pVCpu) (&((a_pVCpu)->CTX_SUFF(pVM)->cpum.ro.HostFeatures))
2226
2227/**
2228 * Evaluates to true if we're presenting an Intel CPU to the guest.
2229 */
2230#define IEM_IS_GUEST_CPU_INTEL(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_INTEL )
2231
2232/**
2233 * Evaluates to true if we're presenting an AMD CPU to the guest.
2234 */
2235#define IEM_IS_GUEST_CPU_AMD(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_AMD || (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_HYGON )
2236
2237/**
2238 * Check if the address is canonical.
2239 */
2240#define IEM_IS_CANONICAL(a_u64Addr) X86_IS_CANONICAL(a_u64Addr)
2241
2242/**
2243 * Gets the effective VEX.VVVV value.
2244 *
2245 * The 4th bit is ignored if not 64-bit code.
2246 * @returns effective V-register value.
2247 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2248 */
2249#define IEM_GET_EFFECTIVE_VVVV(a_pVCpu) \
2250 ((a_pVCpu)->iem.s.enmCpuMode == IEMMODE_64BIT ? (a_pVCpu)->iem.s.uVex3rdReg : (a_pVCpu)->iem.s.uVex3rdReg & 7)
2251
2252
2253#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
2254
2255/**
2256 * Check if the guest has entered VMX root operation.
2257 */
2258# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (CPUMIsGuestInVmxRootMode(IEM_GET_CTX(a_pVCpu)))
2259
2260/**
2261 * Check if the guest has entered VMX non-root operation.
2262 */
2263# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) (CPUMIsGuestInVmxNonRootMode(IEM_GET_CTX(a_pVCpu)))
2264
2265/**
2266 * Check if the nested-guest has the given Pin-based VM-execution control set.
2267 */
2268# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_PinCtl) \
2269 (CPUMIsGuestVmxPinCtlsSet(IEM_GET_CTX(a_pVCpu), (a_PinCtl)))
2270
2271/**
2272 * Check if the nested-guest has the given Processor-based VM-execution control set.
2273 */
2274# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_ProcCtl) \
2275 (CPUMIsGuestVmxProcCtlsSet(IEM_GET_CTX(a_pVCpu), (a_ProcCtl)))
2276
2277/**
2278 * Check if the nested-guest has the given Secondary Processor-based VM-execution
2279 * control set.
2280 */
2281# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_ProcCtl2) \
2282 (CPUMIsGuestVmxProcCtls2Set(IEM_GET_CTX(a_pVCpu), (a_ProcCtl2)))
2283
2284/** Gets the guest-physical address of the shadows VMCS for the given VCPU. */
2285# define IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysShadowVmcs)
2286
2287/** Whether a shadow VMCS is present for the given VCPU. */
2288# define IEM_VMX_HAS_SHADOW_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) != NIL_RTGCPHYS)
2289
2290/** Gets the VMXON region pointer. */
2291# define IEM_VMX_GET_VMXON_PTR(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmxon)
2292
2293/** Gets the guest-physical address of the current VMCS for the given VCPU. */
2294# define IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs)
2295
2296/** Whether a current VMCS is present for the given VCPU. */
2297# define IEM_VMX_HAS_CURRENT_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) != NIL_RTGCPHYS)
2298
2299/** Assigns the guest-physical address of the current VMCS for the given VCPU. */
2300# define IEM_VMX_SET_CURRENT_VMCS(a_pVCpu, a_GCPhysVmcs) \
2301 do \
2302 { \
2303 Assert((a_GCPhysVmcs) != NIL_RTGCPHYS); \
2304 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = (a_GCPhysVmcs); \
2305 } while (0)
2306
2307/** Clears any current VMCS for the given VCPU. */
2308# define IEM_VMX_CLEAR_CURRENT_VMCS(a_pVCpu) \
2309 do \
2310 { \
2311 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = NIL_RTGCPHYS; \
2312 } while (0)
2313
2314/**
2315 * Invokes the VMX VM-exit handler for an instruction intercept.
2316 */
2317# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) \
2318 do { return iemVmxVmexitInstr((a_pVCpu), (a_uExitReason), (a_cbInstr)); } while (0)
2319
2320/**
2321 * Invokes the VMX VM-exit handler for an instruction intercept where the
2322 * instruction provides additional VM-exit information.
2323 */
2324# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) \
2325 do { return iemVmxVmexitInstrNeedsInfo((a_pVCpu), (a_uExitReason), (a_uInstrId), (a_cbInstr)); } while (0)
2326
2327/**
2328 * Invokes the VMX VM-exit handler for a task switch.
2329 */
2330# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) \
2331 do { return iemVmxVmexitTaskSwitch((a_pVCpu), (a_enmTaskSwitch), (a_SelNewTss), (a_cbInstr)); } while (0)
2332
2333/**
2334 * Invokes the VMX VM-exit handler for MWAIT.
2335 */
2336# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) \
2337 do { return iemVmxVmexitInstrMwait((a_pVCpu), (a_fMonitorArmed), (a_cbInstr)); } while (0)
2338
2339/**
2340 * Invokes the VMX VM-exit handler for EPT faults.
2341 */
2342# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) \
2343 do { return iemVmxVmexitEpt(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr); } while (0)
2344
2345/**
2346 * Invokes the VMX VM-exit handler.
2347 */
2348# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) \
2349 do { return iemVmxVmexit((a_pVCpu), (a_uExitReason), (a_uExitQual)); } while (0)
2350
2351#else
2352# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (false)
2353# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) (false)
2354# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_cbInstr) (false)
2355# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_cbInstr) (false)
2356# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_cbInstr) (false)
2357# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
2358# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
2359# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
2360# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
2361# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
2362# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) do { return VERR_VMX_IPE_1; } while (0)
2363
2364#endif
2365
2366#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
2367/**
2368 * Check if an SVM control/instruction intercept is set.
2369 */
2370# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) \
2371 (CPUMIsGuestSvmCtrlInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_Intercept)))
2372
2373/**
2374 * Check if an SVM read CRx intercept is set.
2375 */
2376# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
2377 (CPUMIsGuestSvmReadCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
2378
2379/**
2380 * Check if an SVM write CRx intercept is set.
2381 */
2382# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
2383 (CPUMIsGuestSvmWriteCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
2384
2385/**
2386 * Check if an SVM read DRx intercept is set.
2387 */
2388# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
2389 (CPUMIsGuestSvmReadDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
2390
2391/**
2392 * Check if an SVM write DRx intercept is set.
2393 */
2394# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
2395 (CPUMIsGuestSvmWriteDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
2396
2397/**
2398 * Check if an SVM exception intercept is set.
2399 */
2400# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) \
2401 (CPUMIsGuestSvmXcptInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uVector)))
2402
2403/**
2404 * Invokes the SVM \#VMEXIT handler for the nested-guest.
2405 */
2406# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) \
2407 do { return iemSvmVmexit((a_pVCpu), (a_uExitCode), (a_uExitInfo1), (a_uExitInfo2)); } while (0)
2408
2409/**
2410 * Invokes the 'MOV CRx' SVM \#VMEXIT handler after constructing the
2411 * corresponding decode assist information.
2412 */
2413# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) \
2414 do \
2415 { \
2416 uint64_t uExitInfo1; \
2417 if ( IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmDecodeAssists \
2418 && (a_enmAccessCrX) == IEMACCESSCRX_MOV_CRX) \
2419 uExitInfo1 = SVM_EXIT1_MOV_CRX_MASK | ((a_iGReg) & 7); \
2420 else \
2421 uExitInfo1 = 0; \
2422 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, uExitInfo1, 0); \
2423 } while (0)
2424
2425/** Check and handles SVM nested-guest instruction intercept and updates
2426 * NRIP if needed.
2427 */
2428# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, a_uExitInfo1, a_uExitInfo2) \
2429 do \
2430 { \
2431 if (IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept)) \
2432 { \
2433 IEM_SVM_UPDATE_NRIP(a_pVCpu); \
2434 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2); \
2435 } \
2436 } while (0)
2437
2438/** Checks and handles SVM nested-guest CR0 read intercept. */
2439# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2) \
2440 do \
2441 { \
2442 if (!IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, 0)) \
2443 { /* probably likely */ } \
2444 else \
2445 { \
2446 IEM_SVM_UPDATE_NRIP(a_pVCpu); \
2447 IEM_SVM_VMEXIT_RET(a_pVCpu, SVM_EXIT_READ_CR0, a_uExitInfo1, a_uExitInfo2); \
2448 } \
2449 } while (0)
2450
2451/**
2452 * Updates the NextRIP (NRI) field in the nested-guest VMCB.
2453 */
2454# define IEM_SVM_UPDATE_NRIP(a_pVCpu) \
2455 do { \
2456 if (IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmNextRipSave) \
2457 CPUMGuestSvmUpdateNRip(a_pVCpu, IEM_GET_CTX(a_pVCpu), IEM_GET_INSTR_LEN(a_pVCpu)); \
2458 } while (0)
2459
2460#else
2461# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) (false)
2462# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
2463# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
2464# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
2465# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
2466# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) (false)
2467# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) do { return VERR_SVM_IPE_1; } while (0)
2468# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) do { return VERR_SVM_IPE_1; } while (0)
2469# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, a_uExitInfo1, a_uExitInfo2) do { } while (0)
2470# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2) do { } while (0)
2471# define IEM_SVM_UPDATE_NRIP(a_pVCpu) do { } while (0)
2472
2473#endif
2474
2475/** @} */
2476
2477
2478
2479/**
2480 * Selector descriptor table entry as fetched by iemMemFetchSelDesc.
2481 */
2482typedef union IEMSELDESC
2483{
2484 /** The legacy view. */
2485 X86DESC Legacy;
2486 /** The long mode view. */
2487 X86DESC64 Long;
2488} IEMSELDESC;
2489/** Pointer to a selector descriptor table entry. */
2490typedef IEMSELDESC *PIEMSELDESC;
2491
2492/** @name Raising Exceptions.
2493 * @{ */
2494VBOXSTRICTRC iemTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, uint32_t uNextEip, uint32_t fFlags,
2495 uint16_t uErr, uint64_t uCr2, RTSEL SelTSS, PIEMSELDESC pNewDescTSS) RT_NOEXCEPT;
2496
2497VBOXSTRICTRC iemRaiseXcptOrInt(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags,
2498 uint16_t uErr, uint64_t uCr2) RT_NOEXCEPT;
2499#ifdef IEM_WITH_SETJMP
2500DECL_NO_RETURN(void) iemRaiseXcptOrIntJmp(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector,
2501 uint32_t fFlags, uint16_t uErr, uint64_t uCr2) RT_NOEXCEPT;
2502#endif
2503VBOXSTRICTRC iemRaiseDivideError(PVMCPUCC pVCpu) RT_NOEXCEPT;
2504VBOXSTRICTRC iemRaiseDebugException(PVMCPUCC pVCpu) RT_NOEXCEPT;
2505VBOXSTRICTRC iemRaiseBoundRangeExceeded(PVMCPUCC pVCpu) RT_NOEXCEPT;
2506VBOXSTRICTRC iemRaiseUndefinedOpcode(PVMCPUCC pVCpu) RT_NOEXCEPT;
2507VBOXSTRICTRC iemRaiseDeviceNotAvailable(PVMCPUCC pVCpu) RT_NOEXCEPT;
2508VBOXSTRICTRC iemRaiseTaskSwitchFaultWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
2509VBOXSTRICTRC iemRaiseTaskSwitchFaultCurrentTSS(PVMCPUCC pVCpu) RT_NOEXCEPT;
2510VBOXSTRICTRC iemRaiseTaskSwitchFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
2511VBOXSTRICTRC iemRaiseTaskSwitchFaultBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
2512/*VBOXSTRICTRC iemRaiseSelectorNotPresent(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;*/
2513VBOXSTRICTRC iemRaiseSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
2514VBOXSTRICTRC iemRaiseSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
2515VBOXSTRICTRC iemRaiseStackSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
2516VBOXSTRICTRC iemRaiseStackSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
2517VBOXSTRICTRC iemRaiseGeneralProtectionFault(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
2518VBOXSTRICTRC iemRaiseGeneralProtectionFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
2519#ifdef IEM_WITH_SETJMP
2520DECL_NO_RETURN(void) iemRaiseGeneralProtectionFault0Jmp(PVMCPUCC pVCpu) RT_NOEXCEPT;
2521#endif
2522VBOXSTRICTRC iemRaiseGeneralProtectionFaultBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
2523VBOXSTRICTRC iemRaiseNotCanonical(PVMCPUCC pVCpu) RT_NOEXCEPT;
2524VBOXSTRICTRC iemRaiseSelectorBounds(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
2525#ifdef IEM_WITH_SETJMP
2526DECL_NO_RETURN(void) iemRaiseSelectorBoundsJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
2527#endif
2528VBOXSTRICTRC iemRaiseSelectorBoundsBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
2529#ifdef IEM_WITH_SETJMP
2530DECL_NO_RETURN(void) iemRaiseSelectorBoundsBySelectorJmp(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
2531#endif
2532VBOXSTRICTRC iemRaiseSelectorInvalidAccess(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
2533#ifdef IEM_WITH_SETJMP
2534DECL_NO_RETURN(void) iemRaiseSelectorInvalidAccessJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
2535#endif
2536VBOXSTRICTRC iemRaisePageFault(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t fAccess, int rc) RT_NOEXCEPT;
2537#ifdef IEM_WITH_SETJMP
2538DECL_NO_RETURN(void) iemRaisePageFaultJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t fAccess, int rc) RT_NOEXCEPT;
2539#endif
2540VBOXSTRICTRC iemRaiseMathFault(PVMCPUCC pVCpu);
2541VBOXSTRICTRC iemRaiseAlignmentCheckException(PVMCPUCC pVCpu);
2542
2543IEM_CIMPL_DEF_0(iemCImplRaiseDivideError);
2544IEM_CIMPL_DEF_0(iemCImplRaiseInvalidLockPrefix);
2545IEM_CIMPL_DEF_0(iemCImplRaiseInvalidOpcode);
2546
2547/**
2548 * Macro for calling iemCImplRaiseDivideError().
2549 *
2550 * This enables us to add/remove arguments and force different levels of
2551 * inlining as we wish.
2552 *
2553 * @return Strict VBox status code.
2554 */
2555#define IEMOP_RAISE_DIVIDE_ERROR() IEM_MC_DEFER_TO_CIMPL_0(iemCImplRaiseDivideError)
2556
2557/**
2558 * Macro for calling iemCImplRaiseInvalidLockPrefix().
2559 *
2560 * This enables us to add/remove arguments and force different levels of
2561 * inlining as we wish.
2562 *
2563 * @return Strict VBox status code.
2564 */
2565#define IEMOP_RAISE_INVALID_LOCK_PREFIX() IEM_MC_DEFER_TO_CIMPL_0(iemCImplRaiseInvalidLockPrefix)
2566
2567/**
2568 * Macro for calling iemCImplRaiseInvalidOpcode().
2569 *
2570 * This enables us to add/remove arguments and force different levels of
2571 * inlining as we wish.
2572 *
2573 * @return Strict VBox status code.
2574 */
2575#define IEMOP_RAISE_INVALID_OPCODE() IEM_MC_DEFER_TO_CIMPL_0(iemCImplRaiseInvalidOpcode)
2576/** @} */
2577
2578/** @name Register Access.
2579 * @{ */
2580VBOXSTRICTRC iemRegRipRelativeJumpS8(PVMCPUCC pVCpu, int8_t offNextInstr) RT_NOEXCEPT;
2581VBOXSTRICTRC iemRegRipRelativeJumpS16(PVMCPUCC pVCpu, int16_t offNextInstr) RT_NOEXCEPT;
2582VBOXSTRICTRC iemRegRipRelativeJumpS32(PVMCPUCC pVCpu, int32_t offNextInstr) RT_NOEXCEPT;
2583VBOXSTRICTRC iemRegRipJump(PVMCPUCC pVCpu, uint64_t uNewRip) RT_NOEXCEPT;
2584/** @} */
2585
2586/** @name FPU access and helpers.
2587 * @{ */
2588void iemFpuPushResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult) RT_NOEXCEPT;
2589void iemFpuPushResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2590void iemFpuPushResultTwo(PVMCPUCC pVCpu, PIEMFPURESULTTWO pResult) RT_NOEXCEPT;
2591void iemFpuStoreResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg) RT_NOEXCEPT;
2592void iemFpuStoreResultThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg) RT_NOEXCEPT;
2593void iemFpuStoreResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
2594 uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2595void iemFpuStoreResultWithMemOpThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
2596 uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2597void iemFpuUpdateOpcodeAndIp(PVMCPUCC pVCpu) RT_NOEXCEPT;
2598void iemFpuUpdateFSW(PVMCPUCC pVCpu, uint16_t u16FSW) RT_NOEXCEPT;
2599void iemFpuUpdateFSWThenPop(PVMCPUCC pVCpu, uint16_t u16FSW) RT_NOEXCEPT;
2600void iemFpuUpdateFSWWithMemOp(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2601void iemFpuUpdateFSWThenPopPop(PVMCPUCC pVCpu, uint16_t u16FSW) RT_NOEXCEPT;
2602void iemFpuUpdateFSWWithMemOpThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2603void iemFpuStackUnderflow(PVMCPUCC pVCpu, uint8_t iStReg) RT_NOEXCEPT;
2604void iemFpuStackUnderflowWithMemOp(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2605void iemFpuStackUnderflowThenPop(PVMCPUCC pVCpu, uint8_t iStReg) RT_NOEXCEPT;
2606void iemFpuStackUnderflowWithMemOpThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2607void iemFpuStackUnderflowThenPopPop(PVMCPUCC pVCpu) RT_NOEXCEPT;
2608void iemFpuStackPushUnderflow(PVMCPUCC pVCpu) RT_NOEXCEPT;
2609void iemFpuStackPushUnderflowTwo(PVMCPUCC pVCpu) RT_NOEXCEPT;
2610void iemFpuStackPushOverflow(PVMCPUCC pVCpu) RT_NOEXCEPT;
2611void iemFpuStackPushOverflowWithMemOp(PVMCPUCC pVCpu, uint8_t iEffSeg, RTGCPTR GCPtrEff) RT_NOEXCEPT;
2612/** @} */
2613
2614/** @name Memory access.
2615 * @{ */
2616VBOXSTRICTRC iemMemMap(PVMCPUCC pVCpu, void **ppvMem, size_t cbMem, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t fAccess) RT_NOEXCEPT;
2617VBOXSTRICTRC iemMemCommitAndUnmap(PVMCPUCC pVCpu, void *pvMem, uint32_t fAccess) RT_NOEXCEPT;
2618#ifndef IN_RING3
2619VBOXSTRICTRC iemMemCommitAndUnmapPostponeTroubleToR3(PVMCPUCC pVCpu, void *pvMem, uint32_t fAccess) RT_NOEXCEPT;
2620#endif
2621void iemMemRollback(PVMCPUCC pVCpu) RT_NOEXCEPT;
2622VBOXSTRICTRC iemMemApplySegment(PVMCPUCC pVCpu, uint32_t fAccess, uint8_t iSegReg, size_t cbMem, PRTGCPTR pGCPtrMem) RT_NOEXCEPT;
2623VBOXSTRICTRC iemMemMarkSelDescAccessed(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
2624VBOXSTRICTRC iemMemPageTranslateAndCheckAccess(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t fAccess, PRTGCPHYS pGCPhysMem) RT_NOEXCEPT;
2625
2626#ifdef IEM_WITH_CODE_TLB
2627void iemOpcodeFetchBytesJmp(PVMCPUCC pVCpu, size_t cbDst, void *pvDst) RT_NOEXCEPT;
2628#else
2629VBOXSTRICTRC iemOpcodeFetchMoreBytes(PVMCPUCC pVCpu, size_t cbMin) RT_NOEXCEPT;
2630#endif
2631#ifdef IEM_WITH_SETJMP
2632uint8_t iemOpcodeGetNextU8SlowJmp(PVMCPUCC pVCpu) RT_NOEXCEPT;
2633uint16_t iemOpcodeGetNextU16SlowJmp(PVMCPUCC pVCpu) RT_NOEXCEPT;
2634uint32_t iemOpcodeGetNextU32SlowJmp(PVMCPUCC pVCpu) RT_NOEXCEPT;
2635uint64_t iemOpcodeGetNextU64SlowJmp(PVMCPUCC pVCpu) RT_NOEXCEPT;
2636#else
2637VBOXSTRICTRC iemOpcodeGetNextU8Slow(PVMCPUCC pVCpu, uint8_t *pb) RT_NOEXCEPT;
2638VBOXSTRICTRC iemOpcodeGetNextS8SxU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
2639VBOXSTRICTRC iemOpcodeGetNextS8SxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
2640VBOXSTRICTRC iemOpcodeGetNextS8SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
2641VBOXSTRICTRC iemOpcodeGetNextU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
2642VBOXSTRICTRC iemOpcodeGetNextU16ZxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
2643VBOXSTRICTRC iemOpcodeGetNextU16ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
2644VBOXSTRICTRC iemOpcodeGetNextU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
2645VBOXSTRICTRC iemOpcodeGetNextU32ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
2646VBOXSTRICTRC iemOpcodeGetNextS32SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
2647VBOXSTRICTRC iemOpcodeGetNextU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
2648#endif
2649
2650VBOXSTRICTRC iemMemFetchDataU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2651VBOXSTRICTRC iemMemFetchDataU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2652VBOXSTRICTRC iemMemFetchDataU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2653VBOXSTRICTRC iemMemFetchDataU32_ZX_U64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2654VBOXSTRICTRC iemMemFetchDataU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2655VBOXSTRICTRC iemMemFetchDataU64AlignedU128(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2656VBOXSTRICTRC iemMemFetchDataR80(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2657VBOXSTRICTRC iemMemFetchDataD80(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2658VBOXSTRICTRC iemMemFetchDataU128(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2659VBOXSTRICTRC iemMemFetchDataU128AlignedSse(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2660VBOXSTRICTRC iemMemFetchDataU256(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2661VBOXSTRICTRC iemMemFetchDataU256AlignedSse(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2662VBOXSTRICTRC iemMemFetchDataXdtr(PVMCPUCC pVCpu, uint16_t *pcbLimit, PRTGCPTR pGCPtrBase, uint8_t iSegReg,
2663 RTGCPTR GCPtrMem, IEMMODE enmOpSize) RT_NOEXCEPT;
2664#ifdef IEM_WITH_SETJMP
2665uint8_t iemMemFetchDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2666uint16_t iemMemFetchDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2667uint32_t iemMemFetchDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2668uint64_t iemMemFetchDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2669uint64_t iemMemFetchDataU64AlignedU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2670void iemMemFetchDataR80Jmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2671void iemMemFetchDataD80Jmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2672void iemMemFetchDataU128Jmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2673void iemMemFetchDataU128AlignedSseJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2674void iemMemFetchDataU256Jmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2675void iemMemFetchDataU256AlignedSseJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2676#endif
2677
2678VBOXSTRICTRC iemMemFetchSysU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2679VBOXSTRICTRC iemMemFetchSysU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2680VBOXSTRICTRC iemMemFetchSysU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2681VBOXSTRICTRC iemMemFetchSysU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2682VBOXSTRICTRC iemMemFetchSelDesc(PVMCPUCC pVCpu, PIEMSELDESC pDesc, uint16_t uSel, uint8_t uXcpt) RT_NOEXCEPT;
2683
2684VBOXSTRICTRC iemMemStoreDataU8(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) RT_NOEXCEPT;
2685VBOXSTRICTRC iemMemStoreDataU16(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) RT_NOEXCEPT;
2686VBOXSTRICTRC iemMemStoreDataU32(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) RT_NOEXCEPT;
2687VBOXSTRICTRC iemMemStoreDataU64(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) RT_NOEXCEPT;
2688VBOXSTRICTRC iemMemStoreDataU128(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
2689VBOXSTRICTRC iemMemStoreDataU128AlignedSse(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
2690VBOXSTRICTRC iemMemStoreDataU256(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
2691VBOXSTRICTRC iemMemStoreDataU256AlignedAvx(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
2692VBOXSTRICTRC iemMemStoreDataXdtr(PVMCPUCC pVCpu, uint16_t cbLimit, RTGCPTR GCPtrBase, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
2693#ifdef IEM_WITH_SETJMP
2694void iemMemStoreDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) RT_NOEXCEPT;
2695void iemMemStoreDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) RT_NOEXCEPT;
2696void iemMemStoreDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) RT_NOEXCEPT;
2697void iemMemStoreDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) RT_NOEXCEPT;
2698void iemMemStoreDataU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
2699void iemMemStoreDataU128AlignedSseJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
2700void iemMemStoreDataU256Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
2701void iemMemStoreDataU256AlignedAvxJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
2702#endif
2703
2704VBOXSTRICTRC iemMemStackPushBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, void **ppvMem, uint64_t *puNewRsp) RT_NOEXCEPT;
2705VBOXSTRICTRC iemMemStackPushCommitSpecial(PVMCPUCC pVCpu, void *pvMem, uint64_t uNewRsp) RT_NOEXCEPT;
2706VBOXSTRICTRC iemMemStackPushU16(PVMCPUCC pVCpu, uint16_t u16Value) RT_NOEXCEPT;
2707VBOXSTRICTRC iemMemStackPushU32(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
2708VBOXSTRICTRC iemMemStackPushU64(PVMCPUCC pVCpu, uint64_t u64Value) RT_NOEXCEPT;
2709VBOXSTRICTRC iemMemStackPushU16Ex(PVMCPUCC pVCpu, uint16_t u16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
2710VBOXSTRICTRC iemMemStackPushU32Ex(PVMCPUCC pVCpu, uint32_t u32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
2711VBOXSTRICTRC iemMemStackPushU64Ex(PVMCPUCC pVCpu, uint64_t u64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
2712VBOXSTRICTRC iemMemStackPushU32SReg(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
2713VBOXSTRICTRC iemMemStackPopBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, void const **ppvMem, uint64_t *puNewRsp) RT_NOEXCEPT;
2714VBOXSTRICTRC iemMemStackPopContinueSpecial(PVMCPUCC pVCpu, size_t cbMem, void const **ppvMem, uint64_t *puNewRsp) RT_NOEXCEPT;
2715VBOXSTRICTRC iemMemStackPopDoneSpecial(PVMCPUCC pVCpu, void const *pvMem) RT_NOEXCEPT;
2716VBOXSTRICTRC iemMemStackPopU16(PVMCPUCC pVCpu, uint16_t *pu16Value) RT_NOEXCEPT;
2717VBOXSTRICTRC iemMemStackPopU32(PVMCPUCC pVCpu, uint32_t *pu32Value) RT_NOEXCEPT;
2718VBOXSTRICTRC iemMemStackPopU64(PVMCPUCC pVCpu, uint64_t *pu64Value) RT_NOEXCEPT;
2719VBOXSTRICTRC iemMemStackPopU16Ex(PVMCPUCC pVCpu, uint16_t *pu16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
2720VBOXSTRICTRC iemMemStackPopU32Ex(PVMCPUCC pVCpu, uint32_t *pu32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
2721VBOXSTRICTRC iemMemStackPopU64Ex(PVMCPUCC pVCpu, uint64_t *pu64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
2722/** @} */
2723
2724/** @name IEMAllCImpl.cpp
2725 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/'
2726 * @{ */
2727IEM_CIMPL_PROTO_0(iemCImpl_popa_16);
2728IEM_CIMPL_PROTO_0(iemCImpl_popa_32);
2729IEM_CIMPL_PROTO_0(iemCImpl_pusha_16);
2730IEM_CIMPL_PROTO_0(iemCImpl_pusha_32);
2731IEM_CIMPL_PROTO_1(iemCImpl_pushf, IEMMODE, enmEffOpSize);
2732IEM_CIMPL_PROTO_1(iemCImpl_popf, IEMMODE, enmEffOpSize);
2733IEM_CIMPL_PROTO_1(iemCImpl_call_16, uint16_t, uNewPC);
2734IEM_CIMPL_PROTO_1(iemCImpl_call_rel_16, int16_t, offDisp);
2735IEM_CIMPL_PROTO_1(iemCImpl_call_32, uint32_t, uNewPC);
2736IEM_CIMPL_PROTO_1(iemCImpl_call_rel_32, int32_t, offDisp);
2737IEM_CIMPL_PROTO_1(iemCImpl_call_64, uint64_t, uNewPC);
2738IEM_CIMPL_PROTO_1(iemCImpl_call_rel_64, int64_t, offDisp);
2739IEM_CIMPL_PROTO_4(iemCImpl_BranchTaskSegment, uint16_t, uSel, IEMBRANCH, enmBranch, IEMMODE, enmEffOpSize, PIEMSELDESC, pDesc);
2740IEM_CIMPL_PROTO_4(iemCImpl_BranchTaskGate, uint16_t, uSel, IEMBRANCH, enmBranch, IEMMODE, enmEffOpSize, PIEMSELDESC, pDesc);
2741IEM_CIMPL_PROTO_4(iemCImpl_BranchCallGate, uint16_t, uSel, IEMBRANCH, enmBranch, IEMMODE, enmEffOpSize, PIEMSELDESC, pDesc);
2742IEM_CIMPL_PROTO_4(iemCImpl_BranchSysSel, uint16_t, uSel, IEMBRANCH, enmBranch, IEMMODE, enmEffOpSize, PIEMSELDESC, pDesc);
2743IEM_CIMPL_PROTO_3(iemCImpl_FarJmp, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
2744IEM_CIMPL_PROTO_3(iemCImpl_callf, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
2745IEM_CIMPL_PROTO_2(iemCImpl_retf, IEMMODE, enmEffOpSize, uint16_t, cbPop);
2746IEM_CIMPL_PROTO_2(iemCImpl_retn, IEMMODE, enmEffOpSize, uint16_t, cbPop);
2747IEM_CIMPL_PROTO_3(iemCImpl_enter, IEMMODE, enmEffOpSize, uint16_t, cbFrame, uint8_t, cParameters);
2748IEM_CIMPL_PROTO_1(iemCImpl_leave, IEMMODE, enmEffOpSize);
2749IEM_CIMPL_PROTO_2(iemCImpl_int, uint8_t, u8Int, IEMINT, enmInt);
2750IEM_CIMPL_PROTO_1(iemCImpl_iret_real_v8086, IEMMODE, enmEffOpSize);
2751IEM_CIMPL_PROTO_4(iemCImpl_iret_prot_v8086, uint32_t, uNewEip, uint16_t, uNewCs, uint32_t, uNewFlags, uint64_t, uNewRsp);
2752IEM_CIMPL_PROTO_1(iemCImpl_iret_prot_NestedTask, IEMMODE, enmEffOpSize);
2753IEM_CIMPL_PROTO_1(iemCImpl_iret_prot, IEMMODE, enmEffOpSize);
2754IEM_CIMPL_PROTO_1(iemCImpl_iret_64bit, IEMMODE, enmEffOpSize);
2755IEM_CIMPL_PROTO_1(iemCImpl_iret, IEMMODE, enmEffOpSize);
2756IEM_CIMPL_PROTO_0(iemCImpl_loadall286);
2757IEM_CIMPL_PROTO_0(iemCImpl_syscall);
2758IEM_CIMPL_PROTO_0(iemCImpl_sysret);
2759IEM_CIMPL_PROTO_0(iemCImpl_sysenter);
2760IEM_CIMPL_PROTO_1(iemCImpl_sysexit, IEMMODE, enmEffOpSize);
2761IEM_CIMPL_PROTO_2(iemCImpl_LoadSReg, uint8_t, iSegReg, uint16_t, uSel);
2762IEM_CIMPL_PROTO_2(iemCImpl_load_SReg, uint8_t, iSegReg, uint16_t, uSel);
2763IEM_CIMPL_PROTO_2(iemCImpl_pop_Sreg, uint8_t, iSegReg, IEMMODE, enmEffOpSize);
2764IEM_CIMPL_PROTO_5(iemCImpl_load_SReg_Greg, uint16_t, uSel, uint64_t, offSeg, uint8_t, iSegReg, uint8_t, iGReg, IEMMODE, enmEffOpSize);
2765IEM_CIMPL_PROTO_2(iemCImpl_VerX, uint16_t, uSel, bool, fWrite);
2766IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u64, uint64_t *, pu64Dst, uint16_t, uSel, bool, fIsLar);
2767IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u16, uint16_t *, pu16Dst, uint16_t, uSel, bool, fIsLar);
2768IEM_CIMPL_PROTO_3(iemCImpl_lgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
2769IEM_CIMPL_PROTO_2(iemCImpl_sgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2770IEM_CIMPL_PROTO_3(iemCImpl_lidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
2771IEM_CIMPL_PROTO_2(iemCImpl_sidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2772IEM_CIMPL_PROTO_1(iemCImpl_lldt, uint16_t, uNewLdt);
2773IEM_CIMPL_PROTO_2(iemCImpl_sldt_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
2774IEM_CIMPL_PROTO_2(iemCImpl_sldt_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2775IEM_CIMPL_PROTO_1(iemCImpl_ltr, uint16_t, uNewTr);
2776IEM_CIMPL_PROTO_2(iemCImpl_str_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
2777IEM_CIMPL_PROTO_2(iemCImpl_str_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2778IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Cd, uint8_t, iGReg, uint8_t, iCrReg);
2779IEM_CIMPL_PROTO_2(iemCImpl_smsw_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
2780IEM_CIMPL_PROTO_2(iemCImpl_smsw_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2781IEM_CIMPL_PROTO_4(iemCImpl_load_CrX, uint8_t, iCrReg, uint64_t, uNewCrX, IEMACCESSCRX, enmAccessCrX, uint8_t, iGReg);
2782IEM_CIMPL_PROTO_2(iemCImpl_mov_Cd_Rd, uint8_t, iCrReg, uint8_t, iGReg);
2783IEM_CIMPL_PROTO_2(iemCImpl_lmsw, uint16_t, u16NewMsw, RTGCPTR, GCPtrEffDst);
2784IEM_CIMPL_PROTO_0(iemCImpl_clts);
2785IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Dd, uint8_t, iGReg, uint8_t, iDrReg);
2786IEM_CIMPL_PROTO_2(iemCImpl_mov_Dd_Rd, uint8_t, iDrReg, uint8_t, iGReg);
2787IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Td, uint8_t, iGReg, uint8_t, iTrReg);
2788IEM_CIMPL_PROTO_2(iemCImpl_mov_Td_Rd, uint8_t, iTrReg, uint8_t, iGReg);
2789IEM_CIMPL_PROTO_1(iemCImpl_invlpg, RTGCPTR, GCPtrPage);
2790IEM_CIMPL_PROTO_3(iemCImpl_invpcid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvpcidDesc, uint64_t, uInvpcidType);
2791IEM_CIMPL_PROTO_0(iemCImpl_invd);
2792IEM_CIMPL_PROTO_0(iemCImpl_wbinvd);
2793IEM_CIMPL_PROTO_0(iemCImpl_rsm);
2794IEM_CIMPL_PROTO_0(iemCImpl_rdtsc);
2795IEM_CIMPL_PROTO_0(iemCImpl_rdtscp);
2796IEM_CIMPL_PROTO_0(iemCImpl_rdpmc);
2797IEM_CIMPL_PROTO_0(iemCImpl_rdmsr);
2798IEM_CIMPL_PROTO_0(iemCImpl_wrmsr);
2799IEM_CIMPL_PROTO_3(iemCImpl_in, uint16_t, u16Port, bool, fImm, uint8_t, cbReg);
2800IEM_CIMPL_PROTO_1(iemCImpl_in_eAX_DX, uint8_t, cbReg);
2801IEM_CIMPL_PROTO_3(iemCImpl_out, uint16_t, u16Port, bool, fImm, uint8_t, cbReg);
2802IEM_CIMPL_PROTO_1(iemCImpl_out_DX_eAX, uint8_t, cbReg);
2803IEM_CIMPL_PROTO_0(iemCImpl_cli);
2804IEM_CIMPL_PROTO_0(iemCImpl_sti);
2805IEM_CIMPL_PROTO_0(iemCImpl_hlt);
2806IEM_CIMPL_PROTO_1(iemCImpl_monitor, uint8_t, iEffSeg);
2807IEM_CIMPL_PROTO_0(iemCImpl_mwait);
2808IEM_CIMPL_PROTO_0(iemCImpl_swapgs);
2809IEM_CIMPL_PROTO_0(iemCImpl_cpuid);
2810IEM_CIMPL_PROTO_1(iemCImpl_aad, uint8_t, bImm);
2811IEM_CIMPL_PROTO_1(iemCImpl_aam, uint8_t, bImm);
2812IEM_CIMPL_PROTO_0(iemCImpl_daa);
2813IEM_CIMPL_PROTO_0(iemCImpl_das);
2814IEM_CIMPL_PROTO_0(iemCImpl_aaa);
2815IEM_CIMPL_PROTO_0(iemCImpl_aas);
2816IEM_CIMPL_PROTO_3(iemCImpl_bound_16, int16_t, idxArray, int16_t, idxLowerBound, int16_t, idxUpperBound);
2817IEM_CIMPL_PROTO_3(iemCImpl_bound_32, int32_t, idxArray, int32_t, idxLowerBound, int32_t, idxUpperBound);
2818IEM_CIMPL_PROTO_0(iemCImpl_xgetbv);
2819IEM_CIMPL_PROTO_0(iemCImpl_xsetbv);
2820IEM_CIMPL_PROTO_4(iemCImpl_cmpxchg16b_fallback_rendezvous, PRTUINT128U, pu128Dst, PRTUINT128U, pu128RaxRdx,
2821 PRTUINT128U, pu128RbxRcx, uint32_t *, pEFlags);
2822IEM_CIMPL_PROTO_2(iemCImpl_clflush_clflushopt, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
2823IEM_CIMPL_PROTO_1(iemCImpl_finit, bool, fCheckXcpts);
2824IEM_CIMPL_PROTO_3(iemCImpl_fxsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
2825IEM_CIMPL_PROTO_3(iemCImpl_fxrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
2826IEM_CIMPL_PROTO_3(iemCImpl_xsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
2827IEM_CIMPL_PROTO_3(iemCImpl_xrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
2828IEM_CIMPL_PROTO_2(iemCImpl_stmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
2829IEM_CIMPL_PROTO_2(iemCImpl_vstmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
2830IEM_CIMPL_PROTO_2(iemCImpl_ldmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
2831IEM_CIMPL_PROTO_3(iemCImpl_fnstenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2832IEM_CIMPL_PROTO_3(iemCImpl_fnsave, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
2833IEM_CIMPL_PROTO_3(iemCImpl_fldenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
2834IEM_CIMPL_PROTO_3(iemCImpl_frstor, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
2835IEM_CIMPL_PROTO_1(iemCImpl_fldcw, uint16_t, u16Fcw);
2836IEM_CIMPL_PROTO_1(iemCImpl_fxch_underflow, uint8_t, iStReg);
2837IEM_CIMPL_PROTO_3(iemCImpl_fcomi_fucomi, uint8_t, iStReg, PFNIEMAIMPLFPUR80EFL, pfnAImpl, bool, fPop);
2838/** @} */
2839
2840/** @name IEMAllCImplStrInstr.cpp.h
2841 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/' -e 's/RT_CONCAT4(//' \
2842 * -e 's/,ADDR_SIZE)/64/g' -e 's/,OP_SIZE,/64/g' -e 's/,OP_rAX,/rax/g' IEMAllCImplStrInstr.cpp.h
2843 * @{ */
2844IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr16, uint8_t, iEffSeg);
2845IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr16, uint8_t, iEffSeg);
2846IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m16);
2847IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m16);
2848IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr16, uint8_t, iEffSeg);
2849IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m16);
2850IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m16, int8_t, iEffSeg);
2851IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr16, bool, fIoChecked);
2852IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr16, bool, fIoChecked);
2853IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
2854IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
2855
2856IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr16, uint8_t, iEffSeg);
2857IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr16, uint8_t, iEffSeg);
2858IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m16);
2859IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m16);
2860IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr16, uint8_t, iEffSeg);
2861IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m16);
2862IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m16, int8_t, iEffSeg);
2863IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr16, bool, fIoChecked);
2864IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr16, bool, fIoChecked);
2865IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
2866IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
2867
2868IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr16, uint8_t, iEffSeg);
2869IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr16, uint8_t, iEffSeg);
2870IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m16);
2871IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m16);
2872IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr16, uint8_t, iEffSeg);
2873IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m16);
2874IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m16, int8_t, iEffSeg);
2875IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr16, bool, fIoChecked);
2876IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr16, bool, fIoChecked);
2877IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
2878IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
2879
2880
2881IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr32, uint8_t, iEffSeg);
2882IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr32, uint8_t, iEffSeg);
2883IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m32);
2884IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m32);
2885IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr32, uint8_t, iEffSeg);
2886IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m32);
2887IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m32, int8_t, iEffSeg);
2888IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr32, bool, fIoChecked);
2889IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr32, bool, fIoChecked);
2890IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2891IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2892
2893IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr32, uint8_t, iEffSeg);
2894IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr32, uint8_t, iEffSeg);
2895IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m32);
2896IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m32);
2897IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr32, uint8_t, iEffSeg);
2898IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m32);
2899IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m32, int8_t, iEffSeg);
2900IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr32, bool, fIoChecked);
2901IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr32, bool, fIoChecked);
2902IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2903IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2904
2905IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr32, uint8_t, iEffSeg);
2906IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr32, uint8_t, iEffSeg);
2907IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m32);
2908IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m32);
2909IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr32, uint8_t, iEffSeg);
2910IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m32);
2911IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m32, int8_t, iEffSeg);
2912IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr32, bool, fIoChecked);
2913IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr32, bool, fIoChecked);
2914IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2915IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2916
2917IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr32, uint8_t, iEffSeg);
2918IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr32, uint8_t, iEffSeg);
2919IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m32);
2920IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m32);
2921IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr32, uint8_t, iEffSeg);
2922IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m32);
2923IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m32, int8_t, iEffSeg);
2924IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr32, bool, fIoChecked);
2925IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr32, bool, fIoChecked);
2926IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2927IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
2928
2929
2930IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr64, uint8_t, iEffSeg);
2931IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr64, uint8_t, iEffSeg);
2932IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m64);
2933IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m64);
2934IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr64, uint8_t, iEffSeg);
2935IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m64);
2936IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m64, int8_t, iEffSeg);
2937IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr64, bool, fIoChecked);
2938IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr64, bool, fIoChecked);
2939IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2940IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2941
2942IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr64, uint8_t, iEffSeg);
2943IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr64, uint8_t, iEffSeg);
2944IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m64);
2945IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m64);
2946IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr64, uint8_t, iEffSeg);
2947IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m64);
2948IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m64, int8_t, iEffSeg);
2949IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr64, bool, fIoChecked);
2950IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr64, bool, fIoChecked);
2951IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2952IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2953
2954IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr64, uint8_t, iEffSeg);
2955IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr64, uint8_t, iEffSeg);
2956IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m64);
2957IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m64);
2958IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr64, uint8_t, iEffSeg);
2959IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m64);
2960IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m64, int8_t, iEffSeg);
2961IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr64, bool, fIoChecked);
2962IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr64, bool, fIoChecked);
2963IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2964IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2965
2966IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr64, uint8_t, iEffSeg);
2967IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr64, uint8_t, iEffSeg);
2968IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m64);
2969IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m64);
2970IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr64, uint8_t, iEffSeg);
2971IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m64);
2972IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m64, int8_t, iEffSeg);
2973IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr64, bool, fIoChecked);
2974IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr64, bool, fIoChecked);
2975IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2976IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
2977/** @} */
2978
2979#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
2980VBOXSTRICTRC iemVmxVmexit(PVMCPUCC pVCpu, uint32_t uExitReason, uint64_t u64ExitQual) RT_NOEXCEPT;
2981VBOXSTRICTRC iemVmxVmexitInstr(PVMCPUCC pVCpu, uint32_t uExitReason, uint8_t cbInstr) RT_NOEXCEPT;
2982VBOXSTRICTRC iemVmxVmexitInstrNeedsInfo(PVMCPUCC pVCpu, uint32_t uExitReason, VMXINSTRID uInstrId, uint8_t cbInstr) RT_NOEXCEPT;
2983VBOXSTRICTRC iemVmxVmexitTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, RTSEL SelNewTss, uint8_t cbInstr) RT_NOEXCEPT;
2984VBOXSTRICTRC iemVmxVmexitEvent(PVMCPUCC pVCpu, uint8_t uVector, uint32_t fFlags, uint32_t uErrCode, uint64_t uCr2, uint8_t cbInstr) RT_NOEXCEPT;
2985VBOXSTRICTRC iemVmxVmexitEventDoubleFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
2986VBOXSTRICTRC iemVmxVmexitEpt(PVMCPUCC pVCpu, PPGMPTWALK pWalk, uint32_t fAccess, uint32_t fSlatFail, uint8_t cbInstr) RT_NOEXCEPT;
2987VBOXSTRICTRC iemVmxVmexitPreemptTimer(PVMCPUCC pVCpu) RT_NOEXCEPT;
2988VBOXSTRICTRC iemVmxVmexitInstrMwait(PVMCPUCC pVCpu, bool fMonitorHwArmed, uint8_t cbInstr) RT_NOEXCEPT;
2989VBOXSTRICTRC iemVmxVmexitInstrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port,
2990 bool fImm, uint8_t cbAccess, uint8_t cbInstr) RT_NOEXCEPT;
2991VBOXSTRICTRC iemVmxVmexitInstrStrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port, uint8_t cbAccess,
2992 bool fRep, VMXEXITINSTRINFO ExitInstrInfo, uint8_t cbInstr) RT_NOEXCEPT;
2993VBOXSTRICTRC iemVmxVmexitInstrMovDrX(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint8_t iDrReg, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
2994VBOXSTRICTRC iemVmxVmexitInstrMovToCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
2995VBOXSTRICTRC iemVmxVmexitInstrMovFromCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
2996VBOXSTRICTRC iemVmxVmexitInstrMovToCr3(PVMCPUCC pVCpu, uint64_t uNewCr3, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
2997VBOXSTRICTRC iemVmxVmexitInstrMovFromCr3(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
2998VBOXSTRICTRC iemVmxVmexitInstrMovToCr0Cr4(PVMCPUCC pVCpu, uint8_t iCrReg, uint64_t *puNewCrX, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
2999VBOXSTRICTRC iemVmxVmexitInstrClts(PVMCPUCC pVCpu, uint8_t cbInstr) RT_NOEXCEPT;
3000VBOXSTRICTRC iemVmxVmexitInstrLmsw(PVMCPUCC pVCpu, uint32_t uGuestCr0, uint16_t *pu16NewMsw,
3001 RTGCPTR GCPtrEffDst, uint8_t cbInstr) RT_NOEXCEPT;
3002VBOXSTRICTRC iemVmxVmexitInstrInvlpg(PVMCPUCC pVCpu, RTGCPTR GCPtrPage, uint8_t cbInstr) RT_NOEXCEPT;
3003VBOXSTRICTRC iemVmxApicWriteEmulation(PVMCPUCC pVCpu) RT_NOEXCEPT;
3004VBOXSTRICTRC iemVmxVirtApicAccessUnused(PVMCPUCC pVCpu, PRTGCPHYS pGCPhysAccess, size_t cbAccess, uint32_t fAccess) RT_NOEXCEPT;
3005uint32_t iemVmxVirtApicReadRaw32(PVMCPUCC pVCpu, uint16_t offReg) RT_NOEXCEPT;
3006void iemVmxVirtApicWriteRaw32(PVMCPUCC pVCpu, uint16_t offReg, uint32_t uReg) RT_NOEXCEPT;
3007VBOXSTRICTRC iemVmxInvvpid(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrInvvpidDesc,
3008 uint64_t u64InvvpidType, PCVMXVEXITINFO pExitInfo) RT_NOEXCEPT;
3009bool iemVmxIsRdmsrWrmsrInterceptSet(PCVMCPU pVCpu, uint32_t uExitReason, uint32_t idMsr) RT_NOEXCEPT;
3010IEM_CIMPL_PROTO_0(iemCImpl_vmxoff);
3011IEM_CIMPL_PROTO_2(iemCImpl_vmxon, uint8_t, iEffSeg, RTGCPTR, GCPtrVmxon);
3012IEM_CIMPL_PROTO_0(iemCImpl_vmlaunch);
3013IEM_CIMPL_PROTO_0(iemCImpl_vmresume);
3014IEM_CIMPL_PROTO_2(iemCImpl_vmptrld, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
3015IEM_CIMPL_PROTO_2(iemCImpl_vmptrst, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
3016IEM_CIMPL_PROTO_2(iemCImpl_vmclear, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
3017IEM_CIMPL_PROTO_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64VmcsField);
3018IEM_CIMPL_PROTO_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64VmcsField);
3019IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64VmcsField);
3020IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg32, uint32_t *, pu32Dst, uint32_t, u32VmcsField);
3021IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64VmcsField);
3022IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32VmcsField);
3023IEM_CIMPL_PROTO_3(iemCImpl_invvpid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvvpidDesc, uint64_t, uInvvpidType);
3024IEM_CIMPL_PROTO_3(iemCImpl_invept, uint8_t, iEffSeg, RTGCPTR, GCPtrInveptDesc, uint64_t, uInveptType);
3025IEM_CIMPL_PROTO_0(iemCImpl_vmx_pause);
3026IEM_CIMPL_PROTO_0(iemCImpl_vmcall);
3027#endif
3028
3029#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
3030VBOXSTRICTRC iemSvmVmexit(PVMCPUCC pVCpu, uint64_t uExitCode, uint64_t uExitInfo1, uint64_t uExitInfo2) RT_NOEXCEPT;
3031VBOXSTRICTRC iemHandleSvmEventIntercept(PVMCPUCC pVCpu, uint8_t u8Vector, uint32_t fFlags, uint32_t uErr, uint64_t uCr2) RT_NOEXCEPT;
3032VBOXSTRICTRC iemSvmHandleIOIntercept(PVMCPUCC pVCpu, uint16_t u16Port, SVMIOIOTYPE enmIoType, uint8_t cbReg,
3033 uint8_t cAddrSizeBits, uint8_t iEffSeg, bool fRep, bool fStrIo, uint8_t cbInstr) RT_NOEXCEPT;
3034VBOXSTRICTRC iemSvmHandleMsrIntercept(PVMCPUCC pVCpu, uint32_t idMsr, bool fWrite) RT_NOEXCEPT;
3035IEM_CIMPL_PROTO_0(iemCImpl_vmrun);
3036IEM_CIMPL_PROTO_0(iemCImpl_vmload);
3037IEM_CIMPL_PROTO_0(iemCImpl_vmsave);
3038IEM_CIMPL_PROTO_0(iemCImpl_clgi);
3039IEM_CIMPL_PROTO_0(iemCImpl_stgi);
3040IEM_CIMPL_PROTO_0(iemCImpl_invlpga);
3041IEM_CIMPL_PROTO_0(iemCImpl_skinit);
3042IEM_CIMPL_PROTO_0(iemCImpl_svm_pause);
3043IEM_CIMPL_PROTO_0(iemCImpl_vmmcall);
3044#endif
3045
3046IEM_CIMPL_PROTO_1(iemCImpl_Hypercall, uint16_t, uDisOpcode);
3047
3048
3049extern const PFNIEMOP g_apfnOneByteMap[256];
3050
3051/** @} */
3052
3053RT_C_DECLS_END
3054
3055#endif /* !VMM_INCLUDED_SRC_include_IEMInternal_h */
3056
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