VirtualBox

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

Last change on this file since 102424 was 102424, checked in by vboxsync, 12 months ago

VMM/IEM: Continue refactoring IEM_MC_MEM_MAP into type specific MCs using bUnmapInfo. bugref:10371

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