VirtualBox

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

Last change on this file since 104367 was 104367, checked in by vboxsync, 8 months ago

VMM/IEM: Use IEMInternal.h from IEMAllN8veHlpA-arm64.S and produce member offsets for IEMCPU and VMCPU that can be used from same. bugref:10653 bugref:10370

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 319.7 KB
Line 
1/* $Id: IEMInternal.h 104367 2024-04-18 22:38:19Z vboxsync $ */
2/** @file
3 * IEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2011-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef VMM_INCLUDED_SRC_include_IEMInternal_h
29#define VMM_INCLUDED_SRC_include_IEMInternal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#ifndef RT_IN_ASSEMBLER
35# include <VBox/vmm/cpum.h>
36# include <VBox/vmm/iem.h>
37# include <VBox/vmm/pgm.h>
38# include <VBox/vmm/stam.h>
39# include <VBox/param.h>
40
41# include <iprt/setjmp-without-sigmask.h>
42# include <iprt/list.h>
43#endif /* !RT_IN_ASSEMBLER */
44
45
46RT_C_DECLS_BEGIN
47
48
49/** @defgroup grp_iem_int Internals
50 * @ingroup grp_iem
51 * @internal
52 * @{
53 */
54
55/** For expanding symbol in slickedit and other products tagging and
56 * crossreferencing IEM symbols. */
57#ifndef IEM_STATIC
58# define IEM_STATIC static
59#endif
60
61/** @def IEM_WITH_SETJMP
62 * Enables alternative status code handling using setjmps.
63 *
64 * This adds a bit of expense via the setjmp() call since it saves all the
65 * non-volatile registers. However, it eliminates return code checks and allows
66 * for more optimal return value passing (return regs instead of stack buffer).
67 */
68#if defined(DOXYGEN_RUNNING) || defined(RT_OS_WINDOWS) || 1
69# define IEM_WITH_SETJMP
70#endif
71
72/** @def IEM_WITH_THROW_CATCH
73 * Enables using C++ throw/catch as an alternative to setjmp/longjmp in user
74 * mode code when IEM_WITH_SETJMP is in effect.
75 *
76 * With GCC 11.3.1 and code TLB on linux, using throw/catch instead of
77 * setjmp/long resulted in bs2-test-1 running 3.00% faster and all but on test
78 * result value improving by more than 1%. (Best out of three.)
79 *
80 * With Visual C++ 2019 and code TLB on windows, using throw/catch instead of
81 * setjmp/long resulted in bs2-test-1 running 3.68% faster and all but some of
82 * the MMIO and CPUID tests ran noticeably faster. Variation is greater than on
83 * Linux, but it should be quite a bit faster for normal code.
84 */
85#if (defined(__cplusplus) && defined(IEM_WITH_SETJMP) && defined(IN_RING3) && (defined(__GNUC__) || defined(_MSC_VER))) \
86 || defined(DOXYGEN_RUNNING)
87# define IEM_WITH_THROW_CATCH
88#endif
89
90/** @def IEMNATIVE_WITH_DELAYED_PC_UPDATING
91 * Enables the delayed PC updating optimization (see @bugref{10373}).
92 */
93#if defined(DOXYGEN_RUNNING) || 1
94# define IEMNATIVE_WITH_DELAYED_PC_UPDATING
95#endif
96
97/** Enables the SIMD register allocator @bugref{10614}. */
98#if defined(DOXYGEN_RUNNING) || 1
99# define IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
100#endif
101/** Enables access to even callee saved registers. */
102//# define IEMNATIVE_WITH_SIMD_REG_ACCESS_ALL_REGISTERS
103
104#if defined(DOXYGEN_RUNNING) || 1
105/** @def IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
106 * Delay the writeback or dirty registers as long as possible. */
107# define IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK
108#endif
109
110/** @def VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
111 * Enables a quicker alternative to throw/longjmp for IEM_DO_LONGJMP when
112 * executing native translation blocks.
113 *
114 * This exploits the fact that we save all non-volatile registers in the TB
115 * prologue and thus just need to do the same as the TB epilogue to get the
116 * effect of a longjmp/throw. Since MSC marks XMM6 thru XMM15 as
117 * non-volatile (and does something even more crazy for ARM), this probably
118 * won't work reliably on Windows. */
119#if defined(DOXYGEN_RUNNING) || (!defined(RT_OS_WINDOWS) && (defined(RT_ARCH_ARM64) /*|| defined(_RT_ARCH_AMD64)*/))
120# define VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
121#endif
122#ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
123# if !defined(IN_RING3) \
124 || !defined(VBOX_WITH_IEM_RECOMPILER) \
125 || !defined(VBOX_WITH_IEM_NATIVE_RECOMPILER)
126# undef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
127# elif defined(RT_OS_WINDOWS)
128# pragma message("VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP is not safe to use on windows")
129# endif
130#endif
131
132
133/** @def IEM_DO_LONGJMP
134 *
135 * Wrapper around longjmp / throw.
136 *
137 * @param a_pVCpu The CPU handle.
138 * @param a_rc The status code jump back with / throw.
139 */
140#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
141# ifdef IEM_WITH_THROW_CATCH
142# ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
143# define IEM_DO_LONGJMP(a_pVCpu, a_rc) do { \
144 if ((a_pVCpu)->iem.s.pvTbFramePointerR3) \
145 iemNativeTbLongJmp((a_pVCpu)->iem.s.pvTbFramePointerR3, (a_rc)); \
146 throw int(a_rc); \
147 } while (0)
148# else
149# define IEM_DO_LONGJMP(a_pVCpu, a_rc) throw int(a_rc)
150# endif
151# else
152# define IEM_DO_LONGJMP(a_pVCpu, a_rc) longjmp(*(a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf), (a_rc))
153# endif
154#endif
155
156/** For use with IEM function that may do a longjmp (when enabled).
157 *
158 * Visual C++ has trouble longjmp'ing from/over functions with the noexcept
159 * attribute. So, we indicate that function that may be part of a longjmp may
160 * throw "exceptions" and that the compiler should definitely not generate and
161 * std::terminate calling unwind code.
162 *
163 * Here is one example of this ending in std::terminate:
164 * @code{.txt}
16500 00000041`cadfda10 00007ffc`5d5a1f9f ucrtbase!abort+0x4e
16601 00000041`cadfda40 00007ffc`57af229a ucrtbase!terminate+0x1f
16702 00000041`cadfda70 00007ffb`eec91030 VCRUNTIME140!__std_terminate+0xa [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\ehhelpers.cpp @ 192]
16803 00000041`cadfdaa0 00007ffb`eec92c6d VCRUNTIME140_1!_CallSettingFrame+0x20 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm @ 50]
16904 00000041`cadfdad0 00007ffb`eec93ae5 VCRUNTIME140_1!__FrameHandler4::FrameUnwindToState+0x241 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1085]
17005 00000041`cadfdc00 00007ffb`eec92258 VCRUNTIME140_1!__FrameHandler4::FrameUnwindToEmptyState+0x2d [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp @ 218]
17106 00000041`cadfdc30 00007ffb`eec940e9 VCRUNTIME140_1!__InternalCxxFrameHandler<__FrameHandler4>+0x194 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 304]
17207 00000041`cadfdcd0 00007ffc`5f9f249f VCRUNTIME140_1!__CxxFrameHandler4+0xa9 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\risctrnsctrl.cpp @ 290]
17308 00000041`cadfdd40 00007ffc`5f980939 ntdll!RtlpExecuteHandlerForUnwind+0xf
17409 00000041`cadfdd70 00007ffc`5f9a0edd ntdll!RtlUnwindEx+0x339
1750a 00000041`cadfe490 00007ffc`57aff976 ntdll!RtlUnwind+0xcd
1760b 00000041`cadfea00 00007ffb`e1b5de01 VCRUNTIME140!__longjmp_internal+0xe6 [d:\agent\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\longjmp.asm @ 140]
1770c (Inline Function) --------`-------- VBoxVMM!iemOpcodeGetNextU8SlowJmp+0x95 [L:\vbox-intern\src\VBox\VMM\VMMAll\IEMAll.cpp @ 1155]
1780d 00000041`cadfea50 00007ffb`e1b60f6b VBoxVMM!iemOpcodeGetNextU8Jmp+0xc1 [L:\vbox-intern\src\VBox\VMM\include\IEMInline.h @ 402]
1790e 00000041`cadfea90 00007ffb`e1cc6201 VBoxVMM!IEMExecForExits+0xdb [L:\vbox-intern\src\VBox\VMM\VMMAll\IEMAll.cpp @ 10185]
1800f 00000041`cadfec70 00007ffb`e1d0df8d VBoxVMM!EMHistoryExec+0x4f1 [L:\vbox-intern\src\VBox\VMM\VMMAll\EMAll.cpp @ 452]
18110 00000041`cadfed60 00007ffb`e1d0d4c0 VBoxVMM!nemR3WinHandleExitCpuId+0x79d [L:\vbox-intern\src\VBox\VMM\VMMAll\NEMAllNativeTemplate-win.cpp.h @ 1829] @encode
182 @endcode
183 *
184 * @see https://developercommunity.visualstudio.com/t/fragile-behavior-of-longjmp-called-from-noexcept-f/1532859
185 */
186#if defined(IEM_WITH_SETJMP) && (defined(_MSC_VER) || defined(IEM_WITH_THROW_CATCH))
187# define IEM_NOEXCEPT_MAY_LONGJMP RT_NOEXCEPT_EX(false)
188#else
189# define IEM_NOEXCEPT_MAY_LONGJMP RT_NOEXCEPT
190#endif
191
192#define IEM_IMPLEMENTS_TASKSWITCH
193
194/** @def IEM_WITH_3DNOW
195 * Includes the 3DNow decoding. */
196#if (!defined(IEM_WITH_3DNOW) && !defined(IEM_WITHOUT_3DNOW)) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
197# define IEM_WITH_3DNOW
198#endif
199
200/** @def IEM_WITH_THREE_0F_38
201 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
202#if (!defined(IEM_WITH_THREE_0F_38) && !defined(IEM_WITHOUT_THREE_0F_38)) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
203# define IEM_WITH_THREE_0F_38
204#endif
205
206/** @def IEM_WITH_THREE_0F_3A
207 * Includes the three byte opcode map for instrs starting with 0x0f 0x38. */
208#if (!defined(IEM_WITH_THREE_0F_3A) && !defined(IEM_WITHOUT_THREE_0F_3A)) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
209# define IEM_WITH_THREE_0F_3A
210#endif
211
212/** @def IEM_WITH_VEX
213 * Includes the VEX decoding. */
214#if (!defined(IEM_WITH_VEX) && !defined(IEM_WITHOUT_VEX)) || defined(DOXYGEN_RUNNING) /* For doxygen, set in Config.kmk. */
215# define IEM_WITH_VEX
216#endif
217
218/** @def IEM_CFG_TARGET_CPU
219 * The minimum target CPU for the IEM emulation (IEMTARGETCPU_XXX value).
220 *
221 * By default we allow this to be configured by the user via the
222 * CPUM/GuestCpuName config string, but this comes at a slight cost during
223 * decoding. So, for applications of this code where there is no need to
224 * be dynamic wrt target CPU, just modify this define.
225 */
226#if !defined(IEM_CFG_TARGET_CPU) || defined(DOXYGEN_RUNNING)
227# define IEM_CFG_TARGET_CPU IEMTARGETCPU_DYNAMIC
228#endif
229
230//#define IEM_WITH_CODE_TLB // - work in progress
231//#define IEM_WITH_DATA_TLB // - work in progress
232
233
234/** @def IEM_USE_UNALIGNED_DATA_ACCESS
235 * Use unaligned accesses instead of elaborate byte assembly. */
236#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86) || defined(DOXYGEN_RUNNING)
237# define IEM_USE_UNALIGNED_DATA_ACCESS
238#endif
239
240//#define IEM_LOG_MEMORY_WRITES
241
242
243
244#ifndef RT_IN_ASSEMBLER /* the rest of the file */
245
246# if !defined(IN_TSTVMSTRUCT) && !defined(DOXYGEN_RUNNING)
247/** Instruction statistics. */
248typedef struct IEMINSTRSTATS
249{
250# define IEM_DO_INSTR_STAT(a_Name, a_szDesc) uint32_t a_Name;
251# include "IEMInstructionStatisticsTmpl.h"
252# undef IEM_DO_INSTR_STAT
253} IEMINSTRSTATS;
254#else
255struct IEMINSTRSTATS;
256typedef struct IEMINSTRSTATS IEMINSTRSTATS;
257#endif
258/** Pointer to IEM instruction statistics. */
259typedef IEMINSTRSTATS *PIEMINSTRSTATS;
260
261
262/** @name IEMTARGETCPU_EFL_BEHAVIOR_XXX - IEMCPU::aidxTargetCpuEflFlavour
263 * @{ */
264#define IEMTARGETCPU_EFL_BEHAVIOR_NATIVE 0 /**< Native x86 EFLAGS result; Intel EFLAGS when on non-x86 hosts. */
265#define IEMTARGETCPU_EFL_BEHAVIOR_INTEL 1 /**< Intel EFLAGS result. */
266#define IEMTARGETCPU_EFL_BEHAVIOR_AMD 2 /**< AMD EFLAGS result */
267#define IEMTARGETCPU_EFL_BEHAVIOR_RESERVED 3 /**< Reserved/dummy entry slot that's the same as 0. */
268#define IEMTARGETCPU_EFL_BEHAVIOR_MASK 3 /**< For masking the index before use. */
269/** Selects the right variant from a_aArray.
270 * pVCpu is implicit in the caller context. */
271#define IEMTARGETCPU_EFL_BEHAVIOR_SELECT(a_aArray) \
272 (a_aArray[pVCpu->iem.s.aidxTargetCpuEflFlavour[1] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
273/** Variation of IEMTARGETCPU_EFL_BEHAVIOR_SELECT for when no native worker can
274 * be used because the host CPU does not support the operation. */
275#define IEMTARGETCPU_EFL_BEHAVIOR_SELECT_NON_NATIVE(a_aArray) \
276 (a_aArray[pVCpu->iem.s.aidxTargetCpuEflFlavour[0] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
277/** Variation of IEMTARGETCPU_EFL_BEHAVIOR_SELECT for a two dimentional
278 * array paralleling IEMCPU::aidxTargetCpuEflFlavour and a single bit index
279 * into the two.
280 * @sa IEM_SELECT_NATIVE_OR_FALLBACK */
281#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
282# define IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX(a_aaArray, a_fNative) \
283 (a_aaArray[a_fNative][pVCpu->iem.s.aidxTargetCpuEflFlavour[a_fNative] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
284#else
285# define IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX(a_aaArray, a_fNative) \
286 (a_aaArray[0][pVCpu->iem.s.aidxTargetCpuEflFlavour[0] & IEMTARGETCPU_EFL_BEHAVIOR_MASK])
287#endif
288/** @} */
289
290/**
291 * Picks @a a_pfnNative or @a a_pfnFallback according to the host CPU feature
292 * indicator given by @a a_fCpumFeatureMember (CPUMFEATURES member).
293 *
294 * On non-x86 hosts, this will shortcut to the fallback w/o checking the
295 * indicator.
296 *
297 * @sa IEMTARGETCPU_EFL_BEHAVIOR_SELECT_EX
298 */
299#if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
300# define IEM_SELECT_HOST_OR_FALLBACK(a_fCpumFeatureMember, a_pfnNative, a_pfnFallback) \
301 (g_CpumHostFeatures.s.a_fCpumFeatureMember ? a_pfnNative : a_pfnFallback)
302#else
303# define IEM_SELECT_HOST_OR_FALLBACK(a_fCpumFeatureMember, a_pfnNative, a_pfnFallback) (a_pfnFallback)
304#endif
305
306
307/**
308 * Extended operand mode that includes a representation of 8-bit.
309 *
310 * This is used for packing down modes when invoking some C instruction
311 * implementations.
312 */
313typedef enum IEMMODEX
314{
315 IEMMODEX_16BIT = IEMMODE_16BIT,
316 IEMMODEX_32BIT = IEMMODE_32BIT,
317 IEMMODEX_64BIT = IEMMODE_64BIT,
318 IEMMODEX_8BIT
319} IEMMODEX;
320AssertCompileSize(IEMMODEX, 4);
321
322
323/**
324 * Branch types.
325 */
326typedef enum IEMBRANCH
327{
328 IEMBRANCH_JUMP = 1,
329 IEMBRANCH_CALL,
330 IEMBRANCH_TRAP,
331 IEMBRANCH_SOFTWARE_INT,
332 IEMBRANCH_HARDWARE_INT
333} IEMBRANCH;
334AssertCompileSize(IEMBRANCH, 4);
335
336
337/**
338 * INT instruction types.
339 */
340typedef enum IEMINT
341{
342 /** INT n instruction (opcode 0xcd imm). */
343 IEMINT_INTN = 0,
344 /** Single byte INT3 instruction (opcode 0xcc). */
345 IEMINT_INT3 = IEM_XCPT_FLAGS_BP_INSTR,
346 /** Single byte INTO instruction (opcode 0xce). */
347 IEMINT_INTO = IEM_XCPT_FLAGS_OF_INSTR,
348 /** Single byte INT1 (ICEBP) instruction (opcode 0xf1). */
349 IEMINT_INT1 = IEM_XCPT_FLAGS_ICEBP_INSTR
350} IEMINT;
351AssertCompileSize(IEMINT, 4);
352
353
354/**
355 * A FPU result.
356 */
357typedef struct IEMFPURESULT
358{
359 /** The output value. */
360 RTFLOAT80U r80Result;
361 /** The output status. */
362 uint16_t FSW;
363} IEMFPURESULT;
364AssertCompileMemberOffset(IEMFPURESULT, FSW, 10);
365/** Pointer to a FPU result. */
366typedef IEMFPURESULT *PIEMFPURESULT;
367/** Pointer to a const FPU result. */
368typedef IEMFPURESULT const *PCIEMFPURESULT;
369
370
371/**
372 * A FPU result consisting of two output values and FSW.
373 */
374typedef struct IEMFPURESULTTWO
375{
376 /** The first output value. */
377 RTFLOAT80U r80Result1;
378 /** The output status. */
379 uint16_t FSW;
380 /** The second output value. */
381 RTFLOAT80U r80Result2;
382} IEMFPURESULTTWO;
383AssertCompileMemberOffset(IEMFPURESULTTWO, FSW, 10);
384AssertCompileMemberOffset(IEMFPURESULTTWO, r80Result2, 12);
385/** Pointer to a FPU result consisting of two output values and FSW. */
386typedef IEMFPURESULTTWO *PIEMFPURESULTTWO;
387/** Pointer to a const FPU result consisting of two output values and FSW. */
388typedef IEMFPURESULTTWO const *PCIEMFPURESULTTWO;
389
390
391/**
392 * IEM TLB entry.
393 *
394 * Lookup assembly:
395 * @code{.asm}
396 ; Calculate tag.
397 mov rax, [VA]
398 shl rax, 16
399 shr rax, 16 + X86_PAGE_SHIFT
400 or rax, [uTlbRevision]
401
402 ; Do indexing.
403 movzx ecx, al
404 lea rcx, [pTlbEntries + rcx]
405
406 ; Check tag.
407 cmp [rcx + IEMTLBENTRY.uTag], rax
408 jne .TlbMiss
409
410 ; Check access.
411 mov rax, ACCESS_FLAGS | MAPPING_R3_NOT_VALID | 0xffffff00
412 and rax, [rcx + IEMTLBENTRY.fFlagsAndPhysRev]
413 cmp rax, [uTlbPhysRev]
414 jne .TlbMiss
415
416 ; Calc address and we're done.
417 mov eax, X86_PAGE_OFFSET_MASK
418 and eax, [VA]
419 or rax, [rcx + IEMTLBENTRY.pMappingR3]
420 %ifdef VBOX_WITH_STATISTICS
421 inc qword [cTlbHits]
422 %endif
423 jmp .Done
424
425 .TlbMiss:
426 mov r8d, ACCESS_FLAGS
427 mov rdx, [VA]
428 mov rcx, [pVCpu]
429 call iemTlbTypeMiss
430 .Done:
431
432 @endcode
433 *
434 */
435typedef struct IEMTLBENTRY
436{
437 /** The TLB entry tag.
438 * Bits 35 thru 0 are made up of the virtual address shifted right 12 bits, this
439 * is ASSUMING a virtual address width of 48 bits.
440 *
441 * Bits 63 thru 36 are made up of the TLB revision (zero means invalid).
442 *
443 * The TLB lookup code uses the current TLB revision, which won't ever be zero,
444 * enabling an extremely cheap TLB invalidation most of the time. When the TLB
445 * revision wraps around though, the tags needs to be zeroed.
446 *
447 * @note Try use SHRD instruction? After seeing
448 * https://gmplib.org/~tege/x86-timing.pdf, maybe not.
449 *
450 * @todo This will need to be reorganized for 57-bit wide virtual address and
451 * PCID (currently 12 bits) and ASID (currently 6 bits) support. We'll
452 * have to move the TLB entry versioning entirely to the
453 * fFlagsAndPhysRev member then, 57 bit wide VAs means we'll only have
454 * 19 bits left (64 - 57 + 12 = 19) and they'll almost entire be
455 * consumed by PCID and ASID (12 + 6 = 18).
456 */
457 uint64_t uTag;
458 /** Access flags and physical TLB revision.
459 *
460 * - Bit 0 - page tables - not executable (X86_PTE_PAE_NX).
461 * - Bit 1 - page tables - not writable (complemented X86_PTE_RW).
462 * - Bit 2 - page tables - not user (complemented X86_PTE_US).
463 * - Bit 3 - pgm phys/virt - not directly writable.
464 * - Bit 4 - pgm phys page - not directly readable.
465 * - Bit 5 - page tables - not accessed (complemented X86_PTE_A).
466 * - Bit 6 - page tables - not dirty (complemented X86_PTE_D).
467 * - Bit 7 - tlb entry - pMappingR3 member not valid.
468 * - Bits 63 thru 8 are used for the physical TLB revision number.
469 *
470 * We're using complemented bit meanings here because it makes it easy to check
471 * whether special action is required. For instance a user mode write access
472 * would do a "TEST fFlags, (X86_PTE_RW | X86_PTE_US | X86_PTE_D)" and a
473 * non-zero result would mean special handling needed because either it wasn't
474 * writable, or it wasn't user, or the page wasn't dirty. A user mode read
475 * access would do "TEST fFlags, X86_PTE_US"; and a kernel mode read wouldn't
476 * need to check any PTE flag.
477 */
478 uint64_t fFlagsAndPhysRev;
479 /** The guest physical page address. */
480 uint64_t GCPhys;
481 /** Pointer to the ring-3 mapping. */
482 R3PTRTYPE(uint8_t *) pbMappingR3;
483#if HC_ARCH_BITS == 32
484 uint32_t u32Padding1;
485#endif
486} IEMTLBENTRY;
487AssertCompileSize(IEMTLBENTRY, 32);
488/** Pointer to an IEM TLB entry. */
489typedef IEMTLBENTRY *PIEMTLBENTRY;
490
491/** @name IEMTLBE_F_XXX - TLB entry flags (IEMTLBENTRY::fFlagsAndPhysRev)
492 * @{ */
493#define IEMTLBE_F_PT_NO_EXEC RT_BIT_64(0) /**< Page tables: Not executable. */
494#define IEMTLBE_F_PT_NO_WRITE RT_BIT_64(1) /**< Page tables: Not writable. */
495#define IEMTLBE_F_PT_NO_USER RT_BIT_64(2) /**< Page tables: Not user accessible (supervisor only). */
496#define IEMTLBE_F_PG_NO_WRITE RT_BIT_64(3) /**< Phys page: Not writable (access handler, ROM, whatever). */
497#define IEMTLBE_F_PG_NO_READ RT_BIT_64(4) /**< Phys page: Not readable (MMIO / access handler, ROM) */
498#define IEMTLBE_F_PT_NO_ACCESSED RT_BIT_64(5) /**< Phys tables: Not accessed (need to be marked accessed). */
499#define IEMTLBE_F_PT_NO_DIRTY RT_BIT_64(6) /**< Page tables: Not dirty (needs to be made dirty on write). */
500#define IEMTLBE_F_NO_MAPPINGR3 RT_BIT_64(7) /**< TLB entry: The IEMTLBENTRY::pMappingR3 member is invalid. */
501#define IEMTLBE_F_PG_UNASSIGNED RT_BIT_64(8) /**< Phys page: Unassigned memory (not RAM, ROM, MMIO2 or MMIO). */
502#define IEMTLBE_F_PG_CODE_PAGE RT_BIT_64(9) /**< Phys page: Code page. */
503#define IEMTLBE_F_PHYS_REV UINT64_C(0xfffffffffffffc00) /**< Physical revision mask. @sa IEMTLB_PHYS_REV_INCR */
504/** @} */
505
506
507/**
508 * An IEM TLB.
509 *
510 * We've got two of these, one for data and one for instructions.
511 */
512typedef struct IEMTLB
513{
514 /** The TLB revision.
515 * This is actually only 28 bits wide (see IEMTLBENTRY::uTag) and is incremented
516 * by adding RT_BIT_64(36) to it. When it wraps around and becomes zero, all
517 * the tags in the TLB must be zeroed and the revision set to RT_BIT_64(36).
518 * (The revision zero indicates an invalid TLB entry.)
519 *
520 * The initial value is choosen to cause an early wraparound. */
521 uint64_t uTlbRevision;
522 /** The TLB physical address revision - shadow of PGM variable.
523 *
524 * This is actually only 56 bits wide (see IEMTLBENTRY::fFlagsAndPhysRev) and is
525 * incremented by adding RT_BIT_64(8). When it wraps around and becomes zero,
526 * a rendezvous is called and each CPU wipe the IEMTLBENTRY::pMappingR3 as well
527 * as IEMTLBENTRY::fFlagsAndPhysRev bits 63 thru 8, 4, and 3.
528 *
529 * The initial value is choosen to cause an early wraparound. */
530 uint64_t volatile uTlbPhysRev;
531
532 /* Statistics: */
533
534 /** TLB hits (VBOX_WITH_STATISTICS only). */
535 uint64_t cTlbHits;
536 /** TLB misses. */
537 uint32_t cTlbMisses;
538 /** Slow read path. */
539 uint32_t cTlbSlowReadPath;
540 /** Safe read path. */
541 uint32_t cTlbSafeReadPath;
542 /** Safe write path. */
543 uint32_t cTlbSafeWritePath;
544#if 0
545 /** TLB misses because of tag mismatch. */
546 uint32_t cTlbMissesTag;
547 /** TLB misses because of virtual access violation. */
548 uint32_t cTlbMissesVirtAccess;
549 /** TLB misses because of dirty bit. */
550 uint32_t cTlbMissesDirty;
551 /** TLB misses because of MMIO */
552 uint32_t cTlbMissesMmio;
553 /** TLB misses because of write access handlers. */
554 uint32_t cTlbMissesWriteHandler;
555 /** TLB misses because no r3(/r0) mapping. */
556 uint32_t cTlbMissesMapping;
557#endif
558 /** Alignment padding. */
559 uint32_t au32Padding[6];
560
561 /** The TLB entries.
562 * We've choosen 256 because that way we can obtain the result directly from a
563 * 8-bit register without an additional AND instruction. */
564 IEMTLBENTRY aEntries[256];
565} IEMTLB;
566AssertCompileSizeAlignment(IEMTLB, 64);
567/** IEMTLB::uTlbRevision increment. */
568#define IEMTLB_REVISION_INCR RT_BIT_64(36)
569/** IEMTLB::uTlbRevision mask. */
570#define IEMTLB_REVISION_MASK (~(RT_BIT_64(36) - 1))
571/** IEMTLB::uTlbPhysRev increment.
572 * @sa IEMTLBE_F_PHYS_REV */
573#define IEMTLB_PHYS_REV_INCR RT_BIT_64(10)
574/**
575 * Calculates the TLB tag for a virtual address.
576 * @returns Tag value for indexing and comparing with IEMTLB::uTag.
577 * @param a_pTlb The TLB.
578 * @param a_GCPtr The virtual address. Must be RTGCPTR or same size or
579 * the clearing of the top 16 bits won't work (if 32-bit
580 * we'll end up with mostly zeros).
581 */
582#define IEMTLB_CALC_TAG(a_pTlb, a_GCPtr) ( IEMTLB_CALC_TAG_NO_REV(a_GCPtr) | (a_pTlb)->uTlbRevision )
583/**
584 * Calculates the TLB tag for a virtual address but without TLB revision.
585 * @returns Tag value for indexing and comparing with IEMTLB::uTag.
586 * @param a_GCPtr The virtual address. Must be RTGCPTR or same size or
587 * the clearing of the top 16 bits won't work (if 32-bit
588 * we'll end up with mostly zeros).
589 */
590#define IEMTLB_CALC_TAG_NO_REV(a_GCPtr) ( (((a_GCPtr) << 16) >> (GUEST_PAGE_SHIFT + 16)) )
591/**
592 * Converts a TLB tag value into a TLB index.
593 * @returns Index into IEMTLB::aEntries.
594 * @param a_uTag Value returned by IEMTLB_CALC_TAG.
595 */
596#define IEMTLB_TAG_TO_INDEX(a_uTag) ( (uint8_t)(a_uTag) )
597/**
598 * Converts a TLB tag value into a TLB index.
599 * @returns Index into IEMTLB::aEntries.
600 * @param a_pTlb The TLB.
601 * @param a_uTag Value returned by IEMTLB_CALC_TAG.
602 */
603#define IEMTLB_TAG_TO_ENTRY(a_pTlb, a_uTag) ( &(a_pTlb)->aEntries[IEMTLB_TAG_TO_INDEX(a_uTag)] )
604
605
606/** @name IEM_MC_F_XXX - MC block flags/clues.
607 * @todo Merge with IEM_CIMPL_F_XXX
608 * @{ */
609#define IEM_MC_F_ONLY_8086 RT_BIT_32(0)
610#define IEM_MC_F_MIN_186 RT_BIT_32(1)
611#define IEM_MC_F_MIN_286 RT_BIT_32(2)
612#define IEM_MC_F_NOT_286_OR_OLDER IEM_MC_F_MIN_386
613#define IEM_MC_F_MIN_386 RT_BIT_32(3)
614#define IEM_MC_F_MIN_486 RT_BIT_32(4)
615#define IEM_MC_F_MIN_PENTIUM RT_BIT_32(5)
616#define IEM_MC_F_MIN_PENTIUM_II IEM_MC_F_MIN_PENTIUM
617#define IEM_MC_F_MIN_CORE IEM_MC_F_MIN_PENTIUM
618#define IEM_MC_F_64BIT RT_BIT_32(6)
619#define IEM_MC_F_NOT_64BIT RT_BIT_32(7)
620/** This is set by IEMAllN8vePython.py to indicate a variation without the
621 * flags-clearing-and-checking, when there is also a variation with that.
622 * @note Do not use this manully, it's only for python and for testing in
623 * the native recompiler! */
624#define IEM_MC_F_WITHOUT_FLAGS RT_BIT_32(8)
625/** @} */
626
627/** @name IEM_CIMPL_F_XXX - State change clues for CIMPL calls.
628 *
629 * These clues are mainly for the recompiler, so that it can emit correct code.
630 *
631 * They are processed by the python script and which also automatically
632 * calculates flags for MC blocks based on the statements, extending the use of
633 * these flags to describe MC block behavior to the recompiler core. The python
634 * script pass the flags to the IEM_MC2_END_EMIT_CALLS macro, but mainly for
635 * error checking purposes. The script emits the necessary fEndTb = true and
636 * similar statements as this reduces compile time a tiny bit.
637 *
638 * @{ */
639/** Flag set if direct branch, clear if absolute or indirect. */
640#define IEM_CIMPL_F_BRANCH_DIRECT RT_BIT_32(0)
641/** Flag set if indirect branch, clear if direct or relative.
642 * This is also used for all system control transfers (SYSCALL, SYSRET, INT, ++)
643 * as well as for return instructions (RET, IRET, RETF). */
644#define IEM_CIMPL_F_BRANCH_INDIRECT RT_BIT_32(1)
645/** Flag set if relative branch, clear if absolute or indirect. */
646#define IEM_CIMPL_F_BRANCH_RELATIVE RT_BIT_32(2)
647/** Flag set if conditional branch, clear if unconditional. */
648#define IEM_CIMPL_F_BRANCH_CONDITIONAL RT_BIT_32(3)
649/** Flag set if it's a far branch (changes CS). */
650#define IEM_CIMPL_F_BRANCH_FAR RT_BIT_32(4)
651/** Convenience: Testing any kind of branch. */
652#define IEM_CIMPL_F_BRANCH_ANY (IEM_CIMPL_F_BRANCH_DIRECT | IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_RELATIVE)
653
654/** Execution flags may change (IEMCPU::fExec). */
655#define IEM_CIMPL_F_MODE RT_BIT_32(5)
656/** May change significant portions of RFLAGS. */
657#define IEM_CIMPL_F_RFLAGS RT_BIT_32(6)
658/** May change the status bits (X86_EFL_STATUS_BITS) in RFLAGS. */
659#define IEM_CIMPL_F_STATUS_FLAGS RT_BIT_32(7)
660/** May trigger interrupt shadowing. */
661#define IEM_CIMPL_F_INHIBIT_SHADOW RT_BIT_32(8)
662/** May enable interrupts, so recheck IRQ immediately afterwards executing
663 * the instruction. */
664#define IEM_CIMPL_F_CHECK_IRQ_AFTER RT_BIT_32(9)
665/** May disable interrupts, so recheck IRQ immediately before executing the
666 * instruction. */
667#define IEM_CIMPL_F_CHECK_IRQ_BEFORE RT_BIT_32(10)
668/** Convenience: Check for IRQ both before and after an instruction. */
669#define IEM_CIMPL_F_CHECK_IRQ_BEFORE_AND_AFTER (IEM_CIMPL_F_CHECK_IRQ_BEFORE | IEM_CIMPL_F_CHECK_IRQ_AFTER)
670/** May trigger a VM exit (treated like IEM_CIMPL_F_MODE atm). */
671#define IEM_CIMPL_F_VMEXIT RT_BIT_32(11)
672/** May modify FPU state.
673 * @todo Not sure if this is useful yet. */
674#define IEM_CIMPL_F_FPU RT_BIT_32(12)
675/** REP prefixed instruction which may yield before updating PC.
676 * @todo Not sure if this is useful, REP functions now return non-zero
677 * status if they don't update the PC. */
678#define IEM_CIMPL_F_REP RT_BIT_32(13)
679/** I/O instruction.
680 * @todo Not sure if this is useful yet. */
681#define IEM_CIMPL_F_IO RT_BIT_32(14)
682/** Force end of TB after the instruction. */
683#define IEM_CIMPL_F_END_TB RT_BIT_32(15)
684/** Flag set if a branch may also modify the stack (push/pop return address). */
685#define IEM_CIMPL_F_BRANCH_STACK RT_BIT_32(16)
686/** Flag set if a branch may also modify the stack (push/pop return address)
687 * and switch it (load/restore SS:RSP). */
688#define IEM_CIMPL_F_BRANCH_STACK_FAR RT_BIT_32(17)
689/** Convenience: Raise exception (technically unnecessary, since it shouldn't return VINF_SUCCESS). */
690#define IEM_CIMPL_F_XCPT \
691 (IEM_CIMPL_F_BRANCH_INDIRECT | IEM_CIMPL_F_BRANCH_FAR | IEM_CIMPL_F_BRANCH_STACK_FAR \
692 | IEM_CIMPL_F_MODE | IEM_CIMPL_F_RFLAGS | IEM_CIMPL_F_VMEXIT)
693
694/** The block calls a C-implementation instruction function with two implicit arguments.
695 * Mutually exclusive with IEM_CIMPL_F_CALLS_AIMPL and
696 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
697 * @note The python scripts will add this if missing. */
698#define IEM_CIMPL_F_CALLS_CIMPL RT_BIT_32(18)
699/** The block calls an ASM-implementation instruction function.
700 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL and
701 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
702 * @note The python scripts will add this if missing. */
703#define IEM_CIMPL_F_CALLS_AIMPL RT_BIT_32(19)
704/** The block calls an ASM-implementation instruction function with an implicit
705 * X86FXSTATE pointer argument.
706 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL, IEM_CIMPL_F_CALLS_AIMPL and
707 * IEM_CIMPL_F_CALLS_AIMPL_WITH_XSTATE.
708 * @note The python scripts will add this if missing. */
709#define IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE RT_BIT_32(20)
710/** The block calls an ASM-implementation instruction function with an implicit
711 * X86XSAVEAREA pointer argument.
712 * Mutually exclusive with IEM_CIMPL_F_CALLS_CIMPL, IEM_CIMPL_F_CALLS_AIMPL and
713 * IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE.
714 * @note No different from IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE, so same value.
715 * @note The python scripts will add this if missing. */
716#define IEM_CIMPL_F_CALLS_AIMPL_WITH_XSTATE IEM_CIMPL_F_CALLS_AIMPL_WITH_FXSTATE
717/** @} */
718
719
720/** @name IEM_F_XXX - Execution mode flags (IEMCPU::fExec, IEMTB::fFlags).
721 *
722 * These flags are set when entering IEM and adjusted as code is executed, such
723 * that they will always contain the current values as instructions are
724 * finished.
725 *
726 * In recompiled execution mode, (most of) these flags are included in the
727 * translation block selection key and stored in IEMTB::fFlags alongside the
728 * IEMTB_F_XXX flags. The latter flags uses bits 31 thru 24, which are all zero
729 * in IEMCPU::fExec.
730 *
731 * @{ */
732/** Mode: The block target mode mask. */
733#define IEM_F_MODE_MASK UINT32_C(0x0000001f)
734/** Mode: The IEMMODE part of the IEMTB_F_MODE_MASK value. */
735#define IEM_F_MODE_CPUMODE_MASK UINT32_C(0x00000003)
736/** X86 Mode: Bit used to indicating pre-386 CPU in 16-bit mode (for eliminating
737 * conditional in EIP/IP updating), and flat wide open CS, SS, DS, and ES in
738 * 32-bit mode (for simplifying most memory accesses). */
739#define IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK UINT32_C(0x00000004)
740/** X86 Mode: Bit indicating protected mode, real mode (or SMM) when not set. */
741#define IEM_F_MODE_X86_PROT_MASK UINT32_C(0x00000008)
742/** X86 Mode: Bit used to indicate virtual 8086 mode (only 16-bit). */
743#define IEM_F_MODE_X86_V86_MASK UINT32_C(0x00000010)
744
745/** X86 Mode: 16-bit on 386 or later. */
746#define IEM_F_MODE_X86_16BIT UINT32_C(0x00000000)
747/** X86 Mode: 80286, 80186 and 8086/88 targetting blocks (EIP update opt). */
748#define IEM_F_MODE_X86_16BIT_PRE_386 UINT32_C(0x00000004)
749/** X86 Mode: 16-bit protected mode on 386 or later. */
750#define IEM_F_MODE_X86_16BIT_PROT UINT32_C(0x00000008)
751/** X86 Mode: 16-bit protected mode on 386 or later. */
752#define IEM_F_MODE_X86_16BIT_PROT_PRE_386 UINT32_C(0x0000000c)
753/** X86 Mode: 16-bit virtual 8086 protected mode (on 386 or later). */
754#define IEM_F_MODE_X86_16BIT_PROT_V86 UINT32_C(0x00000018)
755
756/** X86 Mode: 32-bit on 386 or later. */
757#define IEM_F_MODE_X86_32BIT UINT32_C(0x00000001)
758/** X86 Mode: 32-bit mode with wide open flat CS, SS, DS and ES. */
759#define IEM_F_MODE_X86_32BIT_FLAT UINT32_C(0x00000005)
760/** X86 Mode: 32-bit protected mode. */
761#define IEM_F_MODE_X86_32BIT_PROT UINT32_C(0x00000009)
762/** X86 Mode: 32-bit protected mode with wide open flat CS, SS, DS and ES. */
763#define IEM_F_MODE_X86_32BIT_PROT_FLAT UINT32_C(0x0000000d)
764
765/** X86 Mode: 64-bit (includes protected, but not the flat bit). */
766#define IEM_F_MODE_X86_64BIT UINT32_C(0x0000000a)
767
768/** X86 Mode: Checks if @a a_fExec represent a FLAT mode. */
769#define IEM_F_MODE_X86_IS_FLAT(a_fExec) ( ((a_fExec) & IEM_F_MODE_MASK) == IEM_F_MODE_X86_64BIT \
770 || ((a_fExec) & IEM_F_MODE_MASK) == IEM_F_MODE_X86_32BIT_PROT_FLAT \
771 || ((a_fExec) & IEM_F_MODE_MASK) == IEM_F_MODE_X86_32BIT_FLAT)
772
773/** Bypass access handlers when set. */
774#define IEM_F_BYPASS_HANDLERS UINT32_C(0x00010000)
775/** Have pending hardware instruction breakpoints. */
776#define IEM_F_PENDING_BRK_INSTR UINT32_C(0x00020000)
777/** Have pending hardware data breakpoints. */
778#define IEM_F_PENDING_BRK_DATA UINT32_C(0x00040000)
779
780/** X86: Have pending hardware I/O breakpoints. */
781#define IEM_F_PENDING_BRK_X86_IO UINT32_C(0x00000400)
782/** X86: Disregard the lock prefix (implied or not) when set. */
783#define IEM_F_X86_DISREGARD_LOCK UINT32_C(0x00000800)
784
785/** Pending breakpoint mask (what iemCalcExecDbgFlags works out). */
786#define IEM_F_PENDING_BRK_MASK (IEM_F_PENDING_BRK_INSTR | IEM_F_PENDING_BRK_DATA | IEM_F_PENDING_BRK_X86_IO)
787
788/** Caller configurable options. */
789#define IEM_F_USER_OPTS (IEM_F_BYPASS_HANDLERS | IEM_F_X86_DISREGARD_LOCK)
790
791/** X86: The current protection level (CPL) shift factor. */
792#define IEM_F_X86_CPL_SHIFT 8
793/** X86: The current protection level (CPL) mask. */
794#define IEM_F_X86_CPL_MASK UINT32_C(0x00000300)
795/** X86: The current protection level (CPL) shifted mask. */
796#define IEM_F_X86_CPL_SMASK UINT32_C(0x00000003)
797
798/** X86 execution context.
799 * The IEM_F_X86_CTX_XXX values are individual flags that can be combined (with
800 * the exception of IEM_F_X86_CTX_NORMAL). This allows running VMs from SMM
801 * mode. */
802#define IEM_F_X86_CTX_MASK UINT32_C(0x0000f000)
803/** X86 context: Plain regular execution context. */
804#define IEM_F_X86_CTX_NORMAL UINT32_C(0x00000000)
805/** X86 context: VT-x enabled. */
806#define IEM_F_X86_CTX_VMX UINT32_C(0x00001000)
807/** X86 context: AMD-V enabled. */
808#define IEM_F_X86_CTX_SVM UINT32_C(0x00002000)
809/** X86 context: In AMD-V or VT-x guest mode. */
810#define IEM_F_X86_CTX_IN_GUEST UINT32_C(0x00004000)
811/** X86 context: System management mode (SMM). */
812#define IEM_F_X86_CTX_SMM UINT32_C(0x00008000)
813
814/** @todo Add TF+RF+INHIBIT indicator(s), so we can eliminate the conditional in
815 * iemRegFinishClearingRF() most for most situations (CPUMCTX_DBG_HIT_DRX_MASK
816 * and CPUMCTX_DBG_DBGF_MASK are covered by the IEM_F_PENDING_BRK_XXX bits
817 * alread). */
818
819/** @todo Add TF+RF+INHIBIT indicator(s), so we can eliminate the conditional in
820 * iemRegFinishClearingRF() most for most situations
821 * (CPUMCTX_DBG_HIT_DRX_MASK and CPUMCTX_DBG_DBGF_MASK are covered by
822 * the IEM_F_PENDING_BRK_XXX bits alread). */
823
824/** @} */
825
826
827/** @name IEMTB_F_XXX - Translation block flags (IEMTB::fFlags).
828 *
829 * Extends the IEM_F_XXX flags (subject to IEMTB_F_IEM_F_MASK) to make up the
830 * translation block flags. The combined flag mask (subject to
831 * IEMTB_F_KEY_MASK) is used as part of the lookup key for translation blocks.
832 *
833 * @{ */
834/** Mask of IEM_F_XXX flags included in IEMTB_F_XXX. */
835#define IEMTB_F_IEM_F_MASK UINT32_C(0x00ffffff)
836
837/** Type: The block type mask. */
838#define IEMTB_F_TYPE_MASK UINT32_C(0x03000000)
839/** Type: Purly threaded recompiler (via tables). */
840#define IEMTB_F_TYPE_THREADED UINT32_C(0x01000000)
841/** Type: Native recompilation. */
842#define IEMTB_F_TYPE_NATIVE UINT32_C(0x02000000)
843
844/** Set when we're starting the block in an "interrupt shadow".
845 * We don't need to distingish between the two types of this mask, thus the one.
846 * @see CPUMCTX_INHIBIT_SHADOW, CPUMIsInInterruptShadow() */
847#define IEMTB_F_INHIBIT_SHADOW UINT32_C(0x04000000)
848/** Set when we're currently inhibiting NMIs
849 * @see CPUMCTX_INHIBIT_NMI, CPUMAreInterruptsInhibitedByNmi() */
850#define IEMTB_F_INHIBIT_NMI UINT32_C(0x08000000)
851
852/** Checks that EIP/IP is wihin CS.LIM before each instruction. Used when
853 * we're close the limit before starting a TB, as determined by
854 * iemGetTbFlagsForCurrentPc(). */
855#define IEMTB_F_CS_LIM_CHECKS UINT32_C(0x10000000)
856
857/** Mask of the IEMTB_F_XXX flags that are part of the TB lookup key.
858 *
859 * @note We skip all of IEM_F_X86_CTX_MASK, with the exception of SMM (which we
860 * don't implement), because we don't currently generate any context
861 * specific code - that's all handled in CIMPL functions.
862 *
863 * For the threaded recompiler we don't generate any CPL specific code
864 * either, but the native recompiler does for memory access (saves getting
865 * the CPL from fExec and turning it into IEMTLBE_F_PT_NO_USER).
866 * Since most OSes will not share code between rings, this shouldn't
867 * have any real effect on TB/memory/recompiling load.
868 */
869#define IEMTB_F_KEY_MASK ((UINT32_MAX & ~(IEM_F_X86_CTX_MASK | IEMTB_F_TYPE_MASK)) | IEM_F_X86_CTX_SMM)
870/** @} */
871
872AssertCompile( (IEM_F_MODE_X86_16BIT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
873AssertCompile(!(IEM_F_MODE_X86_16BIT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
874AssertCompile(!(IEM_F_MODE_X86_16BIT & IEM_F_MODE_X86_PROT_MASK));
875AssertCompile(!(IEM_F_MODE_X86_16BIT & IEM_F_MODE_X86_V86_MASK));
876AssertCompile( (IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
877AssertCompile( IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
878AssertCompile(!(IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_X86_PROT_MASK));
879AssertCompile(!(IEM_F_MODE_X86_16BIT_PRE_386 & IEM_F_MODE_X86_V86_MASK));
880AssertCompile( (IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
881AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
882AssertCompile( IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_X86_PROT_MASK);
883AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT & IEM_F_MODE_X86_V86_MASK));
884AssertCompile( (IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_16BIT);
885AssertCompile( IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
886AssertCompile( IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_PROT_MASK);
887AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT_PRE_386 & IEM_F_MODE_X86_V86_MASK));
888AssertCompile( IEM_F_MODE_X86_16BIT_PROT_V86 & IEM_F_MODE_X86_PROT_MASK);
889AssertCompile(!(IEM_F_MODE_X86_16BIT_PROT_V86 & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
890AssertCompile( IEM_F_MODE_X86_16BIT_PROT_V86 & IEM_F_MODE_X86_V86_MASK);
891
892AssertCompile( (IEM_F_MODE_X86_32BIT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
893AssertCompile(!(IEM_F_MODE_X86_32BIT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
894AssertCompile(!(IEM_F_MODE_X86_32BIT & IEM_F_MODE_X86_PROT_MASK));
895AssertCompile( (IEM_F_MODE_X86_32BIT_FLAT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
896AssertCompile( IEM_F_MODE_X86_32BIT_FLAT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
897AssertCompile(!(IEM_F_MODE_X86_32BIT_FLAT & IEM_F_MODE_X86_PROT_MASK));
898AssertCompile( (IEM_F_MODE_X86_32BIT_PROT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
899AssertCompile(!(IEM_F_MODE_X86_32BIT_PROT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
900AssertCompile( IEM_F_MODE_X86_32BIT_PROT & IEM_F_MODE_X86_PROT_MASK);
901AssertCompile( (IEM_F_MODE_X86_32BIT_PROT_FLAT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_32BIT);
902AssertCompile( IEM_F_MODE_X86_32BIT_PROT_FLAT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK);
903AssertCompile( IEM_F_MODE_X86_32BIT_PROT_FLAT & IEM_F_MODE_X86_PROT_MASK);
904
905AssertCompile( (IEM_F_MODE_X86_64BIT & IEM_F_MODE_CPUMODE_MASK) == IEMMODE_64BIT);
906AssertCompile( IEM_F_MODE_X86_64BIT & IEM_F_MODE_X86_PROT_MASK);
907AssertCompile(!(IEM_F_MODE_X86_64BIT & IEM_F_MODE_X86_FLAT_OR_PRE_386_MASK));
908
909/** Native instruction type for use with the native code generator.
910 * This is a byte (uint8_t) for x86 and amd64 and uint32_t for the other(s). */
911#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
912typedef uint8_t IEMNATIVEINSTR;
913#else
914typedef uint32_t IEMNATIVEINSTR;
915#endif
916/** Pointer to a native instruction unit. */
917typedef IEMNATIVEINSTR *PIEMNATIVEINSTR;
918/** Pointer to a const native instruction unit. */
919typedef IEMNATIVEINSTR const *PCIEMNATIVEINSTR;
920
921/**
922 * A call for the threaded call table.
923 */
924typedef struct IEMTHRDEDCALLENTRY
925{
926 /** The function to call (IEMTHREADEDFUNCS). */
927 uint16_t enmFunction;
928
929 /** Instruction number in the TB (for statistics). */
930 uint8_t idxInstr;
931 /** The opcode length. */
932 uint8_t cbOpcode;
933 /** Offset into IEMTB::pabOpcodes. */
934 uint16_t offOpcode;
935
936 /** TB lookup table index (7 bits) and large size (1 bits).
937 *
938 * The default size is 1 entry, but for indirect calls and returns we set the
939 * top bit and allocate 4 (IEM_TB_LOOKUP_TAB_LARGE_SIZE) entries. The large
940 * tables uses RIP for selecting the entry to use, as it is assumed a hash table
941 * lookup isn't that slow compared to sequentially trying out 4 TBs.
942 *
943 * By default lookup table entry 0 for a TB is reserved as a fallback for
944 * calltable entries w/o explicit entreis, so this member will be non-zero if
945 * there is a lookup entry associated with this call.
946 *
947 * @sa IEM_TB_LOOKUP_TAB_GET_SIZE, IEM_TB_LOOKUP_TAB_GET_IDX
948 */
949 uint8_t uTbLookup;
950
951 /** Unused atm. */
952 uint8_t uUnused0;
953
954 /** Generic parameters. */
955 uint64_t auParams[3];
956} IEMTHRDEDCALLENTRY;
957AssertCompileSize(IEMTHRDEDCALLENTRY, sizeof(uint64_t) * 4);
958/** Pointer to a threaded call entry. */
959typedef struct IEMTHRDEDCALLENTRY *PIEMTHRDEDCALLENTRY;
960/** Pointer to a const threaded call entry. */
961typedef IEMTHRDEDCALLENTRY const *PCIEMTHRDEDCALLENTRY;
962
963/** The number of TB lookup table entries for a large allocation
964 * (IEMTHRDEDCALLENTRY::uTbLookup bit 7 set). */
965#define IEM_TB_LOOKUP_TAB_LARGE_SIZE 4
966/** Get the lookup table size from IEMTHRDEDCALLENTRY::uTbLookup. */
967#define IEM_TB_LOOKUP_TAB_GET_SIZE(a_uTbLookup) (!((a_uTbLookup) & 0x80) ? 1 : IEM_TB_LOOKUP_TAB_LARGE_SIZE)
968/** Get the first lookup table index from IEMTHRDEDCALLENTRY::uTbLookup. */
969#define IEM_TB_LOOKUP_TAB_GET_IDX(a_uTbLookup) ((a_uTbLookup) & 0x7f)
970/** Get the lookup table index from IEMTHRDEDCALLENTRY::uTbLookup and RIP. */
971#define IEM_TB_LOOKUP_TAB_GET_IDX_WITH_RIP(a_uTbLookup, a_Rip) \
972 (!((a_uTbLookup) & 0x80) ? (a_uTbLookup) & 0x7f : ((a_uTbLookup) & 0x7f) + ((a_Rip) & (IEM_TB_LOOKUP_TAB_LARGE_SIZE - 1)) )
973
974/** Make a IEMTHRDEDCALLENTRY::uTbLookup value. */
975#define IEM_TB_LOOKUP_TAB_MAKE(a_idxTable, a_fLarge) ((a_idxTable) | ((a_fLarge) ? 0x80 : 0))
976
977/**
978 * Native IEM TB 'function' typedef.
979 *
980 * This will throw/longjmp on occation.
981 *
982 * @note AMD64 doesn't have that many non-volatile registers and does sport
983 * 32-bit address displacments, so we don't need pCtx.
984 *
985 * On ARM64 pCtx allows us to directly address the whole register
986 * context without requiring a separate indexing register holding the
987 * offset. This saves an instruction loading the offset for each guest
988 * CPU context access, at the cost of a non-volatile register.
989 * Fortunately, ARM64 has quite a lot more registers.
990 */
991typedef
992#ifdef RT_ARCH_AMD64
993int FNIEMTBNATIVE(PVMCPUCC pVCpu)
994#else
995int FNIEMTBNATIVE(PVMCPUCC pVCpu, PCPUMCTX pCtx)
996#endif
997#if RT_CPLUSPLUS_PREREQ(201700)
998 IEM_NOEXCEPT_MAY_LONGJMP
999#endif
1000 ;
1001/** Pointer to a native IEM TB entry point function.
1002 * This will throw/longjmp on occation. */
1003typedef FNIEMTBNATIVE *PFNIEMTBNATIVE;
1004
1005
1006/**
1007 * Translation block debug info entry type.
1008 */
1009typedef enum IEMTBDBGENTRYTYPE
1010{
1011 kIemTbDbgEntryType_Invalid = 0,
1012 /** The entry is for marking a native code position.
1013 * Entries following this all apply to this position. */
1014 kIemTbDbgEntryType_NativeOffset,
1015 /** The entry is for a new guest instruction. */
1016 kIemTbDbgEntryType_GuestInstruction,
1017 /** Marks the start of a threaded call. */
1018 kIemTbDbgEntryType_ThreadedCall,
1019 /** Marks the location of a label. */
1020 kIemTbDbgEntryType_Label,
1021 /** Info about a host register shadowing a guest register. */
1022 kIemTbDbgEntryType_GuestRegShadowing,
1023#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
1024 /** Info about a host SIMD register shadowing a guest SIMD register. */
1025 kIemTbDbgEntryType_GuestSimdRegShadowing,
1026#endif
1027#ifdef IEMNATIVE_WITH_DELAYED_PC_UPDATING
1028 /** Info about a delayed RIP update. */
1029 kIemTbDbgEntryType_DelayedPcUpdate,
1030#endif
1031#if defined(IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK) || defined(IEMNATIVE_WITH_SIMD_REG_ALLOCATOR)
1032 /** Info about a shadowed guest register becoming dirty. */
1033 kIemTbDbgEntryType_GuestRegDirty,
1034 /** Info about register writeback/flush oepration. */
1035 kIemTbDbgEntryType_GuestRegWriteback,
1036#endif
1037 kIemTbDbgEntryType_End
1038} IEMTBDBGENTRYTYPE;
1039
1040/**
1041 * Translation block debug info entry.
1042 */
1043typedef union IEMTBDBGENTRY
1044{
1045 /** Plain 32-bit view. */
1046 uint32_t u;
1047
1048 /** Generic view for getting at the type field. */
1049 struct
1050 {
1051 /** IEMTBDBGENTRYTYPE */
1052 uint32_t uType : 4;
1053 uint32_t uTypeSpecific : 28;
1054 } Gen;
1055
1056 struct
1057 {
1058 /** kIemTbDbgEntryType_ThreadedCall1. */
1059 uint32_t uType : 4;
1060 /** Native code offset. */
1061 uint32_t offNative : 28;
1062 } NativeOffset;
1063
1064 struct
1065 {
1066 /** kIemTbDbgEntryType_GuestInstruction. */
1067 uint32_t uType : 4;
1068 uint32_t uUnused : 4;
1069 /** The IEM_F_XXX flags. */
1070 uint32_t fExec : 24;
1071 } GuestInstruction;
1072
1073 struct
1074 {
1075 /* kIemTbDbgEntryType_ThreadedCall. */
1076 uint32_t uType : 4;
1077 /** Set if the call was recompiled to native code, clear if just calling
1078 * threaded function. */
1079 uint32_t fRecompiled : 1;
1080 uint32_t uUnused : 11;
1081 /** The threaded call number (IEMTHREADEDFUNCS). */
1082 uint32_t enmCall : 16;
1083 } ThreadedCall;
1084
1085 struct
1086 {
1087 /* kIemTbDbgEntryType_Label. */
1088 uint32_t uType : 4;
1089 uint32_t uUnused : 4;
1090 /** The label type (IEMNATIVELABELTYPE). */
1091 uint32_t enmLabel : 8;
1092 /** The label data. */
1093 uint32_t uData : 16;
1094 } Label;
1095
1096 struct
1097 {
1098 /* kIemTbDbgEntryType_GuestRegShadowing. */
1099 uint32_t uType : 4;
1100 uint32_t uUnused : 4;
1101 /** The guest register being shadowed (IEMNATIVEGSTREG). */
1102 uint32_t idxGstReg : 8;
1103 /** The host new register number, UINT8_MAX if dropped. */
1104 uint32_t idxHstReg : 8;
1105 /** The previous host register number, UINT8_MAX if new. */
1106 uint32_t idxHstRegPrev : 8;
1107 } GuestRegShadowing;
1108
1109#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
1110 struct
1111 {
1112 /* kIemTbDbgEntryType_GuestSimdRegShadowing. */
1113 uint32_t uType : 4;
1114 uint32_t uUnused : 4;
1115 /** The guest register being shadowed (IEMNATIVEGSTSIMDREG). */
1116 uint32_t idxGstSimdReg : 8;
1117 /** The host new register number, UINT8_MAX if dropped. */
1118 uint32_t idxHstSimdReg : 8;
1119 /** The previous host register number, UINT8_MAX if new. */
1120 uint32_t idxHstSimdRegPrev : 8;
1121 } GuestSimdRegShadowing;
1122#endif
1123
1124#ifdef IEMNATIVE_WITH_DELAYED_PC_UPDATING
1125 struct
1126 {
1127 /* kIemTbDbgEntryType_DelayedPcUpdate. */
1128 uint32_t uType : 4;
1129 /* The instruction offset added to the program counter. */
1130 uint32_t offPc : 14;
1131 /** Number of instructions skipped. */
1132 uint32_t cInstrSkipped : 14;
1133 } DelayedPcUpdate;
1134#endif
1135
1136#if defined(IEMNATIVE_WITH_DELAYED_REGISTER_WRITEBACK) || defined(IEMNATIVE_WITH_SIMD_REG_ALLOCATOR)
1137 struct
1138 {
1139 /* kIemTbDbgEntryType_GuestRegDirty. */
1140 uint32_t uType : 4;
1141 uint32_t uUnused : 11;
1142 /** Flag whether this is about a SIMD (true) or general (false) register. */
1143 uint32_t fSimdReg : 1;
1144 /** The guest register index being marked as dirty. */
1145 uint32_t idxGstReg : 8;
1146 /** The host register number this register is shadowed in .*/
1147 uint32_t idxHstReg : 8;
1148 } GuestRegDirty;
1149
1150 struct
1151 {
1152 /* kIemTbDbgEntryType_GuestRegWriteback. */
1153 uint32_t uType : 4;
1154 /** Flag whether this is about a SIMD (true) or general (false) register flush. */
1155 uint32_t fSimdReg : 1;
1156 /** The mask shift. */
1157 uint32_t cShift : 2;
1158 /** The guest register mask being written back. */
1159 uint32_t fGstReg : 25;
1160 } GuestRegWriteback;
1161#endif
1162
1163} IEMTBDBGENTRY;
1164AssertCompileSize(IEMTBDBGENTRY, sizeof(uint32_t));
1165/** Pointer to a debug info entry. */
1166typedef IEMTBDBGENTRY *PIEMTBDBGENTRY;
1167/** Pointer to a const debug info entry. */
1168typedef IEMTBDBGENTRY const *PCIEMTBDBGENTRY;
1169
1170/**
1171 * Translation block debug info.
1172 */
1173typedef struct IEMTBDBG
1174{
1175 /** Number of entries in aEntries. */
1176 uint32_t cEntries;
1177 /** The offset of the last kIemTbDbgEntryType_NativeOffset record. */
1178 uint32_t offNativeLast;
1179 /** Debug info entries. */
1180 RT_FLEXIBLE_ARRAY_EXTENSION
1181 IEMTBDBGENTRY aEntries[RT_FLEXIBLE_ARRAY];
1182} IEMTBDBG;
1183/** Pointer to TB debug info. */
1184typedef IEMTBDBG *PIEMTBDBG;
1185/** Pointer to const TB debug info. */
1186typedef IEMTBDBG const *PCIEMTBDBG;
1187
1188
1189/**
1190 * Translation block.
1191 *
1192 * The current plan is to just keep TBs and associated lookup hash table private
1193 * to each VCpu as that simplifies TB removal greatly (no races) and generally
1194 * avoids using expensive atomic primitives for updating lists and stuff.
1195 */
1196#pragma pack(2) /* to prevent the Thrd structure from being padded unnecessarily */
1197typedef struct IEMTB
1198{
1199 /** Next block with the same hash table entry. */
1200 struct IEMTB *pNext;
1201 /** Usage counter. */
1202 uint32_t cUsed;
1203 /** The IEMCPU::msRecompilerPollNow last time it was used. */
1204 uint32_t msLastUsed;
1205
1206 /** @name What uniquely identifies the block.
1207 * @{ */
1208 RTGCPHYS GCPhysPc;
1209 /** IEMTB_F_XXX (i.e. IEM_F_XXX ++). */
1210 uint32_t fFlags;
1211 union
1212 {
1213 struct
1214 {
1215 /**< Relevant CS X86DESCATTR_XXX bits. */
1216 uint16_t fAttr;
1217 } x86;
1218 };
1219 /** @} */
1220
1221 /** Number of opcode ranges. */
1222 uint8_t cRanges;
1223 /** Statistics: Number of instructions in the block. */
1224 uint8_t cInstructions;
1225
1226 /** Type specific info. */
1227 union
1228 {
1229 struct
1230 {
1231 /** The call sequence table. */
1232 PIEMTHRDEDCALLENTRY paCalls;
1233 /** Number of calls in paCalls. */
1234 uint16_t cCalls;
1235 /** Number of calls allocated. */
1236 uint16_t cAllocated;
1237 } Thrd;
1238 struct
1239 {
1240 /** The native instructions (PFNIEMTBNATIVE). */
1241 PIEMNATIVEINSTR paInstructions;
1242 /** Number of instructions pointed to by paInstructions. */
1243 uint32_t cInstructions;
1244 } Native;
1245 /** Generic view for zeroing when freeing. */
1246 struct
1247 {
1248 uintptr_t uPtr;
1249 uint32_t uData;
1250 } Gen;
1251 };
1252
1253 /** The allocation chunk this TB belongs to. */
1254 uint8_t idxAllocChunk;
1255 /** The number of entries in the lookup table.
1256 * Because we're out of space, the TB lookup table is located before the
1257 * opcodes pointed to by pabOpcodes. */
1258 uint8_t cTbLookupEntries;
1259
1260 /** Number of bytes of opcodes stored in pabOpcodes.
1261 * @todo this field isn't really needed, aRanges keeps the actual info. */
1262 uint16_t cbOpcodes;
1263 /** Pointer to the opcode bytes this block was recompiled from.
1264 * This also points to the TB lookup table, which starts cTbLookupEntries
1265 * entries before the opcodes (we don't have room atm for another point). */
1266 uint8_t *pabOpcodes;
1267
1268 /** Debug info if enabled.
1269 * This is only generated by the native recompiler. */
1270 PIEMTBDBG pDbgInfo;
1271
1272 /* --- 64 byte cache line end --- */
1273
1274 /** Opcode ranges.
1275 *
1276 * The opcode checkers and maybe TLB loading functions will use this to figure
1277 * out what to do. The parameter will specify an entry and the opcode offset to
1278 * start at and the minimum number of bytes to verify (instruction length).
1279 *
1280 * When VT-x and AMD-V looks up the opcode bytes for an exitting instruction,
1281 * they'll first translate RIP (+ cbInstr - 1) to a physical address using the
1282 * code TLB (must have a valid entry for that address) and scan the ranges to
1283 * locate the corresponding opcodes. Probably.
1284 */
1285 struct IEMTBOPCODERANGE
1286 {
1287 /** Offset within pabOpcodes. */
1288 uint16_t offOpcodes;
1289 /** Number of bytes. */
1290 uint16_t cbOpcodes;
1291 /** The page offset. */
1292 RT_GCC_EXTENSION
1293 uint16_t offPhysPage : 12;
1294 /** Unused bits. */
1295 RT_GCC_EXTENSION
1296 uint16_t u2Unused : 2;
1297 /** Index into GCPhysPc + aGCPhysPages for the physical page address. */
1298 RT_GCC_EXTENSION
1299 uint16_t idxPhysPage : 2;
1300 } aRanges[8];
1301
1302 /** Physical pages that this TB covers.
1303 * The GCPhysPc w/o page offset is element zero, so starting here with 1. */
1304 RTGCPHYS aGCPhysPages[2];
1305} IEMTB;
1306#pragma pack()
1307AssertCompileMemberAlignment(IEMTB, GCPhysPc, sizeof(RTGCPHYS));
1308AssertCompileMemberAlignment(IEMTB, Thrd, sizeof(void *));
1309AssertCompileMemberAlignment(IEMTB, pabOpcodes, sizeof(void *));
1310AssertCompileMemberAlignment(IEMTB, pDbgInfo, sizeof(void *));
1311AssertCompileMemberAlignment(IEMTB, aGCPhysPages, sizeof(RTGCPHYS));
1312AssertCompileMemberOffset(IEMTB, aRanges, 64);
1313AssertCompileMemberSize(IEMTB, aRanges[0], 6);
1314#if 1
1315AssertCompileSize(IEMTB, 128);
1316# define IEMTB_SIZE_IS_POWER_OF_TWO /**< The IEMTB size is a power of two. */
1317#else
1318AssertCompileSize(IEMTB, 168);
1319# undef IEMTB_SIZE_IS_POWER_OF_TWO
1320#endif
1321
1322/** Pointer to a translation block. */
1323typedef IEMTB *PIEMTB;
1324/** Pointer to a const translation block. */
1325typedef IEMTB const *PCIEMTB;
1326
1327/** Gets address of the given TB lookup table entry. */
1328#define IEMTB_GET_TB_LOOKUP_TAB_ENTRY(a_pTb, a_idx) \
1329 ((PIEMTB *)&(a_pTb)->pabOpcodes[-(int)((a_pTb)->cTbLookupEntries - (a_idx)) * sizeof(PIEMTB)])
1330
1331
1332/**
1333 * A chunk of memory in the TB allocator.
1334 */
1335typedef struct IEMTBCHUNK
1336{
1337 /** Pointer to the translation blocks in this chunk. */
1338 PIEMTB paTbs;
1339#ifdef IN_RING0
1340 /** Allocation handle. */
1341 RTR0MEMOBJ hMemObj;
1342#endif
1343} IEMTBCHUNK;
1344
1345/**
1346 * A per-CPU translation block allocator.
1347 *
1348 * Because of how the IEMTBCACHE uses the lower 6 bits of the TB address to keep
1349 * the length of the collision list, and of course also for cache line alignment
1350 * reasons, the TBs must be allocated with at least 64-byte alignment.
1351 * Memory is there therefore allocated using one of the page aligned allocators.
1352 *
1353 *
1354 * To avoid wasting too much memory, it is allocated piecemeal as needed,
1355 * in chunks (IEMTBCHUNK) of 2 MiB or more. The TB has an 8-bit chunk index
1356 * that enables us to quickly calculate the allocation bitmap position when
1357 * freeing the translation block.
1358 */
1359typedef struct IEMTBALLOCATOR
1360{
1361 /** Magic value (IEMTBALLOCATOR_MAGIC). */
1362 uint32_t uMagic;
1363
1364#ifdef IEMTB_SIZE_IS_POWER_OF_TWO
1365 /** Mask corresponding to cTbsPerChunk - 1. */
1366 uint32_t fChunkMask;
1367 /** Shift count corresponding to cTbsPerChunk. */
1368 uint8_t cChunkShift;
1369#else
1370 uint32_t uUnused;
1371 uint8_t bUnused;
1372#endif
1373 /** Number of chunks we're allowed to allocate. */
1374 uint8_t cMaxChunks;
1375 /** Number of chunks currently populated. */
1376 uint16_t cAllocatedChunks;
1377 /** Number of translation blocks per chunk. */
1378 uint32_t cTbsPerChunk;
1379 /** Chunk size. */
1380 uint32_t cbPerChunk;
1381
1382 /** The maximum number of TBs. */
1383 uint32_t cMaxTbs;
1384 /** Total number of TBs in the populated chunks.
1385 * (cAllocatedChunks * cTbsPerChunk) */
1386 uint32_t cTotalTbs;
1387 /** The current number of TBs in use.
1388 * The number of free TBs: cAllocatedTbs - cInUseTbs; */
1389 uint32_t cInUseTbs;
1390 /** Statistics: Number of the cInUseTbs that are native ones. */
1391 uint32_t cNativeTbs;
1392 /** Statistics: Number of the cInUseTbs that are threaded ones. */
1393 uint32_t cThreadedTbs;
1394
1395 /** Where to start pruning TBs from when we're out.
1396 * See iemTbAllocatorAllocSlow for details. */
1397 uint32_t iPruneFrom;
1398 /** Hint about which bit to start scanning the bitmap from. */
1399 uint32_t iStartHint;
1400 /** Where to start pruning native TBs from when we're out of executable memory.
1401 * See iemTbAllocatorFreeupNativeSpace for details. */
1402 uint32_t iPruneNativeFrom;
1403 uint32_t uPadding;
1404
1405 /** Statistics: Number of TB allocation calls. */
1406 STAMCOUNTER StatAllocs;
1407 /** Statistics: Number of TB free calls. */
1408 STAMCOUNTER StatFrees;
1409 /** Statistics: Time spend pruning. */
1410 STAMPROFILE StatPrune;
1411 /** Statistics: Time spend pruning native TBs. */
1412 STAMPROFILE StatPruneNative;
1413
1414 /** The delayed free list (see iemTbAlloctorScheduleForFree). */
1415 PIEMTB pDelayedFreeHead;
1416
1417 /** Allocation chunks. */
1418 IEMTBCHUNK aChunks[256];
1419
1420 /** Allocation bitmap for all possible chunk chunks. */
1421 RT_FLEXIBLE_ARRAY_EXTENSION
1422 uint64_t bmAllocated[RT_FLEXIBLE_ARRAY];
1423} IEMTBALLOCATOR;
1424/** Pointer to a TB allocator. */
1425typedef struct IEMTBALLOCATOR *PIEMTBALLOCATOR;
1426
1427/** Magic value for the TB allocator (Emmet Harley Cohen). */
1428#define IEMTBALLOCATOR_MAGIC UINT32_C(0x19900525)
1429
1430
1431/**
1432 * A per-CPU translation block cache (hash table).
1433 *
1434 * The hash table is allocated once during IEM initialization and size double
1435 * the max TB count, rounded up to the nearest power of two (so we can use and
1436 * AND mask rather than a rest division when hashing).
1437 */
1438typedef struct IEMTBCACHE
1439{
1440 /** Magic value (IEMTBCACHE_MAGIC). */
1441 uint32_t uMagic;
1442 /** Size of the hash table. This is a power of two. */
1443 uint32_t cHash;
1444 /** The mask corresponding to cHash. */
1445 uint32_t uHashMask;
1446 uint32_t uPadding;
1447
1448 /** @name Statistics
1449 * @{ */
1450 /** Number of collisions ever. */
1451 STAMCOUNTER cCollisions;
1452
1453 /** Statistics: Number of TB lookup misses. */
1454 STAMCOUNTER cLookupMisses;
1455 /** Statistics: Number of TB lookup hits via hash table (debug only). */
1456 STAMCOUNTER cLookupHits;
1457 /** Statistics: Number of TB lookup hits via TB associated lookup table (debug only). */
1458 STAMCOUNTER cLookupHitsViaTbLookupTable;
1459 STAMCOUNTER auPadding2[2];
1460 /** Statistics: Collision list length pruning. */
1461 STAMPROFILE StatPrune;
1462 /** @} */
1463
1464 /** The hash table itself.
1465 * @note The lower 6 bits of the pointer is used for keeping the collision
1466 * list length, so we can take action when it grows too long.
1467 * This works because TBs are allocated using a 64 byte (or
1468 * higher) alignment from page aligned chunks of memory, so the lower
1469 * 6 bits of the address will always be zero.
1470 * See IEMTBCACHE_PTR_COUNT_MASK, IEMTBCACHE_PTR_MAKE and friends.
1471 */
1472 RT_FLEXIBLE_ARRAY_EXTENSION
1473 PIEMTB apHash[RT_FLEXIBLE_ARRAY];
1474} IEMTBCACHE;
1475/** Pointer to a per-CPU translation block cahce. */
1476typedef IEMTBCACHE *PIEMTBCACHE;
1477
1478/** Magic value for IEMTBCACHE (Johnny O'Neal). */
1479#define IEMTBCACHE_MAGIC UINT32_C(0x19561010)
1480
1481/** The collision count mask for IEMTBCACHE::apHash entries. */
1482#define IEMTBCACHE_PTR_COUNT_MASK ((uintptr_t)0x3f)
1483/** The max collision count for IEMTBCACHE::apHash entries before pruning. */
1484#define IEMTBCACHE_PTR_MAX_COUNT ((uintptr_t)0x30)
1485/** Combine a TB pointer and a collision list length into a value for an
1486 * IEMTBCACHE::apHash entry. */
1487#define IEMTBCACHE_PTR_MAKE(a_pTb, a_cCount) (PIEMTB)((uintptr_t)(a_pTb) | (a_cCount))
1488/** Combine a TB pointer and a collision list length into a value for an
1489 * IEMTBCACHE::apHash entry. */
1490#define IEMTBCACHE_PTR_GET_TB(a_pHashEntry) (PIEMTB)((uintptr_t)(a_pHashEntry) & ~IEMTBCACHE_PTR_COUNT_MASK)
1491/** Combine a TB pointer and a collision list length into a value for an
1492 * IEMTBCACHE::apHash entry. */
1493#define IEMTBCACHE_PTR_GET_COUNT(a_pHashEntry) ((uintptr_t)(a_pHashEntry) & IEMTBCACHE_PTR_COUNT_MASK)
1494
1495/**
1496 * Calculates the hash table slot for a TB from physical PC address and TB flags.
1497 */
1498#define IEMTBCACHE_HASH(a_paCache, a_fTbFlags, a_GCPhysPc) \
1499 IEMTBCACHE_HASH_NO_KEY_MASK(a_paCache, (a_fTbFlags) & IEMTB_F_KEY_MASK, a_GCPhysPc)
1500
1501/**
1502 * Calculates the hash table slot for a TB from physical PC address and TB
1503 * flags, ASSUMING the caller has applied IEMTB_F_KEY_MASK to @a a_fTbFlags.
1504 */
1505#define IEMTBCACHE_HASH_NO_KEY_MASK(a_paCache, a_fTbFlags, a_GCPhysPc) \
1506 (((uint32_t)(a_GCPhysPc) ^ (a_fTbFlags)) & (a_paCache)->uHashMask)
1507
1508
1509/** @name IEMBRANCHED_F_XXX - Branched indicator (IEMCPU::fTbBranched).
1510 *
1511 * These flags parallels the main IEM_CIMPL_F_BRANCH_XXX flags.
1512 *
1513 * @{ */
1514/** Value if no branching happened recently. */
1515#define IEMBRANCHED_F_NO UINT8_C(0x00)
1516/** Flag set if direct branch, clear if absolute or indirect. */
1517#define IEMBRANCHED_F_DIRECT UINT8_C(0x01)
1518/** Flag set if indirect branch, clear if direct or relative. */
1519#define IEMBRANCHED_F_INDIRECT UINT8_C(0x02)
1520/** Flag set if relative branch, clear if absolute or indirect. */
1521#define IEMBRANCHED_F_RELATIVE UINT8_C(0x04)
1522/** Flag set if conditional branch, clear if unconditional. */
1523#define IEMBRANCHED_F_CONDITIONAL UINT8_C(0x08)
1524/** Flag set if it's a far branch. */
1525#define IEMBRANCHED_F_FAR UINT8_C(0x10)
1526/** Flag set if the stack pointer is modified. */
1527#define IEMBRANCHED_F_STACK UINT8_C(0x20)
1528/** Flag set if the stack pointer and (maybe) the stack segment are modified. */
1529#define IEMBRANCHED_F_STACK_FAR UINT8_C(0x40)
1530/** Flag set (by IEM_MC_REL_JMP_XXX) if it's a zero bytes relative jump. */
1531#define IEMBRANCHED_F_ZERO UINT8_C(0x80)
1532/** @} */
1533
1534
1535/**
1536 * The per-CPU IEM state.
1537 */
1538typedef struct IEMCPU
1539{
1540 /** Info status code that needs to be propagated to the IEM caller.
1541 * This cannot be passed internally, as it would complicate all success
1542 * checks within the interpreter making the code larger and almost impossible
1543 * to get right. Instead, we'll store status codes to pass on here. Each
1544 * source of these codes will perform appropriate sanity checks. */
1545 int32_t rcPassUp; /* 0x00 */
1546 /** Execution flag, IEM_F_XXX. */
1547 uint32_t fExec; /* 0x04 */
1548
1549 /** @name Decoder state.
1550 * @{ */
1551#ifdef IEM_WITH_CODE_TLB
1552 /** The offset of the next instruction byte. */
1553 uint32_t offInstrNextByte; /* 0x08 */
1554 /** The number of bytes available at pbInstrBuf for the current instruction.
1555 * This takes the max opcode length into account so that doesn't need to be
1556 * checked separately. */
1557 uint32_t cbInstrBuf; /* 0x0c */
1558 /** Pointer to the page containing RIP, user specified buffer or abOpcode.
1559 * This can be NULL if the page isn't mappable for some reason, in which
1560 * case we'll do fallback stuff.
1561 *
1562 * If we're executing an instruction from a user specified buffer,
1563 * IEMExecOneWithPrefetchedByPC and friends, this is not necessarily a page
1564 * aligned pointer but pointer to the user data.
1565 *
1566 * For instructions crossing pages, this will start on the first page and be
1567 * advanced to the next page by the time we've decoded the instruction. This
1568 * therefore precludes stuff like <tt>pbInstrBuf[offInstrNextByte + cbInstrBuf - cbCurInstr]</tt>
1569 */
1570 uint8_t const *pbInstrBuf; /* 0x10 */
1571# if ARCH_BITS == 32
1572 uint32_t uInstrBufHigh; /** The high dword of the host context pbInstrBuf member. */
1573# endif
1574 /** The program counter corresponding to pbInstrBuf.
1575 * This is set to a non-canonical address when we need to invalidate it. */
1576 uint64_t uInstrBufPc; /* 0x18 */
1577 /** The guest physical address corresponding to pbInstrBuf. */
1578 RTGCPHYS GCPhysInstrBuf; /* 0x20 */
1579 /** The number of bytes available at pbInstrBuf in total (for IEMExecLots).
1580 * This takes the CS segment limit into account.
1581 * @note Set to zero when the code TLB is flushed to trigger TLB reload. */
1582 uint16_t cbInstrBufTotal; /* 0x28 */
1583# ifndef IEM_WITH_OPAQUE_DECODER_STATE
1584 /** Offset into pbInstrBuf of the first byte of the current instruction.
1585 * Can be negative to efficiently handle cross page instructions. */
1586 int16_t offCurInstrStart; /* 0x2a */
1587
1588 /** The prefix mask (IEM_OP_PRF_XXX). */
1589 uint32_t fPrefixes; /* 0x2c */
1590 /** The extra REX ModR/M register field bit (REX.R << 3). */
1591 uint8_t uRexReg; /* 0x30 */
1592 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
1593 * (REX.B << 3). */
1594 uint8_t uRexB; /* 0x31 */
1595 /** The extra REX SIB index field bit (REX.X << 3). */
1596 uint8_t uRexIndex; /* 0x32 */
1597
1598 /** The effective segment register (X86_SREG_XXX). */
1599 uint8_t iEffSeg; /* 0x33 */
1600
1601 /** The offset of the ModR/M byte relative to the start of the instruction. */
1602 uint8_t offModRm; /* 0x34 */
1603
1604# ifdef IEM_WITH_CODE_TLB_AND_OPCODE_BUF
1605 /** The current offset into abOpcode. */
1606 uint8_t offOpcode; /* 0x35 */
1607# else
1608 uint8_t bUnused; /* 0x35 */
1609# endif
1610# else /* IEM_WITH_OPAQUE_DECODER_STATE */
1611 uint8_t abOpaqueDecoderPart1[0x36 - 0x2a];
1612# endif /* IEM_WITH_OPAQUE_DECODER_STATE */
1613
1614#else /* !IEM_WITH_CODE_TLB */
1615# ifndef IEM_WITH_OPAQUE_DECODER_STATE
1616 /** The size of what has currently been fetched into abOpcode. */
1617 uint8_t cbOpcode; /* 0x08 */
1618 /** The current offset into abOpcode. */
1619 uint8_t offOpcode; /* 0x09 */
1620 /** The offset of the ModR/M byte relative to the start of the instruction. */
1621 uint8_t offModRm; /* 0x0a */
1622
1623 /** The effective segment register (X86_SREG_XXX). */
1624 uint8_t iEffSeg; /* 0x0b */
1625
1626 /** The prefix mask (IEM_OP_PRF_XXX). */
1627 uint32_t fPrefixes; /* 0x0c */
1628 /** The extra REX ModR/M register field bit (REX.R << 3). */
1629 uint8_t uRexReg; /* 0x10 */
1630 /** The extra REX ModR/M r/m field, SIB base and opcode reg bit
1631 * (REX.B << 3). */
1632 uint8_t uRexB; /* 0x11 */
1633 /** The extra REX SIB index field bit (REX.X << 3). */
1634 uint8_t uRexIndex; /* 0x12 */
1635
1636# else /* IEM_WITH_OPAQUE_DECODER_STATE */
1637 uint8_t abOpaqueDecoderPart1[0x13 - 0x08];
1638# endif /* IEM_WITH_OPAQUE_DECODER_STATE */
1639#endif /* !IEM_WITH_CODE_TLB */
1640
1641#ifndef IEM_WITH_OPAQUE_DECODER_STATE
1642 /** The effective operand mode. */
1643 IEMMODE enmEffOpSize; /* 0x36, 0x13 */
1644 /** The default addressing mode. */
1645 IEMMODE enmDefAddrMode; /* 0x37, 0x14 */
1646 /** The effective addressing mode. */
1647 IEMMODE enmEffAddrMode; /* 0x38, 0x15 */
1648 /** The default operand mode. */
1649 IEMMODE enmDefOpSize; /* 0x39, 0x16 */
1650
1651 /** Prefix index (VEX.pp) for two byte and three byte tables. */
1652 uint8_t idxPrefix; /* 0x3a, 0x17 */
1653 /** 3rd VEX/EVEX/XOP register.
1654 * Please use IEM_GET_EFFECTIVE_VVVV to access. */
1655 uint8_t uVex3rdReg; /* 0x3b, 0x18 */
1656 /** The VEX/EVEX/XOP length field. */
1657 uint8_t uVexLength; /* 0x3c, 0x19 */
1658 /** Additional EVEX stuff. */
1659 uint8_t fEvexStuff; /* 0x3d, 0x1a */
1660
1661# ifndef IEM_WITH_CODE_TLB
1662 /** Explicit alignment padding. */
1663 uint8_t abAlignment2a[1]; /* 0x1b */
1664# endif
1665 /** The FPU opcode (FOP). */
1666 uint16_t uFpuOpcode; /* 0x3e, 0x1c */
1667# ifndef IEM_WITH_CODE_TLB
1668 /** Explicit alignment padding. */
1669 uint8_t abAlignment2b[2]; /* 0x1e */
1670# endif
1671
1672 /** The opcode bytes. */
1673 uint8_t abOpcode[15]; /* 0x40, 0x20 */
1674 /** Explicit alignment padding. */
1675# ifdef IEM_WITH_CODE_TLB
1676 //uint8_t abAlignment2c[0x4f - 0x4f]; /* 0x4f */
1677# else
1678 uint8_t abAlignment2c[0x4f - 0x2f]; /* 0x2f */
1679# endif
1680
1681#else /* IEM_WITH_OPAQUE_DECODER_STATE */
1682# ifdef IEM_WITH_CODE_TLB
1683 uint8_t abOpaqueDecoderPart2[0x4f - 0x36];
1684# else
1685 uint8_t abOpaqueDecoderPart2[0x4f - 0x13];
1686# endif
1687#endif /* IEM_WITH_OPAQUE_DECODER_STATE */
1688 /** @} */
1689
1690
1691 /** The number of active guest memory mappings. */
1692 uint8_t cActiveMappings; /* 0x4f, 0x4f */
1693
1694 /** Records for tracking guest memory mappings. */
1695 struct
1696 {
1697 /** The address of the mapped bytes. */
1698 R3R0PTRTYPE(void *) pv;
1699 /** The access flags (IEM_ACCESS_XXX).
1700 * IEM_ACCESS_INVALID if the entry is unused. */
1701 uint32_t fAccess;
1702#if HC_ARCH_BITS == 64
1703 uint32_t u32Alignment4; /**< Alignment padding. */
1704#endif
1705 } aMemMappings[3]; /* 0x50 LB 0x30 */
1706
1707 /** Locking records for the mapped memory. */
1708 union
1709 {
1710 PGMPAGEMAPLOCK Lock;
1711 uint64_t au64Padding[2];
1712 } aMemMappingLocks[3]; /* 0x80 LB 0x30 */
1713
1714 /** Bounce buffer info.
1715 * This runs in parallel to aMemMappings. */
1716 struct
1717 {
1718 /** The physical address of the first byte. */
1719 RTGCPHYS GCPhysFirst;
1720 /** The physical address of the second page. */
1721 RTGCPHYS GCPhysSecond;
1722 /** The number of bytes in the first page. */
1723 uint16_t cbFirst;
1724 /** The number of bytes in the second page. */
1725 uint16_t cbSecond;
1726 /** Whether it's unassigned memory. */
1727 bool fUnassigned;
1728 /** Explicit alignment padding. */
1729 bool afAlignment5[3];
1730 } aMemBbMappings[3]; /* 0xb0 LB 0x48 */
1731
1732 /** The flags of the current exception / interrupt. */
1733 uint32_t fCurXcpt; /* 0xf8 */
1734 /** The current exception / interrupt. */
1735 uint8_t uCurXcpt; /* 0xfc */
1736 /** Exception / interrupt recursion depth. */
1737 int8_t cXcptRecursions; /* 0xfb */
1738
1739 /** The next unused mapping index.
1740 * @todo try find room for this up with cActiveMappings. */
1741 uint8_t iNextMapping; /* 0xfd */
1742 uint8_t abAlignment7[1];
1743
1744 /** Bounce buffer storage.
1745 * This runs in parallel to aMemMappings and aMemBbMappings. */
1746 struct
1747 {
1748 uint8_t ab[512];
1749 } aBounceBuffers[3]; /* 0x100 LB 0x600 */
1750
1751
1752 /** Pointer set jump buffer - ring-3 context. */
1753 R3PTRTYPE(jmp_buf *) pJmpBufR3;
1754 /** Pointer set jump buffer - ring-0 context. */
1755 R0PTRTYPE(jmp_buf *) pJmpBufR0;
1756
1757 /** @todo Should move this near @a fCurXcpt later. */
1758 /** The CR2 for the current exception / interrupt. */
1759 uint64_t uCurXcptCr2;
1760 /** The error code for the current exception / interrupt. */
1761 uint32_t uCurXcptErr;
1762
1763 /** @name Statistics
1764 * @{ */
1765 /** The number of instructions we've executed. */
1766 uint32_t cInstructions;
1767 /** The number of potential exits. */
1768 uint32_t cPotentialExits;
1769 /** The number of bytes data or stack written (mostly for IEMExecOneEx).
1770 * This may contain uncommitted writes. */
1771 uint32_t cbWritten;
1772 /** Counts the VERR_IEM_INSTR_NOT_IMPLEMENTED returns. */
1773 uint32_t cRetInstrNotImplemented;
1774 /** Counts the VERR_IEM_ASPECT_NOT_IMPLEMENTED returns. */
1775 uint32_t cRetAspectNotImplemented;
1776 /** Counts informational statuses returned (other than VINF_SUCCESS). */
1777 uint32_t cRetInfStatuses;
1778 /** Counts other error statuses returned. */
1779 uint32_t cRetErrStatuses;
1780 /** Number of times rcPassUp has been used. */
1781 uint32_t cRetPassUpStatus;
1782 /** Number of times RZ left with instruction commit pending for ring-3. */
1783 uint32_t cPendingCommit;
1784 /** Number of misaligned (host sense) atomic instruction accesses. */
1785 uint32_t cMisalignedAtomics;
1786 /** Number of long jumps. */
1787 uint32_t cLongJumps;
1788 /** @} */
1789
1790 /** @name Target CPU information.
1791 * @{ */
1792#if IEM_CFG_TARGET_CPU == IEMTARGETCPU_DYNAMIC
1793 /** The target CPU. */
1794 uint8_t uTargetCpu;
1795#else
1796 uint8_t bTargetCpuPadding;
1797#endif
1798 /** For selecting assembly works matching the target CPU EFLAGS behaviour, see
1799 * IEMTARGETCPU_EFL_BEHAVIOR_XXX for values, with the 1st entry for when no
1800 * native host support and the 2nd for when there is.
1801 *
1802 * The two values are typically indexed by a g_CpumHostFeatures bit.
1803 *
1804 * This is for instance used for the BSF & BSR instructions where AMD and
1805 * Intel CPUs produce different EFLAGS. */
1806 uint8_t aidxTargetCpuEflFlavour[2];
1807
1808 /** The CPU vendor. */
1809 CPUMCPUVENDOR enmCpuVendor;
1810 /** @} */
1811
1812 /** @name Host CPU information.
1813 * @{ */
1814 /** The CPU vendor. */
1815 CPUMCPUVENDOR enmHostCpuVendor;
1816 /** @} */
1817
1818 /** Counts RDMSR \#GP(0) LogRel(). */
1819 uint8_t cLogRelRdMsr;
1820 /** Counts WRMSR \#GP(0) LogRel(). */
1821 uint8_t cLogRelWrMsr;
1822 /** Alignment padding. */
1823 uint8_t abAlignment9[42];
1824
1825 /** @name Recompilation
1826 * @{ */
1827 /** Pointer to the current translation block.
1828 * This can either be one being executed or one being compiled. */
1829 R3PTRTYPE(PIEMTB) pCurTbR3;
1830#ifdef VBOX_WITH_IEM_NATIVE_RECOMPILER_LONGJMP
1831 /** Frame pointer for the last native TB to execute. */
1832 R3PTRTYPE(void *) pvTbFramePointerR3;
1833#else
1834 R3PTRTYPE(void *) pvUnusedR3;
1835#endif
1836 /** Fixed TB used for threaded recompilation.
1837 * This is allocated once with maxed-out sizes and re-used afterwards. */
1838 R3PTRTYPE(PIEMTB) pThrdCompileTbR3;
1839 /** Pointer to the ring-3 TB cache for this EMT. */
1840 R3PTRTYPE(PIEMTBCACHE) pTbCacheR3;
1841 /** Pointer to the ring-3 TB lookup entry.
1842 * This either points to pTbLookupEntryDummyR3 or an actually lookuptable
1843 * entry, thus it can always safely be used w/o NULL checking. */
1844 R3PTRTYPE(PIEMTB *) ppTbLookupEntryR3;
1845 /** The PC (RIP) at the start of pCurTbR3/pCurTbR0.
1846 * The TBs are based on physical addresses, so this is needed to correleated
1847 * RIP to opcode bytes stored in the TB (AMD-V / VT-x). */
1848 uint64_t uCurTbStartPc;
1849 /** Number of threaded TBs executed. */
1850 uint64_t cTbExecThreaded;
1851 /** Number of native TBs executed. */
1852 uint64_t cTbExecNative;
1853 /** Whether we need to check the opcode bytes for the current instruction.
1854 * This is set by a previous instruction if it modified memory or similar. */
1855 bool fTbCheckOpcodes;
1856 /** Indicates whether and how we just branched - IEMBRANCHED_F_XXX. */
1857 uint8_t fTbBranched;
1858 /** Set when GCPhysInstrBuf is updated because of a page crossing. */
1859 bool fTbCrossedPage;
1860 /** Whether to end the current TB. */
1861 bool fEndTb;
1862 /** Number of instructions before we need emit an IRQ check call again.
1863 * This helps making sure we don't execute too long w/o checking for
1864 * interrupts and immediately following instructions that may enable
1865 * interrupts (e.g. POPF, IRET, STI). With STI an additional hack is
1866 * required to make sure we check following the next instruction as well, see
1867 * fTbCurInstrIsSti. */
1868 uint8_t cInstrTillIrqCheck;
1869 /** Indicates that the current instruction is an STI. This is set by the
1870 * iemCImpl_sti code and subsequently cleared by the recompiler. */
1871 bool fTbCurInstrIsSti;
1872 /** The size of the IEMTB::pabOpcodes allocation in pThrdCompileTbR3. */
1873 uint16_t cbOpcodesAllocated;
1874 /** The current instruction number in a native TB.
1875 * This is set by code that may trigger an unexpected TB exit (throw/longjmp)
1876 * and will be picked up by the TB execution loop. Only used when
1877 * IEMNATIVE_WITH_INSTRUCTION_COUNTING is defined. */
1878 uint8_t idxTbCurInstr;
1879 /** Spaced reserved for recompiler data / alignment. */
1880 bool afRecompilerStuff1[3];
1881 /** The virtual sync time at the last timer poll call. */
1882 uint32_t msRecompilerPollNow;
1883 /** The IEMTB::cUsed value when to attempt native recompilation of a TB. */
1884 uint32_t uTbNativeRecompileAtUsedCount;
1885 /** The IEM_CIMPL_F_XXX mask for the current instruction. */
1886 uint32_t fTbCurInstr;
1887 /** The IEM_CIMPL_F_XXX mask for the previous instruction. */
1888 uint32_t fTbPrevInstr;
1889 /** Strict: Tracking skipped EFLAGS calculations. Any bits set here are
1890 * currently not up to date in EFLAGS. */
1891 uint32_t fSkippingEFlags;
1892 /** Previous GCPhysInstrBuf value - only valid if fTbCrossedPage is set. */
1893 RTGCPHYS GCPhysInstrBufPrev;
1894 /** Pointer to the ring-3 TB allocator for this EMT. */
1895 R3PTRTYPE(PIEMTBALLOCATOR) pTbAllocatorR3;
1896 /** Pointer to the ring-3 executable memory allocator for this EMT. */
1897 R3PTRTYPE(struct IEMEXECMEMALLOCATOR *) pExecMemAllocatorR3;
1898 /** Pointer to the native recompiler state for ring-3. */
1899 R3PTRTYPE(struct IEMRECOMPILERSTATE *) pNativeRecompilerStateR3;
1900 /** Dummy entry for ppTbLookupEntryR3. */
1901 R3PTRTYPE(PIEMTB) pTbLookupEntryDummyR3;
1902
1903 /** Statistics: Times TB execution was broken off before reaching the end. */
1904 STAMCOUNTER StatTbExecBreaks;
1905 /** Statistics: Times BltIn_CheckIrq breaks out of the TB. */
1906 STAMCOUNTER StatCheckIrqBreaks;
1907 /** Statistics: Times BltIn_CheckMode breaks out of the TB. */
1908 STAMCOUNTER StatCheckModeBreaks;
1909 /** Threaded TB statistics: Times execution break on call with lookup entries. */
1910 STAMCOUNTER StatTbThreadedExecBreaksWithLookup;
1911 /** Threaded TB statistics: Times execution break on call without lookup entries. */
1912 STAMCOUNTER StatTbThreadedExecBreaksWithoutLookup;
1913 /** Statistics: Times a post jump target check missed and had to find new TB. */
1914 STAMCOUNTER StatCheckBranchMisses;
1915 /** Statistics: Times a jump or page crossing required a TB with CS.LIM checking. */
1916 STAMCOUNTER StatCheckNeedCsLimChecking;
1917 /** Statistics: Times a loop was detected within a TB.. */
1918 STAMCOUNTER StatTbLoopInTbDetected;
1919 /** Exec memory allocator statistics: Number of times allocaintg executable memory failed. */
1920 STAMCOUNTER StatNativeExecMemInstrBufAllocFailed;
1921 /** Native TB statistics: Number of fully recompiled TBs. */
1922 STAMCOUNTER StatNativeFullyRecompiledTbs;
1923 /** TB statistics: Number of instructions per TB. */
1924 STAMPROFILE StatTbInstr;
1925 /** TB statistics: Number of TB lookup table entries per TB. */
1926 STAMPROFILE StatTbLookupEntries;
1927 /** Threaded TB statistics: Number of calls per TB. */
1928 STAMPROFILE StatTbThreadedCalls;
1929 /** Native TB statistics: Native code size per TB. */
1930 STAMPROFILE StatTbNativeCode;
1931 /** Native TB statistics: Profiling native recompilation. */
1932 STAMPROFILE StatNativeRecompilation;
1933 /** Native TB statistics: Number of calls per TB that were recompiled properly. */
1934 STAMPROFILE StatNativeCallsRecompiled;
1935 /** Native TB statistics: Number of threaded calls per TB that weren't recompiled. */
1936 STAMPROFILE StatNativeCallsThreaded;
1937 /** Native recompiled execution: TLB hits for data fetches. */
1938 STAMCOUNTER StatNativeTlbHitsForFetch;
1939 /** Native recompiled execution: TLB hits for data stores. */
1940 STAMCOUNTER StatNativeTlbHitsForStore;
1941 /** Native recompiled execution: TLB hits for stack accesses. */
1942 STAMCOUNTER StatNativeTlbHitsForStack;
1943 /** Native recompiled execution: TLB hits for mapped accesses. */
1944 STAMCOUNTER StatNativeTlbHitsForMapped;
1945 /** Native recompiled execution: Code TLB misses for new page. */
1946 STAMCOUNTER StatNativeCodeTlbMissesNewPage;
1947 /** Native recompiled execution: Code TLB hits for new page. */
1948 STAMCOUNTER StatNativeCodeTlbHitsForNewPage;
1949 /** Native recompiled execution: Code TLB misses for new page with offset. */
1950 STAMCOUNTER StatNativeCodeTlbMissesNewPageWithOffset;
1951 /** Native recompiled execution: Code TLB hits for new page with offset. */
1952 STAMCOUNTER StatNativeCodeTlbHitsForNewPageWithOffset;
1953
1954 /** Native recompiler: Number of calls to iemNativeRegAllocFindFree. */
1955 STAMCOUNTER StatNativeRegFindFree;
1956 /** Native recompiler: Number of times iemNativeRegAllocFindFree needed
1957 * to free a variable. */
1958 STAMCOUNTER StatNativeRegFindFreeVar;
1959 /** Native recompiler: Number of times iemNativeRegAllocFindFree did
1960 * not need to free any variables. */
1961 STAMCOUNTER StatNativeRegFindFreeNoVar;
1962 /** Native recompiler: Liveness info freed shadowed guest registers in
1963 * iemNativeRegAllocFindFree. */
1964 STAMCOUNTER StatNativeRegFindFreeLivenessUnshadowed;
1965 /** Native recompiler: Liveness info helped with the allocation in
1966 * iemNativeRegAllocFindFree. */
1967 STAMCOUNTER StatNativeRegFindFreeLivenessHelped;
1968
1969 /** Native recompiler: Number of times status flags calc has been skipped. */
1970 STAMCOUNTER StatNativeEflSkippedArithmetic;
1971 /** Native recompiler: Number of times status flags calc has been skipped. */
1972 STAMCOUNTER StatNativeEflSkippedLogical;
1973
1974 /** Native recompiler: Number of opportunities to skip EFLAGS.CF updating. */
1975 STAMCOUNTER StatNativeLivenessEflCfSkippable;
1976 /** Native recompiler: Number of opportunities to skip EFLAGS.PF updating. */
1977 STAMCOUNTER StatNativeLivenessEflPfSkippable;
1978 /** Native recompiler: Number of opportunities to skip EFLAGS.AF updating. */
1979 STAMCOUNTER StatNativeLivenessEflAfSkippable;
1980 /** Native recompiler: Number of opportunities to skip EFLAGS.ZF updating. */
1981 STAMCOUNTER StatNativeLivenessEflZfSkippable;
1982 /** Native recompiler: Number of opportunities to skip EFLAGS.SF updating. */
1983 STAMCOUNTER StatNativeLivenessEflSfSkippable;
1984 /** Native recompiler: Number of opportunities to skip EFLAGS.OF updating. */
1985 STAMCOUNTER StatNativeLivenessEflOfSkippable;
1986 /** Native recompiler: Number of required EFLAGS.CF updates. */
1987 STAMCOUNTER StatNativeLivenessEflCfRequired;
1988 /** Native recompiler: Number of required EFLAGS.PF updates. */
1989 STAMCOUNTER StatNativeLivenessEflPfRequired;
1990 /** Native recompiler: Number of required EFLAGS.AF updates. */
1991 STAMCOUNTER StatNativeLivenessEflAfRequired;
1992 /** Native recompiler: Number of required EFLAGS.ZF updates. */
1993 STAMCOUNTER StatNativeLivenessEflZfRequired;
1994 /** Native recompiler: Number of required EFLAGS.SF updates. */
1995 STAMCOUNTER StatNativeLivenessEflSfRequired;
1996 /** Native recompiler: Number of required EFLAGS.OF updates. */
1997 STAMCOUNTER StatNativeLivenessEflOfRequired;
1998 /** Native recompiler: Number of potentially delayable EFLAGS.CF updates. */
1999 STAMCOUNTER StatNativeLivenessEflCfDelayable;
2000 /** Native recompiler: Number of potentially delayable EFLAGS.PF updates. */
2001 STAMCOUNTER StatNativeLivenessEflPfDelayable;
2002 /** Native recompiler: Number of potentially delayable EFLAGS.AF updates. */
2003 STAMCOUNTER StatNativeLivenessEflAfDelayable;
2004 /** Native recompiler: Number of potentially delayable EFLAGS.ZF updates. */
2005 STAMCOUNTER StatNativeLivenessEflZfDelayable;
2006 /** Native recompiler: Number of potentially delayable EFLAGS.SF updates. */
2007 STAMCOUNTER StatNativeLivenessEflSfDelayable;
2008 /** Native recompiler: Number of potentially delayable EFLAGS.OF updates. */
2009 STAMCOUNTER StatNativeLivenessEflOfDelayable;
2010
2011 /** Native recompiler: Number of potential PC updates in total. */
2012 STAMCOUNTER StatNativePcUpdateTotal;
2013 /** Native recompiler: Number of PC updates which could be delayed. */
2014 STAMCOUNTER StatNativePcUpdateDelayed;
2015
2016//#ifdef IEMNATIVE_WITH_SIMD_REG_ALLOCATOR
2017 /** Native recompiler: Number of calls to iemNativeSimdRegAllocFindFree. */
2018 STAMCOUNTER StatNativeSimdRegFindFree;
2019 /** Native recompiler: Number of times iemNativeSimdRegAllocFindFree needed
2020 * to free a variable. */
2021 STAMCOUNTER StatNativeSimdRegFindFreeVar;
2022 /** Native recompiler: Number of times iemNativeSimdRegAllocFindFree did
2023 * not need to free any variables. */
2024 STAMCOUNTER StatNativeSimdRegFindFreeNoVar;
2025 /** Native recompiler: Liveness info freed shadowed guest registers in
2026 * iemNativeSimdRegAllocFindFree. */
2027 STAMCOUNTER StatNativeSimdRegFindFreeLivenessUnshadowed;
2028 /** Native recompiler: Liveness info helped with the allocation in
2029 * iemNativeSimdRegAllocFindFree. */
2030 STAMCOUNTER StatNativeSimdRegFindFreeLivenessHelped;
2031
2032 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE() checks. */
2033 STAMCOUNTER StatNativeMaybeDeviceNotAvailXcptCheckPotential;
2034 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_WAIT_DEVICE_NOT_AVAILABLE() checks. */
2035 STAMCOUNTER StatNativeMaybeWaitDeviceNotAvailXcptCheckPotential;
2036 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() checks. */
2037 STAMCOUNTER StatNativeMaybeSseXcptCheckPotential;
2038 /** Native recompiler: Number of potential IEM_MC_MAYBE_RAISE_AVX_RELATED_XCPT() checks. */
2039 STAMCOUNTER StatNativeMaybeAvxXcptCheckPotential;
2040
2041 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE() checks omitted. */
2042 STAMCOUNTER StatNativeMaybeDeviceNotAvailXcptCheckOmitted;
2043 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_WAIT_DEVICE_NOT_AVAILABLE() checks omitted. */
2044 STAMCOUNTER StatNativeMaybeWaitDeviceNotAvailXcptCheckOmitted;
2045 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT() checks omitted. */
2046 STAMCOUNTER StatNativeMaybeSseXcptCheckOmitted;
2047 /** Native recompiler: Number of IEM_MC_MAYBE_RAISE_AVX_RELATED_XCPT() checks omitted. */
2048 STAMCOUNTER StatNativeMaybeAvxXcptCheckOmitted;
2049//#endif
2050
2051 /** Native recompiler: The TB finished executing completely without jumping to a an exit label. */
2052 STAMCOUNTER StatNativeTbFinished;
2053 /** Native recompiler: The TB finished executing jumping to the ReturnBreak label. */
2054 STAMCOUNTER StatNativeTbExitReturnBreak;
2055 /** Native recompiler: The TB finished executing jumping to the ReturnWithFlags label. */
2056 STAMCOUNTER StatNativeTbExitReturnWithFlags;
2057
2058 /** Native recompiler: The TB finished executing jumping to the RaiseDe label. */
2059 STAMCOUNTER StatNativeTbExitRaiseDe;
2060 /** Native recompiler: The TB finished executing jumping to the RaiseUd label. */
2061 STAMCOUNTER StatNativeTbExitRaiseUd;
2062 /** Native recompiler: The TB finished executing jumping to the RaiseSseRelated label. */
2063 STAMCOUNTER StatNativeTbExitRaiseSseRelated;
2064 /** Native recompiler: The TB finished executing jumping to the RaiseAvxRelated label. */
2065 STAMCOUNTER StatNativeTbExitRaiseAvxRelated;
2066 /** Native recompiler: The TB finished executing jumping to the RaiseSseAvxFpRelated label. */
2067 STAMCOUNTER StatNativeTbExitRaiseSseAvxFpRelated;
2068 /** Native recompiler: The TB finished executing jumping to the RaiseNm label. */
2069 STAMCOUNTER StatNativeTbExitRaiseNm;
2070 /** Native recompiler: The TB finished executing jumping to the RaiseGp0 label. */
2071 STAMCOUNTER StatNativeTbExitRaiseGp0;
2072 /** Native recompiler: The TB finished executing jumping to the RaiseMf label. */
2073 STAMCOUNTER StatNativeTbExitRaiseMf;
2074 /** Native recompiler: The TB finished executing jumping to the RaiseXf label. */
2075 STAMCOUNTER StatNativeTbExitRaiseXf;
2076 /** Native recompiler: The TB finished executing jumping to the ObsoleteTb label. */
2077 STAMCOUNTER StatNativeTbExitObsoleteTb;
2078
2079 uint64_t au64Padding[4];
2080 /** @} */
2081
2082 /** Data TLB.
2083 * @remarks Must be 64-byte aligned. */
2084 IEMTLB DataTlb;
2085 /** Instruction TLB.
2086 * @remarks Must be 64-byte aligned. */
2087 IEMTLB CodeTlb;
2088
2089 /** Exception statistics. */
2090 STAMCOUNTER aStatXcpts[32];
2091 /** Interrupt statistics. */
2092 uint32_t aStatInts[256];
2093
2094#if defined(VBOX_WITH_STATISTICS) && !defined(IN_TSTVMSTRUCT) && !defined(DOXYGEN_RUNNING)
2095 /** Instruction statistics for ring-0/raw-mode. */
2096 IEMINSTRSTATS StatsRZ;
2097 /** Instruction statistics for ring-3. */
2098 IEMINSTRSTATS StatsR3;
2099# ifdef VBOX_WITH_IEM_RECOMPILER
2100 /** Statistics per threaded function call.
2101 * Updated by both the threaded and native recompilers. */
2102 uint32_t acThreadedFuncStats[0x6000 /*24576*/];
2103# endif
2104#endif
2105} IEMCPU;
2106AssertCompileMemberOffset(IEMCPU, cActiveMappings, 0x4f);
2107AssertCompileMemberAlignment(IEMCPU, aMemMappings, 16);
2108AssertCompileMemberAlignment(IEMCPU, aMemMappingLocks, 16);
2109AssertCompileMemberAlignment(IEMCPU, aBounceBuffers, 64);
2110AssertCompileMemberAlignment(IEMCPU, DataTlb, 64);
2111AssertCompileMemberAlignment(IEMCPU, CodeTlb, 64);
2112
2113/** Pointer to the per-CPU IEM state. */
2114typedef IEMCPU *PIEMCPU;
2115/** Pointer to the const per-CPU IEM state. */
2116typedef IEMCPU const *PCIEMCPU;
2117
2118
2119/** @def IEM_GET_CTX
2120 * Gets the guest CPU context for the calling EMT.
2121 * @returns PCPUMCTX
2122 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2123 */
2124#define IEM_GET_CTX(a_pVCpu) (&(a_pVCpu)->cpum.GstCtx)
2125
2126/** @def IEM_CTX_ASSERT
2127 * Asserts that the @a a_fExtrnMbz is present in the CPU context.
2128 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2129 * @param a_fExtrnMbz The mask of CPUMCTX_EXTRN_XXX flags that must be zero.
2130 */
2131#define IEM_CTX_ASSERT(a_pVCpu, a_fExtrnMbz) \
2132 AssertMsg(!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz)), \
2133 ("fExtrn=%#RX64 & fExtrnMbz=%#RX64 -> %#RX64\n", \
2134 (a_pVCpu)->cpum.GstCtx.fExtrn, (a_fExtrnMbz), (a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnMbz) ))
2135
2136/** @def IEM_CTX_IMPORT_RET
2137 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
2138 *
2139 * Will call the keep to import the bits as needed.
2140 *
2141 * Returns on import failure.
2142 *
2143 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2144 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
2145 */
2146#define IEM_CTX_IMPORT_RET(a_pVCpu, a_fExtrnImport) \
2147 do { \
2148 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
2149 { /* likely */ } \
2150 else \
2151 { \
2152 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
2153 AssertRCReturn(rcCtxImport, rcCtxImport); \
2154 } \
2155 } while (0)
2156
2157/** @def IEM_CTX_IMPORT_NORET
2158 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
2159 *
2160 * Will call the keep to import the bits as needed.
2161 *
2162 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2163 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
2164 */
2165#define IEM_CTX_IMPORT_NORET(a_pVCpu, a_fExtrnImport) \
2166 do { \
2167 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
2168 { /* likely */ } \
2169 else \
2170 { \
2171 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
2172 AssertLogRelRC(rcCtxImport); \
2173 } \
2174 } while (0)
2175
2176/** @def IEM_CTX_IMPORT_JMP
2177 * Makes sure the CPU context bits given by @a a_fExtrnImport are imported.
2178 *
2179 * Will call the keep to import the bits as needed.
2180 *
2181 * Jumps on import failure.
2182 *
2183 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2184 * @param a_fExtrnImport The mask of CPUMCTX_EXTRN_XXX flags to import.
2185 */
2186#define IEM_CTX_IMPORT_JMP(a_pVCpu, a_fExtrnImport) \
2187 do { \
2188 if (!((a_pVCpu)->cpum.GstCtx.fExtrn & (a_fExtrnImport))) \
2189 { /* likely */ } \
2190 else \
2191 { \
2192 int rcCtxImport = CPUMImportGuestStateOnDemand(a_pVCpu, a_fExtrnImport); \
2193 AssertRCStmt(rcCtxImport, IEM_DO_LONGJMP(pVCpu, rcCtxImport)); \
2194 } \
2195 } while (0)
2196
2197
2198
2199/** @def IEM_GET_TARGET_CPU
2200 * Gets the current IEMTARGETCPU value.
2201 * @returns IEMTARGETCPU value.
2202 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
2203 */
2204#if IEM_CFG_TARGET_CPU != IEMTARGETCPU_DYNAMIC
2205# define IEM_GET_TARGET_CPU(a_pVCpu) (IEM_CFG_TARGET_CPU)
2206#else
2207# define IEM_GET_TARGET_CPU(a_pVCpu) ((a_pVCpu)->iem.s.uTargetCpu)
2208#endif
2209
2210/** @def IEM_GET_INSTR_LEN
2211 * Gets the instruction length. */
2212#ifdef IEM_WITH_CODE_TLB
2213# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offInstrNextByte - (uint32_t)(int32_t)(a_pVCpu)->iem.s.offCurInstrStart)
2214#else
2215# define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offOpcode)
2216#endif
2217
2218/** @def IEM_TRY_SETJMP
2219 * Wrapper around setjmp / try, hiding all the ugly differences.
2220 *
2221 * @note Use with extreme care as this is a fragile macro.
2222 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
2223 * @param a_rcTarget The variable that should receive the status code in case
2224 * of a longjmp/throw.
2225 */
2226/** @def IEM_TRY_SETJMP_AGAIN
2227 * For when setjmp / try is used again in the same variable scope as a previous
2228 * IEM_TRY_SETJMP invocation.
2229 */
2230/** @def IEM_CATCH_LONGJMP_BEGIN
2231 * Start wrapper for catch / setjmp-else.
2232 *
2233 * This will set up a scope.
2234 *
2235 * @note Use with extreme care as this is a fragile macro.
2236 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
2237 * @param a_rcTarget The variable that should receive the status code in case
2238 * of a longjmp/throw.
2239 */
2240/** @def IEM_CATCH_LONGJMP_END
2241 * End wrapper for catch / setjmp-else.
2242 *
2243 * This will close the scope set up by IEM_CATCH_LONGJMP_BEGIN and clean up the
2244 * state.
2245 *
2246 * @note Use with extreme care as this is a fragile macro.
2247 * @param a_pVCpu The cross context virtual CPU structure of the calling EMT.
2248 */
2249#if defined(IEM_WITH_SETJMP) || defined(DOXYGEN_RUNNING)
2250# ifdef IEM_WITH_THROW_CATCH
2251# define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
2252 a_rcTarget = VINF_SUCCESS; \
2253 try
2254# define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
2255 IEM_TRY_SETJMP(a_pVCpu, a_rcTarget)
2256# define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
2257 catch (int rcThrown) \
2258 { \
2259 a_rcTarget = rcThrown
2260# define IEM_CATCH_LONGJMP_END(a_pVCpu) \
2261 } \
2262 ((void)0)
2263# else /* !IEM_WITH_THROW_CATCH */
2264# define IEM_TRY_SETJMP(a_pVCpu, a_rcTarget) \
2265 jmp_buf JmpBuf; \
2266 jmp_buf * volatile pSavedJmpBuf = (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf); \
2267 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
2268 if ((rcStrict = setjmp(JmpBuf)) == 0)
2269# define IEM_TRY_SETJMP_AGAIN(a_pVCpu, a_rcTarget) \
2270 pSavedJmpBuf = (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf); \
2271 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = &JmpBuf; \
2272 if ((rcStrict = setjmp(JmpBuf)) == 0)
2273# define IEM_CATCH_LONGJMP_BEGIN(a_pVCpu, a_rcTarget) \
2274 else \
2275 { \
2276 ((void)0)
2277# define IEM_CATCH_LONGJMP_END(a_pVCpu) \
2278 } \
2279 (a_pVCpu)->iem.s.CTX_SUFF(pJmpBuf) = pSavedJmpBuf
2280# endif /* !IEM_WITH_THROW_CATCH */
2281#endif /* IEM_WITH_SETJMP */
2282
2283
2284/**
2285 * Shared per-VM IEM data.
2286 */
2287typedef struct IEM
2288{
2289 /** The VMX APIC-access page handler type. */
2290 PGMPHYSHANDLERTYPE hVmxApicAccessPage;
2291#ifndef VBOX_WITHOUT_CPUID_HOST_CALL
2292 /** Set if the CPUID host call functionality is enabled. */
2293 bool fCpuIdHostCall;
2294#endif
2295} IEM;
2296
2297
2298
2299/** @name IEM_ACCESS_XXX - Access details.
2300 * @{ */
2301#define IEM_ACCESS_INVALID UINT32_C(0x000000ff)
2302#define IEM_ACCESS_TYPE_READ UINT32_C(0x00000001)
2303#define IEM_ACCESS_TYPE_WRITE UINT32_C(0x00000002)
2304#define IEM_ACCESS_TYPE_EXEC UINT32_C(0x00000004)
2305#define IEM_ACCESS_TYPE_MASK UINT32_C(0x00000007)
2306#define IEM_ACCESS_WHAT_CODE UINT32_C(0x00000010)
2307#define IEM_ACCESS_WHAT_DATA UINT32_C(0x00000020)
2308#define IEM_ACCESS_WHAT_STACK UINT32_C(0x00000030)
2309#define IEM_ACCESS_WHAT_SYS UINT32_C(0x00000040)
2310#define IEM_ACCESS_WHAT_MASK UINT32_C(0x00000070)
2311/** The writes are partial, so if initialize the bounce buffer with the
2312 * orignal RAM content. */
2313#define IEM_ACCESS_PARTIAL_WRITE UINT32_C(0x00000100)
2314/** Used in aMemMappings to indicate that the entry is bounce buffered. */
2315#define IEM_ACCESS_BOUNCE_BUFFERED UINT32_C(0x00000200)
2316/** Bounce buffer with ring-3 write pending, first page. */
2317#define IEM_ACCESS_PENDING_R3_WRITE_1ST UINT32_C(0x00000400)
2318/** Bounce buffer with ring-3 write pending, second page. */
2319#define IEM_ACCESS_PENDING_R3_WRITE_2ND UINT32_C(0x00000800)
2320/** Not locked, accessed via the TLB. */
2321#define IEM_ACCESS_NOT_LOCKED UINT32_C(0x00001000)
2322/** Atomic access.
2323 * This enables special alignment checks and the VINF_EM_EMULATE_SPLIT_LOCK
2324 * fallback for misaligned stuff. See @bugref{10547}. */
2325#define IEM_ACCESS_ATOMIC UINT32_C(0x00002000)
2326/** Valid bit mask. */
2327#define IEM_ACCESS_VALID_MASK UINT32_C(0x00003fff)
2328/** Shift count for the TLB flags (upper word). */
2329#define IEM_ACCESS_SHIFT_TLB_FLAGS 16
2330
2331/** Atomic read+write data alias. */
2332#define IEM_ACCESS_DATA_ATOMIC (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA | IEM_ACCESS_ATOMIC)
2333/** Read+write data alias. */
2334#define IEM_ACCESS_DATA_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
2335/** Write data alias. */
2336#define IEM_ACCESS_DATA_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_DATA)
2337/** Read data alias. */
2338#define IEM_ACCESS_DATA_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_DATA)
2339/** Instruction fetch alias. */
2340#define IEM_ACCESS_INSTRUCTION (IEM_ACCESS_TYPE_EXEC | IEM_ACCESS_WHAT_CODE)
2341/** Stack write alias. */
2342#define IEM_ACCESS_STACK_W (IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
2343/** Stack read alias. */
2344#define IEM_ACCESS_STACK_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_STACK)
2345/** Stack read+write alias. */
2346#define IEM_ACCESS_STACK_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_STACK)
2347/** Read system table alias. */
2348#define IEM_ACCESS_SYS_R (IEM_ACCESS_TYPE_READ | IEM_ACCESS_WHAT_SYS)
2349/** Read+write system table alias. */
2350#define IEM_ACCESS_SYS_RW (IEM_ACCESS_TYPE_READ | IEM_ACCESS_TYPE_WRITE | IEM_ACCESS_WHAT_SYS)
2351/** @} */
2352
2353/** @name Prefix constants (IEMCPU::fPrefixes)
2354 * @{ */
2355#define IEM_OP_PRF_SEG_CS RT_BIT_32(0) /**< CS segment prefix (0x2e). */
2356#define IEM_OP_PRF_SEG_SS RT_BIT_32(1) /**< SS segment prefix (0x36). */
2357#define IEM_OP_PRF_SEG_DS RT_BIT_32(2) /**< DS segment prefix (0x3e). */
2358#define IEM_OP_PRF_SEG_ES RT_BIT_32(3) /**< ES segment prefix (0x26). */
2359#define IEM_OP_PRF_SEG_FS RT_BIT_32(4) /**< FS segment prefix (0x64). */
2360#define IEM_OP_PRF_SEG_GS RT_BIT_32(5) /**< GS segment prefix (0x65). */
2361#define IEM_OP_PRF_SEG_MASK UINT32_C(0x3f)
2362
2363#define IEM_OP_PRF_SIZE_OP RT_BIT_32(8) /**< Operand size prefix (0x66). */
2364#define IEM_OP_PRF_SIZE_REX_W RT_BIT_32(9) /**< REX.W prefix (0x48-0x4f). */
2365#define IEM_OP_PRF_SIZE_ADDR RT_BIT_32(10) /**< Address size prefix (0x67). */
2366
2367#define IEM_OP_PRF_LOCK RT_BIT_32(16) /**< Lock prefix (0xf0). */
2368#define IEM_OP_PRF_REPNZ RT_BIT_32(17) /**< Repeat-not-zero prefix (0xf2). */
2369#define IEM_OP_PRF_REPZ RT_BIT_32(18) /**< Repeat-if-zero prefix (0xf3). */
2370
2371#define IEM_OP_PRF_REX RT_BIT_32(24) /**< Any REX prefix (0x40-0x4f). */
2372#define IEM_OP_PRF_REX_B RT_BIT_32(25) /**< REX.B prefix (0x41,0x43,0x45,0x47,0x49,0x4b,0x4d,0x4f). */
2373#define IEM_OP_PRF_REX_X RT_BIT_32(26) /**< REX.X prefix (0x42,0x43,0x46,0x47,0x4a,0x4b,0x4e,0x4f). */
2374#define IEM_OP_PRF_REX_R RT_BIT_32(27) /**< REX.R prefix (0x44,0x45,0x46,0x47,0x4c,0x4d,0x4e,0x4f). */
2375/** Mask with all the REX prefix flags.
2376 * This is generally for use when needing to undo the REX prefixes when they
2377 * are followed legacy prefixes and therefore does not immediately preceed
2378 * the first opcode byte.
2379 * For testing whether any REX prefix is present, use IEM_OP_PRF_REX instead. */
2380#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 )
2381
2382#define IEM_OP_PRF_VEX RT_BIT_32(28) /**< Indiciates VEX prefix. */
2383#define IEM_OP_PRF_EVEX RT_BIT_32(29) /**< Indiciates EVEX prefix. */
2384#define IEM_OP_PRF_XOP RT_BIT_32(30) /**< Indiciates XOP prefix. */
2385/** @} */
2386
2387/** @name IEMOPFORM_XXX - Opcode forms
2388 * @note These are ORed together with IEMOPHINT_XXX.
2389 * @{ */
2390/** ModR/M: reg, r/m */
2391#define IEMOPFORM_RM 0
2392/** ModR/M: reg, r/m (register) */
2393#define IEMOPFORM_RM_REG (IEMOPFORM_RM | IEMOPFORM_MOD3)
2394/** ModR/M: reg, r/m (memory) */
2395#define IEMOPFORM_RM_MEM (IEMOPFORM_RM | IEMOPFORM_NOT_MOD3)
2396/** ModR/M: reg, r/m, imm */
2397#define IEMOPFORM_RMI 1
2398/** ModR/M: reg, r/m (register), imm */
2399#define IEMOPFORM_RMI_REG (IEMOPFORM_RMI | IEMOPFORM_MOD3)
2400/** ModR/M: reg, r/m (memory), imm */
2401#define IEMOPFORM_RMI_MEM (IEMOPFORM_RMI | IEMOPFORM_NOT_MOD3)
2402/** ModR/M: reg, r/m, xmm0 */
2403#define IEMOPFORM_RM0 2
2404/** ModR/M: reg, r/m (register), xmm0 */
2405#define IEMOPFORM_RM0_REG (IEMOPFORM_RM0 | IEMOPFORM_MOD3)
2406/** ModR/M: reg, r/m (memory), xmm0 */
2407#define IEMOPFORM_RM0_MEM (IEMOPFORM_RM0 | IEMOPFORM_NOT_MOD3)
2408/** ModR/M: r/m, reg */
2409#define IEMOPFORM_MR 3
2410/** ModR/M: r/m (register), reg */
2411#define IEMOPFORM_MR_REG (IEMOPFORM_MR | IEMOPFORM_MOD3)
2412/** ModR/M: r/m (memory), reg */
2413#define IEMOPFORM_MR_MEM (IEMOPFORM_MR | IEMOPFORM_NOT_MOD3)
2414/** ModR/M: r/m, reg, imm */
2415#define IEMOPFORM_MRI 4
2416/** ModR/M: r/m (register), reg, imm */
2417#define IEMOPFORM_MRI_REG (IEMOPFORM_MRI | IEMOPFORM_MOD3)
2418/** ModR/M: r/m (memory), reg, imm */
2419#define IEMOPFORM_MRI_MEM (IEMOPFORM_MRI | IEMOPFORM_NOT_MOD3)
2420/** ModR/M: r/m only */
2421#define IEMOPFORM_M 5
2422/** ModR/M: r/m only (register). */
2423#define IEMOPFORM_M_REG (IEMOPFORM_M | IEMOPFORM_MOD3)
2424/** ModR/M: r/m only (memory). */
2425#define IEMOPFORM_M_MEM (IEMOPFORM_M | IEMOPFORM_NOT_MOD3)
2426/** ModR/M: r/m, imm */
2427#define IEMOPFORM_MI 6
2428/** ModR/M: r/m (register), imm */
2429#define IEMOPFORM_MI_REG (IEMOPFORM_MI | IEMOPFORM_MOD3)
2430/** ModR/M: r/m (memory), imm */
2431#define IEMOPFORM_MI_MEM (IEMOPFORM_MI | IEMOPFORM_NOT_MOD3)
2432/** ModR/M: r/m, 1 (shift and rotate instructions) */
2433#define IEMOPFORM_M1 7
2434/** ModR/M: r/m (register), 1. */
2435#define IEMOPFORM_M1_REG (IEMOPFORM_M1 | IEMOPFORM_MOD3)
2436/** ModR/M: r/m (memory), 1. */
2437#define IEMOPFORM_M1_MEM (IEMOPFORM_M1 | IEMOPFORM_NOT_MOD3)
2438/** ModR/M: r/m, CL (shift and rotate instructions)
2439 * @todo This should just've been a generic fixed register. But the python
2440 * code doesn't needs more convincing. */
2441#define IEMOPFORM_M_CL 8
2442/** ModR/M: r/m (register), CL. */
2443#define IEMOPFORM_M_CL_REG (IEMOPFORM_M_CL | IEMOPFORM_MOD3)
2444/** ModR/M: r/m (memory), CL. */
2445#define IEMOPFORM_M_CL_MEM (IEMOPFORM_M_CL | IEMOPFORM_NOT_MOD3)
2446/** ModR/M: reg only */
2447#define IEMOPFORM_R 9
2448
2449/** VEX+ModR/M: reg, r/m */
2450#define IEMOPFORM_VEX_RM 16
2451/** VEX+ModR/M: reg, r/m (register) */
2452#define IEMOPFORM_VEX_RM_REG (IEMOPFORM_VEX_RM | IEMOPFORM_MOD3)
2453/** VEX+ModR/M: reg, r/m (memory) */
2454#define IEMOPFORM_VEX_RM_MEM (IEMOPFORM_VEX_RM | IEMOPFORM_NOT_MOD3)
2455/** VEX+ModR/M: r/m, reg */
2456#define IEMOPFORM_VEX_MR 17
2457/** VEX+ModR/M: r/m (register), reg */
2458#define IEMOPFORM_VEX_MR_REG (IEMOPFORM_VEX_MR | IEMOPFORM_MOD3)
2459/** VEX+ModR/M: r/m (memory), reg */
2460#define IEMOPFORM_VEX_MR_MEM (IEMOPFORM_VEX_MR | IEMOPFORM_NOT_MOD3)
2461/** VEX+ModR/M: r/m, reg, imm8 */
2462#define IEMOPFORM_VEX_MRI 18
2463/** VEX+ModR/M: r/m (register), reg, imm8 */
2464#define IEMOPFORM_VEX_MRI_REG (IEMOPFORM_VEX_MRI | IEMOPFORM_MOD3)
2465/** VEX+ModR/M: r/m (memory), reg, imm8 */
2466#define IEMOPFORM_VEX_MRI_MEM (IEMOPFORM_VEX_MRI | IEMOPFORM_NOT_MOD3)
2467/** VEX+ModR/M: r/m only */
2468#define IEMOPFORM_VEX_M 19
2469/** VEX+ModR/M: r/m only (register). */
2470#define IEMOPFORM_VEX_M_REG (IEMOPFORM_VEX_M | IEMOPFORM_MOD3)
2471/** VEX+ModR/M: r/m only (memory). */
2472#define IEMOPFORM_VEX_M_MEM (IEMOPFORM_VEX_M | IEMOPFORM_NOT_MOD3)
2473/** VEX+ModR/M: reg only */
2474#define IEMOPFORM_VEX_R 20
2475/** VEX+ModR/M: reg, vvvv, r/m */
2476#define IEMOPFORM_VEX_RVM 21
2477/** VEX+ModR/M: reg, vvvv, r/m (register). */
2478#define IEMOPFORM_VEX_RVM_REG (IEMOPFORM_VEX_RVM | IEMOPFORM_MOD3)
2479/** VEX+ModR/M: reg, vvvv, r/m (memory). */
2480#define IEMOPFORM_VEX_RVM_MEM (IEMOPFORM_VEX_RVM | IEMOPFORM_NOT_MOD3)
2481/** VEX+ModR/M: reg, vvvv, r/m, imm */
2482#define IEMOPFORM_VEX_RVMI 22
2483/** VEX+ModR/M: reg, vvvv, r/m (register), imm. */
2484#define IEMOPFORM_VEX_RVMI_REG (IEMOPFORM_VEX_RVMI | IEMOPFORM_MOD3)
2485/** VEX+ModR/M: reg, vvvv, r/m (memory), imm. */
2486#define IEMOPFORM_VEX_RVMI_MEM (IEMOPFORM_VEX_RVMI | IEMOPFORM_NOT_MOD3)
2487/** VEX+ModR/M: reg, vvvv, r/m, imm(reg) */
2488#define IEMOPFORM_VEX_RVMR 23
2489/** VEX+ModR/M: reg, vvvv, r/m (register), imm(reg). */
2490#define IEMOPFORM_VEX_RVMR_REG (IEMOPFORM_VEX_RVMI | IEMOPFORM_MOD3)
2491/** VEX+ModR/M: reg, vvvv, r/m (memory), imm(reg). */
2492#define IEMOPFORM_VEX_RVMR_MEM (IEMOPFORM_VEX_RVMI | IEMOPFORM_NOT_MOD3)
2493/** VEX+ModR/M: reg, r/m, vvvv */
2494#define IEMOPFORM_VEX_RMV 24
2495/** VEX+ModR/M: reg, r/m, vvvv (register). */
2496#define IEMOPFORM_VEX_RMV_REG (IEMOPFORM_VEX_RMV | IEMOPFORM_MOD3)
2497/** VEX+ModR/M: reg, r/m, vvvv (memory). */
2498#define IEMOPFORM_VEX_RMV_MEM (IEMOPFORM_VEX_RMV | IEMOPFORM_NOT_MOD3)
2499/** VEX+ModR/M: reg, r/m, imm8 */
2500#define IEMOPFORM_VEX_RMI 25
2501/** VEX+ModR/M: reg, r/m, imm8 (register). */
2502#define IEMOPFORM_VEX_RMI_REG (IEMOPFORM_VEX_RMI | IEMOPFORM_MOD3)
2503/** VEX+ModR/M: reg, r/m, imm8 (memory). */
2504#define IEMOPFORM_VEX_RMI_MEM (IEMOPFORM_VEX_RMI | IEMOPFORM_NOT_MOD3)
2505/** VEX+ModR/M: r/m, vvvv, reg */
2506#define IEMOPFORM_VEX_MVR 26
2507/** VEX+ModR/M: r/m, vvvv, reg (register) */
2508#define IEMOPFORM_VEX_MVR_REG (IEMOPFORM_VEX_MVR | IEMOPFORM_MOD3)
2509/** VEX+ModR/M: r/m, vvvv, reg (memory) */
2510#define IEMOPFORM_VEX_MVR_MEM (IEMOPFORM_VEX_MVR | IEMOPFORM_NOT_MOD3)
2511/** VEX+ModR/M+/n: vvvv, r/m */
2512#define IEMOPFORM_VEX_VM 27
2513/** VEX+ModR/M+/n: vvvv, r/m (register) */
2514#define IEMOPFORM_VEX_VM_REG (IEMOPFORM_VEX_VM | IEMOPFORM_MOD3)
2515/** VEX+ModR/M+/n: vvvv, r/m (memory) */
2516#define IEMOPFORM_VEX_VM_MEM (IEMOPFORM_VEX_VM | IEMOPFORM_NOT_MOD3)
2517/** VEX+ModR/M+/n: vvvv, r/m, imm8 */
2518#define IEMOPFORM_VEX_VMI 28
2519/** VEX+ModR/M+/n: vvvv, r/m, imm8 (register) */
2520#define IEMOPFORM_VEX_VMI_REG (IEMOPFORM_VEX_VMI | IEMOPFORM_MOD3)
2521/** VEX+ModR/M+/n: vvvv, r/m, imm8 (memory) */
2522#define IEMOPFORM_VEX_VMI_MEM (IEMOPFORM_VEX_VMI | IEMOPFORM_NOT_MOD3)
2523
2524/** Fixed register instruction, no R/M. */
2525#define IEMOPFORM_FIXED 32
2526
2527/** The r/m is a register. */
2528#define IEMOPFORM_MOD3 RT_BIT_32(8)
2529/** The r/m is a memory access. */
2530#define IEMOPFORM_NOT_MOD3 RT_BIT_32(9)
2531/** @} */
2532
2533/** @name IEMOPHINT_XXX - Additional Opcode Hints
2534 * @note These are ORed together with IEMOPFORM_XXX.
2535 * @{ */
2536/** Ignores the operand size prefix (66h). */
2537#define IEMOPHINT_IGNORES_OZ_PFX RT_BIT_32(10)
2538/** Ignores REX.W (aka WIG). */
2539#define IEMOPHINT_IGNORES_REXW RT_BIT_32(11)
2540/** Both the operand size prefixes (66h + REX.W) are ignored. */
2541#define IEMOPHINT_IGNORES_OP_SIZES (IEMOPHINT_IGNORES_OZ_PFX | IEMOPHINT_IGNORES_REXW)
2542/** Allowed with the lock prefix. */
2543#define IEMOPHINT_LOCK_ALLOWED RT_BIT_32(11)
2544/** The VEX.L value is ignored (aka LIG). */
2545#define IEMOPHINT_VEX_L_IGNORED RT_BIT_32(12)
2546/** The VEX.L value must be zero (i.e. 128-bit width only). */
2547#define IEMOPHINT_VEX_L_ZERO RT_BIT_32(13)
2548/** The VEX.L value must be one (i.e. 256-bit width only). */
2549#define IEMOPHINT_VEX_L_ONE RT_BIT_32(14)
2550/** The VEX.V value must be zero. */
2551#define IEMOPHINT_VEX_V_ZERO RT_BIT_32(15)
2552/** The REX.W/VEX.V value must be zero. */
2553#define IEMOPHINT_REX_W_ZERO RT_BIT_32(16)
2554#define IEMOPHINT_VEX_W_ZERO IEMOPHINT_REX_W_ZERO
2555/** The REX.W/VEX.V value must be one. */
2556#define IEMOPHINT_REX_W_ONE RT_BIT_32(17)
2557#define IEMOPHINT_VEX_W_ONE IEMOPHINT_REX_W_ONE
2558
2559/** Hint to IEMAllInstructionPython.py that this macro should be skipped. */
2560#define IEMOPHINT_SKIP_PYTHON RT_BIT_32(31)
2561/** @} */
2562
2563/**
2564 * Possible hardware task switch sources.
2565 */
2566typedef enum IEMTASKSWITCH
2567{
2568 /** Task switch caused by an interrupt/exception. */
2569 IEMTASKSWITCH_INT_XCPT = 1,
2570 /** Task switch caused by a far CALL. */
2571 IEMTASKSWITCH_CALL,
2572 /** Task switch caused by a far JMP. */
2573 IEMTASKSWITCH_JUMP,
2574 /** Task switch caused by an IRET. */
2575 IEMTASKSWITCH_IRET
2576} IEMTASKSWITCH;
2577AssertCompileSize(IEMTASKSWITCH, 4);
2578
2579/**
2580 * Possible CrX load (write) sources.
2581 */
2582typedef enum IEMACCESSCRX
2583{
2584 /** CrX access caused by 'mov crX' instruction. */
2585 IEMACCESSCRX_MOV_CRX,
2586 /** CrX (CR0) write caused by 'lmsw' instruction. */
2587 IEMACCESSCRX_LMSW,
2588 /** CrX (CR0) write caused by 'clts' instruction. */
2589 IEMACCESSCRX_CLTS,
2590 /** CrX (CR0) read caused by 'smsw' instruction. */
2591 IEMACCESSCRX_SMSW
2592} IEMACCESSCRX;
2593
2594#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
2595/** @name IEM_SLAT_FAIL_XXX - Second-level address translation failure information.
2596 *
2597 * These flags provide further context to SLAT page-walk failures that could not be
2598 * determined by PGM (e.g, PGM is not privy to memory access permissions).
2599 *
2600 * @{
2601 */
2602/** Translating a nested-guest linear address failed accessing a nested-guest
2603 * physical address. */
2604# define IEM_SLAT_FAIL_LINEAR_TO_PHYS_ADDR RT_BIT_32(0)
2605/** Translating a nested-guest linear address failed accessing a
2606 * paging-structure entry or updating accessed/dirty bits. */
2607# define IEM_SLAT_FAIL_LINEAR_TO_PAGE_TABLE RT_BIT_32(1)
2608/** @} */
2609
2610DECLCALLBACK(FNPGMPHYSHANDLER) iemVmxApicAccessPageHandler;
2611# ifndef IN_RING3
2612DECLCALLBACK(FNPGMRZPHYSPFHANDLER) iemVmxApicAccessPagePfHandler;
2613# endif
2614#endif
2615
2616/**
2617 * Indicates to the verifier that the given flag set is undefined.
2618 *
2619 * Can be invoked again to add more flags.
2620 *
2621 * This is a NOOP if the verifier isn't compiled in.
2622 *
2623 * @note We're temporarily keeping this until code is converted to new
2624 * disassembler style opcode handling.
2625 */
2626#define IEMOP_VERIFICATION_UNDEFINED_EFLAGS(a_fEfl) do { } while (0)
2627
2628
2629/** @def IEM_DECL_IMPL_TYPE
2630 * For typedef'ing an instruction implementation function.
2631 *
2632 * @param a_RetType The return type.
2633 * @param a_Name The name of the type.
2634 * @param a_ArgList The argument list enclosed in parentheses.
2635 */
2636
2637/** @def IEM_DECL_IMPL_DEF
2638 * For defining an instruction implementation function.
2639 *
2640 * @param a_RetType The return type.
2641 * @param a_Name The name of the type.
2642 * @param a_ArgList The argument list enclosed in parentheses.
2643 */
2644
2645#if defined(__GNUC__) && defined(RT_ARCH_X86)
2646# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2647 __attribute__((__fastcall__)) a_RetType (a_Name) a_ArgList
2648# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2649 __attribute__((__fastcall__, __nothrow__)) DECL_HIDDEN_ONLY(a_RetType) a_Name a_ArgList
2650# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2651 __attribute__((__fastcall__, __nothrow__)) DECL_HIDDEN_ONLY(a_RetType) a_Name a_ArgList
2652
2653#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
2654# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2655 a_RetType (__fastcall a_Name) a_ArgList
2656# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2657 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
2658# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2659 a_RetType __fastcall a_Name a_ArgList RT_NOEXCEPT
2660
2661#elif __cplusplus >= 201700 /* P0012R1 support */
2662# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2663 a_RetType (VBOXCALL a_Name) a_ArgList RT_NOEXCEPT
2664# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2665 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList RT_NOEXCEPT
2666# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2667 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList RT_NOEXCEPT
2668
2669#else
2670# define IEM_DECL_IMPL_TYPE(a_RetType, a_Name, a_ArgList) \
2671 a_RetType (VBOXCALL a_Name) a_ArgList
2672# define IEM_DECL_IMPL_DEF(a_RetType, a_Name, a_ArgList) \
2673 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList
2674# define IEM_DECL_IMPL_PROTO(a_RetType, a_Name, a_ArgList) \
2675 DECL_HIDDEN_ONLY(a_RetType) VBOXCALL a_Name a_ArgList
2676
2677#endif
2678
2679/** Defined in IEMAllAImplC.cpp but also used by IEMAllAImplA.asm. */
2680RT_C_DECLS_BEGIN
2681extern uint8_t const g_afParity[256];
2682RT_C_DECLS_END
2683
2684
2685/** @name Arithmetic assignment operations on bytes (binary).
2686 * @{ */
2687typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU8, (uint32_t fEFlagsIn, uint8_t *pu8Dst, uint8_t u8Src));
2688typedef FNIEMAIMPLBINU8 *PFNIEMAIMPLBINU8;
2689FNIEMAIMPLBINU8 iemAImpl_add_u8, iemAImpl_add_u8_locked;
2690FNIEMAIMPLBINU8 iemAImpl_adc_u8, iemAImpl_adc_u8_locked;
2691FNIEMAIMPLBINU8 iemAImpl_sub_u8, iemAImpl_sub_u8_locked;
2692FNIEMAIMPLBINU8 iemAImpl_sbb_u8, iemAImpl_sbb_u8_locked;
2693FNIEMAIMPLBINU8 iemAImpl_or_u8, iemAImpl_or_u8_locked;
2694FNIEMAIMPLBINU8 iemAImpl_xor_u8, iemAImpl_xor_u8_locked;
2695FNIEMAIMPLBINU8 iemAImpl_and_u8, iemAImpl_and_u8_locked;
2696/** @} */
2697
2698/** @name Arithmetic assignment operations on words (binary).
2699 * @{ */
2700typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU16, (uint32_t fEFlagsIn, uint16_t *pu16Dst, uint16_t u16Src));
2701typedef FNIEMAIMPLBINU16 *PFNIEMAIMPLBINU16;
2702FNIEMAIMPLBINU16 iemAImpl_add_u16, iemAImpl_add_u16_locked;
2703FNIEMAIMPLBINU16 iemAImpl_adc_u16, iemAImpl_adc_u16_locked;
2704FNIEMAIMPLBINU16 iemAImpl_sub_u16, iemAImpl_sub_u16_locked;
2705FNIEMAIMPLBINU16 iemAImpl_sbb_u16, iemAImpl_sbb_u16_locked;
2706FNIEMAIMPLBINU16 iemAImpl_or_u16, iemAImpl_or_u16_locked;
2707FNIEMAIMPLBINU16 iemAImpl_xor_u16, iemAImpl_xor_u16_locked;
2708FNIEMAIMPLBINU16 iemAImpl_and_u16, iemAImpl_and_u16_locked;
2709/** @} */
2710
2711
2712/** @name Arithmetic assignment operations on double words (binary).
2713 * @{ */
2714typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU32, (uint32_t fEFlagsIn, uint32_t *pu32Dst, uint32_t u32Src));
2715typedef FNIEMAIMPLBINU32 *PFNIEMAIMPLBINU32;
2716FNIEMAIMPLBINU32 iemAImpl_add_u32, iemAImpl_add_u32_locked;
2717FNIEMAIMPLBINU32 iemAImpl_adc_u32, iemAImpl_adc_u32_locked;
2718FNIEMAIMPLBINU32 iemAImpl_sub_u32, iemAImpl_sub_u32_locked;
2719FNIEMAIMPLBINU32 iemAImpl_sbb_u32, iemAImpl_sbb_u32_locked;
2720FNIEMAIMPLBINU32 iemAImpl_or_u32, iemAImpl_or_u32_locked;
2721FNIEMAIMPLBINU32 iemAImpl_xor_u32, iemAImpl_xor_u32_locked;
2722FNIEMAIMPLBINU32 iemAImpl_and_u32, iemAImpl_and_u32_locked;
2723FNIEMAIMPLBINU32 iemAImpl_blsi_u32, iemAImpl_blsi_u32_fallback;
2724FNIEMAIMPLBINU32 iemAImpl_blsr_u32, iemAImpl_blsr_u32_fallback;
2725FNIEMAIMPLBINU32 iemAImpl_blsmsk_u32, iemAImpl_blsmsk_u32_fallback;
2726/** @} */
2727
2728/** @name Arithmetic assignment operations on quad words (binary).
2729 * @{ */
2730typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINU64, (uint32_t fEFlagsIn, uint64_t *pu64Dst, uint64_t u64Src));
2731typedef FNIEMAIMPLBINU64 *PFNIEMAIMPLBINU64;
2732FNIEMAIMPLBINU64 iemAImpl_add_u64, iemAImpl_add_u64_locked;
2733FNIEMAIMPLBINU64 iemAImpl_adc_u64, iemAImpl_adc_u64_locked;
2734FNIEMAIMPLBINU64 iemAImpl_sub_u64, iemAImpl_sub_u64_locked;
2735FNIEMAIMPLBINU64 iemAImpl_sbb_u64, iemAImpl_sbb_u64_locked;
2736FNIEMAIMPLBINU64 iemAImpl_or_u64, iemAImpl_or_u64_locked;
2737FNIEMAIMPLBINU64 iemAImpl_xor_u64, iemAImpl_xor_u64_locked;
2738FNIEMAIMPLBINU64 iemAImpl_and_u64, iemAImpl_and_u64_locked;
2739FNIEMAIMPLBINU64 iemAImpl_blsi_u64, iemAImpl_blsi_u64_fallback;
2740FNIEMAIMPLBINU64 iemAImpl_blsr_u64, iemAImpl_blsr_u64_fallback;
2741FNIEMAIMPLBINU64 iemAImpl_blsmsk_u64, iemAImpl_blsmsk_u64_fallback;
2742/** @} */
2743
2744typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU8, (uint32_t fEFlagsIn, uint8_t const *pu8Dst, uint8_t u8Src));
2745typedef FNIEMAIMPLBINROU8 *PFNIEMAIMPLBINROU8;
2746typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU16,(uint32_t fEFlagsIn, uint16_t const *pu16Dst, uint16_t u16Src));
2747typedef FNIEMAIMPLBINROU16 *PFNIEMAIMPLBINROU16;
2748typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU32,(uint32_t fEFlagsIn, uint32_t const *pu32Dst, uint32_t u32Src));
2749typedef FNIEMAIMPLBINROU32 *PFNIEMAIMPLBINROU32;
2750typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLBINROU64,(uint32_t fEFlagsIn, uint64_t const *pu64Dst, uint64_t u64Src));
2751typedef FNIEMAIMPLBINROU64 *PFNIEMAIMPLBINROU64;
2752
2753/** @name Compare operations (thrown in with the binary ops).
2754 * @{ */
2755FNIEMAIMPLBINROU8 iemAImpl_cmp_u8;
2756FNIEMAIMPLBINROU16 iemAImpl_cmp_u16;
2757FNIEMAIMPLBINROU32 iemAImpl_cmp_u32;
2758FNIEMAIMPLBINROU64 iemAImpl_cmp_u64;
2759/** @} */
2760
2761/** @name Test operations (thrown in with the binary ops).
2762 * @{ */
2763FNIEMAIMPLBINROU8 iemAImpl_test_u8;
2764FNIEMAIMPLBINROU16 iemAImpl_test_u16;
2765FNIEMAIMPLBINROU32 iemAImpl_test_u32;
2766FNIEMAIMPLBINROU64 iemAImpl_test_u64;
2767/** @} */
2768
2769/** @name Bit operations operations (thrown in with the binary ops).
2770 * @{ */
2771FNIEMAIMPLBINROU16 iemAImpl_bt_u16;
2772FNIEMAIMPLBINROU32 iemAImpl_bt_u32;
2773FNIEMAIMPLBINROU64 iemAImpl_bt_u64;
2774FNIEMAIMPLBINU16 iemAImpl_btc_u16, iemAImpl_btc_u16_locked;
2775FNIEMAIMPLBINU32 iemAImpl_btc_u32, iemAImpl_btc_u32_locked;
2776FNIEMAIMPLBINU64 iemAImpl_btc_u64, iemAImpl_btc_u64_locked;
2777FNIEMAIMPLBINU16 iemAImpl_btr_u16, iemAImpl_btr_u16_locked;
2778FNIEMAIMPLBINU32 iemAImpl_btr_u32, iemAImpl_btr_u32_locked;
2779FNIEMAIMPLBINU64 iemAImpl_btr_u64, iemAImpl_btr_u64_locked;
2780FNIEMAIMPLBINU16 iemAImpl_bts_u16, iemAImpl_bts_u16_locked;
2781FNIEMAIMPLBINU32 iemAImpl_bts_u32, iemAImpl_bts_u32_locked;
2782FNIEMAIMPLBINU64 iemAImpl_bts_u64, iemAImpl_bts_u64_locked;
2783/** @} */
2784
2785/** @name Arithmetic three operand operations on double words (binary).
2786 * @{ */
2787typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU32, (uint32_t *pu32Dst, uint32_t u32Src1, uint32_t u32Src2, uint32_t *pEFlags));
2788typedef FNIEMAIMPLBINVEXU32 *PFNIEMAIMPLBINVEXU32;
2789FNIEMAIMPLBINVEXU32 iemAImpl_andn_u32, iemAImpl_andn_u32_fallback;
2790FNIEMAIMPLBINVEXU32 iemAImpl_bextr_u32, iemAImpl_bextr_u32_fallback;
2791FNIEMAIMPLBINVEXU32 iemAImpl_bzhi_u32, iemAImpl_bzhi_u32_fallback;
2792/** @} */
2793
2794/** @name Arithmetic three operand operations on quad words (binary).
2795 * @{ */
2796typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU64, (uint64_t *pu64Dst, uint64_t u64Src1, uint64_t u64Src2, uint32_t *pEFlags));
2797typedef FNIEMAIMPLBINVEXU64 *PFNIEMAIMPLBINVEXU64;
2798FNIEMAIMPLBINVEXU64 iemAImpl_andn_u64, iemAImpl_andn_u64_fallback;
2799FNIEMAIMPLBINVEXU64 iemAImpl_bextr_u64, iemAImpl_bextr_u64_fallback;
2800FNIEMAIMPLBINVEXU64 iemAImpl_bzhi_u64, iemAImpl_bzhi_u64_fallback;
2801/** @} */
2802
2803/** @name Arithmetic three operand operations on double words w/o EFLAGS (binary).
2804 * @{ */
2805typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU32NOEFL, (uint32_t *pu32Dst, uint32_t u32Src1, uint32_t u32Src2));
2806typedef FNIEMAIMPLBINVEXU32NOEFL *PFNIEMAIMPLBINVEXU32NOEFL;
2807FNIEMAIMPLBINVEXU32NOEFL iemAImpl_pdep_u32, iemAImpl_pdep_u32_fallback;
2808FNIEMAIMPLBINVEXU32NOEFL iemAImpl_pext_u32, iemAImpl_pext_u32_fallback;
2809FNIEMAIMPLBINVEXU32NOEFL iemAImpl_sarx_u32, iemAImpl_sarx_u32_fallback;
2810FNIEMAIMPLBINVEXU32NOEFL iemAImpl_shlx_u32, iemAImpl_shlx_u32_fallback;
2811FNIEMAIMPLBINVEXU32NOEFL iemAImpl_shrx_u32, iemAImpl_shrx_u32_fallback;
2812FNIEMAIMPLBINVEXU32NOEFL iemAImpl_rorx_u32;
2813/** @} */
2814
2815/** @name Arithmetic three operand operations on quad words w/o EFLAGS (binary).
2816 * @{ */
2817typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBINVEXU64NOEFL, (uint64_t *pu64Dst, uint64_t u64Src1, uint64_t u64Src2));
2818typedef FNIEMAIMPLBINVEXU64NOEFL *PFNIEMAIMPLBINVEXU64NOEFL;
2819FNIEMAIMPLBINVEXU64NOEFL iemAImpl_pdep_u64, iemAImpl_pdep_u64_fallback;
2820FNIEMAIMPLBINVEXU64NOEFL iemAImpl_pext_u64, iemAImpl_pext_u64_fallback;
2821FNIEMAIMPLBINVEXU64NOEFL iemAImpl_sarx_u64, iemAImpl_sarx_u64_fallback;
2822FNIEMAIMPLBINVEXU64NOEFL iemAImpl_shlx_u64, iemAImpl_shlx_u64_fallback;
2823FNIEMAIMPLBINVEXU64NOEFL iemAImpl_shrx_u64, iemAImpl_shrx_u64_fallback;
2824FNIEMAIMPLBINVEXU64NOEFL iemAImpl_rorx_u64;
2825/** @} */
2826
2827/** @name MULX 32-bit and 64-bit.
2828 * @{ */
2829typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMULXVEXU32, (uint32_t *puDst1, uint32_t *puDst2, uint32_t uSrc1, uint32_t uSrc2));
2830typedef FNIEMAIMPLMULXVEXU32 *PFNIEMAIMPLMULXVEXU32;
2831FNIEMAIMPLMULXVEXU32 iemAImpl_mulx_u32, iemAImpl_mulx_u32_fallback;
2832
2833typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMULXVEXU64, (uint64_t *puDst1, uint64_t *puDst2, uint64_t uSrc1, uint64_t uSrc2));
2834typedef FNIEMAIMPLMULXVEXU64 *PFNIEMAIMPLMULXVEXU64;
2835FNIEMAIMPLMULXVEXU64 iemAImpl_mulx_u64, iemAImpl_mulx_u64_fallback;
2836/** @} */
2837
2838
2839/** @name Exchange memory with register operations.
2840 * @{ */
2841IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_locked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
2842IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_locked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
2843IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_locked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
2844IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_locked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
2845IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u8_unlocked, (uint8_t *pu8Mem, uint8_t *pu8Reg));
2846IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u16_unlocked,(uint16_t *pu16Mem, uint16_t *pu16Reg));
2847IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u32_unlocked,(uint32_t *pu32Mem, uint32_t *pu32Reg));
2848IEM_DECL_IMPL_DEF(void, iemAImpl_xchg_u64_unlocked,(uint64_t *pu64Mem, uint64_t *pu64Reg));
2849/** @} */
2850
2851/** @name Exchange and add operations.
2852 * @{ */
2853IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
2854IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
2855IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
2856IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
2857IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u8_locked, (uint8_t *pu8Dst, uint8_t *pu8Reg, uint32_t *pEFlags));
2858IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u16_locked,(uint16_t *pu16Dst, uint16_t *pu16Reg, uint32_t *pEFlags));
2859IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u32_locked,(uint32_t *pu32Dst, uint32_t *pu32Reg, uint32_t *pEFlags));
2860IEM_DECL_IMPL_DEF(void, iemAImpl_xadd_u64_locked,(uint64_t *pu64Dst, uint64_t *pu64Reg, uint32_t *pEFlags));
2861/** @} */
2862
2863/** @name Compare and exchange.
2864 * @{ */
2865IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
2866IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u8_locked, (uint8_t *pu8Dst, uint8_t *puAl, uint8_t uSrcReg, uint32_t *pEFlags));
2867IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16, (uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
2868IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u16_locked,(uint16_t *pu16Dst, uint16_t *puAx, uint16_t uSrcReg, uint32_t *pEFlags));
2869IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32, (uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
2870IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u32_locked,(uint32_t *pu32Dst, uint32_t *puEax, uint32_t uSrcReg, uint32_t *pEFlags));
2871#if ARCH_BITS == 32
2872IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
2873IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t *puSrcReg, uint32_t *pEFlags));
2874#else
2875IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64, (uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
2876IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg_u64_locked,(uint64_t *pu64Dst, uint64_t *puRax, uint64_t uSrcReg, uint32_t *pEFlags));
2877#endif
2878IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
2879 uint32_t *pEFlags));
2880IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg8b_locked,(uint64_t *pu64Dst, PRTUINT64U pu64EaxEdx, PRTUINT64U pu64EbxEcx,
2881 uint32_t *pEFlags));
2882IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
2883 uint32_t *pEFlags));
2884IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_locked,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx, PRTUINT128U pu128RbxRcx,
2885 uint32_t *pEFlags));
2886#ifndef RT_ARCH_ARM64
2887IEM_DECL_IMPL_DEF(void, iemAImpl_cmpxchg16b_fallback,(PRTUINT128U pu128Dst, PRTUINT128U pu128RaxRdx,
2888 PRTUINT128U pu128RbxRcx, uint32_t *pEFlags));
2889#endif
2890/** @} */
2891
2892/** @name Memory ordering
2893 * @{ */
2894typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEMFENCE,(void));
2895typedef FNIEMAIMPLMEMFENCE *PFNIEMAIMPLMEMFENCE;
2896IEM_DECL_IMPL_DEF(void, iemAImpl_mfence,(void));
2897IEM_DECL_IMPL_DEF(void, iemAImpl_sfence,(void));
2898IEM_DECL_IMPL_DEF(void, iemAImpl_lfence,(void));
2899#ifndef RT_ARCH_ARM64
2900IEM_DECL_IMPL_DEF(void, iemAImpl_alt_mem_fence,(void));
2901#endif
2902/** @} */
2903
2904/** @name Double precision shifts
2905 * @{ */
2906typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU16,(uint16_t *pu16Dst, uint16_t u16Src, uint8_t cShift, uint32_t *pEFlags));
2907typedef FNIEMAIMPLSHIFTDBLU16 *PFNIEMAIMPLSHIFTDBLU16;
2908typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU32,(uint32_t *pu32Dst, uint32_t u32Src, uint8_t cShift, uint32_t *pEFlags));
2909typedef FNIEMAIMPLSHIFTDBLU32 *PFNIEMAIMPLSHIFTDBLU32;
2910typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLSHIFTDBLU64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t cShift, uint32_t *pEFlags));
2911typedef FNIEMAIMPLSHIFTDBLU64 *PFNIEMAIMPLSHIFTDBLU64;
2912FNIEMAIMPLSHIFTDBLU16 iemAImpl_shld_u16, iemAImpl_shld_u16_amd, iemAImpl_shld_u16_intel;
2913FNIEMAIMPLSHIFTDBLU32 iemAImpl_shld_u32, iemAImpl_shld_u32_amd, iemAImpl_shld_u32_intel;
2914FNIEMAIMPLSHIFTDBLU64 iemAImpl_shld_u64, iemAImpl_shld_u64_amd, iemAImpl_shld_u64_intel;
2915FNIEMAIMPLSHIFTDBLU16 iemAImpl_shrd_u16, iemAImpl_shrd_u16_amd, iemAImpl_shrd_u16_intel;
2916FNIEMAIMPLSHIFTDBLU32 iemAImpl_shrd_u32, iemAImpl_shrd_u32_amd, iemAImpl_shrd_u32_intel;
2917FNIEMAIMPLSHIFTDBLU64 iemAImpl_shrd_u64, iemAImpl_shrd_u64_amd, iemAImpl_shrd_u64_intel;
2918/** @} */
2919
2920
2921/** @name Bit search operations (thrown in with the binary ops).
2922 * @{ */
2923FNIEMAIMPLBINU16 iemAImpl_bsf_u16, iemAImpl_bsf_u16_amd, iemAImpl_bsf_u16_intel;
2924FNIEMAIMPLBINU32 iemAImpl_bsf_u32, iemAImpl_bsf_u32_amd, iemAImpl_bsf_u32_intel;
2925FNIEMAIMPLBINU64 iemAImpl_bsf_u64, iemAImpl_bsf_u64_amd, iemAImpl_bsf_u64_intel;
2926FNIEMAIMPLBINU16 iemAImpl_bsr_u16, iemAImpl_bsr_u16_amd, iemAImpl_bsr_u16_intel;
2927FNIEMAIMPLBINU32 iemAImpl_bsr_u32, iemAImpl_bsr_u32_amd, iemAImpl_bsr_u32_intel;
2928FNIEMAIMPLBINU64 iemAImpl_bsr_u64, iemAImpl_bsr_u64_amd, iemAImpl_bsr_u64_intel;
2929FNIEMAIMPLBINU16 iemAImpl_lzcnt_u16, iemAImpl_lzcnt_u16_amd, iemAImpl_lzcnt_u16_intel;
2930FNIEMAIMPLBINU32 iemAImpl_lzcnt_u32, iemAImpl_lzcnt_u32_amd, iemAImpl_lzcnt_u32_intel;
2931FNIEMAIMPLBINU64 iemAImpl_lzcnt_u64, iemAImpl_lzcnt_u64_amd, iemAImpl_lzcnt_u64_intel;
2932FNIEMAIMPLBINU16 iemAImpl_tzcnt_u16, iemAImpl_tzcnt_u16_amd, iemAImpl_tzcnt_u16_intel;
2933FNIEMAIMPLBINU32 iemAImpl_tzcnt_u32, iemAImpl_tzcnt_u32_amd, iemAImpl_tzcnt_u32_intel;
2934FNIEMAIMPLBINU64 iemAImpl_tzcnt_u64, iemAImpl_tzcnt_u64_amd, iemAImpl_tzcnt_u64_intel;
2935FNIEMAIMPLBINU16 iemAImpl_popcnt_u16, iemAImpl_popcnt_u16_fallback;
2936FNIEMAIMPLBINU32 iemAImpl_popcnt_u32, iemAImpl_popcnt_u32_fallback;
2937FNIEMAIMPLBINU64 iemAImpl_popcnt_u64, iemAImpl_popcnt_u64_fallback;
2938/** @} */
2939
2940/** @name Signed multiplication operations (thrown in with the binary ops).
2941 * @{ */
2942FNIEMAIMPLBINU16 iemAImpl_imul_two_u16, iemAImpl_imul_two_u16_amd, iemAImpl_imul_two_u16_intel;
2943FNIEMAIMPLBINU32 iemAImpl_imul_two_u32, iemAImpl_imul_two_u32_amd, iemAImpl_imul_two_u32_intel;
2944FNIEMAIMPLBINU64 iemAImpl_imul_two_u64, iemAImpl_imul_two_u64_amd, iemAImpl_imul_two_u64_intel;
2945/** @} */
2946
2947/** @name Arithmetic assignment operations on bytes (unary).
2948 * @{ */
2949typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU8, (uint8_t *pu8Dst, uint32_t *pEFlags));
2950typedef FNIEMAIMPLUNARYU8 *PFNIEMAIMPLUNARYU8;
2951FNIEMAIMPLUNARYU8 iemAImpl_inc_u8, iemAImpl_inc_u8_locked;
2952FNIEMAIMPLUNARYU8 iemAImpl_dec_u8, iemAImpl_dec_u8_locked;
2953FNIEMAIMPLUNARYU8 iemAImpl_not_u8, iemAImpl_not_u8_locked;
2954FNIEMAIMPLUNARYU8 iemAImpl_neg_u8, iemAImpl_neg_u8_locked;
2955/** @} */
2956
2957/** @name Arithmetic assignment operations on words (unary).
2958 * @{ */
2959typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU16, (uint16_t *pu16Dst, uint32_t *pEFlags));
2960typedef FNIEMAIMPLUNARYU16 *PFNIEMAIMPLUNARYU16;
2961FNIEMAIMPLUNARYU16 iemAImpl_inc_u16, iemAImpl_inc_u16_locked;
2962FNIEMAIMPLUNARYU16 iemAImpl_dec_u16, iemAImpl_dec_u16_locked;
2963FNIEMAIMPLUNARYU16 iemAImpl_not_u16, iemAImpl_not_u16_locked;
2964FNIEMAIMPLUNARYU16 iemAImpl_neg_u16, iemAImpl_neg_u16_locked;
2965/** @} */
2966
2967/** @name Arithmetic assignment operations on double words (unary).
2968 * @{ */
2969typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU32, (uint32_t *pu32Dst, uint32_t *pEFlags));
2970typedef FNIEMAIMPLUNARYU32 *PFNIEMAIMPLUNARYU32;
2971FNIEMAIMPLUNARYU32 iemAImpl_inc_u32, iemAImpl_inc_u32_locked;
2972FNIEMAIMPLUNARYU32 iemAImpl_dec_u32, iemAImpl_dec_u32_locked;
2973FNIEMAIMPLUNARYU32 iemAImpl_not_u32, iemAImpl_not_u32_locked;
2974FNIEMAIMPLUNARYU32 iemAImpl_neg_u32, iemAImpl_neg_u32_locked;
2975/** @} */
2976
2977/** @name Arithmetic assignment operations on quad words (unary).
2978 * @{ */
2979typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLUNARYU64, (uint64_t *pu64Dst, uint32_t *pEFlags));
2980typedef FNIEMAIMPLUNARYU64 *PFNIEMAIMPLUNARYU64;
2981FNIEMAIMPLUNARYU64 iemAImpl_inc_u64, iemAImpl_inc_u64_locked;
2982FNIEMAIMPLUNARYU64 iemAImpl_dec_u64, iemAImpl_dec_u64_locked;
2983FNIEMAIMPLUNARYU64 iemAImpl_not_u64, iemAImpl_not_u64_locked;
2984FNIEMAIMPLUNARYU64 iemAImpl_neg_u64, iemAImpl_neg_u64_locked;
2985/** @} */
2986
2987
2988/** @name Shift operations on bytes (Group 2).
2989 * @{ */
2990typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU8,(uint32_t fEFlagsIn, uint8_t *pu8Dst, uint8_t cShift));
2991typedef FNIEMAIMPLSHIFTU8 *PFNIEMAIMPLSHIFTU8;
2992FNIEMAIMPLSHIFTU8 iemAImpl_rol_u8, iemAImpl_rol_u8_amd, iemAImpl_rol_u8_intel;
2993FNIEMAIMPLSHIFTU8 iemAImpl_ror_u8, iemAImpl_ror_u8_amd, iemAImpl_ror_u8_intel;
2994FNIEMAIMPLSHIFTU8 iemAImpl_rcl_u8, iemAImpl_rcl_u8_amd, iemAImpl_rcl_u8_intel;
2995FNIEMAIMPLSHIFTU8 iemAImpl_rcr_u8, iemAImpl_rcr_u8_amd, iemAImpl_rcr_u8_intel;
2996FNIEMAIMPLSHIFTU8 iemAImpl_shl_u8, iemAImpl_shl_u8_amd, iemAImpl_shl_u8_intel;
2997FNIEMAIMPLSHIFTU8 iemAImpl_shr_u8, iemAImpl_shr_u8_amd, iemAImpl_shr_u8_intel;
2998FNIEMAIMPLSHIFTU8 iemAImpl_sar_u8, iemAImpl_sar_u8_amd, iemAImpl_sar_u8_intel;
2999/** @} */
3000
3001/** @name Shift operations on words (Group 2).
3002 * @{ */
3003typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU16,(uint32_t fEFlagsIn, uint16_t *pu16Dst, uint8_t cShift));
3004typedef FNIEMAIMPLSHIFTU16 *PFNIEMAIMPLSHIFTU16;
3005FNIEMAIMPLSHIFTU16 iemAImpl_rol_u16, iemAImpl_rol_u16_amd, iemAImpl_rol_u16_intel;
3006FNIEMAIMPLSHIFTU16 iemAImpl_ror_u16, iemAImpl_ror_u16_amd, iemAImpl_ror_u16_intel;
3007FNIEMAIMPLSHIFTU16 iemAImpl_rcl_u16, iemAImpl_rcl_u16_amd, iemAImpl_rcl_u16_intel;
3008FNIEMAIMPLSHIFTU16 iemAImpl_rcr_u16, iemAImpl_rcr_u16_amd, iemAImpl_rcr_u16_intel;
3009FNIEMAIMPLSHIFTU16 iemAImpl_shl_u16, iemAImpl_shl_u16_amd, iemAImpl_shl_u16_intel;
3010FNIEMAIMPLSHIFTU16 iemAImpl_shr_u16, iemAImpl_shr_u16_amd, iemAImpl_shr_u16_intel;
3011FNIEMAIMPLSHIFTU16 iemAImpl_sar_u16, iemAImpl_sar_u16_amd, iemAImpl_sar_u16_intel;
3012/** @} */
3013
3014/** @name Shift operations on double words (Group 2).
3015 * @{ */
3016typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU32,(uint32_t fEFlagsIn, uint32_t *pu32Dst, uint8_t cShift));
3017typedef FNIEMAIMPLSHIFTU32 *PFNIEMAIMPLSHIFTU32;
3018FNIEMAIMPLSHIFTU32 iemAImpl_rol_u32, iemAImpl_rol_u32_amd, iemAImpl_rol_u32_intel;
3019FNIEMAIMPLSHIFTU32 iemAImpl_ror_u32, iemAImpl_ror_u32_amd, iemAImpl_ror_u32_intel;
3020FNIEMAIMPLSHIFTU32 iemAImpl_rcl_u32, iemAImpl_rcl_u32_amd, iemAImpl_rcl_u32_intel;
3021FNIEMAIMPLSHIFTU32 iemAImpl_rcr_u32, iemAImpl_rcr_u32_amd, iemAImpl_rcr_u32_intel;
3022FNIEMAIMPLSHIFTU32 iemAImpl_shl_u32, iemAImpl_shl_u32_amd, iemAImpl_shl_u32_intel;
3023FNIEMAIMPLSHIFTU32 iemAImpl_shr_u32, iemAImpl_shr_u32_amd, iemAImpl_shr_u32_intel;
3024FNIEMAIMPLSHIFTU32 iemAImpl_sar_u32, iemAImpl_sar_u32_amd, iemAImpl_sar_u32_intel;
3025/** @} */
3026
3027/** @name Shift operations on words (Group 2).
3028 * @{ */
3029typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSHIFTU64,(uint32_t fEFlagsIn, uint64_t *pu64Dst, uint8_t cShift));
3030typedef FNIEMAIMPLSHIFTU64 *PFNIEMAIMPLSHIFTU64;
3031FNIEMAIMPLSHIFTU64 iemAImpl_rol_u64, iemAImpl_rol_u64_amd, iemAImpl_rol_u64_intel;
3032FNIEMAIMPLSHIFTU64 iemAImpl_ror_u64, iemAImpl_ror_u64_amd, iemAImpl_ror_u64_intel;
3033FNIEMAIMPLSHIFTU64 iemAImpl_rcl_u64, iemAImpl_rcl_u64_amd, iemAImpl_rcl_u64_intel;
3034FNIEMAIMPLSHIFTU64 iemAImpl_rcr_u64, iemAImpl_rcr_u64_amd, iemAImpl_rcr_u64_intel;
3035FNIEMAIMPLSHIFTU64 iemAImpl_shl_u64, iemAImpl_shl_u64_amd, iemAImpl_shl_u64_intel;
3036FNIEMAIMPLSHIFTU64 iemAImpl_shr_u64, iemAImpl_shr_u64_amd, iemAImpl_shr_u64_intel;
3037FNIEMAIMPLSHIFTU64 iemAImpl_sar_u64, iemAImpl_sar_u64_amd, iemAImpl_sar_u64_intel;
3038/** @} */
3039
3040/** @name Multiplication and division operations.
3041 * @{ */
3042typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU8,(uint16_t *pu16AX, uint8_t u8FactorDivisor, uint32_t *pEFlags));
3043typedef FNIEMAIMPLMULDIVU8 *PFNIEMAIMPLMULDIVU8;
3044FNIEMAIMPLMULDIVU8 iemAImpl_mul_u8, iemAImpl_mul_u8_amd, iemAImpl_mul_u8_intel;
3045FNIEMAIMPLMULDIVU8 iemAImpl_imul_u8, iemAImpl_imul_u8_amd, iemAImpl_imul_u8_intel;
3046FNIEMAIMPLMULDIVU8 iemAImpl_div_u8, iemAImpl_div_u8_amd, iemAImpl_div_u8_intel;
3047FNIEMAIMPLMULDIVU8 iemAImpl_idiv_u8, iemAImpl_idiv_u8_amd, iemAImpl_idiv_u8_intel;
3048
3049typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU16,(uint16_t *pu16AX, uint16_t *pu16DX, uint16_t u16FactorDivisor, uint32_t *pEFlags));
3050typedef FNIEMAIMPLMULDIVU16 *PFNIEMAIMPLMULDIVU16;
3051FNIEMAIMPLMULDIVU16 iemAImpl_mul_u16, iemAImpl_mul_u16_amd, iemAImpl_mul_u16_intel;
3052FNIEMAIMPLMULDIVU16 iemAImpl_imul_u16, iemAImpl_imul_u16_amd, iemAImpl_imul_u16_intel;
3053FNIEMAIMPLMULDIVU16 iemAImpl_div_u16, iemAImpl_div_u16_amd, iemAImpl_div_u16_intel;
3054FNIEMAIMPLMULDIVU16 iemAImpl_idiv_u16, iemAImpl_idiv_u16_amd, iemAImpl_idiv_u16_intel;
3055
3056typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU32,(uint32_t *pu32EAX, uint32_t *pu32EDX, uint32_t u32FactorDivisor, uint32_t *pEFlags));
3057typedef FNIEMAIMPLMULDIVU32 *PFNIEMAIMPLMULDIVU32;
3058FNIEMAIMPLMULDIVU32 iemAImpl_mul_u32, iemAImpl_mul_u32_amd, iemAImpl_mul_u32_intel;
3059FNIEMAIMPLMULDIVU32 iemAImpl_imul_u32, iemAImpl_imul_u32_amd, iemAImpl_imul_u32_intel;
3060FNIEMAIMPLMULDIVU32 iemAImpl_div_u32, iemAImpl_div_u32_amd, iemAImpl_div_u32_intel;
3061FNIEMAIMPLMULDIVU32 iemAImpl_idiv_u32, iemAImpl_idiv_u32_amd, iemAImpl_idiv_u32_intel;
3062
3063typedef IEM_DECL_IMPL_TYPE(int, FNIEMAIMPLMULDIVU64,(uint64_t *pu64RAX, uint64_t *pu64RDX, uint64_t u64FactorDivisor, uint32_t *pEFlags));
3064typedef FNIEMAIMPLMULDIVU64 *PFNIEMAIMPLMULDIVU64;
3065FNIEMAIMPLMULDIVU64 iemAImpl_mul_u64, iemAImpl_mul_u64_amd, iemAImpl_mul_u64_intel;
3066FNIEMAIMPLMULDIVU64 iemAImpl_imul_u64, iemAImpl_imul_u64_amd, iemAImpl_imul_u64_intel;
3067FNIEMAIMPLMULDIVU64 iemAImpl_div_u64, iemAImpl_div_u64_amd, iemAImpl_div_u64_intel;
3068FNIEMAIMPLMULDIVU64 iemAImpl_idiv_u64, iemAImpl_idiv_u64_amd, iemAImpl_idiv_u64_intel;
3069/** @} */
3070
3071/** @name Byte Swap.
3072 * @{ */
3073IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u16,(uint32_t *pu32Dst)); /* Yes, 32-bit register access. */
3074IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u32,(uint32_t *pu32Dst));
3075IEM_DECL_IMPL_TYPE(void, iemAImpl_bswap_u64,(uint64_t *pu64Dst));
3076/** @} */
3077
3078/** @name Misc.
3079 * @{ */
3080FNIEMAIMPLBINU16 iemAImpl_arpl;
3081/** @} */
3082
3083/** @name RDRAND and RDSEED
3084 * @{ */
3085typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU16,(uint16_t *puDst, uint32_t *pEFlags));
3086typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU32,(uint32_t *puDst, uint32_t *pEFlags));
3087typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLRDRANDSEEDU64,(uint64_t *puDst, uint32_t *pEFlags));
3088typedef FNIEMAIMPLRDRANDSEEDU16 *PFNIEMAIMPLRDRANDSEEDU16;
3089typedef FNIEMAIMPLRDRANDSEEDU32 *PFNIEMAIMPLRDRANDSEEDU32;
3090typedef FNIEMAIMPLRDRANDSEEDU64 *PFNIEMAIMPLRDRANDSEEDU64;
3091
3092FNIEMAIMPLRDRANDSEEDU16 iemAImpl_rdrand_u16, iemAImpl_rdrand_u16_fallback;
3093FNIEMAIMPLRDRANDSEEDU32 iemAImpl_rdrand_u32, iemAImpl_rdrand_u32_fallback;
3094FNIEMAIMPLRDRANDSEEDU64 iemAImpl_rdrand_u64, iemAImpl_rdrand_u64_fallback;
3095FNIEMAIMPLRDRANDSEEDU16 iemAImpl_rdseed_u16, iemAImpl_rdseed_u16_fallback;
3096FNIEMAIMPLRDRANDSEEDU32 iemAImpl_rdseed_u32, iemAImpl_rdseed_u32_fallback;
3097FNIEMAIMPLRDRANDSEEDU64 iemAImpl_rdseed_u64, iemAImpl_rdseed_u64_fallback;
3098/** @} */
3099
3100/** @name ADOX and ADCX
3101 * @{ */
3102FNIEMAIMPLBINU32 iemAImpl_adcx_u32, iemAImpl_adcx_u32_fallback;
3103FNIEMAIMPLBINU64 iemAImpl_adcx_u64, iemAImpl_adcx_u64_fallback;
3104FNIEMAIMPLBINU32 iemAImpl_adox_u32, iemAImpl_adox_u32_fallback;
3105FNIEMAIMPLBINU64 iemAImpl_adox_u64, iemAImpl_adox_u64_fallback;
3106/** @} */
3107
3108/** @name FPU operations taking a 32-bit float argument
3109 * @{ */
3110typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3111 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
3112typedef FNIEMAIMPLFPUR32FSW *PFNIEMAIMPLFPUR32FSW;
3113
3114typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3115 PCRTFLOAT80U pr80Val1, PCRTFLOAT32U pr32Val2));
3116typedef FNIEMAIMPLFPUR32 *PFNIEMAIMPLFPUR32;
3117
3118FNIEMAIMPLFPUR32FSW iemAImpl_fcom_r80_by_r32;
3119FNIEMAIMPLFPUR32 iemAImpl_fadd_r80_by_r32;
3120FNIEMAIMPLFPUR32 iemAImpl_fmul_r80_by_r32;
3121FNIEMAIMPLFPUR32 iemAImpl_fsub_r80_by_r32;
3122FNIEMAIMPLFPUR32 iemAImpl_fsubr_r80_by_r32;
3123FNIEMAIMPLFPUR32 iemAImpl_fdiv_r80_by_r32;
3124FNIEMAIMPLFPUR32 iemAImpl_fdivr_r80_by_r32;
3125
3126IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT32U pr32Val));
3127IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r32,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3128 PRTFLOAT32U pr32Val, PCRTFLOAT80U pr80Val));
3129/** @} */
3130
3131/** @name FPU operations taking a 64-bit float argument
3132 * @{ */
3133typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3134 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
3135typedef FNIEMAIMPLFPUR64FSW *PFNIEMAIMPLFPUR64FSW;
3136
3137typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3138 PCRTFLOAT80U pr80Val1, PCRTFLOAT64U pr64Val2));
3139typedef FNIEMAIMPLFPUR64 *PFNIEMAIMPLFPUR64;
3140
3141FNIEMAIMPLFPUR64FSW iemAImpl_fcom_r80_by_r64;
3142FNIEMAIMPLFPUR64 iemAImpl_fadd_r80_by_r64;
3143FNIEMAIMPLFPUR64 iemAImpl_fmul_r80_by_r64;
3144FNIEMAIMPLFPUR64 iemAImpl_fsub_r80_by_r64;
3145FNIEMAIMPLFPUR64 iemAImpl_fsubr_r80_by_r64;
3146FNIEMAIMPLFPUR64 iemAImpl_fdiv_r80_by_r64;
3147FNIEMAIMPLFPUR64 iemAImpl_fdivr_r80_by_r64;
3148
3149IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT64U pr64Val));
3150IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r64,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3151 PRTFLOAT64U pr32Val, PCRTFLOAT80U pr80Val));
3152/** @} */
3153
3154/** @name FPU operations taking a 80-bit float argument
3155 * @{ */
3156typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3157 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
3158typedef FNIEMAIMPLFPUR80 *PFNIEMAIMPLFPUR80;
3159FNIEMAIMPLFPUR80 iemAImpl_fadd_r80_by_r80;
3160FNIEMAIMPLFPUR80 iemAImpl_fmul_r80_by_r80;
3161FNIEMAIMPLFPUR80 iemAImpl_fsub_r80_by_r80;
3162FNIEMAIMPLFPUR80 iemAImpl_fsubr_r80_by_r80;
3163FNIEMAIMPLFPUR80 iemAImpl_fdiv_r80_by_r80;
3164FNIEMAIMPLFPUR80 iemAImpl_fdivr_r80_by_r80;
3165FNIEMAIMPLFPUR80 iemAImpl_fprem_r80_by_r80;
3166FNIEMAIMPLFPUR80 iemAImpl_fprem1_r80_by_r80;
3167FNIEMAIMPLFPUR80 iemAImpl_fscale_r80_by_r80;
3168
3169FNIEMAIMPLFPUR80 iemAImpl_fpatan_r80_by_r80, iemAImpl_fpatan_r80_by_r80_amd, iemAImpl_fpatan_r80_by_r80_intel;
3170FNIEMAIMPLFPUR80 iemAImpl_fyl2x_r80_by_r80, iemAImpl_fyl2x_r80_by_r80_amd, iemAImpl_fyl2x_r80_by_r80_intel;
3171FNIEMAIMPLFPUR80 iemAImpl_fyl2xp1_r80_by_r80, iemAImpl_fyl2xp1_r80_by_r80_amd, iemAImpl_fyl2xp1_r80_by_r80_intel;
3172
3173typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3174 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
3175typedef FNIEMAIMPLFPUR80FSW *PFNIEMAIMPLFPUR80FSW;
3176FNIEMAIMPLFPUR80FSW iemAImpl_fcom_r80_by_r80;
3177FNIEMAIMPLFPUR80FSW iemAImpl_fucom_r80_by_r80;
3178
3179typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPUR80EFL,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw,
3180 PCRTFLOAT80U pr80Val1, PCRTFLOAT80U pr80Val2));
3181typedef FNIEMAIMPLFPUR80EFL *PFNIEMAIMPLFPUR80EFL;
3182FNIEMAIMPLFPUR80EFL iemAImpl_fcomi_r80_by_r80;
3183FNIEMAIMPLFPUR80EFL iemAImpl_fucomi_r80_by_r80;
3184
3185typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARY,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
3186typedef FNIEMAIMPLFPUR80UNARY *PFNIEMAIMPLFPUR80UNARY;
3187FNIEMAIMPLFPUR80UNARY iemAImpl_fabs_r80;
3188FNIEMAIMPLFPUR80UNARY iemAImpl_fchs_r80;
3189FNIEMAIMPLFPUR80UNARY iemAImpl_f2xm1_r80, iemAImpl_f2xm1_r80_amd, iemAImpl_f2xm1_r80_intel;
3190FNIEMAIMPLFPUR80UNARY iemAImpl_fsqrt_r80;
3191FNIEMAIMPLFPUR80UNARY iemAImpl_frndint_r80;
3192FNIEMAIMPLFPUR80UNARY iemAImpl_fsin_r80, iemAImpl_fsin_r80_amd, iemAImpl_fsin_r80_intel;
3193FNIEMAIMPLFPUR80UNARY iemAImpl_fcos_r80, iemAImpl_fcos_r80_amd, iemAImpl_fcos_r80_intel;
3194
3195typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYFSW,(PCX86FXSTATE pFpuState, uint16_t *pu16Fsw, PCRTFLOAT80U pr80Val));
3196typedef FNIEMAIMPLFPUR80UNARYFSW *PFNIEMAIMPLFPUR80UNARYFSW;
3197FNIEMAIMPLFPUR80UNARYFSW iemAImpl_ftst_r80;
3198FNIEMAIMPLFPUR80UNARYFSW iemAImpl_fxam_r80;
3199
3200typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80LDCONST,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes));
3201typedef FNIEMAIMPLFPUR80LDCONST *PFNIEMAIMPLFPUR80LDCONST;
3202FNIEMAIMPLFPUR80LDCONST iemAImpl_fld1;
3203FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2t;
3204FNIEMAIMPLFPUR80LDCONST iemAImpl_fldl2e;
3205FNIEMAIMPLFPUR80LDCONST iemAImpl_fldpi;
3206FNIEMAIMPLFPUR80LDCONST iemAImpl_fldlg2;
3207FNIEMAIMPLFPUR80LDCONST iemAImpl_fldln2;
3208FNIEMAIMPLFPUR80LDCONST iemAImpl_fldz;
3209
3210typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUR80UNARYTWO,(PCX86FXSTATE pFpuState, PIEMFPURESULTTWO pFpuResTwo,
3211 PCRTFLOAT80U pr80Val));
3212typedef FNIEMAIMPLFPUR80UNARYTWO *PFNIEMAIMPLFPUR80UNARYTWO;
3213FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fptan_r80_r80, iemAImpl_fptan_r80_r80_amd, iemAImpl_fptan_r80_r80_intel;
3214FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fxtract_r80_r80;
3215FNIEMAIMPLFPUR80UNARYTWO iemAImpl_fsincos_r80_r80, iemAImpl_fsincos_r80_r80_amd, iemAImpl_fsincos_r80_r80_intel;
3216
3217IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_r80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTFLOAT80U pr80Val));
3218IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_r80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3219 PRTFLOAT80U pr80Dst, PCRTFLOAT80U pr80Src));
3220
3221IEM_DECL_IMPL_DEF(void, iemAImpl_fld_r80_from_d80,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, PCRTPBCD80U pd80Val));
3222IEM_DECL_IMPL_DEF(void, iemAImpl_fst_r80_to_d80,(PCX86FXSTATE pFpuState, uint16_t *pu16FSW,
3223 PRTPBCD80U pd80Dst, PCRTFLOAT80U pr80Src));
3224
3225/** @} */
3226
3227/** @name FPU operations taking a 16-bit signed integer argument
3228 * @{ */
3229typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3230 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
3231typedef FNIEMAIMPLFPUI16 *PFNIEMAIMPLFPUI16;
3232typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI16,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
3233 int16_t *pi16Dst, PCRTFLOAT80U pr80Src));
3234typedef FNIEMAIMPLFPUSTR80TOI16 *PFNIEMAIMPLFPUSTR80TOI16;
3235
3236FNIEMAIMPLFPUI16 iemAImpl_fiadd_r80_by_i16;
3237FNIEMAIMPLFPUI16 iemAImpl_fimul_r80_by_i16;
3238FNIEMAIMPLFPUI16 iemAImpl_fisub_r80_by_i16;
3239FNIEMAIMPLFPUI16 iemAImpl_fisubr_r80_by_i16;
3240FNIEMAIMPLFPUI16 iemAImpl_fidiv_r80_by_i16;
3241FNIEMAIMPLFPUI16 iemAImpl_fidivr_r80_by_i16;
3242
3243typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI16FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3244 PCRTFLOAT80U pr80Val1, int16_t const *pi16Val2));
3245typedef FNIEMAIMPLFPUI16FSW *PFNIEMAIMPLFPUI16FSW;
3246FNIEMAIMPLFPUI16FSW iemAImpl_ficom_r80_by_i16;
3247
3248IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i16,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int16_t const *pi16Val));
3249FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fist_r80_to_i16;
3250FNIEMAIMPLFPUSTR80TOI16 iemAImpl_fistt_r80_to_i16, iemAImpl_fistt_r80_to_i16_amd, iemAImpl_fistt_r80_to_i16_intel;
3251/** @} */
3252
3253/** @name FPU operations taking a 32-bit signed integer argument
3254 * @{ */
3255typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes,
3256 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
3257typedef FNIEMAIMPLFPUI32 *PFNIEMAIMPLFPUI32;
3258typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI32,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
3259 int32_t *pi32Dst, PCRTFLOAT80U pr80Src));
3260typedef FNIEMAIMPLFPUSTR80TOI32 *PFNIEMAIMPLFPUSTR80TOI32;
3261
3262FNIEMAIMPLFPUI32 iemAImpl_fiadd_r80_by_i32;
3263FNIEMAIMPLFPUI32 iemAImpl_fimul_r80_by_i32;
3264FNIEMAIMPLFPUI32 iemAImpl_fisub_r80_by_i32;
3265FNIEMAIMPLFPUI32 iemAImpl_fisubr_r80_by_i32;
3266FNIEMAIMPLFPUI32 iemAImpl_fidiv_r80_by_i32;
3267FNIEMAIMPLFPUI32 iemAImpl_fidivr_r80_by_i32;
3268
3269typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUI32FSW,(PCX86FXSTATE pFpuState, uint16_t *pFSW,
3270 PCRTFLOAT80U pr80Val1, int32_t const *pi32Val2));
3271typedef FNIEMAIMPLFPUI32FSW *PFNIEMAIMPLFPUI32FSW;
3272FNIEMAIMPLFPUI32FSW iemAImpl_ficom_r80_by_i32;
3273
3274IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i32,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int32_t const *pi32Val));
3275FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fist_r80_to_i32;
3276FNIEMAIMPLFPUSTR80TOI32 iemAImpl_fistt_r80_to_i32;
3277/** @} */
3278
3279/** @name FPU operations taking a 64-bit signed integer argument
3280 * @{ */
3281typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLFPUSTR80TOI64,(PCX86FXSTATE pFpuState, uint16_t *pFpuRes,
3282 int64_t *pi64Dst, PCRTFLOAT80U pr80Src));
3283typedef FNIEMAIMPLFPUSTR80TOI64 *PFNIEMAIMPLFPUSTR80TOI64;
3284
3285IEM_DECL_IMPL_DEF(void, iemAImpl_fild_r80_from_i64,(PCX86FXSTATE pFpuState, PIEMFPURESULT pFpuRes, int64_t const *pi64Val));
3286FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fist_r80_to_i64;
3287FNIEMAIMPLFPUSTR80TOI64 iemAImpl_fistt_r80_to_i64;
3288/** @} */
3289
3290
3291/** Temporary type representing a 256-bit vector register. */
3292typedef struct { uint64_t au64[4]; } IEMVMM256;
3293/** Temporary type pointing to a 256-bit vector register. */
3294typedef IEMVMM256 *PIEMVMM256;
3295/** Temporary type pointing to a const 256-bit vector register. */
3296typedef IEMVMM256 *PCIEMVMM256;
3297
3298
3299/** @name Media (SSE/MMX/AVX) operations: full1 + full2 -> full1.
3300 * @{ */
3301typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U64,(PCX86FXSTATE pFpuState, uint64_t *puDst, uint64_t const *puSrc));
3302typedef FNIEMAIMPLMEDIAF2U64 *PFNIEMAIMPLMEDIAF2U64;
3303typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF2U128,(PCX86FXSTATE pFpuState, PRTUINT128U puDst, PCRTUINT128U puSrc));
3304typedef FNIEMAIMPLMEDIAF2U128 *PFNIEMAIMPLMEDIAF2U128;
3305typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF3U128,(PX86XSAVEAREA pExtState, PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2));
3306typedef FNIEMAIMPLMEDIAF3U128 *PFNIEMAIMPLMEDIAF3U128;
3307typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAF3U256,(PX86XSAVEAREA pExtState, PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2));
3308typedef FNIEMAIMPLMEDIAF3U256 *PFNIEMAIMPLMEDIAF3U256;
3309typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U64,(uint64_t *puDst, uint64_t const *puSrc));
3310typedef FNIEMAIMPLMEDIAOPTF2U64 *PFNIEMAIMPLMEDIAOPTF2U64;
3311typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U128,(PRTUINT128U puDst, PCRTUINT128U puSrc));
3312typedef FNIEMAIMPLMEDIAOPTF2U128 *PFNIEMAIMPLMEDIAOPTF2U128;
3313typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2));
3314typedef FNIEMAIMPLMEDIAOPTF3U128 *PFNIEMAIMPLMEDIAOPTF3U128;
3315typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2));
3316typedef FNIEMAIMPLMEDIAOPTF3U256 *PFNIEMAIMPLMEDIAOPTF3U256;
3317typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U256,(PRTUINT256U puDst, PCRTUINT256U puSrc));
3318typedef FNIEMAIMPLMEDIAOPTF2U256 *PFNIEMAIMPLMEDIAOPTF2U256;
3319FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pshufb_u64, iemAImpl_pshufb_u64_fallback;
3320FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pand_u64, iemAImpl_pandn_u64, iemAImpl_por_u64, iemAImpl_pxor_u64;
3321FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pcmpeqb_u64, iemAImpl_pcmpeqw_u64, iemAImpl_pcmpeqd_u64;
3322FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pcmpgtb_u64, iemAImpl_pcmpgtw_u64, iemAImpl_pcmpgtd_u64;
3323FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddb_u64, iemAImpl_paddsb_u64, iemAImpl_paddusb_u64;
3324FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddw_u64, iemAImpl_paddsw_u64, iemAImpl_paddusw_u64;
3325FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddd_u64;
3326FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_paddq_u64;
3327FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubb_u64, iemAImpl_psubsb_u64, iemAImpl_psubusb_u64;
3328FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubw_u64, iemAImpl_psubsw_u64, iemAImpl_psubusw_u64;
3329FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubd_u64;
3330FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psubq_u64;
3331FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmaddwd_u64, iemAImpl_pmaddwd_u64_fallback;
3332FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmullw_u64, iemAImpl_pmulhw_u64;
3333FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pminub_u64, iemAImpl_pmaxub_u64;
3334FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pminsw_u64, iemAImpl_pmaxsw_u64;
3335FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pabsb_u64, iemAImpl_pabsb_u64_fallback;
3336FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pabsw_u64, iemAImpl_pabsw_u64_fallback;
3337FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pabsd_u64, iemAImpl_pabsd_u64_fallback;
3338FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psignb_u64, iemAImpl_psignb_u64_fallback;
3339FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psignw_u64, iemAImpl_psignw_u64_fallback;
3340FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psignd_u64, iemAImpl_psignd_u64_fallback;
3341FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phaddw_u64, iemAImpl_phaddw_u64_fallback;
3342FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phaddd_u64, iemAImpl_phaddd_u64_fallback;
3343FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phsubw_u64, iemAImpl_phsubw_u64_fallback;
3344FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phsubd_u64, iemAImpl_phsubd_u64_fallback;
3345FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phaddsw_u64, iemAImpl_phaddsw_u64_fallback;
3346FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_phsubsw_u64, iemAImpl_phsubsw_u64_fallback;
3347FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmaddubsw_u64, iemAImpl_pmaddubsw_u64_fallback;
3348FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmulhrsw_u64, iemAImpl_pmulhrsw_u64_fallback;
3349FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmuludq_u64;
3350FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psllw_u64, iemAImpl_psrlw_u64, iemAImpl_psraw_u64;
3351FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pslld_u64, iemAImpl_psrld_u64, iemAImpl_psrad_u64;
3352FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psllq_u64, iemAImpl_psrlq_u64;
3353FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_packsswb_u64, iemAImpl_packuswb_u64;
3354FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_packssdw_u64;
3355FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pmulhuw_u64;
3356FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_pavgb_u64, iemAImpl_pavgw_u64;
3357FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_psadbw_u64;
3358
3359FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pshufb_u128, iemAImpl_pshufb_u128_fallback;
3360FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pand_u128, iemAImpl_pandn_u128, iemAImpl_por_u128, iemAImpl_pxor_u128;
3361FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpeqb_u128, iemAImpl_pcmpeqw_u128, iemAImpl_pcmpeqd_u128;
3362FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpeqq_u128, iemAImpl_pcmpeqq_u128_fallback;
3363FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpgtb_u128, iemAImpl_pcmpgtw_u128, iemAImpl_pcmpgtd_u128;
3364FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pcmpgtq_u128, iemAImpl_pcmpgtq_u128_fallback;
3365FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddb_u128, iemAImpl_paddsb_u128, iemAImpl_paddusb_u128;
3366FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddw_u128, iemAImpl_paddsw_u128, iemAImpl_paddusw_u128;
3367FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddd_u128;
3368FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_paddq_u128;
3369FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubb_u128, iemAImpl_psubsb_u128, iemAImpl_psubusb_u128;
3370FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubw_u128, iemAImpl_psubsw_u128, iemAImpl_psubusw_u128;
3371FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubd_u128;
3372FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psubq_u128;
3373FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmullw_u128, iemAImpl_pmullw_u128_fallback;
3374FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhw_u128;
3375FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulld_u128, iemAImpl_pmulld_u128_fallback;
3376FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaddwd_u128, iemAImpl_pmaddwd_u128_fallback;
3377FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminub_u128;
3378FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminud_u128, iemAImpl_pminud_u128_fallback;
3379FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminuw_u128, iemAImpl_pminuw_u128_fallback;
3380FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminsb_u128, iemAImpl_pminsb_u128_fallback;
3381FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminsd_u128, iemAImpl_pminsd_u128_fallback;
3382FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pminsw_u128, iemAImpl_pminsw_u128_fallback;
3383FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxub_u128;
3384FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxud_u128, iemAImpl_pmaxud_u128_fallback;
3385FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxuw_u128, iemAImpl_pmaxuw_u128_fallback;
3386FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxsb_u128, iemAImpl_pmaxsb_u128_fallback;
3387FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxsw_u128;
3388FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaxsd_u128, iemAImpl_pmaxsd_u128_fallback;
3389FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pabsb_u128, iemAImpl_pabsb_u128_fallback;
3390FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pabsw_u128, iemAImpl_pabsw_u128_fallback;
3391FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pabsd_u128, iemAImpl_pabsd_u128_fallback;
3392FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psignb_u128, iemAImpl_psignb_u128_fallback;
3393FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psignw_u128, iemAImpl_psignw_u128_fallback;
3394FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psignd_u128, iemAImpl_psignd_u128_fallback;
3395FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phaddw_u128, iemAImpl_phaddw_u128_fallback;
3396FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phaddd_u128, iemAImpl_phaddd_u128_fallback;
3397FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phsubw_u128, iemAImpl_phsubw_u128_fallback;
3398FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phsubd_u128, iemAImpl_phsubd_u128_fallback;
3399FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phaddsw_u128, iemAImpl_phaddsw_u128_fallback;
3400FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phsubsw_u128, iemAImpl_phsubsw_u128_fallback;
3401FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaddubsw_u128, iemAImpl_pmaddubsw_u128_fallback;
3402FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhrsw_u128, iemAImpl_pmulhrsw_u128_fallback;
3403FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmuludq_u128;
3404FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmaddwd_u128, iemAImpl_pmaddwd_u128_fallback;
3405FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_packsswb_u128, iemAImpl_packuswb_u128;
3406FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_packssdw_u128, iemAImpl_packusdw_u128;
3407FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psllw_u128, iemAImpl_psrlw_u128, iemAImpl_psraw_u128;
3408FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pslld_u128, iemAImpl_psrld_u128, iemAImpl_psrad_u128;
3409FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psllq_u128, iemAImpl_psrlq_u128;
3410FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmulhuw_u128;
3411FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pavgb_u128, iemAImpl_pavgw_u128;
3412FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_psadbw_u128;
3413FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_pmuldq_u128, iemAImpl_pmuldq_u128_fallback;
3414FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_unpcklps_u128, iemAImpl_unpcklpd_u128;
3415FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_unpckhps_u128, iemAImpl_unpckhpd_u128;
3416FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_phminposuw_u128, iemAImpl_phminposuw_u128_fallback;
3417
3418FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpshufb_u128, iemAImpl_vpshufb_u128_fallback;
3419FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpand_u128, iemAImpl_vpand_u128_fallback;
3420FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpandn_u128, iemAImpl_vpandn_u128_fallback;
3421FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpor_u128, iemAImpl_vpor_u128_fallback;
3422FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpxor_u128, iemAImpl_vpxor_u128_fallback;
3423FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqb_u128, iemAImpl_vpcmpeqb_u128_fallback;
3424FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqw_u128, iemAImpl_vpcmpeqw_u128_fallback;
3425FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqd_u128, iemAImpl_vpcmpeqd_u128_fallback;
3426FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpeqq_u128, iemAImpl_vpcmpeqq_u128_fallback;
3427FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtb_u128, iemAImpl_vpcmpgtb_u128_fallback;
3428FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtw_u128, iemAImpl_vpcmpgtw_u128_fallback;
3429FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtd_u128, iemAImpl_vpcmpgtd_u128_fallback;
3430FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpcmpgtq_u128, iemAImpl_vpcmpgtq_u128_fallback;
3431FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddb_u128, iemAImpl_vpaddb_u128_fallback;
3432FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddw_u128, iemAImpl_vpaddw_u128_fallback;
3433FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddd_u128, iemAImpl_vpaddd_u128_fallback;
3434FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddq_u128, iemAImpl_vpaddq_u128_fallback;
3435FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubb_u128, iemAImpl_vpsubb_u128_fallback;
3436FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubw_u128, iemAImpl_vpsubw_u128_fallback;
3437FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubd_u128, iemAImpl_vpsubd_u128_fallback;
3438FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubq_u128, iemAImpl_vpsubq_u128_fallback;
3439FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminub_u128, iemAImpl_vpminub_u128_fallback;
3440FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminuw_u128, iemAImpl_vpminuw_u128_fallback;
3441FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminud_u128, iemAImpl_vpminud_u128_fallback;
3442FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminsb_u128, iemAImpl_vpminsb_u128_fallback;
3443FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminsw_u128, iemAImpl_vpminsw_u128_fallback;
3444FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpminsd_u128, iemAImpl_vpminsd_u128_fallback;
3445FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxub_u128, iemAImpl_vpmaxub_u128_fallback;
3446FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxuw_u128, iemAImpl_vpmaxuw_u128_fallback;
3447FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxud_u128, iemAImpl_vpmaxud_u128_fallback;
3448FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxsb_u128, iemAImpl_vpmaxsb_u128_fallback;
3449FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxsw_u128, iemAImpl_vpmaxsw_u128_fallback;
3450FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaxsd_u128, iemAImpl_vpmaxsd_u128_fallback;
3451FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpacksswb_u128, iemAImpl_vpacksswb_u128_fallback;
3452FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackssdw_u128, iemAImpl_vpackssdw_u128_fallback;
3453FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackuswb_u128, iemAImpl_vpackuswb_u128_fallback;
3454FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpackusdw_u128, iemAImpl_vpackusdw_u128_fallback;
3455FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmullw_u128, iemAImpl_vpmullw_u128_fallback;
3456FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulld_u128, iemAImpl_vpmulld_u128_fallback;
3457FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhw_u128, iemAImpl_vpmulhw_u128_fallback;
3458FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhuw_u128, iemAImpl_vpmulhuw_u128_fallback;
3459FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpavgb_u128, iemAImpl_vpavgb_u128_fallback;
3460FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpavgw_u128, iemAImpl_vpavgw_u128_fallback;
3461FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignb_u128, iemAImpl_vpsignb_u128_fallback;
3462FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignw_u128, iemAImpl_vpsignw_u128_fallback;
3463FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsignd_u128, iemAImpl_vpsignd_u128_fallback;
3464FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddw_u128, iemAImpl_vphaddw_u128_fallback;
3465FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddd_u128, iemAImpl_vphaddd_u128_fallback;
3466FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubw_u128, iemAImpl_vphsubw_u128_fallback;
3467FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubd_u128, iemAImpl_vphsubd_u128_fallback;
3468FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphaddsw_u128, iemAImpl_vphaddsw_u128_fallback;
3469FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vphsubsw_u128, iemAImpl_vphsubsw_u128_fallback;
3470FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaddubsw_u128, iemAImpl_vpmaddubsw_u128_fallback;
3471FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmulhrsw_u128, iemAImpl_vpmulhrsw_u128_fallback;
3472FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsadbw_u128, iemAImpl_vpsadbw_u128_fallback;
3473FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmuldq_u128, iemAImpl_vpmuldq_u128_fallback;
3474FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmuludq_u128, iemAImpl_vpmuludq_u128_fallback;
3475FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubsb_u128, iemAImpl_vpsubsb_u128_fallback;
3476FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubsw_u128, iemAImpl_vpsubsw_u128_fallback;
3477FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubusb_u128, iemAImpl_vpsubusb_u128_fallback;
3478FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsubusw_u128, iemAImpl_vpsubusw_u128_fallback;
3479FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddusb_u128, iemAImpl_vpaddusb_u128_fallback;
3480FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddusw_u128, iemAImpl_vpaddusw_u128_fallback;
3481FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddsb_u128, iemAImpl_vpaddsb_u128_fallback;
3482FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpaddsw_u128, iemAImpl_vpaddsw_u128_fallback;
3483FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllw_u128, iemAImpl_vpsllw_u128_fallback;
3484FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpslld_u128, iemAImpl_vpslld_u128_fallback;
3485FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllq_u128, iemAImpl_vpsllq_u128_fallback;
3486FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsraw_u128, iemAImpl_vpsraw_u128_fallback;
3487FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrad_u128, iemAImpl_vpsrad_u128_fallback;
3488FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlw_u128, iemAImpl_vpsrlw_u128_fallback;
3489FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrld_u128, iemAImpl_vpsrld_u128_fallback;
3490FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlq_u128, iemAImpl_vpsrlq_u128_fallback;
3491FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpmaddwd_u128, iemAImpl_vpmaddwd_u128_fallback;
3492
3493FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsb_u128, iemAImpl_vpabsb_u128_fallback;
3494FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsw_u128, iemAImpl_vpabsd_u128_fallback;
3495FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vpabsd_u128, iemAImpl_vpabsw_u128_fallback;
3496FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vphminposuw_u128, iemAImpl_vphminposuw_u128_fallback;
3497
3498FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpshufb_u256, iemAImpl_vpshufb_u256_fallback;
3499FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpand_u256, iemAImpl_vpand_u256_fallback;
3500FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpandn_u256, iemAImpl_vpandn_u256_fallback;
3501FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpor_u256, iemAImpl_vpor_u256_fallback;
3502FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpxor_u256, iemAImpl_vpxor_u256_fallback;
3503FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqb_u256, iemAImpl_vpcmpeqb_u256_fallback;
3504FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqw_u256, iemAImpl_vpcmpeqw_u256_fallback;
3505FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqd_u256, iemAImpl_vpcmpeqd_u256_fallback;
3506FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpeqq_u256, iemAImpl_vpcmpeqq_u256_fallback;
3507FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtb_u256, iemAImpl_vpcmpgtb_u256_fallback;
3508FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtw_u256, iemAImpl_vpcmpgtw_u256_fallback;
3509FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtd_u256, iemAImpl_vpcmpgtd_u256_fallback;
3510FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpcmpgtq_u256, iemAImpl_vpcmpgtq_u256_fallback;
3511FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddb_u256, iemAImpl_vpaddb_u256_fallback;
3512FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddw_u256, iemAImpl_vpaddw_u256_fallback;
3513FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddd_u256, iemAImpl_vpaddd_u256_fallback;
3514FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddq_u256, iemAImpl_vpaddq_u256_fallback;
3515FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubb_u256, iemAImpl_vpsubb_u256_fallback;
3516FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubw_u256, iemAImpl_vpsubw_u256_fallback;
3517FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubd_u256, iemAImpl_vpsubd_u256_fallback;
3518FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubq_u256, iemAImpl_vpsubq_u256_fallback;
3519FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminub_u256, iemAImpl_vpminub_u256_fallback;
3520FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminuw_u256, iemAImpl_vpminuw_u256_fallback;
3521FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminud_u256, iemAImpl_vpminud_u256_fallback;
3522FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminsb_u256, iemAImpl_vpminsb_u256_fallback;
3523FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminsw_u256, iemAImpl_vpminsw_u256_fallback;
3524FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpminsd_u256, iemAImpl_vpminsd_u256_fallback;
3525FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxub_u256, iemAImpl_vpmaxub_u256_fallback;
3526FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxuw_u256, iemAImpl_vpmaxuw_u256_fallback;
3527FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxud_u256, iemAImpl_vpmaxud_u256_fallback;
3528FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxsb_u256, iemAImpl_vpmaxsb_u256_fallback;
3529FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxsw_u256, iemAImpl_vpmaxsw_u256_fallback;
3530FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaxsd_u256, iemAImpl_vpmaxsd_u256_fallback;
3531FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpacksswb_u256, iemAImpl_vpacksswb_u256_fallback;
3532FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackssdw_u256, iemAImpl_vpackssdw_u256_fallback;
3533FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackuswb_u256, iemAImpl_vpackuswb_u256_fallback;
3534FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpackusdw_u256, iemAImpl_vpackusdw_u256_fallback;
3535FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmullw_u256, iemAImpl_vpmullw_u256_fallback;
3536FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulld_u256, iemAImpl_vpmulld_u256_fallback;
3537FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhw_u256, iemAImpl_vpmulhw_u256_fallback;
3538FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhuw_u256, iemAImpl_vpmulhuw_u256_fallback;
3539FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpavgb_u256, iemAImpl_vpavgb_u256_fallback;
3540FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpavgw_u256, iemAImpl_vpavgw_u256_fallback;
3541FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignb_u256, iemAImpl_vpsignb_u256_fallback;
3542FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignw_u256, iemAImpl_vpsignw_u256_fallback;
3543FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsignd_u256, iemAImpl_vpsignd_u256_fallback;
3544FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddw_u256, iemAImpl_vphaddw_u256_fallback;
3545FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddd_u256, iemAImpl_vphaddd_u256_fallback;
3546FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubw_u256, iemAImpl_vphsubw_u256_fallback;
3547FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubd_u256, iemAImpl_vphsubd_u256_fallback;
3548FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphaddsw_u256, iemAImpl_vphaddsw_u256_fallback;
3549FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vphsubsw_u256, iemAImpl_vphsubsw_u256_fallback;
3550FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaddubsw_u256, iemAImpl_vpmaddubsw_u256_fallback;
3551FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmulhrsw_u256, iemAImpl_vpmulhrsw_u256_fallback;
3552FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsadbw_u256, iemAImpl_vpsadbw_u256_fallback;
3553FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmuldq_u256, iemAImpl_vpmuldq_u256_fallback;
3554FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmuludq_u256, iemAImpl_vpmuludq_u256_fallback;
3555FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubsb_u256, iemAImpl_vpsubsb_u256_fallback;
3556FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubsw_u256, iemAImpl_vpsubsw_u256_fallback;
3557FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubusb_u256, iemAImpl_vpsubusb_u256_fallback;
3558FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsubusw_u256, iemAImpl_vpsubusw_u256_fallback;
3559FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddusb_u256, iemAImpl_vpaddusb_u256_fallback;
3560FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddusw_u256, iemAImpl_vpaddusw_u256_fallback;
3561FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddsb_u256, iemAImpl_vpaddsb_u256_fallback;
3562FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpaddsw_u256, iemAImpl_vpaddsw_u256_fallback;
3563FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllw_u256, iemAImpl_vpsllw_u256_fallback;
3564FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpslld_u256, iemAImpl_vpslld_u256_fallback;
3565FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllq_u256, iemAImpl_vpsllq_u256_fallback;
3566FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsraw_u256, iemAImpl_vpsraw_u256_fallback;
3567FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrad_u256, iemAImpl_vpsrad_u256_fallback;
3568FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlw_u256, iemAImpl_vpsrlw_u256_fallback;
3569FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrld_u256, iemAImpl_vpsrld_u256_fallback;
3570FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlq_u256, iemAImpl_vpsrlq_u256_fallback;
3571FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpmaddwd_u256, iemAImpl_vpmaddwd_u256_fallback;
3572
3573FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsb_u256, iemAImpl_vpabsb_u256_fallback;
3574FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsw_u256, iemAImpl_vpabsw_u256_fallback;
3575FNIEMAIMPLMEDIAOPTF2U256 iemAImpl_vpabsd_u256, iemAImpl_vpabsd_u256_fallback;
3576/** @} */
3577
3578/** @name Media (SSE/MMX/AVX) operations: lowhalf1 + lowhalf1 -> full1.
3579 * @{ */
3580FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_punpcklbw_u64, iemAImpl_punpcklwd_u64, iemAImpl_punpckldq_u64;
3581FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_punpcklbw_u128, iemAImpl_punpcklwd_u128, iemAImpl_punpckldq_u128, iemAImpl_punpcklqdq_u128;
3582FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpunpcklbw_u128, iemAImpl_vpunpcklbw_u128_fallback,
3583 iemAImpl_vpunpcklwd_u128, iemAImpl_vpunpcklwd_u128_fallback,
3584 iemAImpl_vpunpckldq_u128, iemAImpl_vpunpckldq_u128_fallback,
3585 iemAImpl_vpunpcklqdq_u128, iemAImpl_vpunpcklqdq_u128_fallback,
3586 iemAImpl_vunpcklps_u128, iemAImpl_vunpcklps_u128_fallback,
3587 iemAImpl_vunpcklpd_u128, iemAImpl_vunpcklpd_u128_fallback,
3588 iemAImpl_vunpckhps_u128, iemAImpl_vunpckhps_u128_fallback,
3589 iemAImpl_vunpckhpd_u128, iemAImpl_vunpckhpd_u128_fallback;
3590
3591FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpunpcklbw_u256, iemAImpl_vpunpcklbw_u256_fallback,
3592 iemAImpl_vpunpcklwd_u256, iemAImpl_vpunpcklwd_u256_fallback,
3593 iemAImpl_vpunpckldq_u256, iemAImpl_vpunpckldq_u256_fallback,
3594 iemAImpl_vpunpcklqdq_u256, iemAImpl_vpunpcklqdq_u256_fallback,
3595 iemAImpl_vunpcklps_u256, iemAImpl_vunpcklps_u256_fallback,
3596 iemAImpl_vunpcklpd_u256, iemAImpl_vunpcklpd_u256_fallback,
3597 iemAImpl_vunpckhps_u256, iemAImpl_vunpckhps_u256_fallback,
3598 iemAImpl_vunpckhpd_u256, iemAImpl_vunpckhpd_u256_fallback;
3599/** @} */
3600
3601/** @name Media (SSE/MMX/AVX) operations: hihalf1 + hihalf2 -> full1.
3602 * @{ */
3603FNIEMAIMPLMEDIAOPTF2U64 iemAImpl_punpckhbw_u64, iemAImpl_punpckhwd_u64, iemAImpl_punpckhdq_u64;
3604FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_punpckhbw_u128, iemAImpl_punpckhwd_u128, iemAImpl_punpckhdq_u128, iemAImpl_punpckhqdq_u128;
3605FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpunpckhbw_u128, iemAImpl_vpunpckhbw_u128_fallback,
3606 iemAImpl_vpunpckhwd_u128, iemAImpl_vpunpckhwd_u128_fallback,
3607 iemAImpl_vpunpckhdq_u128, iemAImpl_vpunpckhdq_u128_fallback,
3608 iemAImpl_vpunpckhqdq_u128, iemAImpl_vpunpckhqdq_u128_fallback;
3609FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpunpckhbw_u256, iemAImpl_vpunpckhbw_u256_fallback,
3610 iemAImpl_vpunpckhwd_u256, iemAImpl_vpunpckhwd_u256_fallback,
3611 iemAImpl_vpunpckhdq_u256, iemAImpl_vpunpckhdq_u256_fallback,
3612 iemAImpl_vpunpckhqdq_u256, iemAImpl_vpunpckhqdq_u256_fallback;
3613/** @} */
3614
3615/** @name Media (SSE/MMX/AVX) operation: Packed Shuffle Stuff (evil)
3616 * @{ */
3617typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUFU128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3618typedef FNIEMAIMPLMEDIAPSHUFU128 *PFNIEMAIMPLMEDIAPSHUFU128;
3619typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHUFU256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t bEvil));
3620typedef FNIEMAIMPLMEDIAPSHUFU256 *PFNIEMAIMPLMEDIAPSHUFU256;
3621IEM_DECL_IMPL_DEF(void, iemAImpl_pshufw_u64,(uint64_t *puDst, uint64_t const *puSrc, uint8_t bEvil));
3622FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_pshufhw_u128, iemAImpl_pshuflw_u128, iemAImpl_pshufd_u128;
3623#ifndef IEM_WITHOUT_ASSEMBLY
3624FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpshufhw_u256, iemAImpl_vpshuflw_u256, iemAImpl_vpshufd_u256;
3625#endif
3626FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpshufhw_u256_fallback, iemAImpl_vpshuflw_u256_fallback, iemAImpl_vpshufd_u256_fallback;
3627/** @} */
3628
3629/** @name Media (SSE/MMX/AVX) operation: Shift Immediate Stuff (evil)
3630 * @{ */
3631typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU64,(uint64_t *puDst, uint8_t bShift));
3632typedef FNIEMAIMPLMEDIAPSHIFTU64 *PFNIEMAIMPLMEDIAPSHIFTU64;
3633typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU128,(PRTUINT128U puDst, uint8_t bShift));
3634typedef FNIEMAIMPLMEDIAPSHIFTU128 *PFNIEMAIMPLMEDIAPSHIFTU128;
3635typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAPSHIFTU256,(PRTUINT256U puDst, uint8_t bShift));
3636typedef FNIEMAIMPLMEDIAPSHIFTU256 *PFNIEMAIMPLMEDIAPSHIFTU256;
3637FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psllw_imm_u64, iemAImpl_pslld_imm_u64, iemAImpl_psllq_imm_u64;
3638FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psrlw_imm_u64, iemAImpl_psrld_imm_u64, iemAImpl_psrlq_imm_u64;
3639FNIEMAIMPLMEDIAPSHIFTU64 iemAImpl_psraw_imm_u64, iemAImpl_psrad_imm_u64;
3640FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psllw_imm_u128, iemAImpl_pslld_imm_u128, iemAImpl_psllq_imm_u128;
3641FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psrlw_imm_u128, iemAImpl_psrld_imm_u128, iemAImpl_psrlq_imm_u128;
3642FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_psraw_imm_u128, iemAImpl_psrad_imm_u128;
3643FNIEMAIMPLMEDIAPSHIFTU128 iemAImpl_pslldq_imm_u128, iemAImpl_psrldq_imm_u128;
3644/** @} */
3645
3646/** @name Media (SSE/MMX/AVX) operation: Move Byte Mask
3647 * @{ */
3648IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u64,(uint64_t *pu64Dst, uint64_t const *puSrc));
3649IEM_DECL_IMPL_DEF(void, iemAImpl_pmovmskb_u128,(uint64_t *pu64Dst, PCRTUINT128U puSrc));
3650#ifndef IEM_WITHOUT_ASSEMBLY
3651IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovmskb_u256,(uint64_t *pu64Dst, PCRTUINT256U puSrc));
3652#endif
3653IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovmskb_u256_fallback,(uint64_t *pu64Dst, PCRTUINT256U puSrc));
3654/** @} */
3655
3656/** @name Media (SSE/MMX/AVX) operations: Variable Blend Packed Bytes/R32/R64.
3657 * @{ */
3658typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLBLENDU128,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puMask));
3659typedef FNIEMAIMPLBLENDU128 *PFNIEMAIMPLBLENDU128;
3660typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLAVXBLENDU128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, PCRTUINT128U puMask));
3661typedef FNIEMAIMPLAVXBLENDU128 *PFNIEMAIMPLAVXBLENDU128;
3662typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLAVXBLENDU256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, PCRTUINT256U puMask));
3663typedef FNIEMAIMPLAVXBLENDU256 *PFNIEMAIMPLAVXBLENDU256;
3664
3665FNIEMAIMPLBLENDU128 iemAImpl_pblendvb_u128;
3666FNIEMAIMPLBLENDU128 iemAImpl_pblendvb_u128_fallback;
3667FNIEMAIMPLAVXBLENDU128 iemAImpl_vpblendvb_u128;
3668FNIEMAIMPLAVXBLENDU128 iemAImpl_vpblendvb_u128_fallback;
3669FNIEMAIMPLAVXBLENDU256 iemAImpl_vpblendvb_u256;
3670FNIEMAIMPLAVXBLENDU256 iemAImpl_vpblendvb_u256_fallback;
3671
3672FNIEMAIMPLBLENDU128 iemAImpl_blendvps_u128;
3673FNIEMAIMPLBLENDU128 iemAImpl_blendvps_u128_fallback;
3674FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvps_u128;
3675FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvps_u128_fallback;
3676FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvps_u256;
3677FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvps_u256_fallback;
3678
3679FNIEMAIMPLBLENDU128 iemAImpl_blendvpd_u128;
3680FNIEMAIMPLBLENDU128 iemAImpl_blendvpd_u128_fallback;
3681FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvpd_u128;
3682FNIEMAIMPLAVXBLENDU128 iemAImpl_vblendvpd_u128_fallback;
3683FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvpd_u256;
3684FNIEMAIMPLAVXBLENDU256 iemAImpl_vblendvpd_u256_fallback;
3685/** @} */
3686
3687
3688/** @name Media (SSE/MMX/AVX) operation: Sort this later
3689 * @{ */
3690IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3691IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3692IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3693IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3694IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbw_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3695
3696IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3697IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3698IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3699IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3700IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3701
3702IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3703IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3704IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u128_fallback,(PRTUINT128U puDst, uint16_t uSrc));
3705IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3706IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxbq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3707
3708IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3709IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3710IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3711IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3712IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3713
3714IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3715IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3716IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3717IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3718IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxwq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3719
3720IEM_DECL_IMPL_DEF(void, iemAImpl_pmovsxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3721IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3722IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3723IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3724IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovsxdq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3725
3726IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3727IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u128,(PRTUINT128U puDst, uint64_t uSrc));
3728IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3729IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3730IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbw_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3731
3732IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3733IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u128,(PRTUINT128U puDst, uint32_t uSrc));
3734IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3735IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3736IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3737
3738IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3739IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u128,(PRTUINT128U puDst, uint16_t uSrc));
3740IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u128_fallback,(PRTUINT128U puDst, uint16_t uSrc));
3741IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3742IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxbq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3743
3744IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3745IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u128,(PRTUINT128U puDst, uint64_t uSrc));
3746IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3747IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3748IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwd_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3749
3750IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3751IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u128,(PRTUINT128U puDst, uint32_t uSrc));
3752IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u128_fallback,(PRTUINT128U puDst, uint32_t uSrc));
3753IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3754IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxwq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3755
3756IEM_DECL_IMPL_DEF(void, iemAImpl_pmovzxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3757IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u128,(PRTUINT128U puDst, uint64_t uSrc));
3758IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u128_fallback,(PRTUINT128U puDst, uint64_t uSrc));
3759IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u256,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3760IEM_DECL_IMPL_DEF(void, iemAImpl_vpmovzxdq_u256_fallback,(PRTUINT256U puDst, PCRTUINT128U puSrc));
3761
3762IEM_DECL_IMPL_DEF(void, iemAImpl_shufpd_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3763IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3764IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3765IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3766IEM_DECL_IMPL_DEF(void, iemAImpl_vshufpd_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3767
3768IEM_DECL_IMPL_DEF(void, iemAImpl_shufps_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3769IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3770IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3771IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3772IEM_DECL_IMPL_DEF(void, iemAImpl_vshufps_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3773
3774IEM_DECL_IMPL_DEF(void, iemAImpl_palignr_u64,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t bEvil));
3775IEM_DECL_IMPL_DEF(void, iemAImpl_palignr_u64_fallback,(uint64_t *pu64Dst, uint64_t u64Src, uint8_t bEvil));
3776
3777IEM_DECL_IMPL_DEF(void, iemAImpl_movmskps_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3778IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3779IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u128_fallback,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3780IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u256,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3781IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskps_u256_fallback,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3782
3783IEM_DECL_IMPL_DEF(void, iemAImpl_movmskpd_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3784IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u128,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3785IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u128_fallback,(uint8_t *pu8Dst, PCRTUINT128U puSrc));
3786IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u256,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3787IEM_DECL_IMPL_DEF(void, iemAImpl_vmovmskpd_u256_fallback,(uint8_t *pu8Dst, PCRTUINT256U puSrc));
3788
3789
3790typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U128IMM8,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t bEvil));
3791typedef FNIEMAIMPLMEDIAOPTF2U128IMM8 *PFNIEMAIMPLMEDIAOPTF2U128IMM8;
3792typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF2U256IMM8,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t bEvil));
3793typedef FNIEMAIMPLMEDIAOPTF2U256IMM8 *PFNIEMAIMPLMEDIAOPTF2U256IMM8;
3794typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U128IMM8,(PRTUINT128U puDst, PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint8_t bEvil));
3795typedef FNIEMAIMPLMEDIAOPTF3U128IMM8 *PFNIEMAIMPLMEDIAOPTF3U128IMM8;
3796typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLMEDIAOPTF3U256IMM8,(PRTUINT256U puDst, PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint8_t bEvil));
3797typedef FNIEMAIMPLMEDIAOPTF3U256IMM8 *PFNIEMAIMPLMEDIAOPTF3U256IMM8;
3798
3799FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_palignr_u128, iemAImpl_palignr_u128_fallback;
3800FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_pblendw_u128, iemAImpl_pblendw_u128_fallback;
3801FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_blendps_u128, iemAImpl_blendps_u128_fallback;
3802FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_blendpd_u128, iemAImpl_blendpd_u128_fallback;
3803
3804FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpalignr_u128, iemAImpl_vpalignr_u128_fallback;
3805FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpblendw_u128, iemAImpl_vpblendw_u128_fallback;
3806FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpblendd_u128, iemAImpl_vpblendd_u128_fallback;
3807FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vblendps_u128, iemAImpl_vblendps_u128_fallback;
3808FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vblendpd_u128, iemAImpl_vblendpd_u128_fallback;
3809
3810FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpalignr_u256, iemAImpl_vpalignr_u256_fallback;
3811FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpblendw_u256, iemAImpl_vpblendw_u256_fallback;
3812FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vpblendd_u256, iemAImpl_vpblendd_u256_fallback;
3813FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vblendps_u256, iemAImpl_vblendps_u256_fallback;
3814FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vblendpd_u256, iemAImpl_vblendpd_u256_fallback;
3815FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vperm2i128_u256, iemAImpl_vperm2i128_u256_fallback;
3816FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vperm2f128_u256, iemAImpl_vperm2f128_u256_fallback;
3817
3818FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesimc_u128, iemAImpl_aesimc_u128_fallback;
3819FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesenc_u128, iemAImpl_aesenc_u128_fallback;
3820FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesenclast_u128, iemAImpl_aesenclast_u128_fallback;
3821FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesdec_u128, iemAImpl_aesdec_u128_fallback;
3822FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_aesdeclast_u128, iemAImpl_aesdeclast_u128_fallback;
3823
3824FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesimc_u128, iemAImpl_vaesimc_u128_fallback;
3825FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesenc_u128, iemAImpl_vaesenc_u128_fallback;
3826FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesenclast_u128, iemAImpl_vaesenclast_u128_fallback;
3827FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesdec_u128, iemAImpl_vaesdec_u128_fallback;
3828FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_vaesdeclast_u128, iemAImpl_vaesdeclast_u128_fallback;
3829
3830FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_aeskeygenassist_u128, iemAImpl_aeskeygenassist_u128_fallback;
3831
3832FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vaeskeygenassist_u128, iemAImpl_vaeskeygenassist_u128_fallback;
3833
3834FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1nexte_u128, iemAImpl_sha1nexte_u128_fallback;
3835FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1msg1_u128, iemAImpl_sha1msg1_u128_fallback;
3836FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha1msg2_u128, iemAImpl_sha1msg2_u128_fallback;
3837FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha256msg1_u128, iemAImpl_sha256msg1_u128_fallback;
3838FNIEMAIMPLMEDIAOPTF2U128 iemAImpl_sha256msg2_u128, iemAImpl_sha256msg2_u128_fallback;
3839FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_sha1rnds4_u128, iemAImpl_sha1rnds4_u128_fallback;
3840IEM_DECL_IMPL_DEF(void, iemAImpl_sha256rnds2_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puXmm0Constants));
3841IEM_DECL_IMPL_DEF(void, iemAImpl_sha256rnds2_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, PCRTUINT128U puXmm0Constants));
3842
3843typedef struct IEMPCMPISTRXSRC
3844{
3845 RTUINT128U uSrc1;
3846 RTUINT128U uSrc2;
3847} IEMPCMPISTRXSRC;
3848typedef IEMPCMPISTRXSRC *PIEMPCMPISTRXSRC;
3849typedef const IEMPCMPISTRXSRC *PCIEMPCMPISTRXSRC;
3850
3851typedef struct IEMPCMPESTRXSRC
3852{
3853 RTUINT128U uSrc1;
3854 RTUINT128U uSrc2;
3855 uint64_t u64Rax;
3856 uint64_t u64Rdx;
3857} IEMPCMPESTRXSRC;
3858typedef IEMPCMPESTRXSRC *PIEMPCMPESTRXSRC;
3859typedef const IEMPCMPESTRXSRC *PCIEMPCMPESTRXSRC;
3860
3861typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLPCMPISTRIU128IMM8,(uint32_t *pEFlags, PCRTUINT128U pSrc1, PCRTUINT128U pSrc2, uint8_t bEvil));
3862typedef FNIEMAIMPLPCMPISTRIU128IMM8 *PFNIEMAIMPLPCMPISTRIU128IMM8;
3863typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPESTRIU128IMM8,(uint32_t *pu32Ecx, uint32_t *pEFlags, PCIEMPCMPESTRXSRC pSrc, uint8_t bEvil));
3864typedef FNIEMAIMPLPCMPESTRIU128IMM8 *PFNIEMAIMPLPCMPESTRIU128IMM8;
3865
3866typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPISTRMU128IMM8,(PRTUINT128U puDst, uint32_t *pEFlags, PCIEMPCMPISTRXSRC pSrc, uint8_t bEvil));
3867typedef FNIEMAIMPLPCMPISTRMU128IMM8 *PFNIEMAIMPLPCMPISTRMU128IMM8;
3868typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLPCMPESTRMU128IMM8,(PRTUINT128U puDst, uint32_t *pEFlags, PCIEMPCMPESTRXSRC pSrc, uint8_t bEvil));
3869typedef FNIEMAIMPLPCMPESTRMU128IMM8 *PFNIEMAIMPLPCMPESTRMU128IMM8;
3870
3871FNIEMAIMPLPCMPISTRIU128IMM8 iemAImpl_pcmpistri_u128, iemAImpl_pcmpistri_u128_fallback;
3872FNIEMAIMPLPCMPESTRIU128IMM8 iemAImpl_pcmpestri_u128, iemAImpl_pcmpestri_u128_fallback;
3873FNIEMAIMPLPCMPISTRMU128IMM8 iemAImpl_pcmpistrm_u128, iemAImpl_pcmpistrm_u128_fallback;
3874FNIEMAIMPLPCMPESTRMU128IMM8 iemAImpl_pcmpestrm_u128, iemAImpl_pcmpestrm_u128_fallback;
3875
3876FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_pclmulqdq_u128, iemAImpl_pclmulqdq_u128_fallback;
3877FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vpclmulqdq_u128, iemAImpl_vpclmulqdq_u128_fallback;
3878
3879FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_mpsadbw_u128, iemAImpl_mpsadbw_u128_fallback;
3880FNIEMAIMPLMEDIAOPTF3U128IMM8 iemAImpl_vmpsadbw_u128, iemAImpl_vmpsadbw_u128_fallback;
3881FNIEMAIMPLMEDIAOPTF3U256IMM8 iemAImpl_vmpsadbw_u256, iemAImpl_vmpsadbw_u256_fallback;
3882
3883FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsllw_imm_u128, iemAImpl_vpsllw_imm_u128_fallback;
3884FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsllw_imm_u256, iemAImpl_vpsllw_imm_u256_fallback;
3885FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpslld_imm_u128, iemAImpl_vpslld_imm_u128_fallback;
3886FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpslld_imm_u256, iemAImpl_vpslld_imm_u256_fallback;
3887FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsllq_imm_u128, iemAImpl_vpsllq_imm_u128_fallback;
3888FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsllq_imm_u256, iemAImpl_vpsllq_imm_u256_fallback;
3889IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
3890IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
3891IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
3892IEM_DECL_IMPL_DEF(void, iemAImpl_vpslldq_imm_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
3893
3894FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsraw_imm_u128, iemAImpl_vpsraw_imm_u128_fallback;
3895FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsraw_imm_u256, iemAImpl_vpsraw_imm_u256_fallback;
3896FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrad_imm_u128, iemAImpl_vpsrad_imm_u128_fallback;
3897FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrad_imm_u256, iemAImpl_vpsrad_imm_u256_fallback;
3898
3899FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrlw_imm_u128, iemAImpl_vpsrlw_imm_u128_fallback;
3900FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrlw_imm_u256, iemAImpl_vpsrlw_imm_u256_fallback;
3901FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrld_imm_u128, iemAImpl_vpsrld_imm_u128_fallback;
3902FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrld_imm_u256, iemAImpl_vpsrld_imm_u256_fallback;
3903FNIEMAIMPLMEDIAPSHUFU128 iemAImpl_vpsrlq_imm_u128, iemAImpl_vpsrlq_imm_u128_fallback;
3904FNIEMAIMPLMEDIAPSHUFU256 iemAImpl_vpsrlq_imm_u256, iemAImpl_vpsrlq_imm_u256_fallback;
3905IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u128,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
3906IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u128_fallback,(PRTUINT128U puDst, PCRTUINT128U puSrc, uint8_t uShift));
3907IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u256,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
3908IEM_DECL_IMPL_DEF(void, iemAImpl_vpsrldq_imm_u256_fallback,(PRTUINT256U puDst, PCRTUINT256U puSrc, uint8_t uShift));
3909
3910FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpermilps_u128, iemAImpl_vpermilps_u128_fallback;
3911FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_vpermilps_imm_u128, iemAImpl_vpermilps_imm_u128_fallback;
3912FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpermilps_u256, iemAImpl_vpermilps_u256_fallback;
3913FNIEMAIMPLMEDIAOPTF2U256IMM8 iemAImpl_vpermilps_imm_u256, iemAImpl_vpermilps_imm_u256_fallback;
3914
3915FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpermilpd_u128, iemAImpl_vpermilpd_u128_fallback;
3916FNIEMAIMPLMEDIAOPTF2U128IMM8 iemAImpl_vpermilpd_imm_u128, iemAImpl_vpermilpd_imm_u128_fallback;
3917FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpermilpd_u256, iemAImpl_vpermilpd_u256_fallback;
3918FNIEMAIMPLMEDIAOPTF2U256IMM8 iemAImpl_vpermilpd_imm_u256, iemAImpl_vpermilpd_imm_u256_fallback;
3919
3920FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllvd_u128, iemAImpl_vpsllvd_u128_fallback;
3921FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllvd_u256, iemAImpl_vpsllvd_u256_fallback;
3922FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsllvq_u128, iemAImpl_vpsllvq_u128_fallback;
3923FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsllvq_u256, iemAImpl_vpsllvq_u256_fallback;
3924FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsravd_u128, iemAImpl_vpsravd_u128_fallback;
3925FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsravd_u256, iemAImpl_vpsravd_u256_fallback;
3926FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlvd_u128, iemAImpl_vpsrlvd_u128_fallback;
3927FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlvd_u256, iemAImpl_vpsrlvd_u256_fallback;
3928FNIEMAIMPLMEDIAOPTF3U128 iemAImpl_vpsrlvq_u128, iemAImpl_vpsrlvq_u128_fallback;
3929FNIEMAIMPLMEDIAOPTF3U256 iemAImpl_vpsrlvq_u256, iemAImpl_vpsrlvq_u256_fallback;
3930/** @} */
3931
3932/** @name Media Odds and Ends
3933 * @{ */
3934typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U8,(uint32_t *puDst, uint8_t uSrc));
3935typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U16,(uint32_t *puDst, uint16_t uSrc));
3936typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U32,(uint32_t *puDst, uint32_t uSrc));
3937typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLCR32U64,(uint32_t *puDst, uint64_t uSrc));
3938FNIEMAIMPLCR32U8 iemAImpl_crc32_u8, iemAImpl_crc32_u8_fallback;
3939FNIEMAIMPLCR32U16 iemAImpl_crc32_u16, iemAImpl_crc32_u16_fallback;
3940FNIEMAIMPLCR32U32 iemAImpl_crc32_u32, iemAImpl_crc32_u32_fallback;
3941FNIEMAIMPLCR32U64 iemAImpl_crc32_u64, iemAImpl_crc32_u64_fallback;
3942
3943typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFL128,(PCRTUINT128U puSrc1, PCRTUINT128U puSrc2, uint32_t *pEFlags));
3944typedef FNIEMAIMPLF2EFL128 *PFNIEMAIMPLF2EFL128;
3945typedef IEM_DECL_IMPL_TYPE(void, FNIEMAIMPLF2EFL256,(PCRTUINT256U puSrc1, PCRTUINT256U puSrc2, uint32_t *pEFlags));
3946typedef FNIEMAIMPLF2EFL256 *PFNIEMAIMPLF2EFL256;
3947FNIEMAIMPLF2EFL128 iemAImpl_ptest_u128;
3948FNIEMAIMPLF2EFL256 iemAImpl_vptest_u256, iemAImpl_vptest_u256_fallback;
3949FNIEMAIMPLF2EFL128 iemAImpl_vtestps_u128, iemAImpl_vtestps_u128_fallback;
3950FNIEMAIMPLF2EFL256 iemAImpl_vtestps_u256, iemAImpl_vtestps_u256_fallback;
3951FNIEMAIMPLF2EFL128 iemAImpl_vtestpd_u128, iemAImpl_vtestpd_u128_fallback;
3952FNIEMAIMPLF2EFL256 iemAImpl_vtestpd_u256, iemAImpl_vtestpd_u256_fallback;
3953
3954typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I32U64,(uint32_t uMxCsrIn, int32_t *pi32Dst, const uint64_t *pu64Src)); /* pu64Src is a double precision floating point. */
3955typedef FNIEMAIMPLSSEF2I32U64 *PFNIEMAIMPLSSEF2I32U64;
3956typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I64U64,(uint32_t uMxCsrIn, int64_t *pi64Dst, const uint64_t *pu64Src)); /* pu64Src is a double precision floating point. */
3957typedef FNIEMAIMPLSSEF2I64U64 *PFNIEMAIMPLSSEF2I64U64;
3958typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I32U32,(uint32_t uMxCsrIn, int32_t *pi32Dst, const uint32_t *pu32Src)); /* pu32Src is a single precision floating point. */
3959typedef FNIEMAIMPLSSEF2I32U32 *PFNIEMAIMPLSSEF2I32U32;
3960typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2I64U32,(uint32_t uMxCsrIn, int64_t *pi64Dst, const uint32_t *pu32Src)); /* pu32Src is a single precision floating point. */
3961typedef FNIEMAIMPLSSEF2I64U32 *PFNIEMAIMPLSSEF2I64U32;
3962
3963FNIEMAIMPLSSEF2I32U64 iemAImpl_cvttsd2si_i32_r64;
3964FNIEMAIMPLSSEF2I32U64 iemAImpl_cvtsd2si_i32_r64;
3965
3966FNIEMAIMPLSSEF2I64U64 iemAImpl_cvttsd2si_i64_r64;
3967FNIEMAIMPLSSEF2I64U64 iemAImpl_cvtsd2si_i64_r64;
3968
3969FNIEMAIMPLSSEF2I32U32 iemAImpl_cvttss2si_i32_r32;
3970FNIEMAIMPLSSEF2I32U32 iemAImpl_cvtss2si_i32_r32;
3971
3972FNIEMAIMPLSSEF2I64U32 iemAImpl_cvttss2si_i64_r32;
3973FNIEMAIMPLSSEF2I64U32 iemAImpl_cvtss2si_i64_r32;
3974
3975typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R32I32,(uint32_t uMxCsrIn, PRTFLOAT32U pr32Dst, const int32_t *pi32Src));
3976typedef FNIEMAIMPLSSEF2R32I32 *PFNIEMAIMPLSSEF2R32I32;
3977typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R32I64,(uint32_t uMxCsrIn, PRTFLOAT32U pr32Dst, const int64_t *pi64Src));
3978typedef FNIEMAIMPLSSEF2R32I64 *PFNIEMAIMPLSSEF2R32I64;
3979
3980FNIEMAIMPLSSEF2R32I32 iemAImpl_cvtsi2ss_r32_i32;
3981FNIEMAIMPLSSEF2R32I64 iemAImpl_cvtsi2ss_r32_i64;
3982
3983typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R64I32,(uint32_t uMxCsrIn, PRTFLOAT64U pr64Dst, const int32_t *pi32Src));
3984typedef FNIEMAIMPLSSEF2R64I32 *PFNIEMAIMPLSSEF2R64I32;
3985typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLSSEF2R64I64,(uint32_t uMxCsrIn, PRTFLOAT64U pr64Dst, const int64_t *pi64Src));
3986typedef FNIEMAIMPLSSEF2R64I64 *PFNIEMAIMPLSSEF2R64I64;
3987
3988FNIEMAIMPLSSEF2R64I32 iemAImpl_cvtsi2sd_r64_i32;
3989FNIEMAIMPLSSEF2R64I64 iemAImpl_cvtsi2sd_r64_i64;
3990
3991
3992typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLF2EFLMXCSRR32R32,(uint32_t uMxCsrIn, uint32_t *pfEFlags, RTFLOAT32U uSrc1, RTFLOAT32U uSrc2));
3993typedef FNIEMAIMPLF2EFLMXCSRR32R32 *PFNIEMAIMPLF2EFLMXCSRR32R32;
3994
3995typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLF2EFLMXCSRR64R64,(uint32_t uMxCsrIn, uint32_t *pfEFlags, RTFLOAT64U uSrc1, RTFLOAT64U uSrc2));
3996typedef FNIEMAIMPLF2EFLMXCSRR64R64 *PFNIEMAIMPLF2EFLMXCSRR64R64;
3997
3998FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_ucomiss_u128;
3999FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_vucomiss_u128, iemAImpl_vucomiss_u128_fallback;
4000
4001FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_ucomisd_u128;
4002FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_vucomisd_u128, iemAImpl_vucomisd_u128_fallback;
4003
4004FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_comiss_u128;
4005FNIEMAIMPLF2EFLMXCSRR32R32 iemAImpl_vcomiss_u128, iemAImpl_vcomiss_u128_fallback;
4006
4007FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_comisd_u128;
4008FNIEMAIMPLF2EFLMXCSRR64R64 iemAImpl_vcomisd_u128, iemAImpl_vcomisd_u128_fallback;
4009
4010
4011typedef struct IEMMEDIAF2XMMSRC
4012{
4013 X86XMMREG uSrc1;
4014 X86XMMREG uSrc2;
4015} IEMMEDIAF2XMMSRC;
4016typedef IEMMEDIAF2XMMSRC *PIEMMEDIAF2XMMSRC;
4017typedef const IEMMEDIAF2XMMSRC *PCIEMMEDIAF2XMMSRC;
4018
4019typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRF2XMMIMM8,(uint32_t uMxCsrIn, PX86XMMREG puDst, PCIEMMEDIAF2XMMSRC puSrc, uint8_t bEvil));
4020typedef FNIEMAIMPLMXCSRF2XMMIMM8 *PFNIEMAIMPLMXCSRF2XMMIMM8;
4021
4022FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmpps_u128;
4023FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmppd_u128;
4024FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmpss_u128;
4025FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_cmpsd_u128;
4026FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundss_u128;
4027FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundsd_u128;
4028
4029FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundps_u128, iemAImpl_roundps_u128_fallback;
4030FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_roundpd_u128, iemAImpl_roundpd_u128_fallback;
4031
4032FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_dpps_u128, iemAImpl_dpps_u128_fallback;
4033FNIEMAIMPLMXCSRF2XMMIMM8 iemAImpl_dppd_u128, iemAImpl_dppd_u128_fallback;
4034
4035typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRU64U128,(uint32_t fMxCsrIn, uint64_t *pu64Dst, PCX86XMMREG pSrc));
4036typedef FNIEMAIMPLMXCSRU64U128 *PFNIEMAIMPLMXCSRU64U128;
4037
4038FNIEMAIMPLMXCSRU64U128 iemAImpl_cvtpd2pi_u128;
4039FNIEMAIMPLMXCSRU64U128 iemAImpl_cvttpd2pi_u128;
4040
4041typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRU128U64,(uint32_t fMxCsrIn, PX86XMMREG pDst, uint64_t u64Src));
4042typedef FNIEMAIMPLMXCSRU128U64 *PFNIEMAIMPLMXCSRU128U64;
4043
4044FNIEMAIMPLMXCSRU128U64 iemAImpl_cvtpi2ps_u128;
4045FNIEMAIMPLMXCSRU128U64 iemAImpl_cvtpi2pd_u128;
4046
4047typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLMXCSRU64U64,(uint32_t fMxCsrIn, uint64_t *pu64Dst, uint64_t u64Src));
4048typedef FNIEMAIMPLMXCSRU64U64 *PFNIEMAIMPLMXCSRU64U64;
4049
4050FNIEMAIMPLMXCSRU64U64 iemAImpl_cvtps2pi_u128;
4051FNIEMAIMPLMXCSRU64U64 iemAImpl_cvttps2pi_u128;
4052
4053/** @} */
4054
4055
4056/** @name Function tables.
4057 * @{
4058 */
4059
4060/**
4061 * Function table for a binary operator providing implementation based on
4062 * operand size.
4063 */
4064typedef struct IEMOPBINSIZES
4065{
4066 PFNIEMAIMPLBINU8 pfnNormalU8, pfnLockedU8;
4067 PFNIEMAIMPLBINU16 pfnNormalU16, pfnLockedU16;
4068 PFNIEMAIMPLBINU32 pfnNormalU32, pfnLockedU32;
4069 PFNIEMAIMPLBINU64 pfnNormalU64, pfnLockedU64;
4070} IEMOPBINSIZES;
4071/** Pointer to a binary operator function table. */
4072typedef IEMOPBINSIZES const *PCIEMOPBINSIZES;
4073
4074
4075/**
4076 * Function table for a unary operator providing implementation based on
4077 * operand size.
4078 */
4079typedef struct IEMOPUNARYSIZES
4080{
4081 PFNIEMAIMPLUNARYU8 pfnNormalU8, pfnLockedU8;
4082 PFNIEMAIMPLUNARYU16 pfnNormalU16, pfnLockedU16;
4083 PFNIEMAIMPLUNARYU32 pfnNormalU32, pfnLockedU32;
4084 PFNIEMAIMPLUNARYU64 pfnNormalU64, pfnLockedU64;
4085} IEMOPUNARYSIZES;
4086/** Pointer to a unary operator function table. */
4087typedef IEMOPUNARYSIZES const *PCIEMOPUNARYSIZES;
4088
4089
4090/**
4091 * Function table for a shift operator providing implementation based on
4092 * operand size.
4093 */
4094typedef struct IEMOPSHIFTSIZES
4095{
4096 PFNIEMAIMPLSHIFTU8 pfnNormalU8;
4097 PFNIEMAIMPLSHIFTU16 pfnNormalU16;
4098 PFNIEMAIMPLSHIFTU32 pfnNormalU32;
4099 PFNIEMAIMPLSHIFTU64 pfnNormalU64;
4100} IEMOPSHIFTSIZES;
4101/** Pointer to a shift operator function table. */
4102typedef IEMOPSHIFTSIZES const *PCIEMOPSHIFTSIZES;
4103
4104
4105/**
4106 * Function table for a multiplication or division operation.
4107 */
4108typedef struct IEMOPMULDIVSIZES
4109{
4110 PFNIEMAIMPLMULDIVU8 pfnU8;
4111 PFNIEMAIMPLMULDIVU16 pfnU16;
4112 PFNIEMAIMPLMULDIVU32 pfnU32;
4113 PFNIEMAIMPLMULDIVU64 pfnU64;
4114} IEMOPMULDIVSIZES;
4115/** Pointer to a multiplication or division operation function table. */
4116typedef IEMOPMULDIVSIZES const *PCIEMOPMULDIVSIZES;
4117
4118
4119/**
4120 * Function table for a double precision shift operator providing implementation
4121 * based on operand size.
4122 */
4123typedef struct IEMOPSHIFTDBLSIZES
4124{
4125 PFNIEMAIMPLSHIFTDBLU16 pfnNormalU16;
4126 PFNIEMAIMPLSHIFTDBLU32 pfnNormalU32;
4127 PFNIEMAIMPLSHIFTDBLU64 pfnNormalU64;
4128} IEMOPSHIFTDBLSIZES;
4129/** Pointer to a double precision shift function table. */
4130typedef IEMOPSHIFTDBLSIZES const *PCIEMOPSHIFTDBLSIZES;
4131
4132
4133/**
4134 * Function table for media instruction taking two full sized media source
4135 * registers and one full sized destination register (AVX).
4136 */
4137typedef struct IEMOPMEDIAF3
4138{
4139 PFNIEMAIMPLMEDIAF3U128 pfnU128;
4140 PFNIEMAIMPLMEDIAF3U256 pfnU256;
4141} IEMOPMEDIAF3;
4142/** Pointer to a media operation function table for 3 full sized ops (AVX). */
4143typedef IEMOPMEDIAF3 const *PCIEMOPMEDIAF3;
4144
4145/** @def IEMOPMEDIAF3_INIT_VARS_EX
4146 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4147 * given functions as initializers. For use in AVX functions where a pair of
4148 * functions are only used once and the function table need not be public. */
4149#ifndef TST_IEM_CHECK_MC
4150# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4151# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4152 static IEMOPMEDIAF3 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4153 static IEMOPMEDIAF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4154# else
4155# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4156 static IEMOPMEDIAF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4157# endif
4158#else
4159# define IEMOPMEDIAF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4160#endif
4161/** @def IEMOPMEDIAF3_INIT_VARS
4162 * Generate AVX function tables for the @a a_InstrNm instruction.
4163 * @sa IEMOPMEDIAF3_INIT_VARS_EX */
4164#define IEMOPMEDIAF3_INIT_VARS(a_InstrNm) \
4165 IEMOPMEDIAF3_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4166 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4167
4168/**
4169 * Function table for media instruction taking two full sized media source
4170 * registers and one full sized destination register, but no additional state
4171 * (AVX).
4172 */
4173typedef struct IEMOPMEDIAOPTF3
4174{
4175 PFNIEMAIMPLMEDIAOPTF3U128 pfnU128;
4176 PFNIEMAIMPLMEDIAOPTF3U256 pfnU256;
4177} IEMOPMEDIAOPTF3;
4178/** Pointer to a media operation function table for 3 full sized ops (AVX). */
4179typedef IEMOPMEDIAOPTF3 const *PCIEMOPMEDIAOPTF3;
4180
4181/** @def IEMOPMEDIAOPTF3_INIT_VARS_EX
4182 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4183 * given functions as initializers. For use in AVX functions where a pair of
4184 * functions are only used once and the function table need not be public. */
4185#ifndef TST_IEM_CHECK_MC
4186# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4187# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4188 static IEMOPMEDIAOPTF3 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4189 static IEMOPMEDIAOPTF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4190# else
4191# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4192 static IEMOPMEDIAOPTF3 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4193# endif
4194#else
4195# define IEMOPMEDIAOPTF3_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4196#endif
4197/** @def IEMOPMEDIAOPTF3_INIT_VARS
4198 * Generate AVX function tables for the @a a_InstrNm instruction.
4199 * @sa IEMOPMEDIAOPTF3_INIT_VARS_EX */
4200#define IEMOPMEDIAOPTF3_INIT_VARS(a_InstrNm) \
4201 IEMOPMEDIAOPTF3_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4202 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4203
4204/**
4205 * Function table for media instruction taking one full sized media source
4206 * registers and one full sized destination register, but no additional state
4207 * (AVX).
4208 */
4209typedef struct IEMOPMEDIAOPTF2
4210{
4211 PFNIEMAIMPLMEDIAOPTF2U128 pfnU128;
4212 PFNIEMAIMPLMEDIAOPTF2U256 pfnU256;
4213} IEMOPMEDIAOPTF2;
4214/** Pointer to a media operation function table for 2 full sized ops (AVX). */
4215typedef IEMOPMEDIAOPTF2 const *PCIEMOPMEDIAOPTF2;
4216
4217/** @def IEMOPMEDIAOPTF2_INIT_VARS_EX
4218 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4219 * given functions as initializers. For use in AVX functions where a pair of
4220 * functions are only used once and the function table need not be public. */
4221#ifndef TST_IEM_CHECK_MC
4222# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4223# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4224 static IEMOPMEDIAOPTF2 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4225 static IEMOPMEDIAOPTF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4226# else
4227# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4228 static IEMOPMEDIAOPTF2 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4229# endif
4230#else
4231# define IEMOPMEDIAOPTF2_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4232#endif
4233/** @def IEMOPMEDIAOPTF2_INIT_VARS
4234 * Generate AVX function tables for the @a a_InstrNm instruction.
4235 * @sa IEMOPMEDIAOPTF2_INIT_VARS_EX */
4236#define IEMOPMEDIAOPTF2_INIT_VARS(a_InstrNm) \
4237 IEMOPMEDIAOPTF2_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4238 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4239
4240/**
4241 * Function table for media instruction taking one full sized media source
4242 * register and one full sized destination register and an 8-bit immediate, but no additional state
4243 * (AVX).
4244 */
4245typedef struct IEMOPMEDIAOPTF2IMM8
4246{
4247 PFNIEMAIMPLMEDIAOPTF2U128IMM8 pfnU128;
4248 PFNIEMAIMPLMEDIAOPTF2U256IMM8 pfnU256;
4249} IEMOPMEDIAOPTF2IMM8;
4250/** Pointer to a media operation function table for 2 full sized ops (AVX). */
4251typedef IEMOPMEDIAOPTF2IMM8 const *PCIEMOPMEDIAOPTF2IMM8;
4252
4253/** @def IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX
4254 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4255 * given functions as initializers. For use in AVX functions where a pair of
4256 * functions are only used once and the function table need not be public. */
4257#ifndef TST_IEM_CHECK_MC
4258# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4259# define IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4260 static IEMOPMEDIAOPTF2IMM8 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4261 static IEMOPMEDIAOPTF2IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4262# else
4263# define IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4264 static IEMOPMEDIAOPTF2IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4265# endif
4266#else
4267# define IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4268#endif
4269/** @def IEMOPMEDIAOPTF2IMM8_INIT_VARS
4270 * Generate AVX function tables for the @a a_InstrNm instruction.
4271 * @sa IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX */
4272#define IEMOPMEDIAOPTF2IMM8_INIT_VARS(a_InstrNm) \
4273 IEMOPMEDIAOPTF2IMM8_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u256),\
4274 RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_imm_u256_fallback))
4275
4276/**
4277 * Function table for media instruction taking two full sized media source
4278 * registers and one full sized destination register and an 8-bit immediate, but no additional state
4279 * (AVX).
4280 */
4281typedef struct IEMOPMEDIAOPTF3IMM8
4282{
4283 PFNIEMAIMPLMEDIAOPTF3U128IMM8 pfnU128;
4284 PFNIEMAIMPLMEDIAOPTF3U256IMM8 pfnU256;
4285} IEMOPMEDIAOPTF3IMM8;
4286/** Pointer to a media operation function table for 3 full sized ops (AVX). */
4287typedef IEMOPMEDIAOPTF3IMM8 const *PCIEMOPMEDIAOPTF3IMM8;
4288
4289/** @def IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX
4290 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4291 * given functions as initializers. For use in AVX functions where a pair of
4292 * functions are only used once and the function table need not be public. */
4293#ifndef TST_IEM_CHECK_MC
4294# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4295# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4296 static IEMOPMEDIAOPTF3IMM8 const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4297 static IEMOPMEDIAOPTF3IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4298# else
4299# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4300 static IEMOPMEDIAOPTF3IMM8 const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4301# endif
4302#else
4303# define IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4304#endif
4305/** @def IEMOPMEDIAOPTF3IMM8_INIT_VARS
4306 * Generate AVX function tables for the @a a_InstrNm instruction.
4307 * @sa IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX */
4308#define IEMOPMEDIAOPTF3IMM8_INIT_VARS(a_InstrNm) \
4309 IEMOPMEDIAOPTF3IMM8_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4310 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4311/** @} */
4312
4313
4314/**
4315 * Function table for blend type instruction taking three full sized media source
4316 * registers and one full sized destination register, but no additional state
4317 * (AVX).
4318 */
4319typedef struct IEMOPBLENDOP
4320{
4321 PFNIEMAIMPLAVXBLENDU128 pfnU128;
4322 PFNIEMAIMPLAVXBLENDU256 pfnU256;
4323} IEMOPBLENDOP;
4324/** Pointer to a media operation function table for 4 full sized ops (AVX). */
4325typedef IEMOPBLENDOP const *PCIEMOPBLENDOP;
4326
4327/** @def IEMOPBLENDOP_INIT_VARS_EX
4328 * Declares a s_Host (x86 & amd64 only) and a s_Fallback variable with the
4329 * given functions as initializers. For use in AVX functions where a pair of
4330 * functions are only used once and the function table need not be public. */
4331#ifndef TST_IEM_CHECK_MC
4332# if (defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)) && !defined(IEM_WITHOUT_ASSEMBLY)
4333# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnHostU128, a_pfnHostU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4334 static IEMOPBLENDOP const s_Host = { a_pfnHostU128, a_pfnHostU256 }; \
4335 static IEMOPBLENDOP const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4336# else
4337# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) \
4338 static IEMOPBLENDOP const s_Fallback = { a_pfnFallbackU128, a_pfnFallbackU256 }
4339# endif
4340#else
4341# define IEMOPBLENDOP_INIT_VARS_EX(a_pfnU128, a_pfnU256, a_pfnFallbackU128, a_pfnFallbackU256) (void)0
4342#endif
4343/** @def IEMOPBLENDOP_INIT_VARS
4344 * Generate AVX function tables for the @a a_InstrNm instruction.
4345 * @sa IEMOPBLENDOP_INIT_VARS_EX */
4346#define IEMOPBLENDOP_INIT_VARS(a_InstrNm) \
4347 IEMOPBLENDOP_INIT_VARS_EX(RT_CONCAT3(iemAImpl_,a_InstrNm,_u128), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256),\
4348 RT_CONCAT3(iemAImpl_,a_InstrNm,_u128_fallback), RT_CONCAT3(iemAImpl_,a_InstrNm,_u256_fallback))
4349
4350
4351/** @name SSE/AVX single/double precision floating point operations.
4352 * @{ */
4353typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPSSEF2U128,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
4354typedef FNIEMAIMPLFPSSEF2U128 *PFNIEMAIMPLFPSSEF2U128;
4355typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPSSEF2U128R32,(uint32_t uMxCsrIn, PX86XMMREG Result, PCX86XMMREG puSrc1, PCRTFLOAT32U pr32Src2));
4356typedef FNIEMAIMPLFPSSEF2U128R32 *PFNIEMAIMPLFPSSEF2U128R32;
4357typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPSSEF2U128R64,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCRTFLOAT64U pr64Src2));
4358typedef FNIEMAIMPLFPSSEF2U128R64 *PFNIEMAIMPLFPSSEF2U128R64;
4359
4360typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U128,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2));
4361typedef FNIEMAIMPLFPAVXF3U128 *PFNIEMAIMPLFPAVXF3U128;
4362typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U128R32,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCRTFLOAT32U pr32Src2));
4363typedef FNIEMAIMPLFPAVXF3U128R32 *PFNIEMAIMPLFPAVXF3U128R32;
4364typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U128R64,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCRTFLOAT64U pr64Src2));
4365typedef FNIEMAIMPLFPAVXF3U128R64 *PFNIEMAIMPLFPAVXF3U128R64;
4366
4367typedef IEM_DECL_IMPL_TYPE(uint32_t, FNIEMAIMPLFPAVXF3U256,(uint32_t uMxCsrIn, PX86YMMREG pResult, PCX86YMMREG puSrc1, PCX86YMMREG puSrc2));
4368typedef FNIEMAIMPLFPAVXF3U256 *PFNIEMAIMPLFPAVXF3U256;
4369
4370FNIEMAIMPLFPSSEF2U128 iemAImpl_addps_u128;
4371FNIEMAIMPLFPSSEF2U128 iemAImpl_addpd_u128;
4372FNIEMAIMPLFPSSEF2U128 iemAImpl_mulps_u128;
4373FNIEMAIMPLFPSSEF2U128 iemAImpl_mulpd_u128;
4374FNIEMAIMPLFPSSEF2U128 iemAImpl_subps_u128;
4375FNIEMAIMPLFPSSEF2U128 iemAImpl_subpd_u128;
4376FNIEMAIMPLFPSSEF2U128 iemAImpl_minps_u128;
4377FNIEMAIMPLFPSSEF2U128 iemAImpl_minpd_u128;
4378FNIEMAIMPLFPSSEF2U128 iemAImpl_divps_u128;
4379FNIEMAIMPLFPSSEF2U128 iemAImpl_divpd_u128;
4380FNIEMAIMPLFPSSEF2U128 iemAImpl_maxps_u128;
4381FNIEMAIMPLFPSSEF2U128 iemAImpl_maxpd_u128;
4382FNIEMAIMPLFPSSEF2U128 iemAImpl_haddps_u128;
4383FNIEMAIMPLFPSSEF2U128 iemAImpl_haddpd_u128;
4384FNIEMAIMPLFPSSEF2U128 iemAImpl_hsubps_u128;
4385FNIEMAIMPLFPSSEF2U128 iemAImpl_hsubpd_u128;
4386FNIEMAIMPLFPSSEF2U128 iemAImpl_sqrtps_u128;
4387FNIEMAIMPLFPSSEF2U128 iemAImpl_rsqrtps_u128;
4388FNIEMAIMPLFPSSEF2U128 iemAImpl_sqrtpd_u128;
4389FNIEMAIMPLFPSSEF2U128 iemAImpl_rcpps_u128;
4390FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubps_u128;
4391FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubpd_u128;
4392FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2ps_u128;
4393FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtps2pd_u128;
4394
4395FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2ps_u128;
4396FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtps2dq_u128;
4397FNIEMAIMPLFPSSEF2U128 iemAImpl_cvttps2dq_u128;
4398FNIEMAIMPLFPSSEF2U128 iemAImpl_cvttpd2dq_u128;
4399FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2pd_u128;
4400FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2dq_u128;
4401
4402FNIEMAIMPLFPSSEF2U128R32 iemAImpl_addss_u128_r32;
4403FNIEMAIMPLFPSSEF2U128R64 iemAImpl_addsd_u128_r64;
4404FNIEMAIMPLFPSSEF2U128R32 iemAImpl_mulss_u128_r32;
4405FNIEMAIMPLFPSSEF2U128R64 iemAImpl_mulsd_u128_r64;
4406FNIEMAIMPLFPSSEF2U128R32 iemAImpl_subss_u128_r32;
4407FNIEMAIMPLFPSSEF2U128R64 iemAImpl_subsd_u128_r64;
4408FNIEMAIMPLFPSSEF2U128R32 iemAImpl_minss_u128_r32;
4409FNIEMAIMPLFPSSEF2U128R64 iemAImpl_minsd_u128_r64;
4410FNIEMAIMPLFPSSEF2U128R32 iemAImpl_divss_u128_r32;
4411FNIEMAIMPLFPSSEF2U128R64 iemAImpl_divsd_u128_r64;
4412FNIEMAIMPLFPSSEF2U128R32 iemAImpl_maxss_u128_r32;
4413FNIEMAIMPLFPSSEF2U128R64 iemAImpl_maxsd_u128_r64;
4414FNIEMAIMPLFPSSEF2U128R32 iemAImpl_cvtss2sd_u128_r32;
4415FNIEMAIMPLFPSSEF2U128R64 iemAImpl_cvtsd2ss_u128_r64;
4416FNIEMAIMPLFPSSEF2U128R32 iemAImpl_sqrtss_u128_r32;
4417FNIEMAIMPLFPSSEF2U128R64 iemAImpl_sqrtsd_u128_r64;
4418FNIEMAIMPLFPSSEF2U128R32 iemAImpl_rsqrtss_u128_r32;
4419FNIEMAIMPLFPSSEF2U128R32 iemAImpl_rcpss_u128_r32;
4420
4421FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddps_u128, iemAImpl_vaddps_u128_fallback;
4422FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddpd_u128, iemAImpl_vaddpd_u128_fallback;
4423FNIEMAIMPLFPAVXF3U128 iemAImpl_vmulps_u128, iemAImpl_vmulps_u128_fallback;
4424FNIEMAIMPLFPAVXF3U128 iemAImpl_vmulpd_u128, iemAImpl_vmulpd_u128_fallback;
4425FNIEMAIMPLFPAVXF3U128 iemAImpl_vsubps_u128, iemAImpl_vsubps_u128_fallback;
4426FNIEMAIMPLFPAVXF3U128 iemAImpl_vsubpd_u128, iemAImpl_vsubpd_u128_fallback;
4427FNIEMAIMPLFPAVXF3U128 iemAImpl_vminps_u128, iemAImpl_vminps_u128_fallback;
4428FNIEMAIMPLFPAVXF3U128 iemAImpl_vminpd_u128, iemAImpl_vminpd_u128_fallback;
4429FNIEMAIMPLFPAVXF3U128 iemAImpl_vdivps_u128, iemAImpl_vdivps_u128_fallback;
4430FNIEMAIMPLFPAVXF3U128 iemAImpl_vdivpd_u128, iemAImpl_vdivpd_u128_fallback;
4431FNIEMAIMPLFPAVXF3U128 iemAImpl_vmaxps_u128, iemAImpl_vmaxps_u128_fallback;
4432FNIEMAIMPLFPAVXF3U128 iemAImpl_vmaxpd_u128, iemAImpl_vmaxpd_u128_fallback;
4433FNIEMAIMPLFPAVXF3U128 iemAImpl_vhaddps_u128, iemAImpl_vhaddps_u128_fallback;
4434FNIEMAIMPLFPAVXF3U128 iemAImpl_vhaddpd_u128, iemAImpl_vhaddpd_u128_fallback;
4435FNIEMAIMPLFPAVXF3U128 iemAImpl_vhsubps_u128, iemAImpl_vhsubps_u128_fallback;
4436FNIEMAIMPLFPAVXF3U128 iemAImpl_vhsubpd_u128, iemAImpl_vhsubpd_u128_fallback;
4437FNIEMAIMPLFPAVXF3U128 iemAImpl_vsqrtps_u128, iemAImpl_vsqrtps_u128_fallback;
4438FNIEMAIMPLFPAVXF3U128 iemAImpl_vsqrtpd_u128, iemAImpl_vsqrtpd_u128_fallback;
4439FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddsubps_u128, iemAImpl_vaddsubps_u128_fallback;
4440FNIEMAIMPLFPAVXF3U128 iemAImpl_vaddsubpd_u128, iemAImpl_vaddsubpd_u128_fallback;
4441FNIEMAIMPLFPAVXF3U128 iemAImpl_vcvtpd2ps_u128, iemAImpl_vcvtpd2ps_u128_fallback;
4442FNIEMAIMPLFPAVXF3U128 iemAImpl_vcvtps2pd_u128, iemAImpl_vcvtps2pd_u128_fallback;
4443
4444FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vaddss_u128_r32, iemAImpl_vaddss_u128_r32_fallback;
4445FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vaddsd_u128_r64, iemAImpl_vaddsd_u128_r64_fallback;
4446FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vmulss_u128_r32, iemAImpl_vmulss_u128_r32_fallback;
4447FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vmulsd_u128_r64, iemAImpl_vmulsd_u128_r64_fallback;
4448FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vsubss_u128_r32, iemAImpl_vsubss_u128_r32_fallback;
4449FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vsubsd_u128_r64, iemAImpl_vsubsd_u128_r64_fallback;
4450FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vminss_u128_r32, iemAImpl_vminss_u128_r32_fallback;
4451FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vminsd_u128_r64, iemAImpl_vminsd_u128_r64_fallback;
4452FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vdivss_u128_r32, iemAImpl_vdivss_u128_r32_fallback;
4453FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vdivsd_u128_r64, iemAImpl_vdivsd_u128_r64_fallback;
4454FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vmaxss_u128_r32, iemAImpl_vmaxss_u128_r32_fallback;
4455FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vmaxsd_u128_r64, iemAImpl_vmaxsd_u128_r64_fallback;
4456FNIEMAIMPLFPAVXF3U128R32 iemAImpl_vsqrtss_u128_r32, iemAImpl_vsqrtss_u128_r32_fallback;
4457FNIEMAIMPLFPAVXF3U128R64 iemAImpl_vsqrtsd_u128_r64, iemAImpl_vsqrtsd_u128_r64_fallback;
4458
4459FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddps_u256, iemAImpl_vaddps_u256_fallback;
4460FNIEMAIMPLFPAVXF3U256 iemAImpl_vaddpd_u256, iemAImpl_vaddpd_u256_fallback;
4461FNIEMAIMPLFPAVXF3U256 iemAImpl_vmulps_u256, iemAImpl_vmulps_u256_fallback;
4462FNIEMAIMPLFPAVXF3U256 iemAImpl_vmulpd_u256, iemAImpl_vmulpd_u256_fallback;
4463FNIEMAIMPLFPAVXF3U256 iemAImpl_vsubps_u256, iemAImpl_vsubps_u256_fallback;
4464FNIEMAIMPLFPAVXF3U256 iemAImpl_vsubpd_u256, iemAImpl_vsubpd_u256_fallback;
4465FNIEMAIMPLFPAVXF3U256 iemAImpl_vminps_u256, iemAImpl_vminps_u256_fallback;
4466FNIEMAIMPLFPAVXF3U256 iemAImpl_vminpd_u256, iemAImpl_vminpd_u256_fallback;
4467FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivps_u256, iemAImpl_vdivps_u256_fallback;
4468FNIEMAIMPLFPAVXF3U256 iemAImpl_vdivpd_u256, iemAImpl_vdivpd_u256_fallback;
4469FNIEMAIMPLFPAVXF3U256 iemAImpl_vmaxps_u256, iemAImpl_vmaxps_u256_fallback;
4470FNIEMAIMPLFPAVXF3U256 iemAImpl_vmaxpd_u256, iemAImpl_vmaxpd_u256_fallback;
4471FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddps_u256, iemAImpl_vhaddps_u256_fallback;
4472FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddpd_u256, iemAImpl_vhaddpd_u256_fallback;
4473FNIEMAIMPLFPAVXF3U256 iemAImpl_vhsubps_u256, iemAImpl_vhsubps_u256_fallback;
4474FNIEMAIMPLFPAVXF3U256 iemAImpl_vhsubpd_u256, iemAImpl_vhsubpd_u256_fallback;
4475FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddsubps_u256, iemAImpl_vhaddsubps_u256_fallback;
4476FNIEMAIMPLFPAVXF3U256 iemAImpl_vhaddsubpd_u256, iemAImpl_vhaddsubpd_u256_fallback;
4477FNIEMAIMPLFPAVXF3U256 iemAImpl_vcvtpd2ps_u256, iemAImpl_vcvtpd2ps_u256_fallback;
4478FNIEMAIMPLFPAVXF3U256 iemAImpl_vcvtps2pd_u256, iemAImpl_vcvtps2pd_u256_fallback;
4479/** @} */
4480
4481/** @name C instruction implementations for anything slightly complicated.
4482 * @{ */
4483
4484/**
4485 * For typedef'ing or declaring a C instruction implementation function taking
4486 * no extra arguments.
4487 *
4488 * @param a_Name The name of the type.
4489 */
4490# define IEM_CIMPL_DECL_TYPE_0(a_Name) \
4491 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
4492/**
4493 * For defining a C instruction implementation function taking no extra
4494 * arguments.
4495 *
4496 * @param a_Name The name of the function
4497 */
4498# define IEM_CIMPL_DEF_0(a_Name) \
4499 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
4500/**
4501 * Prototype version of IEM_CIMPL_DEF_0.
4502 */
4503# define IEM_CIMPL_PROTO_0(a_Name) \
4504 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr))
4505/**
4506 * For calling a C instruction implementation function taking no extra
4507 * arguments.
4508 *
4509 * This special call macro adds default arguments to the call and allow us to
4510 * change these later.
4511 *
4512 * @param a_fn The name of the function.
4513 */
4514# define IEM_CIMPL_CALL_0(a_fn) a_fn(pVCpu, cbInstr)
4515
4516/** Type for a C instruction implementation function taking no extra
4517 * arguments. */
4518typedef IEM_CIMPL_DECL_TYPE_0(FNIEMCIMPL0);
4519/** Function pointer type for a C instruction implementation function taking
4520 * no extra arguments. */
4521typedef FNIEMCIMPL0 *PFNIEMCIMPL0;
4522
4523/**
4524 * For typedef'ing or declaring a C instruction implementation function taking
4525 * one extra argument.
4526 *
4527 * @param a_Name The name of the type.
4528 * @param a_Type0 The argument type.
4529 * @param a_Arg0 The argument name.
4530 */
4531# define IEM_CIMPL_DECL_TYPE_1(a_Name, a_Type0, a_Arg0) \
4532 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
4533/**
4534 * For defining a C instruction implementation function taking one extra
4535 * argument.
4536 *
4537 * @param a_Name The name of the function
4538 * @param a_Type0 The argument type.
4539 * @param a_Arg0 The argument name.
4540 */
4541# define IEM_CIMPL_DEF_1(a_Name, a_Type0, a_Arg0) \
4542 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
4543/**
4544 * Prototype version of IEM_CIMPL_DEF_1.
4545 */
4546# define IEM_CIMPL_PROTO_1(a_Name, a_Type0, a_Arg0) \
4547 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0))
4548/**
4549 * For calling a C instruction implementation function taking one extra
4550 * argument.
4551 *
4552 * This special call macro adds default arguments to the call and allow us to
4553 * change these later.
4554 *
4555 * @param a_fn The name of the function.
4556 * @param a0 The name of the 1st argument.
4557 */
4558# define IEM_CIMPL_CALL_1(a_fn, a0) a_fn(pVCpu, cbInstr, (a0))
4559
4560/**
4561 * For typedef'ing or declaring a C instruction implementation function taking
4562 * two extra arguments.
4563 *
4564 * @param a_Name The name of the type.
4565 * @param a_Type0 The type of the 1st argument
4566 * @param a_Arg0 The name of the 1st argument.
4567 * @param a_Type1 The type of the 2nd argument.
4568 * @param a_Arg1 The name of the 2nd argument.
4569 */
4570# define IEM_CIMPL_DECL_TYPE_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
4571 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
4572/**
4573 * For defining a C instruction implementation function taking two extra
4574 * arguments.
4575 *
4576 * @param a_Name The name of the function.
4577 * @param a_Type0 The type of the 1st argument
4578 * @param a_Arg0 The name of the 1st argument.
4579 * @param a_Type1 The type of the 2nd argument.
4580 * @param a_Arg1 The name of the 2nd argument.
4581 */
4582# define IEM_CIMPL_DEF_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
4583 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
4584/**
4585 * Prototype version of IEM_CIMPL_DEF_2.
4586 */
4587# define IEM_CIMPL_PROTO_2(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1) \
4588 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1))
4589/**
4590 * For calling a C instruction implementation function taking two extra
4591 * arguments.
4592 *
4593 * This special call macro adds default arguments to the call and allow us to
4594 * change these later.
4595 *
4596 * @param a_fn The name of the function.
4597 * @param a0 The name of the 1st argument.
4598 * @param a1 The name of the 2nd argument.
4599 */
4600# define IEM_CIMPL_CALL_2(a_fn, a0, a1) a_fn(pVCpu, cbInstr, (a0), (a1))
4601
4602/**
4603 * For typedef'ing or declaring a C instruction implementation function taking
4604 * three extra arguments.
4605 *
4606 * @param a_Name The name of the type.
4607 * @param a_Type0 The type of the 1st argument
4608 * @param a_Arg0 The name of the 1st argument.
4609 * @param a_Type1 The type of the 2nd argument.
4610 * @param a_Arg1 The name of the 2nd argument.
4611 * @param a_Type2 The type of the 3rd argument.
4612 * @param a_Arg2 The name of the 3rd argument.
4613 */
4614# define IEM_CIMPL_DECL_TYPE_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
4615 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
4616/**
4617 * For defining a C instruction implementation function taking three extra
4618 * arguments.
4619 *
4620 * @param a_Name The name of the function.
4621 * @param a_Type0 The type of the 1st argument
4622 * @param a_Arg0 The name of the 1st argument.
4623 * @param a_Type1 The type of the 2nd argument.
4624 * @param a_Arg1 The name of the 2nd argument.
4625 * @param a_Type2 The type of the 3rd argument.
4626 * @param a_Arg2 The name of the 3rd argument.
4627 */
4628# define IEM_CIMPL_DEF_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
4629 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
4630/**
4631 * Prototype version of IEM_CIMPL_DEF_3.
4632 */
4633# define IEM_CIMPL_PROTO_3(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2) \
4634 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2))
4635/**
4636 * For calling a C instruction implementation function taking three extra
4637 * arguments.
4638 *
4639 * This special call macro adds default arguments to the call and allow us to
4640 * change these later.
4641 *
4642 * @param a_fn The name of the function.
4643 * @param a0 The name of the 1st argument.
4644 * @param a1 The name of the 2nd argument.
4645 * @param a2 The name of the 3rd argument.
4646 */
4647# define IEM_CIMPL_CALL_3(a_fn, a0, a1, a2) a_fn(pVCpu, cbInstr, (a0), (a1), (a2))
4648
4649
4650/**
4651 * For typedef'ing or declaring a C instruction implementation function taking
4652 * four extra arguments.
4653 *
4654 * @param a_Name The name of the type.
4655 * @param a_Type0 The type of the 1st argument
4656 * @param a_Arg0 The name of the 1st argument.
4657 * @param a_Type1 The type of the 2nd argument.
4658 * @param a_Arg1 The name of the 2nd argument.
4659 * @param a_Type2 The type of the 3rd argument.
4660 * @param a_Arg2 The name of the 3rd argument.
4661 * @param a_Type3 The type of the 4th argument.
4662 * @param a_Arg3 The name of the 4th argument.
4663 */
4664# define IEM_CIMPL_DECL_TYPE_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
4665 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))
4666/**
4667 * For defining a C instruction implementation function taking four extra
4668 * arguments.
4669 *
4670 * @param a_Name The name of the function.
4671 * @param a_Type0 The type of the 1st argument
4672 * @param a_Arg0 The name of the 1st argument.
4673 * @param a_Type1 The type of the 2nd argument.
4674 * @param a_Arg1 The name of the 2nd argument.
4675 * @param a_Type2 The type of the 3rd argument.
4676 * @param a_Arg2 The name of the 3rd argument.
4677 * @param a_Type3 The type of the 4th argument.
4678 * @param a_Arg3 The name of the 4th argument.
4679 */
4680# define IEM_CIMPL_DEF_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
4681 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4682 a_Type2 a_Arg2, a_Type3 a_Arg3))
4683/**
4684 * Prototype version of IEM_CIMPL_DEF_4.
4685 */
4686# define IEM_CIMPL_PROTO_4(a_Name, a_Type0, a_Arg0, a_Type1, a_Arg1, a_Type2, a_Arg2, a_Type3, a_Arg3) \
4687 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4688 a_Type2 a_Arg2, a_Type3 a_Arg3))
4689/**
4690 * For calling a C instruction implementation function taking four extra
4691 * arguments.
4692 *
4693 * This special call macro adds default arguments to the call and allow us to
4694 * change these later.
4695 *
4696 * @param a_fn The name of the function.
4697 * @param a0 The name of the 1st argument.
4698 * @param a1 The name of the 2nd argument.
4699 * @param a2 The name of the 3rd argument.
4700 * @param a3 The name of the 4th argument.
4701 */
4702# define IEM_CIMPL_CALL_4(a_fn, a0, a1, a2, a3) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3))
4703
4704
4705/**
4706 * For typedef'ing or declaring a C instruction implementation function taking
4707 * five extra arguments.
4708 *
4709 * @param a_Name The name of the type.
4710 * @param a_Type0 The type of the 1st argument
4711 * @param a_Arg0 The name of the 1st argument.
4712 * @param a_Type1 The type of the 2nd argument.
4713 * @param a_Arg1 The name of the 2nd argument.
4714 * @param a_Type2 The type of the 3rd argument.
4715 * @param a_Arg2 The name of the 3rd argument.
4716 * @param a_Type3 The type of the 4th argument.
4717 * @param a_Arg3 The name of the 4th argument.
4718 * @param a_Type4 The type of the 5th argument.
4719 * @param a_Arg4 The name of the 5th argument.
4720 */
4721# 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) \
4722 IEM_DECL_IMPL_TYPE(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, \
4723 a_Type0 a_Arg0, a_Type1 a_Arg1, a_Type2 a_Arg2, \
4724 a_Type3 a_Arg3, a_Type4 a_Arg4))
4725/**
4726 * For defining a C instruction implementation function taking five extra
4727 * arguments.
4728 *
4729 * @param a_Name The name of the function.
4730 * @param a_Type0 The type of the 1st argument
4731 * @param a_Arg0 The name of the 1st argument.
4732 * @param a_Type1 The type of the 2nd argument.
4733 * @param a_Arg1 The name of the 2nd argument.
4734 * @param a_Type2 The type of the 3rd argument.
4735 * @param a_Arg2 The name of the 3rd argument.
4736 * @param a_Type3 The type of the 4th argument.
4737 * @param a_Arg3 The name of the 4th argument.
4738 * @param a_Type4 The type of the 5th argument.
4739 * @param a_Arg4 The name of the 5th argument.
4740 */
4741# 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) \
4742 IEM_DECL_IMPL_DEF(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4743 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
4744/**
4745 * Prototype version of IEM_CIMPL_DEF_5.
4746 */
4747# 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) \
4748 IEM_DECL_IMPL_PROTO(VBOXSTRICTRC, a_Name, (PVMCPUCC pVCpu, uint8_t cbInstr, a_Type0 a_Arg0, a_Type1 a_Arg1, \
4749 a_Type2 a_Arg2, a_Type3 a_Arg3, a_Type4 a_Arg4))
4750/**
4751 * For calling a C instruction implementation function taking five extra
4752 * arguments.
4753 *
4754 * This special call macro adds default arguments to the call and allow us to
4755 * change these later.
4756 *
4757 * @param a_fn The name of the function.
4758 * @param a0 The name of the 1st argument.
4759 * @param a1 The name of the 2nd argument.
4760 * @param a2 The name of the 3rd argument.
4761 * @param a3 The name of the 4th argument.
4762 * @param a4 The name of the 5th argument.
4763 */
4764# define IEM_CIMPL_CALL_5(a_fn, a0, a1, a2, a3, a4) a_fn(pVCpu, cbInstr, (a0), (a1), (a2), (a3), (a4))
4765
4766/** @} */
4767
4768
4769/** @name Opcode Decoder Function Types.
4770 * @{ */
4771
4772/** @typedef PFNIEMOP
4773 * Pointer to an opcode decoder function.
4774 */
4775
4776/** @def FNIEMOP_DEF
4777 * Define an opcode decoder function.
4778 *
4779 * We're using macors for this so that adding and removing parameters as well as
4780 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL
4781 *
4782 * @param a_Name The function name.
4783 */
4784
4785/** @typedef PFNIEMOPRM
4786 * Pointer to an opcode decoder function with RM byte.
4787 */
4788
4789/** @def FNIEMOPRM_DEF
4790 * Define an opcode decoder function with RM byte.
4791 *
4792 * We're using macors for this so that adding and removing parameters as well as
4793 * tweaking compiler specific attributes becomes easier. See FNIEMOP_CALL_1
4794 *
4795 * @param a_Name The function name.
4796 */
4797
4798#if defined(__GNUC__) && defined(RT_ARCH_X86)
4799typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOP)(PVMCPUCC pVCpu);
4800typedef VBOXSTRICTRC (__attribute__((__fastcall__)) * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4801# define FNIEMOP_DEF(a_Name) \
4802 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu)
4803# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4804 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
4805# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4806 IEM_STATIC VBOXSTRICTRC __attribute__((__fastcall__, __nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
4807
4808#elif defined(_MSC_VER) && defined(RT_ARCH_X86)
4809typedef VBOXSTRICTRC (__fastcall * PFNIEMOP)(PVMCPUCC pVCpu);
4810typedef VBOXSTRICTRC (__fastcall * PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4811# define FNIEMOP_DEF(a_Name) \
4812 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
4813# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4814 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) IEM_NOEXCEPT_MAY_LONGJMP
4815# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4816 IEM_STATIC /*__declspec(naked)*/ VBOXSTRICTRC __fastcall a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) IEM_NOEXCEPT_MAY_LONGJMP
4817
4818#elif defined(__GNUC__) && !defined(IEM_WITH_THROW_CATCH)
4819typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
4820typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4821# define FNIEMOP_DEF(a_Name) \
4822 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu)
4823# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4824 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0)
4825# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4826 IEM_STATIC VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1)
4827
4828#else
4829typedef VBOXSTRICTRC (* PFNIEMOP)(PVMCPUCC pVCpu);
4830typedef VBOXSTRICTRC (* PFNIEMOPRM)(PVMCPUCC pVCpu, uint8_t bRm);
4831# define FNIEMOP_DEF(a_Name) \
4832 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP
4833# define FNIEMOP_DEF_1(a_Name, a_Type0, a_Name0) \
4834 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0) IEM_NOEXCEPT_MAY_LONGJMP
4835# define FNIEMOP_DEF_2(a_Name, a_Type0, a_Name0, a_Type1, a_Name1) \
4836 IEM_STATIC VBOXSTRICTRC a_Name(PVMCPUCC pVCpu, a_Type0 a_Name0, a_Type1 a_Name1) IEM_NOEXCEPT_MAY_LONGJMP
4837
4838#endif
4839#define FNIEMOPRM_DEF(a_Name) FNIEMOP_DEF_1(a_Name, uint8_t, bRm)
4840
4841/**
4842 * Call an opcode decoder function.
4843 *
4844 * We're using macors for this so that adding and removing parameters can be
4845 * done as we please. See FNIEMOP_DEF.
4846 */
4847#define FNIEMOP_CALL(a_pfn) (a_pfn)(pVCpu)
4848
4849/**
4850 * Call a common opcode decoder function taking one extra argument.
4851 *
4852 * We're using macors for this so that adding and removing parameters can be
4853 * done as we please. See FNIEMOP_DEF_1.
4854 */
4855#define FNIEMOP_CALL_1(a_pfn, a0) (a_pfn)(pVCpu, a0)
4856
4857/**
4858 * Call a common opcode decoder function taking one extra argument.
4859 *
4860 * We're using macors for this so that adding and removing parameters can be
4861 * done as we please. See FNIEMOP_DEF_1.
4862 */
4863#define FNIEMOP_CALL_2(a_pfn, a0, a1) (a_pfn)(pVCpu, a0, a1)
4864/** @} */
4865
4866
4867/** @name Misc Helpers
4868 * @{ */
4869
4870/** Used to shut up GCC warnings about variables that 'may be used uninitialized'
4871 * due to GCC lacking knowledge about the value range of a switch. */
4872#if RT_CPLUSPLUS_PREREQ(202000)
4873# define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: [[unlikely]] AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
4874#else
4875# define IEM_NOT_REACHED_DEFAULT_CASE_RET() default: AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE)
4876#endif
4877
4878/** Variant of IEM_NOT_REACHED_DEFAULT_CASE_RET that returns a custom value. */
4879#if RT_CPLUSPLUS_PREREQ(202000)
4880# define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: [[unlikely]] AssertFailedReturn(a_RetValue)
4881#else
4882# define IEM_NOT_REACHED_DEFAULT_CASE_RET2(a_RetValue) default: AssertFailedReturn(a_RetValue)
4883#endif
4884
4885/**
4886 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
4887 * occation.
4888 */
4889#ifdef LOG_ENABLED
4890# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
4891 do { \
4892 /*Log*/ LogAlways(("%s: returning IEM_RETURN_ASPECT_NOT_IMPLEMENTED (line %d)\n", __FUNCTION__, __LINE__)); \
4893 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
4894 } while (0)
4895#else
4896# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED() \
4897 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
4898#endif
4899
4900/**
4901 * Returns IEM_RETURN_ASPECT_NOT_IMPLEMENTED, and in debug builds logs the
4902 * occation using the supplied logger statement.
4903 *
4904 * @param a_LoggerArgs What to log on failure.
4905 */
4906#ifdef LOG_ENABLED
4907# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
4908 do { \
4909 LogAlways((LOG_FN_FMT ": ", __PRETTY_FUNCTION__)); LogAlways(a_LoggerArgs); \
4910 /*LogFunc(a_LoggerArgs);*/ \
4911 return VERR_IEM_ASPECT_NOT_IMPLEMENTED; \
4912 } while (0)
4913#else
4914# define IEM_RETURN_ASPECT_NOT_IMPLEMENTED_LOG(a_LoggerArgs) \
4915 return VERR_IEM_ASPECT_NOT_IMPLEMENTED
4916#endif
4917
4918/**
4919 * Gets the CPU mode (from fExec) as a IEMMODE value.
4920 *
4921 * @returns IEMMODE
4922 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4923 */
4924#define IEM_GET_CPU_MODE(a_pVCpu) ((a_pVCpu)->iem.s.fExec & IEM_F_MODE_CPUMODE_MASK)
4925
4926/**
4927 * Check if we're currently executing in real or virtual 8086 mode.
4928 *
4929 * @returns @c true if it is, @c false if not.
4930 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4931 */
4932#define IEM_IS_REAL_OR_V86_MODE(a_pVCpu) (( ((a_pVCpu)->iem.s.fExec ^ IEM_F_MODE_X86_PROT_MASK) \
4933 & (IEM_F_MODE_X86_V86_MASK | IEM_F_MODE_X86_PROT_MASK)) != 0)
4934
4935/**
4936 * Check if we're currently executing in virtual 8086 mode.
4937 *
4938 * @returns @c true if it is, @c false if not.
4939 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4940 */
4941#define IEM_IS_V86_MODE(a_pVCpu) (((a_pVCpu)->iem.s.fExec & IEM_F_MODE_X86_V86_MASK) != 0)
4942
4943/**
4944 * Check if we're currently executing in long mode.
4945 *
4946 * @returns @c true if it is, @c false if not.
4947 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4948 */
4949#define IEM_IS_LONG_MODE(a_pVCpu) (CPUMIsGuestInLongModeEx(IEM_GET_CTX(a_pVCpu)))
4950
4951/**
4952 * Check if we're currently executing in a 16-bit code segment.
4953 *
4954 * @returns @c true if it is, @c false if not.
4955 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4956 */
4957#define IEM_IS_16BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_16BIT)
4958
4959/**
4960 * Check if we're currently executing in a 32-bit code segment.
4961 *
4962 * @returns @c true if it is, @c false if not.
4963 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4964 */
4965#define IEM_IS_32BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_32BIT)
4966
4967/**
4968 * Check if we're currently executing in a 64-bit code segment.
4969 *
4970 * @returns @c true if it is, @c false if not.
4971 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4972 */
4973#define IEM_IS_64BIT_CODE(a_pVCpu) (IEM_GET_CPU_MODE(a_pVCpu) == IEMMODE_64BIT)
4974
4975/**
4976 * Check if we're currently executing in real mode.
4977 *
4978 * @returns @c true if it is, @c false if not.
4979 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4980 */
4981#define IEM_IS_REAL_MODE(a_pVCpu) (!((a_pVCpu)->iem.s.fExec & IEM_F_MODE_X86_PROT_MASK))
4982
4983/**
4984 * Gets the current protection level (CPL).
4985 *
4986 * @returns 0..3
4987 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4988 */
4989#define IEM_GET_CPL(a_pVCpu) (((a_pVCpu)->iem.s.fExec >> IEM_F_X86_CPL_SHIFT) & IEM_F_X86_CPL_SMASK)
4990
4991/**
4992 * Sets the current protection level (CPL).
4993 *
4994 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
4995 */
4996#define IEM_SET_CPL(a_pVCpu, a_uCpl) \
4997 do { (a_pVCpu)->iem.s.fExec = ((a_pVCpu)->iem.s.fExec & ~IEM_F_X86_CPL_MASK) | ((a_uCpl) << IEM_F_X86_CPL_SHIFT); } while (0)
4998
4999/**
5000 * Returns a (const) pointer to the CPUMFEATURES for the guest CPU.
5001 * @returns PCCPUMFEATURES
5002 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5003 */
5004#define IEM_GET_GUEST_CPU_FEATURES(a_pVCpu) (&((a_pVCpu)->CTX_SUFF(pVM)->cpum.ro.GuestFeatures))
5005
5006/**
5007 * Returns a (const) pointer to the CPUMFEATURES for the host CPU.
5008 * @returns PCCPUMFEATURES
5009 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5010 */
5011#define IEM_GET_HOST_CPU_FEATURES(a_pVCpu) (&g_CpumHostFeatures.s)
5012
5013/**
5014 * Evaluates to true if we're presenting an Intel CPU to the guest.
5015 */
5016#define IEM_IS_GUEST_CPU_INTEL(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_INTEL )
5017
5018/**
5019 * Evaluates to true if we're presenting an AMD CPU to the guest.
5020 */
5021#define IEM_IS_GUEST_CPU_AMD(a_pVCpu) ( (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_AMD || (a_pVCpu)->iem.s.enmCpuVendor == CPUMCPUVENDOR_HYGON )
5022
5023/**
5024 * Check if the address is canonical.
5025 */
5026#define IEM_IS_CANONICAL(a_u64Addr) X86_IS_CANONICAL(a_u64Addr)
5027
5028/** Checks if the ModR/M byte is in register mode or not. */
5029#define IEM_IS_MODRM_REG_MODE(a_bRm) ( ((a_bRm) & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT) )
5030/** Checks if the ModR/M byte is in memory mode or not. */
5031#define IEM_IS_MODRM_MEM_MODE(a_bRm) ( ((a_bRm) & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT) )
5032
5033/**
5034 * Gets the register (reg) part of a ModR/M encoding, with REX.R added in.
5035 *
5036 * For use during decoding.
5037 */
5038#define IEM_GET_MODRM_REG(a_pVCpu, a_bRm) ( (((a_bRm) >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | (a_pVCpu)->iem.s.uRexReg )
5039/**
5040 * Gets the r/m part of a ModR/M encoding as a register index, with REX.B added in.
5041 *
5042 * For use during decoding.
5043 */
5044#define IEM_GET_MODRM_RM(a_pVCpu, a_bRm) ( ((a_bRm) & X86_MODRM_RM_MASK) | (a_pVCpu)->iem.s.uRexB )
5045
5046/**
5047 * Gets the register (reg) part of a ModR/M encoding, without REX.R.
5048 *
5049 * For use during decoding.
5050 */
5051#define IEM_GET_MODRM_REG_8(a_bRm) ( (((a_bRm) >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) )
5052/**
5053 * Gets the r/m part of a ModR/M encoding as a register index, without REX.B.
5054 *
5055 * For use during decoding.
5056 */
5057#define IEM_GET_MODRM_RM_8(a_bRm) ( ((a_bRm) & X86_MODRM_RM_MASK) )
5058
5059/**
5060 * Gets the register (reg) part of a ModR/M encoding as an extended 8-bit
5061 * register index, with REX.R added in.
5062 *
5063 * For use during decoding.
5064 *
5065 * @see iemGRegRefU8Ex, iemGRegFetchU8Ex, iemGRegStoreU8Ex
5066 */
5067#define IEM_GET_MODRM_REG_EX8(a_pVCpu, a_bRm) \
5068 ( (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) \
5069 || !((a_bRm) & (4 << X86_MODRM_REG_SHIFT)) /* IEM_GET_MODRM_REG(pVCpu, a_bRm) < 4 */ \
5070 ? IEM_GET_MODRM_REG(pVCpu, a_bRm) : (((a_bRm) >> X86_MODRM_REG_SHIFT) & 3) | 16)
5071/**
5072 * Gets the r/m part of a ModR/M encoding as an extended 8-bit register index,
5073 * with REX.B added in.
5074 *
5075 * For use during decoding.
5076 *
5077 * @see iemGRegRefU8Ex, iemGRegFetchU8Ex, iemGRegStoreU8Ex
5078 */
5079#define IEM_GET_MODRM_RM_EX8(a_pVCpu, a_bRm) \
5080 ( (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX) \
5081 || !((a_bRm) & 4) /* IEM_GET_MODRM_RM(pVCpu, a_bRm) < 4 */ \
5082 ? IEM_GET_MODRM_RM(pVCpu, a_bRm) : ((a_bRm) & 3) | 16)
5083
5084/**
5085 * Combines the prefix REX and ModR/M byte for passing to
5086 * iemOpHlpCalcRmEffAddrThreadedAddr64().
5087 *
5088 * @returns The ModRM byte but with bit 3 set to REX.B and bit 4 to REX.X.
5089 * The two bits are part of the REG sub-field, which isn't needed in
5090 * iemOpHlpCalcRmEffAddrThreadedAddr64().
5091 *
5092 * For use during decoding/recompiling.
5093 */
5094#define IEM_GET_MODRM_EX(a_pVCpu, a_bRm) \
5095 ( ((a_bRm) & ~X86_MODRM_REG_MASK) \
5096 | (uint8_t)( (pVCpu->iem.s.fPrefixes & (IEM_OP_PRF_REX_B | IEM_OP_PRF_REX_X)) >> (25 - 3) ) )
5097AssertCompile(IEM_OP_PRF_REX_B == RT_BIT_32(25));
5098AssertCompile(IEM_OP_PRF_REX_X == RT_BIT_32(26));
5099
5100/**
5101 * Gets the effective VEX.VVVV value.
5102 *
5103 * The 4th bit is ignored if not 64-bit code.
5104 * @returns effective V-register value.
5105 * @param a_pVCpu The cross context virtual CPU structure of the calling thread.
5106 */
5107#define IEM_GET_EFFECTIVE_VVVV(a_pVCpu) \
5108 (IEM_IS_64BIT_CODE(a_pVCpu) ? (a_pVCpu)->iem.s.uVex3rdReg : (a_pVCpu)->iem.s.uVex3rdReg & 7)
5109
5110
5111/**
5112 * Gets the register (reg) part of a the special 4th register byte used by
5113 * vblendvps and vblendvpd.
5114 *
5115 * For use during decoding.
5116 */
5117#define IEM_GET_IMM8_REG(a_pVCpu, a_bRegImm8) \
5118 (IEM_IS_64BIT_CODE(a_pVCpu) ? (a_bRegImm8) >> 4 : ((a_bRegImm8) >> 4) & 7)
5119
5120
5121/**
5122 * Checks if we're executing inside an AMD-V or VT-x guest.
5123 */
5124#if defined(VBOX_WITH_NESTED_HWVIRT_VMX) || defined(VBOX_WITH_NESTED_HWVIRT_SVM)
5125# define IEM_IS_IN_GUEST(a_pVCpu) RT_BOOL((a_pVCpu)->iem.s.fExec & IEM_F_X86_CTX_IN_GUEST)
5126#else
5127# define IEM_IS_IN_GUEST(a_pVCpu) false
5128#endif
5129
5130
5131#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
5132
5133/**
5134 * Check if the guest has entered VMX root operation.
5135 */
5136# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (CPUMIsGuestInVmxRootMode(IEM_GET_CTX(a_pVCpu)))
5137
5138/**
5139 * Check if the guest has entered VMX non-root operation.
5140 */
5141# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) ( ((a_pVCpu)->iem.s.fExec & (IEM_F_X86_CTX_VMX | IEM_F_X86_CTX_IN_GUEST)) \
5142 == (IEM_F_X86_CTX_VMX | IEM_F_X86_CTX_IN_GUEST) )
5143
5144/**
5145 * Check if the nested-guest has the given Pin-based VM-execution control set.
5146 */
5147# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_PinCtl) (CPUMIsGuestVmxPinCtlsSet(IEM_GET_CTX(a_pVCpu), (a_PinCtl)))
5148
5149/**
5150 * Check if the nested-guest has the given Processor-based VM-execution control set.
5151 */
5152# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_ProcCtl) (CPUMIsGuestVmxProcCtlsSet(IEM_GET_CTX(a_pVCpu), (a_ProcCtl)))
5153
5154/**
5155 * Check if the nested-guest has the given Secondary Processor-based VM-execution
5156 * control set.
5157 */
5158# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_ProcCtl2) (CPUMIsGuestVmxProcCtls2Set(IEM_GET_CTX(a_pVCpu), (a_ProcCtl2)))
5159
5160/** Gets the guest-physical address of the shadows VMCS for the given VCPU. */
5161# define IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysShadowVmcs)
5162
5163/** Whether a shadow VMCS is present for the given VCPU. */
5164# define IEM_VMX_HAS_SHADOW_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_SHADOW_VMCS(a_pVCpu) != NIL_RTGCPHYS)
5165
5166/** Gets the VMXON region pointer. */
5167# define IEM_VMX_GET_VMXON_PTR(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmxon)
5168
5169/** Gets the guest-physical address of the current VMCS for the given VCPU. */
5170# define IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) ((a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs)
5171
5172/** Whether a current VMCS is present for the given VCPU. */
5173# define IEM_VMX_HAS_CURRENT_VMCS(a_pVCpu) RT_BOOL(IEM_VMX_GET_CURRENT_VMCS(a_pVCpu) != NIL_RTGCPHYS)
5174
5175/** Assigns the guest-physical address of the current VMCS for the given VCPU. */
5176# define IEM_VMX_SET_CURRENT_VMCS(a_pVCpu, a_GCPhysVmcs) \
5177 do \
5178 { \
5179 Assert((a_GCPhysVmcs) != NIL_RTGCPHYS); \
5180 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = (a_GCPhysVmcs); \
5181 } while (0)
5182
5183/** Clears any current VMCS for the given VCPU. */
5184# define IEM_VMX_CLEAR_CURRENT_VMCS(a_pVCpu) \
5185 do \
5186 { \
5187 (a_pVCpu)->cpum.GstCtx.hwvirt.vmx.GCPhysVmcs = NIL_RTGCPHYS; \
5188 } while (0)
5189
5190/**
5191 * Invokes the VMX VM-exit handler for an instruction intercept.
5192 */
5193# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) \
5194 do { return iemVmxVmexitInstr((a_pVCpu), (a_uExitReason), (a_cbInstr)); } while (0)
5195
5196/**
5197 * Invokes the VMX VM-exit handler for an instruction intercept where the
5198 * instruction provides additional VM-exit information.
5199 */
5200# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) \
5201 do { return iemVmxVmexitInstrNeedsInfo((a_pVCpu), (a_uExitReason), (a_uInstrId), (a_cbInstr)); } while (0)
5202
5203/**
5204 * Invokes the VMX VM-exit handler for a task switch.
5205 */
5206# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) \
5207 do { return iemVmxVmexitTaskSwitch((a_pVCpu), (a_enmTaskSwitch), (a_SelNewTss), (a_cbInstr)); } while (0)
5208
5209/**
5210 * Invokes the VMX VM-exit handler for MWAIT.
5211 */
5212# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) \
5213 do { return iemVmxVmexitInstrMwait((a_pVCpu), (a_fMonitorArmed), (a_cbInstr)); } while (0)
5214
5215/**
5216 * Invokes the VMX VM-exit handler for EPT faults.
5217 */
5218# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) \
5219 do { return iemVmxVmexitEpt(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr); } while (0)
5220
5221/**
5222 * Invokes the VMX VM-exit handler.
5223 */
5224# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) \
5225 do { return iemVmxVmexit((a_pVCpu), (a_uExitReason), (a_uExitQual)); } while (0)
5226
5227#else
5228# define IEM_VMX_IS_ROOT_MODE(a_pVCpu) (false)
5229# define IEM_VMX_IS_NON_ROOT_MODE(a_pVCpu) (false)
5230# define IEM_VMX_IS_PINCTLS_SET(a_pVCpu, a_cbInstr) (false)
5231# define IEM_VMX_IS_PROCCTLS_SET(a_pVCpu, a_cbInstr) (false)
5232# define IEM_VMX_IS_PROCCTLS2_SET(a_pVCpu, a_cbInstr) (false)
5233# define IEM_VMX_VMEXIT_INSTR_RET(a_pVCpu, a_uExitReason, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5234# define IEM_VMX_VMEXIT_INSTR_NEEDS_INFO_RET(a_pVCpu, a_uExitReason, a_uInstrId, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5235# define IEM_VMX_VMEXIT_TASK_SWITCH_RET(a_pVCpu, a_enmTaskSwitch, a_SelNewTss, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5236# define IEM_VMX_VMEXIT_MWAIT_RET(a_pVCpu, a_fMonitorArmed, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5237# define IEM_VMX_VMEXIT_EPT_RET(a_pVCpu, a_pPtWalk, a_fAccess, a_fSlatFail, a_cbInstr) do { return VERR_VMX_IPE_1; } while (0)
5238# define IEM_VMX_VMEXIT_TRIPLE_FAULT_RET(a_pVCpu, a_uExitReason, a_uExitQual) do { return VERR_VMX_IPE_1; } while (0)
5239
5240#endif
5241
5242#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
5243/**
5244 * Checks if we're executing a guest using AMD-V.
5245 */
5246# define IEM_SVM_IS_IN_GUEST(a_pVCpu) ( (a_pVCpu->iem.s.fExec & (IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST)) \
5247 == (IEM_F_X86_CTX_SVM | IEM_F_X86_CTX_IN_GUEST))
5248/**
5249 * Check if an SVM control/instruction intercept is set.
5250 */
5251# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) \
5252 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmCtrlInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_Intercept)))
5253
5254/**
5255 * Check if an SVM read CRx intercept is set.
5256 */
5257# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
5258 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmReadCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
5259
5260/**
5261 * Check if an SVM write CRx intercept is set.
5262 */
5263# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) \
5264 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmWriteCRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uCr)))
5265
5266/**
5267 * Check if an SVM read DRx intercept is set.
5268 */
5269# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
5270 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmReadDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
5271
5272/**
5273 * Check if an SVM write DRx intercept is set.
5274 */
5275# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) \
5276 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmWriteDRxInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uDr)))
5277
5278/**
5279 * Check if an SVM exception intercept is set.
5280 */
5281# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) \
5282 (IEM_SVM_IS_IN_GUEST(a_pVCpu) && CPUMIsGuestSvmXcptInterceptSet(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_uVector)))
5283
5284/**
5285 * Invokes the SVM \#VMEXIT handler for the nested-guest.
5286 */
5287# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) \
5288 do { return iemSvmVmexit((a_pVCpu), (a_uExitCode), (a_uExitInfo1), (a_uExitInfo2)); } while (0)
5289
5290/**
5291 * Invokes the 'MOV CRx' SVM \#VMEXIT handler after constructing the
5292 * corresponding decode assist information.
5293 */
5294# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) \
5295 do \
5296 { \
5297 uint64_t uExitInfo1; \
5298 if ( IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmDecodeAssists \
5299 && (a_enmAccessCrX) == IEMACCESSCRX_MOV_CRX) \
5300 uExitInfo1 = SVM_EXIT1_MOV_CRX_MASK | ((a_iGReg) & 7); \
5301 else \
5302 uExitInfo1 = 0; \
5303 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, uExitInfo1, 0); \
5304 } while (0)
5305
5306/** Check and handles SVM nested-guest instruction intercept and updates
5307 * NRIP if needed.
5308 */
5309# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, a_uExitInfo1, a_uExitInfo2, a_cbInstr) \
5310 do \
5311 { \
5312 if (IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept)) \
5313 { \
5314 IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr); \
5315 IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2); \
5316 } \
5317 } while (0)
5318
5319/** Checks and handles SVM nested-guest CR0 read intercept. */
5320# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2, a_cbInstr) \
5321 do \
5322 { \
5323 if (!IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, 0)) \
5324 { /* probably likely */ } \
5325 else \
5326 { \
5327 IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr); \
5328 IEM_SVM_VMEXIT_RET(a_pVCpu, SVM_EXIT_READ_CR0, a_uExitInfo1, a_uExitInfo2); \
5329 } \
5330 } while (0)
5331
5332/**
5333 * Updates the NextRIP (NRI) field in the nested-guest VMCB.
5334 */
5335# define IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr) \
5336 do { \
5337 if (IEM_GET_GUEST_CPU_FEATURES(a_pVCpu)->fSvmNextRipSave) \
5338 CPUMGuestSvmUpdateNRip(a_pVCpu, IEM_GET_CTX(a_pVCpu), (a_cbInstr)); \
5339 } while (0)
5340
5341#else
5342# define IEM_SVM_IS_CTRL_INTERCEPT_SET(a_pVCpu, a_Intercept) (false)
5343# define IEM_SVM_IS_READ_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
5344# define IEM_SVM_IS_WRITE_CR_INTERCEPT_SET(a_pVCpu, a_uCr) (false)
5345# define IEM_SVM_IS_READ_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
5346# define IEM_SVM_IS_WRITE_DR_INTERCEPT_SET(a_pVCpu, a_uDr) (false)
5347# define IEM_SVM_IS_XCPT_INTERCEPT_SET(a_pVCpu, a_uVector) (false)
5348# define IEM_SVM_VMEXIT_RET(a_pVCpu, a_uExitCode, a_uExitInfo1, a_uExitInfo2) do { return VERR_SVM_IPE_1; } while (0)
5349# define IEM_SVM_CRX_VMEXIT_RET(a_pVCpu, a_uExitCode, a_enmAccessCrX, a_iGReg) do { return VERR_SVM_IPE_1; } while (0)
5350# define IEM_SVM_CHECK_INSTR_INTERCEPT(a_pVCpu, a_Intercept, a_uExitCode, \
5351 a_uExitInfo1, a_uExitInfo2, a_cbInstr) do { } while (0)
5352# define IEM_SVM_CHECK_READ_CR0_INTERCEPT(a_pVCpu, a_uExitInfo1, a_uExitInfo2, a_cbInstr) do { } while (0)
5353# define IEM_SVM_UPDATE_NRIP(a_pVCpu, a_cbInstr) do { } while (0)
5354
5355#endif
5356
5357/** @} */
5358
5359uint32_t iemCalcExecDbgFlagsSlow(PVMCPUCC pVCpu);
5360VBOXSTRICTRC iemExecInjectPendingTrap(PVMCPUCC pVCpu);
5361
5362
5363/**
5364 * Selector descriptor table entry as fetched by iemMemFetchSelDesc.
5365 */
5366typedef union IEMSELDESC
5367{
5368 /** The legacy view. */
5369 X86DESC Legacy;
5370 /** The long mode view. */
5371 X86DESC64 Long;
5372} IEMSELDESC;
5373/** Pointer to a selector descriptor table entry. */
5374typedef IEMSELDESC *PIEMSELDESC;
5375
5376/** @name Raising Exceptions.
5377 * @{ */
5378VBOXSTRICTRC iemTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, uint32_t uNextEip, uint32_t fFlags,
5379 uint16_t uErr, uint64_t uCr2, RTSEL SelTSS, PIEMSELDESC pNewDescTSS) RT_NOEXCEPT;
5380
5381VBOXSTRICTRC iemRaiseXcptOrInt(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags,
5382 uint16_t uErr, uint64_t uCr2) RT_NOEXCEPT;
5383#ifdef IEM_WITH_SETJMP
5384DECL_NO_RETURN(void) iemRaiseXcptOrIntJmp(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector,
5385 uint32_t fFlags, uint16_t uErr, uint64_t uCr2) IEM_NOEXCEPT_MAY_LONGJMP;
5386#endif
5387VBOXSTRICTRC iemRaiseDivideError(PVMCPUCC pVCpu) RT_NOEXCEPT;
5388#ifdef IEM_WITH_SETJMP
5389DECL_NO_RETURN(void) iemRaiseDivideErrorJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5390#endif
5391VBOXSTRICTRC iemRaiseDebugException(PVMCPUCC pVCpu) RT_NOEXCEPT;
5392VBOXSTRICTRC iemRaiseBoundRangeExceeded(PVMCPUCC pVCpu) RT_NOEXCEPT;
5393VBOXSTRICTRC iemRaiseUndefinedOpcode(PVMCPUCC pVCpu) RT_NOEXCEPT;
5394#ifdef IEM_WITH_SETJMP
5395DECL_NO_RETURN(void) iemRaiseUndefinedOpcodeJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5396#endif
5397VBOXSTRICTRC iemRaiseDeviceNotAvailable(PVMCPUCC pVCpu) RT_NOEXCEPT;
5398#ifdef IEM_WITH_SETJMP
5399DECL_NO_RETURN(void) iemRaiseDeviceNotAvailableJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5400#endif
5401VBOXSTRICTRC iemRaiseTaskSwitchFaultWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
5402VBOXSTRICTRC iemRaiseTaskSwitchFaultCurrentTSS(PVMCPUCC pVCpu) RT_NOEXCEPT;
5403VBOXSTRICTRC iemRaiseTaskSwitchFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
5404VBOXSTRICTRC iemRaiseTaskSwitchFaultBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
5405/*VBOXSTRICTRC iemRaiseSelectorNotPresent(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;*/
5406VBOXSTRICTRC iemRaiseSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
5407VBOXSTRICTRC iemRaiseSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
5408VBOXSTRICTRC iemRaiseStackSelectorNotPresentBySelector(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
5409VBOXSTRICTRC iemRaiseStackSelectorNotPresentWithErr(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
5410VBOXSTRICTRC iemRaiseGeneralProtectionFault(PVMCPUCC pVCpu, uint16_t uErr) RT_NOEXCEPT;
5411VBOXSTRICTRC iemRaiseGeneralProtectionFault0(PVMCPUCC pVCpu) RT_NOEXCEPT;
5412#ifdef IEM_WITH_SETJMP
5413DECL_NO_RETURN(void) iemRaiseGeneralProtectionFault0Jmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5414#endif
5415VBOXSTRICTRC iemRaiseGeneralProtectionFaultBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
5416VBOXSTRICTRC iemRaiseNotCanonical(PVMCPUCC pVCpu) RT_NOEXCEPT;
5417VBOXSTRICTRC iemRaiseSelectorBounds(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
5418#ifdef IEM_WITH_SETJMP
5419DECL_NO_RETURN(void) iemRaiseSelectorBoundsJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) IEM_NOEXCEPT_MAY_LONGJMP;
5420#endif
5421VBOXSTRICTRC iemRaiseSelectorBoundsBySelector(PVMCPUCC pVCpu, RTSEL Sel) RT_NOEXCEPT;
5422#ifdef IEM_WITH_SETJMP
5423DECL_NO_RETURN(void) iemRaiseSelectorBoundsBySelectorJmp(PVMCPUCC pVCpu, RTSEL Sel) IEM_NOEXCEPT_MAY_LONGJMP;
5424#endif
5425VBOXSTRICTRC iemRaiseSelectorInvalidAccess(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) RT_NOEXCEPT;
5426#ifdef IEM_WITH_SETJMP
5427DECL_NO_RETURN(void) iemRaiseSelectorInvalidAccessJmp(PVMCPUCC pVCpu, uint32_t iSegReg, uint32_t fAccess) IEM_NOEXCEPT_MAY_LONGJMP;
5428#endif
5429VBOXSTRICTRC iemRaisePageFault(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t cbAccess, uint32_t fAccess, int rc) RT_NOEXCEPT;
5430#ifdef IEM_WITH_SETJMP
5431DECL_NO_RETURN(void) iemRaisePageFaultJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrWhere, uint32_t cbAccess, uint32_t fAccess, int rc) IEM_NOEXCEPT_MAY_LONGJMP;
5432#endif
5433VBOXSTRICTRC iemRaiseMathFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
5434#ifdef IEM_WITH_SETJMP
5435DECL_NO_RETURN(void) iemRaiseMathFaultJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5436#endif
5437VBOXSTRICTRC iemRaiseAlignmentCheckException(PVMCPUCC pVCpu) RT_NOEXCEPT;
5438#ifdef IEM_WITH_SETJMP
5439DECL_NO_RETURN(void) iemRaiseAlignmentCheckExceptionJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5440#endif
5441VBOXSTRICTRC iemRaiseSimdFpException(PVMCPUCC pVCpu) RT_NOEXCEPT;
5442#ifdef IEM_WITH_SETJMP
5443DECL_NO_RETURN(void) iemRaiseSimdFpExceptionJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5444#endif
5445
5446void iemLogSyscallRealModeInt(PVMCPUCC pVCpu, uint8_t u8Vector, uint8_t cbInstr);
5447void iemLogSyscallProtModeInt(PVMCPUCC pVCpu, uint8_t u8Vector, uint8_t cbInstr);
5448
5449IEM_CIMPL_DEF_0(iemCImplRaiseDivideError);
5450IEM_CIMPL_DEF_0(iemCImplRaiseInvalidLockPrefix);
5451IEM_CIMPL_DEF_0(iemCImplRaiseInvalidOpcode);
5452
5453/**
5454 * Macro for calling iemCImplRaiseDivideError().
5455 *
5456 * This is for things that will _always_ decode to an \#DE, taking the
5457 * recompiler into consideration and everything.
5458 *
5459 * @return Strict VBox status code.
5460 */
5461#define IEMOP_RAISE_DIVIDE_ERROR_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseDivideError)
5462
5463/**
5464 * Macro for calling iemCImplRaiseInvalidLockPrefix().
5465 *
5466 * This is for things that will _always_ decode to an \#UD, taking the
5467 * recompiler into consideration and everything.
5468 *
5469 * @return Strict VBox status code.
5470 */
5471#define IEMOP_RAISE_INVALID_LOCK_PREFIX_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidLockPrefix)
5472
5473/**
5474 * Macro for calling iemCImplRaiseInvalidOpcode() for decode/static \#UDs.
5475 *
5476 * This is for things that will _always_ decode to an \#UD, taking the
5477 * recompiler into consideration and everything.
5478 *
5479 * @return Strict VBox status code.
5480 */
5481#define IEMOP_RAISE_INVALID_OPCODE_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
5482
5483/**
5484 * Macro for calling iemCImplRaiseInvalidOpcode() for runtime-style \#UDs.
5485 *
5486 * Using this macro means you've got _buggy_ _code_ and are doing things that
5487 * belongs exclusively in IEMAllCImpl.cpp during decoding.
5488 *
5489 * @return Strict VBox status code.
5490 * @see IEMOP_RAISE_INVALID_OPCODE_RET
5491 */
5492#define IEMOP_RAISE_INVALID_OPCODE_RUNTIME_RET() IEM_MC_DEFER_TO_CIMPL_0_RET(IEM_CIMPL_F_XCPT, 0, iemCImplRaiseInvalidOpcode)
5493
5494/** @} */
5495
5496/** @name Register Access.
5497 * @{ */
5498VBOXSTRICTRC iemRegRipRelativeJumpS8AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int8_t offNextInstr,
5499 IEMMODE enmEffOpSize) RT_NOEXCEPT;
5500VBOXSTRICTRC iemRegRipRelativeJumpS16AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int16_t offNextInstr) RT_NOEXCEPT;
5501VBOXSTRICTRC iemRegRipRelativeJumpS32AndFinishClearingRF(PVMCPUCC pVCpu, uint8_t cbInstr, int32_t offNextInstr,
5502 IEMMODE enmEffOpSize) RT_NOEXCEPT;
5503/** @} */
5504
5505/** @name FPU access and helpers.
5506 * @{ */
5507void iemFpuPushResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint16_t uFpuOpcode) RT_NOEXCEPT;
5508void iemFpuPushResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5509void iemFpuPushResultTwo(PVMCPUCC pVCpu, PIEMFPURESULTTWO pResult, uint16_t uFpuOpcode) RT_NOEXCEPT;
5510void iemFpuStoreResult(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5511void iemFpuStoreResultThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5512void iemFpuStoreResultWithMemOp(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
5513 uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5514void iemFpuStoreResultWithMemOpThenPop(PVMCPUCC pVCpu, PIEMFPURESULT pResult, uint8_t iStReg,
5515 uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5516void iemFpuUpdateOpcodeAndIp(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5517void iemFpuUpdateFSW(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
5518void iemFpuUpdateFSWThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
5519void iemFpuUpdateFSWWithMemOp(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5520void iemFpuUpdateFSWThenPopPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint16_t uFpuOpcode) RT_NOEXCEPT;
5521void iemFpuUpdateFSWWithMemOpThenPop(PVMCPUCC pVCpu, uint16_t u16FSW, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5522void iemFpuStackUnderflow(PVMCPUCC pVCpu, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5523void iemFpuStackUnderflowWithMemOp(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5524void iemFpuStackUnderflowThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint16_t uFpuOpcode) RT_NOEXCEPT;
5525void iemFpuStackUnderflowWithMemOpThenPop(PVMCPUCC pVCpu, uint8_t iStReg, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5526void iemFpuStackUnderflowThenPopPop(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5527void iemFpuStackPushUnderflow(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5528void iemFpuStackPushUnderflowTwo(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5529void iemFpuStackPushOverflow(PVMCPUCC pVCpu, uint16_t uFpuOpcode) RT_NOEXCEPT;
5530void iemFpuStackPushOverflowWithMemOp(PVMCPUCC pVCpu, uint8_t iEffSeg, RTGCPTR GCPtrEff, uint16_t uFpuOpcode) RT_NOEXCEPT;
5531/** @} */
5532
5533/** @name SSE+AVX SIMD access and helpers.
5534 * @{ */
5535void iemSseUpdateMxcsr(PVMCPUCC pVCpu, uint32_t fMxcsr) RT_NOEXCEPT;
5536/** @} */
5537
5538/** @name Memory access.
5539 * @{ */
5540
5541/** Report a \#GP instead of \#AC and do not restrict to ring-3 */
5542#define IEM_MEMMAP_F_ALIGN_GP RT_BIT_32(16)
5543/** SSE access that should report a \#GP instead of \#AC, unless MXCSR.MM=1
5544 * when it works like normal \#AC. Always used with IEM_MEMMAP_F_ALIGN_GP. */
5545#define IEM_MEMMAP_F_ALIGN_SSE RT_BIT_32(17)
5546/** If \#AC is applicable, raise it. Always used with IEM_MEMMAP_F_ALIGN_GP.
5547 * Users include FXSAVE & FXRSTOR. */
5548#define IEM_MEMMAP_F_ALIGN_GP_OR_AC RT_BIT_32(18)
5549
5550VBOXSTRICTRC iemMemMap(PVMCPUCC pVCpu, void **ppvMem, uint8_t *pbUnmapInfo, size_t cbMem, uint8_t iSegReg, RTGCPTR GCPtrMem,
5551 uint32_t fAccess, uint32_t uAlignCtl) RT_NOEXCEPT;
5552VBOXSTRICTRC iemMemCommitAndUnmap(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5553#ifndef IN_RING3
5554VBOXSTRICTRC iemMemCommitAndUnmapPostponeTroubleToR3(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5555#endif
5556void iemMemRollbackAndUnmap(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5557void iemMemRollback(PVMCPUCC pVCpu) RT_NOEXCEPT;
5558VBOXSTRICTRC iemMemApplySegment(PVMCPUCC pVCpu, uint32_t fAccess, uint8_t iSegReg, size_t cbMem, PRTGCPTR pGCPtrMem) RT_NOEXCEPT;
5559VBOXSTRICTRC iemMemMarkSelDescAccessed(PVMCPUCC pVCpu, uint16_t uSel) RT_NOEXCEPT;
5560VBOXSTRICTRC iemMemPageTranslateAndCheckAccess(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t cbAccess, uint32_t fAccess, PRTGCPHYS pGCPhysMem) RT_NOEXCEPT;
5561
5562void iemOpcodeFlushLight(PVMCPUCC pVCpu, uint8_t cbInstr);
5563void iemOpcodeFlushHeavy(PVMCPUCC pVCpu, uint8_t cbInstr);
5564#ifdef IEM_WITH_CODE_TLB
5565void iemOpcodeFetchBytesJmp(PVMCPUCC pVCpu, size_t cbDst, void *pvDst) IEM_NOEXCEPT_MAY_LONGJMP;
5566#else
5567VBOXSTRICTRC iemOpcodeFetchMoreBytes(PVMCPUCC pVCpu, size_t cbMin) RT_NOEXCEPT;
5568#endif
5569#ifdef IEM_WITH_SETJMP
5570uint8_t iemOpcodeGetNextU8SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5571uint16_t iemOpcodeGetNextU16SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5572uint32_t iemOpcodeGetNextU32SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5573uint64_t iemOpcodeGetNextU64SlowJmp(PVMCPUCC pVCpu) IEM_NOEXCEPT_MAY_LONGJMP;
5574#else
5575VBOXSTRICTRC iemOpcodeGetNextU8Slow(PVMCPUCC pVCpu, uint8_t *pb) RT_NOEXCEPT;
5576VBOXSTRICTRC iemOpcodeGetNextS8SxU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
5577VBOXSTRICTRC iemOpcodeGetNextS8SxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
5578VBOXSTRICTRC iemOpcodeGetNextS8SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5579VBOXSTRICTRC iemOpcodeGetNextU16Slow(PVMCPUCC pVCpu, uint16_t *pu16) RT_NOEXCEPT;
5580VBOXSTRICTRC iemOpcodeGetNextU16ZxU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
5581VBOXSTRICTRC iemOpcodeGetNextU16ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5582VBOXSTRICTRC iemOpcodeGetNextU32Slow(PVMCPUCC pVCpu, uint32_t *pu32) RT_NOEXCEPT;
5583VBOXSTRICTRC iemOpcodeGetNextU32ZxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5584VBOXSTRICTRC iemOpcodeGetNextS32SxU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5585VBOXSTRICTRC iemOpcodeGetNextU64Slow(PVMCPUCC pVCpu, uint64_t *pu64) RT_NOEXCEPT;
5586#endif
5587
5588VBOXSTRICTRC iemMemFetchDataU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5589VBOXSTRICTRC iemMemFetchDataU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5590VBOXSTRICTRC iemMemFetchDataU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5591VBOXSTRICTRC iemMemFetchDataU32_ZX_U64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5592VBOXSTRICTRC iemMemFetchDataU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5593VBOXSTRICTRC iemMemFetchDataU64AlignedU128(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5594VBOXSTRICTRC iemMemFetchDataR80(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5595VBOXSTRICTRC iemMemFetchDataD80(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5596VBOXSTRICTRC iemMemFetchDataU128(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5597VBOXSTRICTRC iemMemFetchDataU128NoAc(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5598VBOXSTRICTRC iemMemFetchDataU128AlignedSse(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5599VBOXSTRICTRC iemMemFetchDataU256(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5600VBOXSTRICTRC iemMemFetchDataU256NoAc(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5601VBOXSTRICTRC iemMemFetchDataU256AlignedAvx(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5602VBOXSTRICTRC iemMemFetchDataXdtr(PVMCPUCC pVCpu, uint16_t *pcbLimit, PRTGCPTR pGCPtrBase, uint8_t iSegReg,
5603 RTGCPTR GCPtrMem, IEMMODE enmOpSize) RT_NOEXCEPT;
5604#ifdef IEM_WITH_SETJMP
5605uint8_t iemMemFetchDataU8SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5606uint16_t iemMemFetchDataU16SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5607uint32_t iemMemFetchDataU32SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5608uint32_t iemMemFlatFetchDataU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5609uint64_t iemMemFetchDataU64SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5610uint64_t iemMemFetchDataU64AlignedU128SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5611void iemMemFetchDataR80SafeJmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5612void iemMemFetchDataD80SafeJmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5613void iemMemFetchDataU128SafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5614void iemMemFetchDataU128NoAcSafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5615void iemMemFetchDataU128AlignedSseSafeJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5616void iemMemFetchDataU256SafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5617void iemMemFetchDataU256NoAcSafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5618void iemMemFetchDataU256AlignedAvxSafeJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5619# if 0 /* these are inlined now */
5620uint8_t iemMemFetchDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5621uint16_t iemMemFetchDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5622uint32_t iemMemFetchDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5623uint32_t iemMemFlatFetchDataU32Jmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5624uint64_t iemMemFetchDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5625uint64_t iemMemFetchDataU64AlignedU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5626void iemMemFetchDataR80Jmp(PVMCPUCC pVCpu, PRTFLOAT80U pr80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5627void iemMemFetchDataD80Jmp(PVMCPUCC pVCpu, PRTPBCD80U pd80Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5628void iemMemFetchDataU128Jmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5629void iemMemFetchDataU128NoAcJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5630void iemMemFetchDataU128AlignedSseJmp(PVMCPUCC pVCpu, PRTUINT128U pu128Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5631void iemMemFetchDataU256NoAcJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5632void iemMemFetchDataU256AlignedAvxJmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5633# endif
5634void iemMemFetchDataU256Jmp(PVMCPUCC pVCpu, PRTUINT256U pu256Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5635#endif
5636
5637VBOXSTRICTRC iemMemFetchSysU8(PVMCPUCC pVCpu, uint8_t *pu8Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5638VBOXSTRICTRC iemMemFetchSysU16(PVMCPUCC pVCpu, uint16_t *pu16Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5639VBOXSTRICTRC iemMemFetchSysU32(PVMCPUCC pVCpu, uint32_t *pu32Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5640VBOXSTRICTRC iemMemFetchSysU64(PVMCPUCC pVCpu, uint64_t *pu64Dst, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5641VBOXSTRICTRC iemMemFetchSelDesc(PVMCPUCC pVCpu, PIEMSELDESC pDesc, uint16_t uSel, uint8_t uXcpt) RT_NOEXCEPT;
5642
5643VBOXSTRICTRC iemMemStoreDataU8(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) RT_NOEXCEPT;
5644VBOXSTRICTRC iemMemStoreDataU16(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) RT_NOEXCEPT;
5645VBOXSTRICTRC iemMemStoreDataU32(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) RT_NOEXCEPT;
5646VBOXSTRICTRC iemMemStoreDataU64(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) RT_NOEXCEPT;
5647VBOXSTRICTRC iemMemStoreDataU128(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
5648VBOXSTRICTRC iemMemStoreDataU128NoAc(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
5649VBOXSTRICTRC iemMemStoreDataU128AlignedSse(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) RT_NOEXCEPT;
5650VBOXSTRICTRC iemMemStoreDataU256(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
5651VBOXSTRICTRC iemMemStoreDataU256NoAc(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
5652VBOXSTRICTRC iemMemStoreDataU256AlignedAvx(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) RT_NOEXCEPT;
5653VBOXSTRICTRC iemMemStoreDataXdtr(PVMCPUCC pVCpu, uint16_t cbLimit, RTGCPTR GCPtrBase, uint8_t iSegReg, RTGCPTR GCPtrMem) RT_NOEXCEPT;
5654#ifdef IEM_WITH_SETJMP
5655void iemMemStoreDataU8SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) IEM_NOEXCEPT_MAY_LONGJMP;
5656void iemMemStoreDataU16SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) IEM_NOEXCEPT_MAY_LONGJMP;
5657void iemMemStoreDataU32SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) IEM_NOEXCEPT_MAY_LONGJMP;
5658void iemMemStoreDataU64SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) IEM_NOEXCEPT_MAY_LONGJMP;
5659void iemMemStoreDataU128SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5660void iemMemStoreDataU128NoAcSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U pu128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5661void iemMemStoreDataU128AlignedSseSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT128U pu128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5662void iemMemStoreDataU256SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5663void iemMemStoreDataU256NoAcSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5664void iemMemStoreDataU256AlignedAvxSafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5665void iemMemStoreDataR80SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTFLOAT80U pr80Value) IEM_NOEXCEPT_MAY_LONGJMP;
5666void iemMemStoreDataD80SafeJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTPBCD80U pd80Value) IEM_NOEXCEPT_MAY_LONGJMP;
5667#if 0
5668void iemMemStoreDataU8Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint8_t u8Value) IEM_NOEXCEPT_MAY_LONGJMP;
5669void iemMemStoreDataU16Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint16_t u16Value) IEM_NOEXCEPT_MAY_LONGJMP;
5670void iemMemStoreDataU32Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint32_t u32Value) IEM_NOEXCEPT_MAY_LONGJMP;
5671void iemMemStoreDataU64Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, uint64_t u64Value) IEM_NOEXCEPT_MAY_LONGJMP;
5672void iemMemStoreDataU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5673void iemMemStoreDataNoAcU128Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5674void iemMemStoreDataU256NoAcJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5675void iemMemStoreDataU256AlignedAvxJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5676#endif
5677void iemMemStoreDataU128AlignedSseJmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, RTUINT128U u128Value) IEM_NOEXCEPT_MAY_LONGJMP;
5678void iemMemStoreDataU256Jmp(PVMCPUCC pVCpu, uint8_t iSegReg, RTGCPTR GCPtrMem, PCRTUINT256U pu256Value) IEM_NOEXCEPT_MAY_LONGJMP;
5679#endif
5680
5681#ifdef IEM_WITH_SETJMP
5682uint8_t *iemMemMapDataU8RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5683uint8_t *iemMemMapDataU8AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5684uint8_t *iemMemMapDataU8WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5685uint8_t const *iemMemMapDataU8RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5686uint16_t *iemMemMapDataU16RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5687uint16_t *iemMemMapDataU16AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5688uint16_t *iemMemMapDataU16WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5689uint16_t const *iemMemMapDataU16RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5690uint32_t *iemMemMapDataU32RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5691uint32_t *iemMemMapDataU32AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5692uint32_t *iemMemMapDataU32WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5693uint32_t const *iemMemMapDataU32RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5694uint64_t *iemMemMapDataU64RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5695uint64_t *iemMemMapDataU64AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5696uint64_t *iemMemMapDataU64WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5697uint64_t const *iemMemMapDataU64RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5698PRTFLOAT80U iemMemMapDataR80RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5699PRTFLOAT80U iemMemMapDataR80WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5700PCRTFLOAT80U iemMemMapDataR80RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5701PRTPBCD80U iemMemMapDataD80RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5702PRTPBCD80U iemMemMapDataD80WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5703PCRTPBCD80U iemMemMapDataD80RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5704PRTUINT128U iemMemMapDataU128RwSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5705PRTUINT128U iemMemMapDataU128AtSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5706PRTUINT128U iemMemMapDataU128WoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5707PCRTUINT128U iemMemMapDataU128RoSafeJmp(PVMCPUCC pVCpu, uint8_t *pbUnmapInfo, uint8_t iSegReg, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5708
5709void iemMemCommitAndUnmapJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5710void iemMemCommitAndUnmapRwSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5711void iemMemCommitAndUnmapAtSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5712void iemMemCommitAndUnmapWoSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5713void iemMemCommitAndUnmapRoSafeJmp(PVMCPUCC pVCpu, uint8_t bUnmapInfo) IEM_NOEXCEPT_MAY_LONGJMP;
5714void iemMemRollbackAndUnmapWoSafe(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5715#endif
5716
5717VBOXSTRICTRC iemMemStackPushBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, uint32_t cbAlign,
5718 void **ppvMem, uint8_t *pbUnmapInfo, uint64_t *puNewRsp) RT_NOEXCEPT;
5719VBOXSTRICTRC iemMemStackPushCommitSpecial(PVMCPUCC pVCpu, uint8_t bUnmapInfo, uint64_t uNewRsp) RT_NOEXCEPT;
5720VBOXSTRICTRC iemMemStackPushU16(PVMCPUCC pVCpu, uint16_t u16Value) RT_NOEXCEPT;
5721VBOXSTRICTRC iemMemStackPushU32(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
5722VBOXSTRICTRC iemMemStackPushU64(PVMCPUCC pVCpu, uint64_t u64Value) RT_NOEXCEPT;
5723VBOXSTRICTRC iemMemStackPushU16Ex(PVMCPUCC pVCpu, uint16_t u16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5724VBOXSTRICTRC iemMemStackPushU32Ex(PVMCPUCC pVCpu, uint32_t u32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5725VBOXSTRICTRC iemMemStackPushU64Ex(PVMCPUCC pVCpu, uint64_t u64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5726VBOXSTRICTRC iemMemStackPushU32SReg(PVMCPUCC pVCpu, uint32_t u32Value) RT_NOEXCEPT;
5727VBOXSTRICTRC iemMemStackPopBeginSpecial(PVMCPUCC pVCpu, size_t cbMem, uint32_t cbAlign,
5728 void const **ppvMem, uint8_t *pbUnmapInfo, uint64_t *puNewRsp) RT_NOEXCEPT;
5729VBOXSTRICTRC iemMemStackPopContinueSpecial(PVMCPUCC pVCpu, size_t off, size_t cbMem,
5730 void const **ppvMem, uint8_t *pbUnmapInfo, uint64_t uCurNewRsp) RT_NOEXCEPT;
5731VBOXSTRICTRC iemMemStackPopDoneSpecial(PVMCPUCC pVCpu, uint8_t bUnmapInfo) RT_NOEXCEPT;
5732VBOXSTRICTRC iemMemStackPopU16(PVMCPUCC pVCpu, uint16_t *pu16Value) RT_NOEXCEPT;
5733VBOXSTRICTRC iemMemStackPopU32(PVMCPUCC pVCpu, uint32_t *pu32Value) RT_NOEXCEPT;
5734VBOXSTRICTRC iemMemStackPopU64(PVMCPUCC pVCpu, uint64_t *pu64Value) RT_NOEXCEPT;
5735VBOXSTRICTRC iemMemStackPopU16Ex(PVMCPUCC pVCpu, uint16_t *pu16Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5736VBOXSTRICTRC iemMemStackPopU32Ex(PVMCPUCC pVCpu, uint32_t *pu32Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5737VBOXSTRICTRC iemMemStackPopU64Ex(PVMCPUCC pVCpu, uint64_t *pu64Value, PRTUINT64U pTmpRsp) RT_NOEXCEPT;
5738
5739#ifdef IEM_WITH_SETJMP
5740void iemMemStackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5741void iemMemStackPushU32SafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5742void iemMemStackPushU32SRegSafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5743void iemMemStackPushU64SafeJmp(PVMCPUCC pVCpu, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5744void iemMemStackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5745void iemMemStackPopGRegU32SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5746void iemMemStackPopGRegU64SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5747
5748void iemMemFlat32StackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5749void iemMemFlat32StackPushU32SafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5750void iemMemFlat32StackPushU32SRegSafeJmp(PVMCPUCC pVCpu, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5751void iemMemFlat32StackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5752void iemMemFlat32StackPopGRegU32SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5753
5754void iemMemFlat64StackPushU16SafeJmp(PVMCPUCC pVCpu, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5755void iemMemFlat64StackPushU64SafeJmp(PVMCPUCC pVCpu, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5756void iemMemFlat64StackPopGRegU16SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5757void iemMemFlat64StackPopGRegU64SafeJmp(PVMCPUCC pVCpu, uint8_t iGReg) IEM_NOEXCEPT_MAY_LONGJMP;
5758
5759void iemMemStoreStackU16SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint16_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5760void iemMemStoreStackU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5761void iemMemStoreStackU32SRegSafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint32_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5762void iemMemStoreStackU64SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem, uint64_t uValue) IEM_NOEXCEPT_MAY_LONGJMP;
5763
5764uint16_t iemMemFetchStackU16SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5765uint32_t iemMemFetchStackU32SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5766uint64_t iemMemFetchStackU64SafeJmp(PVMCPUCC pVCpu, RTGCPTR GCPtrMem) IEM_NOEXCEPT_MAY_LONGJMP;
5767
5768#endif
5769
5770/** @} */
5771
5772/** @name IEMAllCImpl.cpp
5773 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/'
5774 * @{ */
5775IEM_CIMPL_PROTO_2(iemCImpl_pop_mem16, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5776IEM_CIMPL_PROTO_2(iemCImpl_pop_mem32, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5777IEM_CIMPL_PROTO_2(iemCImpl_pop_mem64, uint16_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5778IEM_CIMPL_PROTO_0(iemCImpl_popa_16);
5779IEM_CIMPL_PROTO_0(iemCImpl_popa_32);
5780IEM_CIMPL_PROTO_0(iemCImpl_pusha_16);
5781IEM_CIMPL_PROTO_0(iemCImpl_pusha_32);
5782IEM_CIMPL_PROTO_1(iemCImpl_pushf, IEMMODE, enmEffOpSize);
5783IEM_CIMPL_PROTO_1(iemCImpl_popf, IEMMODE, enmEffOpSize);
5784IEM_CIMPL_PROTO_1(iemCImpl_call_16, uint16_t, uNewPC);
5785IEM_CIMPL_PROTO_1(iemCImpl_call_rel_16, int16_t, offDisp);
5786IEM_CIMPL_PROTO_1(iemCImpl_call_32, uint32_t, uNewPC);
5787IEM_CIMPL_PROTO_1(iemCImpl_call_rel_32, int32_t, offDisp);
5788IEM_CIMPL_PROTO_1(iemCImpl_call_64, uint64_t, uNewPC);
5789IEM_CIMPL_PROTO_1(iemCImpl_call_rel_64, int64_t, offDisp);
5790IEM_CIMPL_PROTO_3(iemCImpl_FarJmp, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
5791IEM_CIMPL_PROTO_3(iemCImpl_callf, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
5792typedef IEM_CIMPL_DECL_TYPE_3(FNIEMCIMPLFARBRANCH, uint16_t, uSel, uint64_t, offSeg, IEMMODE, enmEffOpSize);
5793typedef FNIEMCIMPLFARBRANCH *PFNIEMCIMPLFARBRANCH;
5794IEM_CIMPL_PROTO_2(iemCImpl_retf, IEMMODE, enmEffOpSize, uint16_t, cbPop);
5795IEM_CIMPL_PROTO_0(iemCImpl_retn_16);
5796IEM_CIMPL_PROTO_0(iemCImpl_retn_32);
5797IEM_CIMPL_PROTO_0(iemCImpl_retn_64);
5798IEM_CIMPL_PROTO_1(iemCImpl_retn_iw_16, uint16_t, cbPop);
5799IEM_CIMPL_PROTO_1(iemCImpl_retn_iw_32, uint16_t, cbPop);
5800IEM_CIMPL_PROTO_1(iemCImpl_retn_iw_64, uint16_t, cbPop);
5801IEM_CIMPL_PROTO_3(iemCImpl_enter, IEMMODE, enmEffOpSize, uint16_t, cbFrame, uint8_t, cParameters);
5802IEM_CIMPL_PROTO_1(iemCImpl_leave, IEMMODE, enmEffOpSize);
5803IEM_CIMPL_PROTO_2(iemCImpl_int, uint8_t, u8Int, IEMINT, enmInt);
5804IEM_CIMPL_PROTO_1(iemCImpl_iret_real_v8086, IEMMODE, enmEffOpSize);
5805IEM_CIMPL_PROTO_4(iemCImpl_iret_prot_v8086, uint32_t, uNewEip, uint16_t, uNewCs, uint32_t, uNewFlags, uint64_t, uNewRsp);
5806IEM_CIMPL_PROTO_1(iemCImpl_iret_prot_NestedTask, IEMMODE, enmEffOpSize);
5807IEM_CIMPL_PROTO_1(iemCImpl_iret_prot, IEMMODE, enmEffOpSize);
5808IEM_CIMPL_PROTO_1(iemCImpl_iret_64bit, IEMMODE, enmEffOpSize);
5809IEM_CIMPL_PROTO_1(iemCImpl_iret, IEMMODE, enmEffOpSize);
5810IEM_CIMPL_PROTO_0(iemCImpl_loadall286);
5811IEM_CIMPL_PROTO_0(iemCImpl_syscall);
5812IEM_CIMPL_PROTO_1(iemCImpl_sysret, IEMMODE, enmEffOpSize);
5813IEM_CIMPL_PROTO_0(iemCImpl_sysenter);
5814IEM_CIMPL_PROTO_1(iemCImpl_sysexit, IEMMODE, enmEffOpSize);
5815IEM_CIMPL_PROTO_2(iemCImpl_LoadSReg, uint8_t, iSegReg, uint16_t, uSel);
5816IEM_CIMPL_PROTO_2(iemCImpl_load_SReg, uint8_t, iSegReg, uint16_t, uSel);
5817IEM_CIMPL_PROTO_2(iemCImpl_pop_Sreg, uint8_t, iSegReg, IEMMODE, enmEffOpSize);
5818IEM_CIMPL_PROTO_5(iemCImpl_load_SReg_Greg, uint16_t, uSel, uint64_t, offSeg, uint8_t, iSegReg, uint8_t, iGReg, IEMMODE, enmEffOpSize);
5819IEM_CIMPL_PROTO_2(iemCImpl_VerX, uint16_t, uSel, bool, fWrite);
5820IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u64, uint64_t *, pu64Dst, uint16_t, uSel, bool, fIsLar);
5821IEM_CIMPL_PROTO_3(iemCImpl_LarLsl_u16, uint16_t *, pu16Dst, uint16_t, uSel, bool, fIsLar);
5822IEM_CIMPL_PROTO_3(iemCImpl_lgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
5823IEM_CIMPL_PROTO_2(iemCImpl_sgdt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5824IEM_CIMPL_PROTO_3(iemCImpl_lidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc, IEMMODE, enmEffOpSize);
5825IEM_CIMPL_PROTO_2(iemCImpl_sidt, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5826IEM_CIMPL_PROTO_1(iemCImpl_lldt, uint16_t, uNewLdt);
5827IEM_CIMPL_PROTO_2(iemCImpl_sldt_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
5828IEM_CIMPL_PROTO_2(iemCImpl_sldt_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5829IEM_CIMPL_PROTO_1(iemCImpl_ltr, uint16_t, uNewTr);
5830IEM_CIMPL_PROTO_2(iemCImpl_str_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
5831IEM_CIMPL_PROTO_2(iemCImpl_str_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5832IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Cd, uint8_t, iGReg, uint8_t, iCrReg);
5833IEM_CIMPL_PROTO_2(iemCImpl_smsw_reg, uint8_t, iGReg, uint8_t, enmEffOpSize);
5834IEM_CIMPL_PROTO_2(iemCImpl_smsw_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5835IEM_CIMPL_PROTO_4(iemCImpl_load_CrX, uint8_t, iCrReg, uint64_t, uNewCrX, IEMACCESSCRX, enmAccessCrX, uint8_t, iGReg);
5836IEM_CIMPL_PROTO_2(iemCImpl_mov_Cd_Rd, uint8_t, iCrReg, uint8_t, iGReg);
5837IEM_CIMPL_PROTO_2(iemCImpl_lmsw, uint16_t, u16NewMsw, RTGCPTR, GCPtrEffDst);
5838IEM_CIMPL_PROTO_0(iemCImpl_clts);
5839IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Dd, uint8_t, iGReg, uint8_t, iDrReg);
5840IEM_CIMPL_PROTO_2(iemCImpl_mov_Dd_Rd, uint8_t, iDrReg, uint8_t, iGReg);
5841IEM_CIMPL_PROTO_2(iemCImpl_mov_Rd_Td, uint8_t, iGReg, uint8_t, iTrReg);
5842IEM_CIMPL_PROTO_2(iemCImpl_mov_Td_Rd, uint8_t, iTrReg, uint8_t, iGReg);
5843IEM_CIMPL_PROTO_1(iemCImpl_invlpg, RTGCPTR, GCPtrPage);
5844IEM_CIMPL_PROTO_3(iemCImpl_invpcid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvpcidDesc, uint64_t, uInvpcidType);
5845IEM_CIMPL_PROTO_0(iemCImpl_invd);
5846IEM_CIMPL_PROTO_0(iemCImpl_wbinvd);
5847IEM_CIMPL_PROTO_0(iemCImpl_rsm);
5848IEM_CIMPL_PROTO_0(iemCImpl_rdtsc);
5849IEM_CIMPL_PROTO_0(iemCImpl_rdtscp);
5850IEM_CIMPL_PROTO_0(iemCImpl_rdpmc);
5851IEM_CIMPL_PROTO_0(iemCImpl_rdmsr);
5852IEM_CIMPL_PROTO_0(iemCImpl_wrmsr);
5853IEM_CIMPL_PROTO_3(iemCImpl_in, uint16_t, u16Port, uint8_t, cbReg, uint8_t, bImmAndEffAddrMode);
5854IEM_CIMPL_PROTO_2(iemCImpl_in_eAX_DX, uint8_t, cbReg, IEMMODE, enmEffAddrMode);
5855IEM_CIMPL_PROTO_3(iemCImpl_out, uint16_t, u16Port, uint8_t, cbReg, uint8_t, bImmAndEffAddrMode);
5856IEM_CIMPL_PROTO_2(iemCImpl_out_DX_eAX, uint8_t, cbReg, IEMMODE, enmEffAddrMode);
5857IEM_CIMPL_PROTO_0(iemCImpl_cli);
5858IEM_CIMPL_PROTO_0(iemCImpl_sti);
5859IEM_CIMPL_PROTO_0(iemCImpl_hlt);
5860IEM_CIMPL_PROTO_1(iemCImpl_monitor, uint8_t, iEffSeg);
5861IEM_CIMPL_PROTO_0(iemCImpl_mwait);
5862IEM_CIMPL_PROTO_0(iemCImpl_swapgs);
5863IEM_CIMPL_PROTO_0(iemCImpl_cpuid);
5864IEM_CIMPL_PROTO_1(iemCImpl_aad, uint8_t, bImm);
5865IEM_CIMPL_PROTO_1(iemCImpl_aam, uint8_t, bImm);
5866IEM_CIMPL_PROTO_0(iemCImpl_daa);
5867IEM_CIMPL_PROTO_0(iemCImpl_das);
5868IEM_CIMPL_PROTO_0(iemCImpl_aaa);
5869IEM_CIMPL_PROTO_0(iemCImpl_aas);
5870IEM_CIMPL_PROTO_3(iemCImpl_bound_16, int16_t, idxArray, int16_t, idxLowerBound, int16_t, idxUpperBound);
5871IEM_CIMPL_PROTO_3(iemCImpl_bound_32, int32_t, idxArray, int32_t, idxLowerBound, int32_t, idxUpperBound);
5872IEM_CIMPL_PROTO_0(iemCImpl_xgetbv);
5873IEM_CIMPL_PROTO_0(iemCImpl_xsetbv);
5874IEM_CIMPL_PROTO_5(iemCImpl_cmpxchg16b_fallback_rendezvous, PRTUINT128U, pu128Dst, PRTUINT128U, pu128RaxRdx,
5875 PRTUINT128U, pu128RbxRcx, uint32_t *, pEFlags, uint8_t, bUnmapInfo);
5876IEM_CIMPL_PROTO_2(iemCImpl_clflush_clflushopt, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5877IEM_CIMPL_PROTO_1(iemCImpl_finit, bool, fCheckXcpts);
5878IEM_CIMPL_PROTO_3(iemCImpl_fxsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5879IEM_CIMPL_PROTO_3(iemCImpl_fxrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5880IEM_CIMPL_PROTO_3(iemCImpl_xsave, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5881IEM_CIMPL_PROTO_3(iemCImpl_xrstor, uint8_t, iEffSeg, RTGCPTR, GCPtrEff, IEMMODE, enmEffOpSize);
5882IEM_CIMPL_PROTO_2(iemCImpl_stmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5883IEM_CIMPL_PROTO_2(iemCImpl_vstmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5884IEM_CIMPL_PROTO_2(iemCImpl_ldmxcsr, uint8_t, iEffSeg, RTGCPTR, GCPtrEff);
5885IEM_CIMPL_PROTO_3(iemCImpl_fnstenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5886IEM_CIMPL_PROTO_3(iemCImpl_fnsave, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffDst);
5887IEM_CIMPL_PROTO_3(iemCImpl_fldenv, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
5888IEM_CIMPL_PROTO_3(iemCImpl_frstor, IEMMODE, enmEffOpSize, uint8_t, iEffSeg, RTGCPTR, GCPtrEffSrc);
5889IEM_CIMPL_PROTO_1(iemCImpl_fldcw, uint16_t, u16Fcw);
5890IEM_CIMPL_PROTO_2(iemCImpl_fxch_underflow, uint8_t, iStReg, uint16_t, uFpuOpcode);
5891IEM_CIMPL_PROTO_3(iemCImpl_fcomi_fucomi, uint8_t, iStReg, bool, fUCmp, uint32_t, uPopAndFpuOpcode);
5892IEM_CIMPL_PROTO_2(iemCImpl_rdseed, uint8_t, iReg, IEMMODE, enmEffOpSize);
5893IEM_CIMPL_PROTO_2(iemCImpl_rdrand, uint8_t, iReg, IEMMODE, enmEffOpSize);
5894/** @} */
5895
5896/** @name IEMAllCImplStrInstr.cpp.h
5897 * @note sed -e '/IEM_CIMPL_DEF_/!d' -e 's/IEM_CIMPL_DEF_/IEM_CIMPL_PROTO_/' -e 's/$/;/' -e 's/RT_CONCAT4(//' \
5898 * -e 's/,ADDR_SIZE)/64/g' -e 's/,OP_SIZE,/64/g' -e 's/,OP_rAX,/rax/g' IEMAllCImplStrInstr.cpp.h
5899 * @{ */
5900IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr16, uint8_t, iEffSeg);
5901IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr16, uint8_t, iEffSeg);
5902IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m16);
5903IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m16);
5904IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr16, uint8_t, iEffSeg);
5905IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m16);
5906IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m16, int8_t, iEffSeg);
5907IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr16, bool, fIoChecked);
5908IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr16, bool, fIoChecked);
5909IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5910IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5911
5912IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr16, uint8_t, iEffSeg);
5913IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr16, uint8_t, iEffSeg);
5914IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m16);
5915IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m16);
5916IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr16, uint8_t, iEffSeg);
5917IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m16);
5918IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m16, int8_t, iEffSeg);
5919IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr16, bool, fIoChecked);
5920IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr16, bool, fIoChecked);
5921IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5922IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5923
5924IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr16, uint8_t, iEffSeg);
5925IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr16, uint8_t, iEffSeg);
5926IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m16);
5927IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m16);
5928IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr16, uint8_t, iEffSeg);
5929IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m16);
5930IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m16, int8_t, iEffSeg);
5931IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr16, bool, fIoChecked);
5932IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr16, bool, fIoChecked);
5933IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5934IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr16, uint8_t, iEffSeg, bool, fIoChecked);
5935
5936
5937IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr32, uint8_t, iEffSeg);
5938IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr32, uint8_t, iEffSeg);
5939IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m32);
5940IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m32);
5941IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr32, uint8_t, iEffSeg);
5942IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m32);
5943IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m32, int8_t, iEffSeg);
5944IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr32, bool, fIoChecked);
5945IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr32, bool, fIoChecked);
5946IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5947IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5948
5949IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr32, uint8_t, iEffSeg);
5950IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr32, uint8_t, iEffSeg);
5951IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m32);
5952IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m32);
5953IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr32, uint8_t, iEffSeg);
5954IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m32);
5955IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m32, int8_t, iEffSeg);
5956IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr32, bool, fIoChecked);
5957IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr32, bool, fIoChecked);
5958IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5959IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5960
5961IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr32, uint8_t, iEffSeg);
5962IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr32, uint8_t, iEffSeg);
5963IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m32);
5964IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m32);
5965IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr32, uint8_t, iEffSeg);
5966IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m32);
5967IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m32, int8_t, iEffSeg);
5968IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr32, bool, fIoChecked);
5969IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr32, bool, fIoChecked);
5970IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5971IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5972
5973IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr32, uint8_t, iEffSeg);
5974IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr32, uint8_t, iEffSeg);
5975IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m32);
5976IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m32);
5977IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr32, uint8_t, iEffSeg);
5978IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m32);
5979IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m32, int8_t, iEffSeg);
5980IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr32, bool, fIoChecked);
5981IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr32, bool, fIoChecked);
5982IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5983IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr32, uint8_t, iEffSeg, bool, fIoChecked);
5984
5985
5986IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op8_addr64, uint8_t, iEffSeg);
5987IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op8_addr64, uint8_t, iEffSeg);
5988IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_al_m64);
5989IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_al_m64);
5990IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op8_addr64, uint8_t, iEffSeg);
5991IEM_CIMPL_PROTO_0(iemCImpl_stos_al_m64);
5992IEM_CIMPL_PROTO_1(iemCImpl_lods_al_m64, int8_t, iEffSeg);
5993IEM_CIMPL_PROTO_1(iemCImpl_ins_op8_addr64, bool, fIoChecked);
5994IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op8_addr64, bool, fIoChecked);
5995IEM_CIMPL_PROTO_2(iemCImpl_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5996IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op8_addr64, uint8_t, iEffSeg, bool, fIoChecked);
5997
5998IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op16_addr64, uint8_t, iEffSeg);
5999IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op16_addr64, uint8_t, iEffSeg);
6000IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_ax_m64);
6001IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_ax_m64);
6002IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op16_addr64, uint8_t, iEffSeg);
6003IEM_CIMPL_PROTO_0(iemCImpl_stos_ax_m64);
6004IEM_CIMPL_PROTO_1(iemCImpl_lods_ax_m64, int8_t, iEffSeg);
6005IEM_CIMPL_PROTO_1(iemCImpl_ins_op16_addr64, bool, fIoChecked);
6006IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op16_addr64, bool, fIoChecked);
6007IEM_CIMPL_PROTO_2(iemCImpl_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6008IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op16_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6009
6010IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op32_addr64, uint8_t, iEffSeg);
6011IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op32_addr64, uint8_t, iEffSeg);
6012IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_eax_m64);
6013IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_eax_m64);
6014IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op32_addr64, uint8_t, iEffSeg);
6015IEM_CIMPL_PROTO_0(iemCImpl_stos_eax_m64);
6016IEM_CIMPL_PROTO_1(iemCImpl_lods_eax_m64, int8_t, iEffSeg);
6017IEM_CIMPL_PROTO_1(iemCImpl_ins_op32_addr64, bool, fIoChecked);
6018IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op32_addr64, bool, fIoChecked);
6019IEM_CIMPL_PROTO_2(iemCImpl_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6020IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op32_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6021
6022IEM_CIMPL_PROTO_1(iemCImpl_repe_cmps_op64_addr64, uint8_t, iEffSeg);
6023IEM_CIMPL_PROTO_1(iemCImpl_repne_cmps_op64_addr64, uint8_t, iEffSeg);
6024IEM_CIMPL_PROTO_0(iemCImpl_repe_scas_rax_m64);
6025IEM_CIMPL_PROTO_0(iemCImpl_repne_scas_rax_m64);
6026IEM_CIMPL_PROTO_1(iemCImpl_rep_movs_op64_addr64, uint8_t, iEffSeg);
6027IEM_CIMPL_PROTO_0(iemCImpl_stos_rax_m64);
6028IEM_CIMPL_PROTO_1(iemCImpl_lods_rax_m64, int8_t, iEffSeg);
6029IEM_CIMPL_PROTO_1(iemCImpl_ins_op64_addr64, bool, fIoChecked);
6030IEM_CIMPL_PROTO_1(iemCImpl_rep_ins_op64_addr64, bool, fIoChecked);
6031IEM_CIMPL_PROTO_2(iemCImpl_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6032IEM_CIMPL_PROTO_2(iemCImpl_rep_outs_op64_addr64, uint8_t, iEffSeg, bool, fIoChecked);
6033/** @} */
6034
6035#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
6036VBOXSTRICTRC iemVmxVmexit(PVMCPUCC pVCpu, uint32_t uExitReason, uint64_t u64ExitQual) RT_NOEXCEPT;
6037VBOXSTRICTRC iemVmxVmexitInstr(PVMCPUCC pVCpu, uint32_t uExitReason, uint8_t cbInstr) RT_NOEXCEPT;
6038VBOXSTRICTRC iemVmxVmexitInstrNeedsInfo(PVMCPUCC pVCpu, uint32_t uExitReason, VMXINSTRID uInstrId, uint8_t cbInstr) RT_NOEXCEPT;
6039VBOXSTRICTRC iemVmxVmexitTaskSwitch(PVMCPUCC pVCpu, IEMTASKSWITCH enmTaskSwitch, RTSEL SelNewTss, uint8_t cbInstr) RT_NOEXCEPT;
6040VBOXSTRICTRC iemVmxVmexitEvent(PVMCPUCC pVCpu, uint8_t uVector, uint32_t fFlags, uint32_t uErrCode, uint64_t uCr2, uint8_t cbInstr) RT_NOEXCEPT;
6041VBOXSTRICTRC iemVmxVmexitEventDoubleFault(PVMCPUCC pVCpu) RT_NOEXCEPT;
6042VBOXSTRICTRC iemVmxVmexitEpt(PVMCPUCC pVCpu, PPGMPTWALK pWalk, uint32_t fAccess, uint32_t fSlatFail, uint8_t cbInstr) RT_NOEXCEPT;
6043VBOXSTRICTRC iemVmxVmexitPreemptTimer(PVMCPUCC pVCpu) RT_NOEXCEPT;
6044VBOXSTRICTRC iemVmxVmexitInstrMwait(PVMCPUCC pVCpu, bool fMonitorHwArmed, uint8_t cbInstr) RT_NOEXCEPT;
6045VBOXSTRICTRC iemVmxVmexitInstrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port,
6046 bool fImm, uint8_t cbAccess, uint8_t cbInstr) RT_NOEXCEPT;
6047VBOXSTRICTRC iemVmxVmexitInstrStrIo(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint16_t u16Port, uint8_t cbAccess,
6048 bool fRep, VMXEXITINSTRINFO ExitInstrInfo, uint8_t cbInstr) RT_NOEXCEPT;
6049VBOXSTRICTRC iemVmxVmexitInstrMovDrX(PVMCPUCC pVCpu, VMXINSTRID uInstrId, uint8_t iDrReg, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6050VBOXSTRICTRC iemVmxVmexitInstrMovToCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6051VBOXSTRICTRC iemVmxVmexitInstrMovFromCr8(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6052VBOXSTRICTRC iemVmxVmexitInstrMovToCr3(PVMCPUCC pVCpu, uint64_t uNewCr3, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6053VBOXSTRICTRC iemVmxVmexitInstrMovFromCr3(PVMCPUCC pVCpu, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6054VBOXSTRICTRC iemVmxVmexitInstrMovToCr0Cr4(PVMCPUCC pVCpu, uint8_t iCrReg, uint64_t *puNewCrX, uint8_t iGReg, uint8_t cbInstr) RT_NOEXCEPT;
6055VBOXSTRICTRC iemVmxVmexitInstrClts(PVMCPUCC pVCpu, uint8_t cbInstr) RT_NOEXCEPT;
6056VBOXSTRICTRC iemVmxVmexitInstrLmsw(PVMCPUCC pVCpu, uint32_t uGuestCr0, uint16_t *pu16NewMsw,
6057 RTGCPTR GCPtrEffDst, uint8_t cbInstr) RT_NOEXCEPT;
6058VBOXSTRICTRC iemVmxVmexitInstrInvlpg(PVMCPUCC pVCpu, RTGCPTR GCPtrPage, uint8_t cbInstr) RT_NOEXCEPT;
6059VBOXSTRICTRC iemVmxApicWriteEmulation(PVMCPUCC pVCpu) RT_NOEXCEPT;
6060VBOXSTRICTRC iemVmxVirtApicAccessUnused(PVMCPUCC pVCpu, PRTGCPHYS pGCPhysAccess, size_t cbAccess, uint32_t fAccess) RT_NOEXCEPT;
6061uint32_t iemVmxVirtApicReadRaw32(PVMCPUCC pVCpu, uint16_t offReg) RT_NOEXCEPT;
6062void iemVmxVirtApicWriteRaw32(PVMCPUCC pVCpu, uint16_t offReg, uint32_t uReg) RT_NOEXCEPT;
6063VBOXSTRICTRC iemVmxInvvpid(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t iEffSeg, RTGCPTR GCPtrInvvpidDesc,
6064 uint64_t u64InvvpidType, PCVMXVEXITINFO pExitInfo) RT_NOEXCEPT;
6065bool iemVmxIsRdmsrWrmsrInterceptSet(PCVMCPU pVCpu, uint32_t uExitReason, uint32_t idMsr) RT_NOEXCEPT;
6066IEM_CIMPL_PROTO_0(iemCImpl_vmxoff);
6067IEM_CIMPL_PROTO_2(iemCImpl_vmxon, uint8_t, iEffSeg, RTGCPTR, GCPtrVmxon);
6068IEM_CIMPL_PROTO_0(iemCImpl_vmlaunch);
6069IEM_CIMPL_PROTO_0(iemCImpl_vmresume);
6070IEM_CIMPL_PROTO_2(iemCImpl_vmptrld, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
6071IEM_CIMPL_PROTO_2(iemCImpl_vmptrst, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
6072IEM_CIMPL_PROTO_2(iemCImpl_vmclear, uint8_t, iEffSeg, RTGCPTR, GCPtrVmcs);
6073IEM_CIMPL_PROTO_2(iemCImpl_vmwrite_reg, uint64_t, u64Val, uint64_t, u64VmcsField);
6074IEM_CIMPL_PROTO_3(iemCImpl_vmwrite_mem, uint8_t, iEffSeg, RTGCPTR, GCPtrVal, uint32_t, u64VmcsField);
6075IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg64, uint64_t *, pu64Dst, uint64_t, u64VmcsField);
6076IEM_CIMPL_PROTO_2(iemCImpl_vmread_reg32, uint64_t *, pu32Dst, uint32_t, u32VmcsField);
6077IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg64, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u64VmcsField);
6078IEM_CIMPL_PROTO_3(iemCImpl_vmread_mem_reg32, uint8_t, iEffSeg, RTGCPTR, GCPtrDst, uint32_t, u32VmcsField);
6079IEM_CIMPL_PROTO_3(iemCImpl_invvpid, uint8_t, iEffSeg, RTGCPTR, GCPtrInvvpidDesc, uint64_t, uInvvpidType);
6080IEM_CIMPL_PROTO_3(iemCImpl_invept, uint8_t, iEffSeg, RTGCPTR, GCPtrInveptDesc, uint64_t, uInveptType);
6081IEM_CIMPL_PROTO_0(iemCImpl_vmx_pause);
6082#endif
6083
6084#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
6085VBOXSTRICTRC iemSvmVmexit(PVMCPUCC pVCpu, uint64_t uExitCode, uint64_t uExitInfo1, uint64_t uExitInfo2) RT_NOEXCEPT;
6086VBOXSTRICTRC iemHandleSvmEventIntercept(PVMCPUCC pVCpu, uint8_t cbInstr, uint8_t u8Vector, uint32_t fFlags, uint32_t uErr, uint64_t uCr2) RT_NOEXCEPT;
6087VBOXSTRICTRC iemSvmHandleIOIntercept(PVMCPUCC pVCpu, uint16_t u16Port, SVMIOIOTYPE enmIoType, uint8_t cbReg,
6088 uint8_t cAddrSizeBits, uint8_t iEffSeg, bool fRep, bool fStrIo, uint8_t cbInstr) RT_NOEXCEPT;
6089VBOXSTRICTRC iemSvmHandleMsrIntercept(PVMCPUCC pVCpu, uint32_t idMsr, bool fWrite, uint8_t cbInstr) RT_NOEXCEPT;
6090IEM_CIMPL_PROTO_0(iemCImpl_vmrun);
6091IEM_CIMPL_PROTO_0(iemCImpl_vmload);
6092IEM_CIMPL_PROTO_0(iemCImpl_vmsave);
6093IEM_CIMPL_PROTO_0(iemCImpl_clgi);
6094IEM_CIMPL_PROTO_0(iemCImpl_stgi);
6095IEM_CIMPL_PROTO_0(iemCImpl_invlpga);
6096IEM_CIMPL_PROTO_0(iemCImpl_skinit);
6097IEM_CIMPL_PROTO_0(iemCImpl_svm_pause);
6098#endif
6099
6100IEM_CIMPL_PROTO_0(iemCImpl_vmcall); /* vmx */
6101IEM_CIMPL_PROTO_0(iemCImpl_vmmcall); /* svm */
6102IEM_CIMPL_PROTO_1(iemCImpl_Hypercall, uint16_t, uDisOpcode); /* both */
6103
6104extern const PFNIEMOP g_apfnIemInterpretOnlyOneByteMap[256];
6105extern const PFNIEMOP g_apfnIemInterpretOnlyTwoByteMap[1024];
6106extern const PFNIEMOP g_apfnIemInterpretOnlyThreeByte0f3a[1024];
6107extern const PFNIEMOP g_apfnIemInterpretOnlyThreeByte0f38[1024];
6108extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap1[1024];
6109extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap2[1024];
6110extern const PFNIEMOP g_apfnIemInterpretOnlyVecMap3[1024];
6111
6112/*
6113 * Recompiler related stuff.
6114 */
6115extern const PFNIEMOP g_apfnIemThreadedRecompilerOneByteMap[256];
6116extern const PFNIEMOP g_apfnIemThreadedRecompilerTwoByteMap[1024];
6117extern const PFNIEMOP g_apfnIemThreadedRecompilerThreeByte0f3a[1024];
6118extern const PFNIEMOP g_apfnIemThreadedRecompilerThreeByte0f38[1024];
6119extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap1[1024];
6120extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap2[1024];
6121extern const PFNIEMOP g_apfnIemThreadedRecompilerVecMap3[1024];
6122
6123DECLCALLBACK(int) iemTbInit(PVMCC pVM, uint32_t cInitialTbs, uint32_t cMaxTbs,
6124 uint64_t cbInitialExec, uint64_t cbMaxExec, uint32_t cbChunkExec);
6125void iemThreadedTbObsolete(PVMCPUCC pVCpu, PIEMTB pTb, bool fSafeToFree);
6126DECLHIDDEN(void) iemTbAllocatorFree(PVMCPUCC pVCpu, PIEMTB pTb);
6127void iemTbAllocatorProcessDelayedFrees(PVMCPUCC pVCpu, PIEMTBALLOCATOR pTbAllocator);
6128void iemTbAllocatorFreeupNativeSpace(PVMCPUCC pVCpu, uint32_t cNeededInstrs);
6129DECLHIDDEN(const char *) iemTbFlagsToString(uint32_t fFlags, char *pszBuf, size_t cbBuf) RT_NOEXCEPT;
6130DECLHIDDEN(void) iemThreadedDisassembleTb(PCIEMTB pTb, PCDBGFINFOHLP pHlp) RT_NOEXCEPT;
6131
6132
6133/** @todo FNIEMTHREADEDFUNC and friends may need more work... */
6134#if defined(__GNUC__) && !defined(IEM_WITH_THROW_CATCH)
6135typedef VBOXSTRICTRC /*__attribute__((__nothrow__))*/ FNIEMTHREADEDFUNC(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2);
6136typedef FNIEMTHREADEDFUNC *PFNIEMTHREADEDFUNC;
6137# define IEM_DECL_IEMTHREADEDFUNC_DEF(a_Name) \
6138 VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2)
6139# define IEM_DECL_IEMTHREADEDFUNC_PROTO(a_Name) \
6140 VBOXSTRICTRC __attribute__((__nothrow__)) a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2)
6141
6142#else
6143typedef VBOXSTRICTRC (FNIEMTHREADEDFUNC)(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2);
6144typedef FNIEMTHREADEDFUNC *PFNIEMTHREADEDFUNC;
6145# define IEM_DECL_IEMTHREADEDFUNC_DEF(a_Name) \
6146 VBOXSTRICTRC a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) IEM_NOEXCEPT_MAY_LONGJMP
6147# define IEM_DECL_IEMTHREADEDFUNC_PROTO(a_Name) \
6148 VBOXSTRICTRC a_Name(PVMCPU pVCpu, uint64_t uParam0, uint64_t uParam1, uint64_t uParam2) IEM_NOEXCEPT_MAY_LONGJMP
6149#endif
6150
6151
6152IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_Nop);
6153IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_LogCpuState);
6154
6155IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_DeferToCImpl0);
6156
6157IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckIrq);
6158IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckMode);
6159IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckHwInstrBps);
6160IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLim);
6161
6162IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodes);
6163IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodes);
6164IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesConsiderCsLim);
6165
6166/* Branching: */
6167IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndPcAndOpcodes);
6168IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckPcAndOpcodes);
6169IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckPcAndOpcodesConsiderCsLim);
6170
6171IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesLoadingTlb);
6172IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesLoadingTlb);
6173IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesLoadingTlbConsiderCsLim);
6174
6175/* Natural page crossing: */
6176IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesAcrossPageLoadingTlb);
6177IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesAcrossPageLoadingTlb);
6178IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesAcrossPageLoadingTlbConsiderCsLim);
6179
6180IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesOnNextPageLoadingTlb);
6181IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNextPageLoadingTlb);
6182IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNextPageLoadingTlbConsiderCsLim);
6183
6184IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckCsLimAndOpcodesOnNewPageLoadingTlb);
6185IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNewPageLoadingTlb);
6186IEM_DECL_IEMTHREADEDFUNC_PROTO(iemThreadedFunc_BltIn_CheckOpcodesOnNewPageLoadingTlbConsiderCsLim);
6187
6188bool iemThreadedCompileEmitIrqCheckBefore(PVMCPUCC pVCpu, PIEMTB pTb);
6189bool iemThreadedCompileBeginEmitCallsComplications(PVMCPUCC pVCpu, PIEMTB pTb);
6190
6191/* Native recompiler public bits: */
6192DECLHIDDEN(PIEMTB) iemNativeRecompile(PVMCPUCC pVCpu, PIEMTB pTb) RT_NOEXCEPT;
6193DECLHIDDEN(void) iemNativeDisassembleTb(PCIEMTB pTb, PCDBGFINFOHLP pHlp) RT_NOEXCEPT;
6194int iemExecMemAllocatorInit(PVMCPU pVCpu, uint64_t cbMax, uint64_t cbInitial, uint32_t cbChunk) RT_NOEXCEPT;
6195DECLHIDDEN(void *) iemExecMemAllocatorAlloc(PVMCPU pVCpu, uint32_t cbReq, PIEMTB pTb) RT_NOEXCEPT;
6196DECLHIDDEN(void) iemExecMemAllocatorReadyForUse(PVMCPUCC pVCpu, void *pv, size_t cb) RT_NOEXCEPT;
6197void iemExecMemAllocatorFree(PVMCPU pVCpu, void *pv, size_t cb) RT_NOEXCEPT;
6198DECLASM(DECL_NO_RETURN(void)) iemNativeTbLongJmp(void *pvFramePointer, int rc) RT_NOEXCEPT;
6199
6200#endif /* !RT_IN_ASSEMBLER */
6201
6202
6203/** @} */
6204
6205RT_C_DECLS_END
6206
6207#endif /* !VMM_INCLUDED_SRC_include_IEMInternal_h */
6208
Note: See TracBrowser for help on using the repository browser.

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