VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsTwoByte0f.cpp.h@ 84247

Last change on this file since 84247 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 342.3 KB
Line 
1/* $Id: IEMAllInstructionsTwoByte0f.cpp.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * IEM - Instruction Decoding and Emulation.
4 *
5 * @remarks IEMAllInstructionsVexMap1.cpp.h is a VEX mirror of this file.
6 * Any update here is likely needed in that file too.
7 */
8
9/*
10 * Copyright (C) 2011-2020 Oracle Corporation
11 *
12 * This file is part of VirtualBox Open Source Edition (OSE), as
13 * available from http://www.virtualbox.org. This file is free software;
14 * you can redistribute it and/or modify it under the terms of the GNU
15 * General Public License (GPL) as published by the Free Software
16 * Foundation, in version 2 as it comes in the "COPYING" file of the
17 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19 */
20
21
22/** @name Two byte opcodes (first byte 0x0f).
23 *
24 * @{
25 */
26
27/** Opcode 0x0f 0x00 /0. */
28FNIEMOPRM_DEF(iemOp_Grp6_sldt)
29{
30 IEMOP_MNEMONIC(sldt, "sldt Rv/Mw");
31 IEMOP_HLP_MIN_286();
32 IEMOP_HLP_NO_REAL_OR_V86_MODE();
33
34 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
35 {
36 IEMOP_HLP_DECODED_NL_1(OP_SLDT, IEMOPFORM_M_REG, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
37 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_sldt_reg, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, pVCpu->iem.s.enmEffOpSize);
38 }
39
40 /* Ignore operand size here, memory refs are always 16-bit. */
41 IEM_MC_BEGIN(2, 0);
42 IEM_MC_ARG(uint16_t, iEffSeg, 0);
43 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
44 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
45 IEMOP_HLP_DECODED_NL_1(OP_SLDT, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
46 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
47 IEM_MC_CALL_CIMPL_2(iemCImpl_sldt_mem, iEffSeg, GCPtrEffDst);
48 IEM_MC_END();
49 return VINF_SUCCESS;
50}
51
52
53/** Opcode 0x0f 0x00 /1. */
54FNIEMOPRM_DEF(iemOp_Grp6_str)
55{
56 IEMOP_MNEMONIC(str, "str Rv/Mw");
57 IEMOP_HLP_MIN_286();
58 IEMOP_HLP_NO_REAL_OR_V86_MODE();
59
60
61 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
62 {
63 IEMOP_HLP_DECODED_NL_1(OP_STR, IEMOPFORM_M_REG, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
64 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_str_reg, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, pVCpu->iem.s.enmEffOpSize);
65 }
66
67 /* Ignore operand size here, memory refs are always 16-bit. */
68 IEM_MC_BEGIN(2, 0);
69 IEM_MC_ARG(uint16_t, iEffSeg, 0);
70 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
71 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
72 IEMOP_HLP_DECODED_NL_1(OP_STR, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
73 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
74 IEM_MC_CALL_CIMPL_2(iemCImpl_str_mem, iEffSeg, GCPtrEffDst);
75 IEM_MC_END();
76 return VINF_SUCCESS;
77}
78
79
80/** Opcode 0x0f 0x00 /2. */
81FNIEMOPRM_DEF(iemOp_Grp6_lldt)
82{
83 IEMOP_MNEMONIC(lldt, "lldt Ew");
84 IEMOP_HLP_MIN_286();
85 IEMOP_HLP_NO_REAL_OR_V86_MODE();
86
87 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
88 {
89 IEMOP_HLP_DECODED_NL_1(OP_LLDT, IEMOPFORM_M_REG, OP_PARM_Ew, DISOPTYPE_DANGEROUS);
90 IEM_MC_BEGIN(1, 0);
91 IEM_MC_ARG(uint16_t, u16Sel, 0);
92 IEM_MC_FETCH_GREG_U16(u16Sel, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
93 IEM_MC_CALL_CIMPL_1(iemCImpl_lldt, u16Sel);
94 IEM_MC_END();
95 }
96 else
97 {
98 IEM_MC_BEGIN(1, 1);
99 IEM_MC_ARG(uint16_t, u16Sel, 0);
100 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
101 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
102 IEMOP_HLP_DECODED_NL_1(OP_LLDT, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS);
103 IEM_MC_RAISE_GP0_IF_CPL_NOT_ZERO(); /** @todo test order */
104 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
105 IEM_MC_CALL_CIMPL_1(iemCImpl_lldt, u16Sel);
106 IEM_MC_END();
107 }
108 return VINF_SUCCESS;
109}
110
111
112/** Opcode 0x0f 0x00 /3. */
113FNIEMOPRM_DEF(iemOp_Grp6_ltr)
114{
115 IEMOP_MNEMONIC(ltr, "ltr Ew");
116 IEMOP_HLP_MIN_286();
117 IEMOP_HLP_NO_REAL_OR_V86_MODE();
118
119 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
120 {
121 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
122 IEM_MC_BEGIN(1, 0);
123 IEM_MC_ARG(uint16_t, u16Sel, 0);
124 IEM_MC_FETCH_GREG_U16(u16Sel, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
125 IEM_MC_CALL_CIMPL_1(iemCImpl_ltr, u16Sel);
126 IEM_MC_END();
127 }
128 else
129 {
130 IEM_MC_BEGIN(1, 1);
131 IEM_MC_ARG(uint16_t, u16Sel, 0);
132 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
133 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
134 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
135 IEM_MC_RAISE_GP0_IF_CPL_NOT_ZERO(); /** @todo test order */
136 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
137 IEM_MC_CALL_CIMPL_1(iemCImpl_ltr, u16Sel);
138 IEM_MC_END();
139 }
140 return VINF_SUCCESS;
141}
142
143
144/** Opcode 0x0f 0x00 /3. */
145FNIEMOP_DEF_2(iemOpCommonGrp6VerX, uint8_t, bRm, bool, fWrite)
146{
147 IEMOP_HLP_MIN_286();
148 IEMOP_HLP_NO_REAL_OR_V86_MODE();
149
150 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
151 {
152 IEMOP_HLP_DECODED_NL_1(fWrite ? OP_VERW : OP_VERR, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
153 IEM_MC_BEGIN(2, 0);
154 IEM_MC_ARG(uint16_t, u16Sel, 0);
155 IEM_MC_ARG_CONST(bool, fWriteArg, fWrite, 1);
156 IEM_MC_FETCH_GREG_U16(u16Sel, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
157 IEM_MC_CALL_CIMPL_2(iemCImpl_VerX, u16Sel, fWriteArg);
158 IEM_MC_END();
159 }
160 else
161 {
162 IEM_MC_BEGIN(2, 1);
163 IEM_MC_ARG(uint16_t, u16Sel, 0);
164 IEM_MC_ARG_CONST(bool, fWriteArg, fWrite, 1);
165 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
166 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
167 IEMOP_HLP_DECODED_NL_1(fWrite ? OP_VERW : OP_VERR, IEMOPFORM_M_MEM, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
168 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
169 IEM_MC_CALL_CIMPL_2(iemCImpl_VerX, u16Sel, fWriteArg);
170 IEM_MC_END();
171 }
172 return VINF_SUCCESS;
173}
174
175
176/** Opcode 0x0f 0x00 /4. */
177FNIEMOPRM_DEF(iemOp_Grp6_verr)
178{
179 IEMOP_MNEMONIC(verr, "verr Ew");
180 IEMOP_HLP_MIN_286();
181 return FNIEMOP_CALL_2(iemOpCommonGrp6VerX, bRm, false);
182}
183
184
185/** Opcode 0x0f 0x00 /5. */
186FNIEMOPRM_DEF(iemOp_Grp6_verw)
187{
188 IEMOP_MNEMONIC(verw, "verw Ew");
189 IEMOP_HLP_MIN_286();
190 return FNIEMOP_CALL_2(iemOpCommonGrp6VerX, bRm, true);
191}
192
193
194/**
195 * Group 6 jump table.
196 */
197IEM_STATIC const PFNIEMOPRM g_apfnGroup6[8] =
198{
199 iemOp_Grp6_sldt,
200 iemOp_Grp6_str,
201 iemOp_Grp6_lldt,
202 iemOp_Grp6_ltr,
203 iemOp_Grp6_verr,
204 iemOp_Grp6_verw,
205 iemOp_InvalidWithRM,
206 iemOp_InvalidWithRM
207};
208
209/** Opcode 0x0f 0x00. */
210FNIEMOP_DEF(iemOp_Grp6)
211{
212 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
213 return FNIEMOP_CALL_1(g_apfnGroup6[(bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK], bRm);
214}
215
216
217/** Opcode 0x0f 0x01 /0. */
218FNIEMOP_DEF_1(iemOp_Grp7_sgdt, uint8_t, bRm)
219{
220 IEMOP_MNEMONIC(sgdt, "sgdt Ms");
221 IEMOP_HLP_MIN_286();
222 IEMOP_HLP_64BIT_OP_SIZE();
223 IEM_MC_BEGIN(2, 1);
224 IEM_MC_ARG(uint8_t, iEffSeg, 0);
225 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
226 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
227 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
228 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
229 IEM_MC_CALL_CIMPL_2(iemCImpl_sgdt, iEffSeg, GCPtrEffSrc);
230 IEM_MC_END();
231 return VINF_SUCCESS;
232}
233
234
235/** Opcode 0x0f 0x01 /0. */
236FNIEMOP_DEF(iemOp_Grp7_vmcall)
237{
238 IEMOP_MNEMONIC(vmcall, "vmcall");
239 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the VMX instructions. ASSUMING no lock for now. */
240
241 /* Note! We do not check any CPUMFEATURES::fSvm here as we (GIM) generally
242 want all hypercalls regardless of instruction used, and if a
243 hypercall isn't handled by GIM or HMSvm will raise an #UD.
244 (NEM/win makes ASSUMPTIONS about this behavior.) */
245 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmcall);
246}
247
248
249/** Opcode 0x0f 0x01 /0. */
250#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
251FNIEMOP_DEF(iemOp_Grp7_vmlaunch)
252{
253 IEMOP_MNEMONIC(vmlaunch, "vmlaunch");
254 IEMOP_HLP_IN_VMX_OPERATION("vmlaunch", kVmxVDiag_Vmentry);
255 IEMOP_HLP_VMX_INSTR("vmlaunch", kVmxVDiag_Vmentry);
256 IEMOP_HLP_DONE_DECODING();
257 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmlaunch);
258}
259#else
260FNIEMOP_DEF(iemOp_Grp7_vmlaunch)
261{
262 IEMOP_BITCH_ABOUT_STUB();
263 return IEMOP_RAISE_INVALID_OPCODE();
264}
265#endif
266
267
268/** Opcode 0x0f 0x01 /0. */
269#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
270FNIEMOP_DEF(iemOp_Grp7_vmresume)
271{
272 IEMOP_MNEMONIC(vmresume, "vmresume");
273 IEMOP_HLP_IN_VMX_OPERATION("vmresume", kVmxVDiag_Vmentry);
274 IEMOP_HLP_VMX_INSTR("vmresume", kVmxVDiag_Vmentry);
275 IEMOP_HLP_DONE_DECODING();
276 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmresume);
277}
278#else
279FNIEMOP_DEF(iemOp_Grp7_vmresume)
280{
281 IEMOP_BITCH_ABOUT_STUB();
282 return IEMOP_RAISE_INVALID_OPCODE();
283}
284#endif
285
286
287/** Opcode 0x0f 0x01 /0. */
288#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
289FNIEMOP_DEF(iemOp_Grp7_vmxoff)
290{
291 IEMOP_MNEMONIC(vmxoff, "vmxoff");
292 IEMOP_HLP_IN_VMX_OPERATION("vmxoff", kVmxVDiag_Vmxoff);
293 IEMOP_HLP_VMX_INSTR("vmxoff", kVmxVDiag_Vmxoff);
294 IEMOP_HLP_DONE_DECODING();
295 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmxoff);
296}
297#else
298FNIEMOP_DEF(iemOp_Grp7_vmxoff)
299{
300 IEMOP_BITCH_ABOUT_STUB();
301 return IEMOP_RAISE_INVALID_OPCODE();
302}
303#endif
304
305
306/** Opcode 0x0f 0x01 /1. */
307FNIEMOP_DEF_1(iemOp_Grp7_sidt, uint8_t, bRm)
308{
309 IEMOP_MNEMONIC(sidt, "sidt Ms");
310 IEMOP_HLP_MIN_286();
311 IEMOP_HLP_64BIT_OP_SIZE();
312 IEM_MC_BEGIN(2, 1);
313 IEM_MC_ARG(uint8_t, iEffSeg, 0);
314 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
315 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
316 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
317 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
318 IEM_MC_CALL_CIMPL_2(iemCImpl_sidt, iEffSeg, GCPtrEffSrc);
319 IEM_MC_END();
320 return VINF_SUCCESS;
321}
322
323
324/** Opcode 0x0f 0x01 /1. */
325FNIEMOP_DEF(iemOp_Grp7_monitor)
326{
327 IEMOP_MNEMONIC(monitor, "monitor");
328 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo Verify that monitor is allergic to lock prefixes. */
329 return IEM_MC_DEFER_TO_CIMPL_1(iemCImpl_monitor, pVCpu->iem.s.iEffSeg);
330}
331
332
333/** Opcode 0x0f 0x01 /1. */
334FNIEMOP_DEF(iemOp_Grp7_mwait)
335{
336 IEMOP_MNEMONIC(mwait, "mwait"); /** @todo Verify that mwait is allergic to lock prefixes. */
337 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
338 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_mwait);
339}
340
341
342/** Opcode 0x0f 0x01 /2. */
343FNIEMOP_DEF_1(iemOp_Grp7_lgdt, uint8_t, bRm)
344{
345 IEMOP_MNEMONIC(lgdt, "lgdt");
346 IEMOP_HLP_64BIT_OP_SIZE();
347 IEM_MC_BEGIN(3, 1);
348 IEM_MC_ARG(uint8_t, iEffSeg, 0);
349 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
350 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSizeArg,/*=*/pVCpu->iem.s.enmEffOpSize, 2);
351 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
352 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
353 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
354 IEM_MC_CALL_CIMPL_3(iemCImpl_lgdt, iEffSeg, GCPtrEffSrc, enmEffOpSizeArg);
355 IEM_MC_END();
356 return VINF_SUCCESS;
357}
358
359
360/** Opcode 0x0f 0x01 0xd0. */
361FNIEMOP_DEF(iemOp_Grp7_xgetbv)
362{
363 IEMOP_MNEMONIC(xgetbv, "xgetbv");
364 if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
365 {
366 /** @todo r=ramshankar: We should use
367 * IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX and
368 * IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES here. */
369 IEMOP_HLP_DONE_DECODING_NO_LOCK_REPZ_OR_REPNZ_PREFIXES();
370 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_xgetbv);
371 }
372 return IEMOP_RAISE_INVALID_OPCODE();
373}
374
375
376/** Opcode 0x0f 0x01 0xd1. */
377FNIEMOP_DEF(iemOp_Grp7_xsetbv)
378{
379 IEMOP_MNEMONIC(xsetbv, "xsetbv");
380 if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
381 {
382 /** @todo r=ramshankar: We should use
383 * IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX and
384 * IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES here. */
385 IEMOP_HLP_DONE_DECODING_NO_LOCK_REPZ_OR_REPNZ_PREFIXES();
386 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_xsetbv);
387 }
388 return IEMOP_RAISE_INVALID_OPCODE();
389}
390
391
392/** Opcode 0x0f 0x01 /3. */
393FNIEMOP_DEF_1(iemOp_Grp7_lidt, uint8_t, bRm)
394{
395 IEMOP_MNEMONIC(lidt, "lidt");
396 IEMMODE enmEffOpSize = pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT
397 ? IEMMODE_64BIT
398 : pVCpu->iem.s.enmEffOpSize;
399 IEM_MC_BEGIN(3, 1);
400 IEM_MC_ARG(uint8_t, iEffSeg, 0);
401 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
402 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSizeArg,/*=*/enmEffOpSize, 2);
403 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
404 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
405 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
406 IEM_MC_CALL_CIMPL_3(iemCImpl_lidt, iEffSeg, GCPtrEffSrc, enmEffOpSizeArg);
407 IEM_MC_END();
408 return VINF_SUCCESS;
409}
410
411
412/** Opcode 0x0f 0x01 0xd8. */
413#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
414FNIEMOP_DEF(iemOp_Grp7_Amd_vmrun)
415{
416 IEMOP_MNEMONIC(vmrun, "vmrun");
417 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
418 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmrun);
419}
420#else
421FNIEMOP_UD_STUB(iemOp_Grp7_Amd_vmrun);
422#endif
423
424/** Opcode 0x0f 0x01 0xd9. */
425FNIEMOP_DEF(iemOp_Grp7_Amd_vmmcall)
426{
427 IEMOP_MNEMONIC(vmmcall, "vmmcall");
428 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
429
430 /* Note! We do not check any CPUMFEATURES::fSvm here as we (GIM) generally
431 want all hypercalls regardless of instruction used, and if a
432 hypercall isn't handled by GIM or HMSvm will raise an #UD.
433 (NEM/win makes ASSUMPTIONS about this behavior.) */
434 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmmcall);
435}
436
437/** Opcode 0x0f 0x01 0xda. */
438#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
439FNIEMOP_DEF(iemOp_Grp7_Amd_vmload)
440{
441 IEMOP_MNEMONIC(vmload, "vmload");
442 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
443 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmload);
444}
445#else
446FNIEMOP_UD_STUB(iemOp_Grp7_Amd_vmload);
447#endif
448
449
450/** Opcode 0x0f 0x01 0xdb. */
451#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
452FNIEMOP_DEF(iemOp_Grp7_Amd_vmsave)
453{
454 IEMOP_MNEMONIC(vmsave, "vmsave");
455 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
456 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_vmsave);
457}
458#else
459FNIEMOP_UD_STUB(iemOp_Grp7_Amd_vmsave);
460#endif
461
462
463/** Opcode 0x0f 0x01 0xdc. */
464#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
465FNIEMOP_DEF(iemOp_Grp7_Amd_stgi)
466{
467 IEMOP_MNEMONIC(stgi, "stgi");
468 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
469 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_stgi);
470}
471#else
472FNIEMOP_UD_STUB(iemOp_Grp7_Amd_stgi);
473#endif
474
475
476/** Opcode 0x0f 0x01 0xdd. */
477#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
478FNIEMOP_DEF(iemOp_Grp7_Amd_clgi)
479{
480 IEMOP_MNEMONIC(clgi, "clgi");
481 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
482 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_clgi);
483}
484#else
485FNIEMOP_UD_STUB(iemOp_Grp7_Amd_clgi);
486#endif
487
488
489/** Opcode 0x0f 0x01 0xdf. */
490#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
491FNIEMOP_DEF(iemOp_Grp7_Amd_invlpga)
492{
493 IEMOP_MNEMONIC(invlpga, "invlpga");
494 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
495 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_invlpga);
496}
497#else
498FNIEMOP_UD_STUB(iemOp_Grp7_Amd_invlpga);
499#endif
500
501
502/** Opcode 0x0f 0x01 0xde. */
503#ifdef VBOX_WITH_NESTED_HWVIRT_SVM
504FNIEMOP_DEF(iemOp_Grp7_Amd_skinit)
505{
506 IEMOP_MNEMONIC(skinit, "skinit");
507 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX(); /** @todo check prefix effect on the SVM instructions. ASSUMING no lock for now. */
508 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_skinit);
509}
510#else
511FNIEMOP_UD_STUB(iemOp_Grp7_Amd_skinit);
512#endif
513
514
515/** Opcode 0x0f 0x01 /4. */
516FNIEMOP_DEF_1(iemOp_Grp7_smsw, uint8_t, bRm)
517{
518 IEMOP_MNEMONIC(smsw, "smsw");
519 IEMOP_HLP_MIN_286();
520 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
521 {
522 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
523 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_smsw_reg, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, pVCpu->iem.s.enmEffOpSize);
524 }
525
526 /* Ignore operand size here, memory refs are always 16-bit. */
527 IEM_MC_BEGIN(2, 0);
528 IEM_MC_ARG(uint16_t, iEffSeg, 0);
529 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
530 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
531 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
532 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
533 IEM_MC_CALL_CIMPL_2(iemCImpl_smsw_mem, iEffSeg, GCPtrEffDst);
534 IEM_MC_END();
535 return VINF_SUCCESS;
536}
537
538
539/** Opcode 0x0f 0x01 /6. */
540FNIEMOP_DEF_1(iemOp_Grp7_lmsw, uint8_t, bRm)
541{
542 /* The operand size is effectively ignored, all is 16-bit and only the
543 lower 3-bits are used. */
544 IEMOP_MNEMONIC(lmsw, "lmsw");
545 IEMOP_HLP_MIN_286();
546 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
547 {
548 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
549 IEM_MC_BEGIN(2, 0);
550 IEM_MC_ARG(uint16_t, u16Tmp, 0);
551 IEM_MC_ARG_CONST(RTGCPTR, GCPtrEffDst, NIL_RTGCPTR, 1);
552 IEM_MC_FETCH_GREG_U16(u16Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
553 IEM_MC_CALL_CIMPL_2(iemCImpl_lmsw, u16Tmp, GCPtrEffDst);
554 IEM_MC_END();
555 }
556 else
557 {
558 IEM_MC_BEGIN(2, 0);
559 IEM_MC_ARG(uint16_t, u16Tmp, 0);
560 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
561 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
562 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
563 IEM_MC_FETCH_MEM_U16(u16Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
564 IEM_MC_CALL_CIMPL_2(iemCImpl_lmsw, u16Tmp, GCPtrEffDst);
565 IEM_MC_END();
566 }
567 return VINF_SUCCESS;
568}
569
570
571/** Opcode 0x0f 0x01 /7. */
572FNIEMOP_DEF_1(iemOp_Grp7_invlpg, uint8_t, bRm)
573{
574 IEMOP_MNEMONIC(invlpg, "invlpg");
575 IEMOP_HLP_MIN_486();
576 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
577 IEM_MC_BEGIN(1, 1);
578 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 0);
579 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
580 IEM_MC_CALL_CIMPL_1(iemCImpl_invlpg, GCPtrEffDst);
581 IEM_MC_END();
582 return VINF_SUCCESS;
583}
584
585
586/** Opcode 0x0f 0x01 /7. */
587FNIEMOP_DEF(iemOp_Grp7_swapgs)
588{
589 IEMOP_MNEMONIC(swapgs, "swapgs");
590 IEMOP_HLP_ONLY_64BIT();
591 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
592 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_swapgs);
593}
594
595
596/** Opcode 0x0f 0x01 /7. */
597FNIEMOP_DEF(iemOp_Grp7_rdtscp)
598{
599 IEMOP_MNEMONIC(rdtscp, "rdtscp");
600 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
601 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_rdtscp);
602}
603
604
605/**
606 * Group 7 jump table, memory variant.
607 */
608IEM_STATIC const PFNIEMOPRM g_apfnGroup7Mem[8] =
609{
610 iemOp_Grp7_sgdt,
611 iemOp_Grp7_sidt,
612 iemOp_Grp7_lgdt,
613 iemOp_Grp7_lidt,
614 iemOp_Grp7_smsw,
615 iemOp_InvalidWithRM,
616 iemOp_Grp7_lmsw,
617 iemOp_Grp7_invlpg
618};
619
620
621/** Opcode 0x0f 0x01. */
622FNIEMOP_DEF(iemOp_Grp7)
623{
624 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
625 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
626 return FNIEMOP_CALL_1(g_apfnGroup7Mem[(bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK], bRm);
627
628 switch ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK)
629 {
630 case 0:
631 switch (bRm & X86_MODRM_RM_MASK)
632 {
633 case 1: return FNIEMOP_CALL(iemOp_Grp7_vmcall);
634 case 2: return FNIEMOP_CALL(iemOp_Grp7_vmlaunch);
635 case 3: return FNIEMOP_CALL(iemOp_Grp7_vmresume);
636 case 4: return FNIEMOP_CALL(iemOp_Grp7_vmxoff);
637 }
638 return IEMOP_RAISE_INVALID_OPCODE();
639
640 case 1:
641 switch (bRm & X86_MODRM_RM_MASK)
642 {
643 case 0: return FNIEMOP_CALL(iemOp_Grp7_monitor);
644 case 1: return FNIEMOP_CALL(iemOp_Grp7_mwait);
645 }
646 return IEMOP_RAISE_INVALID_OPCODE();
647
648 case 2:
649 switch (bRm & X86_MODRM_RM_MASK)
650 {
651 case 0: return FNIEMOP_CALL(iemOp_Grp7_xgetbv);
652 case 1: return FNIEMOP_CALL(iemOp_Grp7_xsetbv);
653 }
654 return IEMOP_RAISE_INVALID_OPCODE();
655
656 case 3:
657 switch (bRm & X86_MODRM_RM_MASK)
658 {
659 case 0: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmrun);
660 case 1: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmmcall);
661 case 2: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmload);
662 case 3: return FNIEMOP_CALL(iemOp_Grp7_Amd_vmsave);
663 case 4: return FNIEMOP_CALL(iemOp_Grp7_Amd_stgi);
664 case 5: return FNIEMOP_CALL(iemOp_Grp7_Amd_clgi);
665 case 6: return FNIEMOP_CALL(iemOp_Grp7_Amd_skinit);
666 case 7: return FNIEMOP_CALL(iemOp_Grp7_Amd_invlpga);
667 IEM_NOT_REACHED_DEFAULT_CASE_RET();
668 }
669
670 case 4:
671 return FNIEMOP_CALL_1(iemOp_Grp7_smsw, bRm);
672
673 case 5:
674 return IEMOP_RAISE_INVALID_OPCODE();
675
676 case 6:
677 return FNIEMOP_CALL_1(iemOp_Grp7_lmsw, bRm);
678
679 case 7:
680 switch (bRm & X86_MODRM_RM_MASK)
681 {
682 case 0: return FNIEMOP_CALL(iemOp_Grp7_swapgs);
683 case 1: return FNIEMOP_CALL(iemOp_Grp7_rdtscp);
684 }
685 return IEMOP_RAISE_INVALID_OPCODE();
686
687 IEM_NOT_REACHED_DEFAULT_CASE_RET();
688 }
689}
690
691/** Opcode 0x0f 0x00 /3. */
692FNIEMOP_DEF_1(iemOpCommonLarLsl_Gv_Ew, bool, fIsLar)
693{
694 IEMOP_HLP_NO_REAL_OR_V86_MODE();
695 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
696
697 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
698 {
699 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_REG, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
700 switch (pVCpu->iem.s.enmEffOpSize)
701 {
702 case IEMMODE_16BIT:
703 {
704 IEM_MC_BEGIN(3, 0);
705 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
706 IEM_MC_ARG(uint16_t, u16Sel, 1);
707 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
708
709 IEM_MC_REF_GREG_U16(pu16Dst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
710 IEM_MC_FETCH_GREG_U16(u16Sel, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
711 IEM_MC_CALL_CIMPL_3(iemCImpl_LarLsl_u16, pu16Dst, u16Sel, fIsLarArg);
712
713 IEM_MC_END();
714 return VINF_SUCCESS;
715 }
716
717 case IEMMODE_32BIT:
718 case IEMMODE_64BIT:
719 {
720 IEM_MC_BEGIN(3, 0);
721 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
722 IEM_MC_ARG(uint16_t, u16Sel, 1);
723 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
724
725 IEM_MC_REF_GREG_U64(pu64Dst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
726 IEM_MC_FETCH_GREG_U16(u16Sel, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
727 IEM_MC_CALL_CIMPL_3(iemCImpl_LarLsl_u64, pu64Dst, u16Sel, fIsLarArg);
728
729 IEM_MC_END();
730 return VINF_SUCCESS;
731 }
732
733 IEM_NOT_REACHED_DEFAULT_CASE_RET();
734 }
735 }
736 else
737 {
738 switch (pVCpu->iem.s.enmEffOpSize)
739 {
740 case IEMMODE_16BIT:
741 {
742 IEM_MC_BEGIN(3, 1);
743 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
744 IEM_MC_ARG(uint16_t, u16Sel, 1);
745 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
746 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
747
748 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
749 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_MEM, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
750
751 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
752 IEM_MC_REF_GREG_U16(pu16Dst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
753 IEM_MC_CALL_CIMPL_3(iemCImpl_LarLsl_u16, pu16Dst, u16Sel, fIsLarArg);
754
755 IEM_MC_END();
756 return VINF_SUCCESS;
757 }
758
759 case IEMMODE_32BIT:
760 case IEMMODE_64BIT:
761 {
762 IEM_MC_BEGIN(3, 1);
763 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
764 IEM_MC_ARG(uint16_t, u16Sel, 1);
765 IEM_MC_ARG_CONST(bool, fIsLarArg, fIsLar, 2);
766 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
767
768 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
769 IEMOP_HLP_DECODED_NL_2(fIsLar ? OP_LAR : OP_LSL, IEMOPFORM_RM_MEM, OP_PARM_Gv, OP_PARM_Ew, DISOPTYPE_DANGEROUS | DISOPTYPE_PRIVILEGED_NOTRAP);
770/** @todo testcase: make sure it's a 16-bit read. */
771
772 IEM_MC_FETCH_MEM_U16(u16Sel, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
773 IEM_MC_REF_GREG_U64(pu64Dst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
774 IEM_MC_CALL_CIMPL_3(iemCImpl_LarLsl_u64, pu64Dst, u16Sel, fIsLarArg);
775
776 IEM_MC_END();
777 return VINF_SUCCESS;
778 }
779
780 IEM_NOT_REACHED_DEFAULT_CASE_RET();
781 }
782 }
783}
784
785
786
787/** Opcode 0x0f 0x02. */
788FNIEMOP_DEF(iemOp_lar_Gv_Ew)
789{
790 IEMOP_MNEMONIC(lar, "lar Gv,Ew");
791 return FNIEMOP_CALL_1(iemOpCommonLarLsl_Gv_Ew, true);
792}
793
794
795/** Opcode 0x0f 0x03. */
796FNIEMOP_DEF(iemOp_lsl_Gv_Ew)
797{
798 IEMOP_MNEMONIC(lsl, "lsl Gv,Ew");
799 return FNIEMOP_CALL_1(iemOpCommonLarLsl_Gv_Ew, false);
800}
801
802
803/** Opcode 0x0f 0x05. */
804FNIEMOP_DEF(iemOp_syscall)
805{
806 IEMOP_MNEMONIC(syscall, "syscall"); /** @todo 286 LOADALL */
807 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
808 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_syscall);
809}
810
811
812/** Opcode 0x0f 0x06. */
813FNIEMOP_DEF(iemOp_clts)
814{
815 IEMOP_MNEMONIC(clts, "clts");
816 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
817 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_clts);
818}
819
820
821/** Opcode 0x0f 0x07. */
822FNIEMOP_DEF(iemOp_sysret)
823{
824 IEMOP_MNEMONIC(sysret, "sysret"); /** @todo 386 LOADALL */
825 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
826 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_sysret);
827}
828
829
830/** Opcode 0x0f 0x08. */
831FNIEMOP_DEF(iemOp_invd)
832{
833 IEMOP_MNEMONIC0(FIXED, INVD, invd, DISOPTYPE_PRIVILEGED, 0);
834 IEMOP_HLP_MIN_486();
835 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
836 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_invd);
837}
838
839
840/** Opcode 0x0f 0x09. */
841FNIEMOP_DEF(iemOp_wbinvd)
842{
843 IEMOP_MNEMONIC0(FIXED, WBINVD, wbinvd, DISOPTYPE_PRIVILEGED, 0);
844 IEMOP_HLP_MIN_486();
845 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
846 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_wbinvd);
847}
848
849
850/** Opcode 0x0f 0x0b. */
851FNIEMOP_DEF(iemOp_ud2)
852{
853 IEMOP_MNEMONIC(ud2, "ud2");
854 return IEMOP_RAISE_INVALID_OPCODE();
855}
856
857/** Opcode 0x0f 0x0d. */
858FNIEMOP_DEF(iemOp_nop_Ev_GrpP)
859{
860 /* AMD prefetch group, Intel implements this as NOP Ev (and so do we). */
861 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->f3DNowPrefetch)
862 {
863 IEMOP_MNEMONIC(GrpPNotSupported, "GrpP");
864 return IEMOP_RAISE_INVALID_OPCODE();
865 }
866
867 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
868 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
869 {
870 IEMOP_MNEMONIC(GrpPInvalid, "GrpP");
871 return IEMOP_RAISE_INVALID_OPCODE();
872 }
873
874 switch ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK)
875 {
876 case 2: /* Aliased to /0 for the time being. */
877 case 4: /* Aliased to /0 for the time being. */
878 case 5: /* Aliased to /0 for the time being. */
879 case 6: /* Aliased to /0 for the time being. */
880 case 7: /* Aliased to /0 for the time being. */
881 case 0: IEMOP_MNEMONIC(prefetch, "prefetch"); break;
882 case 1: IEMOP_MNEMONIC(prefetchw_1, "prefetchw"); break;
883 case 3: IEMOP_MNEMONIC(prefetchw_3, "prefetchw"); break;
884 IEM_NOT_REACHED_DEFAULT_CASE_RET();
885 }
886
887 IEM_MC_BEGIN(0, 1);
888 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
889 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
890 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
891 /* Currently a NOP. */
892 NOREF(GCPtrEffSrc);
893 IEM_MC_ADVANCE_RIP();
894 IEM_MC_END();
895 return VINF_SUCCESS;
896}
897
898
899/** Opcode 0x0f 0x0e. */
900FNIEMOP_DEF(iemOp_femms)
901{
902 IEMOP_MNEMONIC(femms, "femms");
903 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
904
905 IEM_MC_BEGIN(0,0);
906 IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE();
907 IEM_MC_MAYBE_RAISE_FPU_XCPT();
908 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
909 IEM_MC_FPU_FROM_MMX_MODE();
910 IEM_MC_ADVANCE_RIP();
911 IEM_MC_END();
912 return VINF_SUCCESS;
913}
914
915
916/** Opcode 0x0f 0x0f. */
917FNIEMOP_DEF(iemOp_3Dnow)
918{
919 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->f3DNow)
920 {
921 IEMOP_MNEMONIC(Inv3Dnow, "3Dnow");
922 return IEMOP_RAISE_INVALID_OPCODE();
923 }
924
925#ifdef IEM_WITH_3DNOW
926 /* This is pretty sparse, use switch instead of table. */
927 uint8_t b; IEM_OPCODE_GET_NEXT_U8(&b);
928 return FNIEMOP_CALL_1(iemOp_3DNowDispatcher, b);
929#else
930 IEMOP_BITCH_ABOUT_STUB();
931 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
932#endif
933}
934
935
936/**
937 * @opcode 0x10
938 * @oppfx none
939 * @opcpuid sse
940 * @opgroup og_sse_simdfp_datamove
941 * @opxcpttype 4UA
942 * @optest op1=1 op2=2 -> op1=2
943 * @optest op1=0 op2=-22 -> op1=-22
944 */
945FNIEMOP_DEF(iemOp_movups_Vps_Wps)
946{
947 IEMOP_MNEMONIC2(RM, MOVUPS, movups, Vps_WO, Wps, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
948 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
949 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
950 {
951 /*
952 * Register, register.
953 */
954 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
955 IEM_MC_BEGIN(0, 0);
956 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
957 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
958 IEM_MC_COPY_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg,
959 (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
960 IEM_MC_ADVANCE_RIP();
961 IEM_MC_END();
962 }
963 else
964 {
965 /*
966 * Memory, register.
967 */
968 IEM_MC_BEGIN(0, 2);
969 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
970 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
971
972 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
973 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
974 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
975 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
976
977 IEM_MC_FETCH_MEM_U128(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
978 IEM_MC_STORE_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
979
980 IEM_MC_ADVANCE_RIP();
981 IEM_MC_END();
982 }
983 return VINF_SUCCESS;
984
985}
986
987
988/**
989 * @opcode 0x10
990 * @oppfx 0x66
991 * @opcpuid sse2
992 * @opgroup og_sse2_pcksclr_datamove
993 * @opxcpttype 4UA
994 * @optest op1=1 op2=2 -> op1=2
995 * @optest op1=0 op2=-42 -> op1=-42
996 */
997FNIEMOP_DEF(iemOp_movupd_Vpd_Wpd)
998{
999 IEMOP_MNEMONIC2(RM, MOVUPD, movupd, Vpd_WO, Wpd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1000 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1001 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1002 {
1003 /*
1004 * Register, register.
1005 */
1006 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1007 IEM_MC_BEGIN(0, 0);
1008 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1009 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1010 IEM_MC_COPY_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg,
1011 (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1012 IEM_MC_ADVANCE_RIP();
1013 IEM_MC_END();
1014 }
1015 else
1016 {
1017 /*
1018 * Memory, register.
1019 */
1020 IEM_MC_BEGIN(0, 2);
1021 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
1022 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1023
1024 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1025 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1026 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1027 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1028
1029 IEM_MC_FETCH_MEM_U128(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1030 IEM_MC_STORE_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1031
1032 IEM_MC_ADVANCE_RIP();
1033 IEM_MC_END();
1034 }
1035 return VINF_SUCCESS;
1036}
1037
1038
1039/**
1040 * @opcode 0x10
1041 * @oppfx 0xf3
1042 * @opcpuid sse
1043 * @opgroup og_sse_simdfp_datamove
1044 * @opxcpttype 5
1045 * @optest op1=1 op2=2 -> op1=2
1046 * @optest op1=0 op2=-22 -> op1=-22
1047 */
1048FNIEMOP_DEF(iemOp_movss_Vss_Wss)
1049{
1050 IEMOP_MNEMONIC2(RM, MOVSS, movss, VssZx_WO, Wss, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1051 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1052 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1053 {
1054 /*
1055 * Register, register.
1056 */
1057 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1058 IEM_MC_BEGIN(0, 1);
1059 IEM_MC_LOCAL(uint32_t, uSrc);
1060
1061 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1062 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1063 IEM_MC_FETCH_XREG_U32(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1064 IEM_MC_STORE_XREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1065
1066 IEM_MC_ADVANCE_RIP();
1067 IEM_MC_END();
1068 }
1069 else
1070 {
1071 /*
1072 * Memory, register.
1073 */
1074 IEM_MC_BEGIN(0, 2);
1075 IEM_MC_LOCAL(uint32_t, uSrc);
1076 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1077
1078 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1079 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1080 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1081 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1082
1083 IEM_MC_FETCH_MEM_U32(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1084 IEM_MC_STORE_XREG_U32_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1085
1086 IEM_MC_ADVANCE_RIP();
1087 IEM_MC_END();
1088 }
1089 return VINF_SUCCESS;
1090}
1091
1092
1093/**
1094 * @opcode 0x10
1095 * @oppfx 0xf2
1096 * @opcpuid sse2
1097 * @opgroup og_sse2_pcksclr_datamove
1098 * @opxcpttype 5
1099 * @optest op1=1 op2=2 -> op1=2
1100 * @optest op1=0 op2=-42 -> op1=-42
1101 */
1102FNIEMOP_DEF(iemOp_movsd_Vsd_Wsd)
1103{
1104 IEMOP_MNEMONIC2(RM, MOVSD, movsd, VsdZx_WO, Wsd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1105 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1106 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1107 {
1108 /*
1109 * Register, register.
1110 */
1111 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1112 IEM_MC_BEGIN(0, 1);
1113 IEM_MC_LOCAL(uint64_t, uSrc);
1114
1115 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1116 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1117 IEM_MC_FETCH_XREG_U64(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1118 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1119
1120 IEM_MC_ADVANCE_RIP();
1121 IEM_MC_END();
1122 }
1123 else
1124 {
1125 /*
1126 * Memory, register.
1127 */
1128 IEM_MC_BEGIN(0, 2);
1129 IEM_MC_LOCAL(uint64_t, uSrc);
1130 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1131
1132 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1133 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1134 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1135 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1136
1137 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1138 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1139
1140 IEM_MC_ADVANCE_RIP();
1141 IEM_MC_END();
1142 }
1143 return VINF_SUCCESS;
1144}
1145
1146
1147/**
1148 * @opcode 0x11
1149 * @oppfx none
1150 * @opcpuid sse
1151 * @opgroup og_sse_simdfp_datamove
1152 * @opxcpttype 4UA
1153 * @optest op1=1 op2=2 -> op1=2
1154 * @optest op1=0 op2=-42 -> op1=-42
1155 */
1156FNIEMOP_DEF(iemOp_movups_Wps_Vps)
1157{
1158 IEMOP_MNEMONIC2(MR, MOVUPS, movups, Wps_WO, Vps, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1159 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1160 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1161 {
1162 /*
1163 * Register, register.
1164 */
1165 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1166 IEM_MC_BEGIN(0, 0);
1167 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1168 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1169 IEM_MC_COPY_XREG_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB,
1170 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1171 IEM_MC_ADVANCE_RIP();
1172 IEM_MC_END();
1173 }
1174 else
1175 {
1176 /*
1177 * Memory, register.
1178 */
1179 IEM_MC_BEGIN(0, 2);
1180 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
1181 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1182
1183 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1184 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1185 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1186 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1187
1188 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1189 IEM_MC_STORE_MEM_U128(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1190
1191 IEM_MC_ADVANCE_RIP();
1192 IEM_MC_END();
1193 }
1194 return VINF_SUCCESS;
1195}
1196
1197
1198/**
1199 * @opcode 0x11
1200 * @oppfx 0x66
1201 * @opcpuid sse2
1202 * @opgroup og_sse2_pcksclr_datamove
1203 * @opxcpttype 4UA
1204 * @optest op1=1 op2=2 -> op1=2
1205 * @optest op1=0 op2=-42 -> op1=-42
1206 */
1207FNIEMOP_DEF(iemOp_movupd_Wpd_Vpd)
1208{
1209 IEMOP_MNEMONIC2(MR, MOVUPD, movupd, Wpd_WO, Vpd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1210 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1211 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1212 {
1213 /*
1214 * Register, register.
1215 */
1216 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1217 IEM_MC_BEGIN(0, 0);
1218 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1219 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1220 IEM_MC_COPY_XREG_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB,
1221 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1222 IEM_MC_ADVANCE_RIP();
1223 IEM_MC_END();
1224 }
1225 else
1226 {
1227 /*
1228 * Memory, register.
1229 */
1230 IEM_MC_BEGIN(0, 2);
1231 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
1232 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1233
1234 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1235 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1236 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1237 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1238
1239 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1240 IEM_MC_STORE_MEM_U128(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1241
1242 IEM_MC_ADVANCE_RIP();
1243 IEM_MC_END();
1244 }
1245 return VINF_SUCCESS;
1246}
1247
1248
1249/**
1250 * @opcode 0x11
1251 * @oppfx 0xf3
1252 * @opcpuid sse
1253 * @opgroup og_sse_simdfp_datamove
1254 * @opxcpttype 5
1255 * @optest op1=1 op2=2 -> op1=2
1256 * @optest op1=0 op2=-22 -> op1=-22
1257 */
1258FNIEMOP_DEF(iemOp_movss_Wss_Vss)
1259{
1260 IEMOP_MNEMONIC2(MR, MOVSS, movss, Wss_WO, Vss, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1261 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1262 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1263 {
1264 /*
1265 * Register, register.
1266 */
1267 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1268 IEM_MC_BEGIN(0, 1);
1269 IEM_MC_LOCAL(uint32_t, uSrc);
1270
1271 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1272 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1273 IEM_MC_FETCH_XREG_U32(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1274 IEM_MC_STORE_XREG_U32((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, uSrc);
1275
1276 IEM_MC_ADVANCE_RIP();
1277 IEM_MC_END();
1278 }
1279 else
1280 {
1281 /*
1282 * Memory, register.
1283 */
1284 IEM_MC_BEGIN(0, 2);
1285 IEM_MC_LOCAL(uint32_t, uSrc);
1286 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1287
1288 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1289 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1290 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1291 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1292
1293 IEM_MC_FETCH_XREG_U32(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1294 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1295
1296 IEM_MC_ADVANCE_RIP();
1297 IEM_MC_END();
1298 }
1299 return VINF_SUCCESS;
1300}
1301
1302
1303/**
1304 * @opcode 0x11
1305 * @oppfx 0xf2
1306 * @opcpuid sse2
1307 * @opgroup og_sse2_pcksclr_datamove
1308 * @opxcpttype 5
1309 * @optest op1=1 op2=2 -> op1=2
1310 * @optest op1=0 op2=-42 -> op1=-42
1311 */
1312FNIEMOP_DEF(iemOp_movsd_Wsd_Vsd)
1313{
1314 IEMOP_MNEMONIC2(MR, MOVSD, movsd, Wsd_WO, Vsd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1315 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1316 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1317 {
1318 /*
1319 * Register, register.
1320 */
1321 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1322 IEM_MC_BEGIN(0, 1);
1323 IEM_MC_LOCAL(uint64_t, uSrc);
1324
1325 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1326 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1327 IEM_MC_FETCH_XREG_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1328 IEM_MC_STORE_XREG_U64((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, uSrc);
1329
1330 IEM_MC_ADVANCE_RIP();
1331 IEM_MC_END();
1332 }
1333 else
1334 {
1335 /*
1336 * Memory, register.
1337 */
1338 IEM_MC_BEGIN(0, 2);
1339 IEM_MC_LOCAL(uint64_t, uSrc);
1340 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1341
1342 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1343 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1344 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1345 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1346
1347 IEM_MC_FETCH_XREG_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1348 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1349
1350 IEM_MC_ADVANCE_RIP();
1351 IEM_MC_END();
1352 }
1353 return VINF_SUCCESS;
1354}
1355
1356
1357FNIEMOP_DEF(iemOp_movlps_Vq_Mq__movhlps)
1358{
1359 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1360 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1361 {
1362 /**
1363 * @opcode 0x12
1364 * @opcodesub 11 mr/reg
1365 * @oppfx none
1366 * @opcpuid sse
1367 * @opgroup og_sse_simdfp_datamove
1368 * @opxcpttype 5
1369 * @optest op1=1 op2=2 -> op1=2
1370 * @optest op1=0 op2=-42 -> op1=-42
1371 */
1372 IEMOP_MNEMONIC2(RM_REG, MOVHLPS, movhlps, Vq_WO, UqHi, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1373
1374 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1375 IEM_MC_BEGIN(0, 1);
1376 IEM_MC_LOCAL(uint64_t, uSrc);
1377
1378 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1379 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1380 IEM_MC_FETCH_XREG_HI_U64(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1381 IEM_MC_STORE_XREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1382
1383 IEM_MC_ADVANCE_RIP();
1384 IEM_MC_END();
1385 }
1386 else
1387 {
1388 /**
1389 * @opdone
1390 * @opcode 0x12
1391 * @opcodesub !11 mr/reg
1392 * @oppfx none
1393 * @opcpuid sse
1394 * @opgroup og_sse_simdfp_datamove
1395 * @opxcpttype 5
1396 * @optest op1=1 op2=2 -> op1=2
1397 * @optest op1=0 op2=-42 -> op1=-42
1398 * @opfunction iemOp_movlps_Vq_Mq__vmovhlps
1399 */
1400 IEMOP_MNEMONIC2(RM_MEM, MOVLPS, movlps, Vq_WO, Mq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1401
1402 IEM_MC_BEGIN(0, 2);
1403 IEM_MC_LOCAL(uint64_t, uSrc);
1404 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1405
1406 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1407 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1408 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1409 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1410
1411 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1412 IEM_MC_STORE_XREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1413
1414 IEM_MC_ADVANCE_RIP();
1415 IEM_MC_END();
1416 }
1417 return VINF_SUCCESS;
1418}
1419
1420
1421/**
1422 * @opcode 0x12
1423 * @opcodesub !11 mr/reg
1424 * @oppfx 0x66
1425 * @opcpuid sse2
1426 * @opgroup og_sse2_pcksclr_datamove
1427 * @opxcpttype 5
1428 * @optest op1=1 op2=2 -> op1=2
1429 * @optest op1=0 op2=-42 -> op1=-42
1430 */
1431FNIEMOP_DEF(iemOp_movlpd_Vq_Mq)
1432{
1433 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1434 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
1435 {
1436 IEMOP_MNEMONIC2(RM_MEM, MOVLPD, movlpd, Vq_WO, Mq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1437
1438 IEM_MC_BEGIN(0, 2);
1439 IEM_MC_LOCAL(uint64_t, uSrc);
1440 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1441
1442 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1443 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1444 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1445 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1446
1447 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1448 IEM_MC_STORE_XREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1449
1450 IEM_MC_ADVANCE_RIP();
1451 IEM_MC_END();
1452 return VINF_SUCCESS;
1453 }
1454
1455 /**
1456 * @opdone
1457 * @opmnemonic ud660f12m3
1458 * @opcode 0x12
1459 * @opcodesub 11 mr/reg
1460 * @oppfx 0x66
1461 * @opunused immediate
1462 * @opcpuid sse
1463 * @optest ->
1464 */
1465 return IEMOP_RAISE_INVALID_OPCODE();
1466}
1467
1468
1469/**
1470 * @opcode 0x12
1471 * @oppfx 0xf3
1472 * @opcpuid sse3
1473 * @opgroup og_sse3_pcksclr_datamove
1474 * @opxcpttype 4
1475 * @optest op1=-1 op2=0xdddddddd00000002eeeeeeee00000001 ->
1476 * op1=0x00000002000000020000000100000001
1477 */
1478FNIEMOP_DEF(iemOp_movsldup_Vdq_Wdq)
1479{
1480 IEMOP_MNEMONIC2(RM, MOVSLDUP, movsldup, Vdq_WO, Wdq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1481 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1482 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1483 {
1484 /*
1485 * Register, register.
1486 */
1487 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1488 IEM_MC_BEGIN(2, 0);
1489 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1490 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
1491
1492 IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT();
1493 IEM_MC_PREPARE_SSE_USAGE();
1494
1495 IEM_MC_REF_XREG_U128_CONST(puSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1496 IEM_MC_REF_XREG_U128(puDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1497 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_movsldup, puDst, puSrc);
1498
1499 IEM_MC_ADVANCE_RIP();
1500 IEM_MC_END();
1501 }
1502 else
1503 {
1504 /*
1505 * Register, memory.
1506 */
1507 IEM_MC_BEGIN(2, 2);
1508 IEM_MC_LOCAL(RTUINT128U, uSrc);
1509 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1510 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1511 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
1512
1513 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1514 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1515 IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT();
1516 IEM_MC_PREPARE_SSE_USAGE();
1517
1518 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1519 IEM_MC_REF_XREG_U128(puDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1520 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_movsldup, puDst, puSrc);
1521
1522 IEM_MC_ADVANCE_RIP();
1523 IEM_MC_END();
1524 }
1525 return VINF_SUCCESS;
1526}
1527
1528
1529/**
1530 * @opcode 0x12
1531 * @oppfx 0xf2
1532 * @opcpuid sse3
1533 * @opgroup og_sse3_pcksclr_datamove
1534 * @opxcpttype 5
1535 * @optest op1=-1 op2=0xddddddddeeeeeeee2222222211111111 ->
1536 * op1=0x22222222111111112222222211111111
1537 */
1538FNIEMOP_DEF(iemOp_movddup_Vdq_Wdq)
1539{
1540 IEMOP_MNEMONIC2(RM, MOVDDUP, movddup, Vdq_WO, Wdq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1541 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1542 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1543 {
1544 /*
1545 * Register, register.
1546 */
1547 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1548 IEM_MC_BEGIN(2, 0);
1549 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1550 IEM_MC_ARG(uint64_t, uSrc, 1);
1551
1552 IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT();
1553 IEM_MC_PREPARE_SSE_USAGE();
1554
1555 IEM_MC_FETCH_XREG_U64(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1556 IEM_MC_REF_XREG_U128(puDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1557 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_movddup, puDst, uSrc);
1558
1559 IEM_MC_ADVANCE_RIP();
1560 IEM_MC_END();
1561 }
1562 else
1563 {
1564 /*
1565 * Register, memory.
1566 */
1567 IEM_MC_BEGIN(2, 2);
1568 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1569 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1570 IEM_MC_ARG(uint64_t, uSrc, 1);
1571
1572 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1573 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1574 IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT();
1575 IEM_MC_PREPARE_SSE_USAGE();
1576
1577 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1578 IEM_MC_REF_XREG_U128(puDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1579 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_movddup, puDst, uSrc);
1580
1581 IEM_MC_ADVANCE_RIP();
1582 IEM_MC_END();
1583 }
1584 return VINF_SUCCESS;
1585}
1586
1587
1588/**
1589 * @opcode 0x13
1590 * @opcodesub !11 mr/reg
1591 * @oppfx none
1592 * @opcpuid sse
1593 * @opgroup og_sse_simdfp_datamove
1594 * @opxcpttype 5
1595 * @optest op1=1 op2=2 -> op1=2
1596 * @optest op1=0 op2=-42 -> op1=-42
1597 */
1598FNIEMOP_DEF(iemOp_movlps_Mq_Vq)
1599{
1600 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1601 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
1602 {
1603 IEMOP_MNEMONIC2(MR_MEM, MOVLPS, movlps, Mq_WO, Vq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1604
1605 IEM_MC_BEGIN(0, 2);
1606 IEM_MC_LOCAL(uint64_t, uSrc);
1607 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1608
1609 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1610 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1611 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1612 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1613
1614 IEM_MC_FETCH_XREG_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1615 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1616
1617 IEM_MC_ADVANCE_RIP();
1618 IEM_MC_END();
1619 return VINF_SUCCESS;
1620 }
1621
1622 /**
1623 * @opdone
1624 * @opmnemonic ud0f13m3
1625 * @opcode 0x13
1626 * @opcodesub 11 mr/reg
1627 * @oppfx none
1628 * @opunused immediate
1629 * @opcpuid sse
1630 * @optest ->
1631 */
1632 return IEMOP_RAISE_INVALID_OPCODE();
1633}
1634
1635
1636/**
1637 * @opcode 0x13
1638 * @opcodesub !11 mr/reg
1639 * @oppfx 0x66
1640 * @opcpuid sse2
1641 * @opgroup og_sse2_pcksclr_datamove
1642 * @opxcpttype 5
1643 * @optest op1=1 op2=2 -> op1=2
1644 * @optest op1=0 op2=-42 -> op1=-42
1645 */
1646FNIEMOP_DEF(iemOp_movlpd_Mq_Vq)
1647{
1648 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1649 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
1650 {
1651 IEMOP_MNEMONIC2(MR_MEM, MOVLPD, movlpd, Mq_WO, Vq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1652 IEM_MC_BEGIN(0, 2);
1653 IEM_MC_LOCAL(uint64_t, uSrc);
1654 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1655
1656 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1657 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1658 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1659 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1660
1661 IEM_MC_FETCH_XREG_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1662 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1663
1664 IEM_MC_ADVANCE_RIP();
1665 IEM_MC_END();
1666 return VINF_SUCCESS;
1667 }
1668
1669 /**
1670 * @opdone
1671 * @opmnemonic ud660f13m3
1672 * @opcode 0x13
1673 * @opcodesub 11 mr/reg
1674 * @oppfx 0x66
1675 * @opunused immediate
1676 * @opcpuid sse
1677 * @optest ->
1678 */
1679 return IEMOP_RAISE_INVALID_OPCODE();
1680}
1681
1682
1683/**
1684 * @opmnemonic udf30f13
1685 * @opcode 0x13
1686 * @oppfx 0xf3
1687 * @opunused intel-modrm
1688 * @opcpuid sse
1689 * @optest ->
1690 * @opdone
1691 */
1692
1693/**
1694 * @opmnemonic udf20f13
1695 * @opcode 0x13
1696 * @oppfx 0xf2
1697 * @opunused intel-modrm
1698 * @opcpuid sse
1699 * @optest ->
1700 * @opdone
1701 */
1702
1703/** Opcode 0x0f 0x14 - unpcklps Vx, Wx*/
1704FNIEMOP_STUB(iemOp_unpcklps_Vx_Wx);
1705/** Opcode 0x66 0x0f 0x14 - unpcklpd Vx, Wx */
1706FNIEMOP_STUB(iemOp_unpcklpd_Vx_Wx);
1707
1708/**
1709 * @opdone
1710 * @opmnemonic udf30f14
1711 * @opcode 0x14
1712 * @oppfx 0xf3
1713 * @opunused intel-modrm
1714 * @opcpuid sse
1715 * @optest ->
1716 * @opdone
1717 */
1718
1719/**
1720 * @opmnemonic udf20f14
1721 * @opcode 0x14
1722 * @oppfx 0xf2
1723 * @opunused intel-modrm
1724 * @opcpuid sse
1725 * @optest ->
1726 * @opdone
1727 */
1728
1729/** Opcode 0x0f 0x15 - unpckhps Vx, Wx */
1730FNIEMOP_STUB(iemOp_unpckhps_Vx_Wx);
1731/** Opcode 0x66 0x0f 0x15 - unpckhpd Vx, Wx */
1732FNIEMOP_STUB(iemOp_unpckhpd_Vx_Wx);
1733/* Opcode 0xf3 0x0f 0x15 - invalid */
1734/* Opcode 0xf2 0x0f 0x15 - invalid */
1735
1736/**
1737 * @opdone
1738 * @opmnemonic udf30f15
1739 * @opcode 0x15
1740 * @oppfx 0xf3
1741 * @opunused intel-modrm
1742 * @opcpuid sse
1743 * @optest ->
1744 * @opdone
1745 */
1746
1747/**
1748 * @opmnemonic udf20f15
1749 * @opcode 0x15
1750 * @oppfx 0xf2
1751 * @opunused intel-modrm
1752 * @opcpuid sse
1753 * @optest ->
1754 * @opdone
1755 */
1756
1757FNIEMOP_DEF(iemOp_movhps_Vdq_Mq__movlhps_Vdq_Uq)
1758{
1759 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1760 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1761 {
1762 /**
1763 * @opcode 0x16
1764 * @opcodesub 11 mr/reg
1765 * @oppfx none
1766 * @opcpuid sse
1767 * @opgroup og_sse_simdfp_datamove
1768 * @opxcpttype 5
1769 * @optest op1=1 op2=2 -> op1=2
1770 * @optest op1=0 op2=-42 -> op1=-42
1771 */
1772 IEMOP_MNEMONIC2(RM_REG, MOVLHPS, movlhps, VqHi_WO, Uq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1773
1774 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1775 IEM_MC_BEGIN(0, 1);
1776 IEM_MC_LOCAL(uint64_t, uSrc);
1777
1778 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1779 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1780 IEM_MC_FETCH_XREG_U64(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1781 IEM_MC_STORE_XREG_HI_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1782
1783 IEM_MC_ADVANCE_RIP();
1784 IEM_MC_END();
1785 }
1786 else
1787 {
1788 /**
1789 * @opdone
1790 * @opcode 0x16
1791 * @opcodesub !11 mr/reg
1792 * @oppfx none
1793 * @opcpuid sse
1794 * @opgroup og_sse_simdfp_datamove
1795 * @opxcpttype 5
1796 * @optest op1=1 op2=2 -> op1=2
1797 * @optest op1=0 op2=-42 -> op1=-42
1798 * @opfunction iemOp_movhps_Vdq_Mq__movlhps_Vdq_Uq
1799 */
1800 IEMOP_MNEMONIC2(RM_MEM, MOVHPS, movhps, VqHi_WO, Mq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1801
1802 IEM_MC_BEGIN(0, 2);
1803 IEM_MC_LOCAL(uint64_t, uSrc);
1804 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1805
1806 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1807 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1808 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1809 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1810
1811 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1812 IEM_MC_STORE_XREG_HI_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1813
1814 IEM_MC_ADVANCE_RIP();
1815 IEM_MC_END();
1816 }
1817 return VINF_SUCCESS;
1818}
1819
1820
1821/**
1822 * @opcode 0x16
1823 * @opcodesub !11 mr/reg
1824 * @oppfx 0x66
1825 * @opcpuid sse2
1826 * @opgroup og_sse2_pcksclr_datamove
1827 * @opxcpttype 5
1828 * @optest op1=1 op2=2 -> op1=2
1829 * @optest op1=0 op2=-42 -> op1=-42
1830 */
1831FNIEMOP_DEF(iemOp_movhpd_Vdq_Mq)
1832{
1833 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1834 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
1835 {
1836 IEMOP_MNEMONIC2(RM_MEM, MOVHPD, movhpd, VqHi_WO, Mq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1837 IEM_MC_BEGIN(0, 2);
1838 IEM_MC_LOCAL(uint64_t, uSrc);
1839 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1840
1841 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1842 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1843 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
1844 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
1845
1846 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1847 IEM_MC_STORE_XREG_HI_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
1848
1849 IEM_MC_ADVANCE_RIP();
1850 IEM_MC_END();
1851 return VINF_SUCCESS;
1852 }
1853
1854 /**
1855 * @opdone
1856 * @opmnemonic ud660f16m3
1857 * @opcode 0x16
1858 * @opcodesub 11 mr/reg
1859 * @oppfx 0x66
1860 * @opunused immediate
1861 * @opcpuid sse
1862 * @optest ->
1863 */
1864 return IEMOP_RAISE_INVALID_OPCODE();
1865}
1866
1867
1868/**
1869 * @opcode 0x16
1870 * @oppfx 0xf3
1871 * @opcpuid sse3
1872 * @opgroup og_sse3_pcksclr_datamove
1873 * @opxcpttype 4
1874 * @optest op1=-1 op2=0x00000002dddddddd00000001eeeeeeee ->
1875 * op1=0x00000002000000020000000100000001
1876 */
1877FNIEMOP_DEF(iemOp_movshdup_Vdq_Wdq)
1878{
1879 IEMOP_MNEMONIC2(RM, MOVSHDUP, movshdup, Vdq_WO, Wdq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1880 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1881 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
1882 {
1883 /*
1884 * Register, register.
1885 */
1886 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1887 IEM_MC_BEGIN(2, 0);
1888 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1889 IEM_MC_ARG(PCRTUINT128U, puSrc, 1);
1890
1891 IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT();
1892 IEM_MC_PREPARE_SSE_USAGE();
1893
1894 IEM_MC_REF_XREG_U128_CONST(puSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
1895 IEM_MC_REF_XREG_U128(puDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1896 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_movshdup, puDst, puSrc);
1897
1898 IEM_MC_ADVANCE_RIP();
1899 IEM_MC_END();
1900 }
1901 else
1902 {
1903 /*
1904 * Register, memory.
1905 */
1906 IEM_MC_BEGIN(2, 2);
1907 IEM_MC_LOCAL(RTUINT128U, uSrc);
1908 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1909 IEM_MC_ARG(PRTUINT128U, puDst, 0);
1910 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, puSrc, uSrc, 1);
1911
1912 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1913 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1914 IEM_MC_MAYBE_RAISE_SSE3_RELATED_XCPT();
1915 IEM_MC_PREPARE_SSE_USAGE();
1916
1917 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
1918 IEM_MC_REF_XREG_U128(puDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1919 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_movshdup, puDst, puSrc);
1920
1921 IEM_MC_ADVANCE_RIP();
1922 IEM_MC_END();
1923 }
1924 return VINF_SUCCESS;
1925}
1926
1927/**
1928 * @opdone
1929 * @opmnemonic udf30f16
1930 * @opcode 0x16
1931 * @oppfx 0xf2
1932 * @opunused intel-modrm
1933 * @opcpuid sse
1934 * @optest ->
1935 * @opdone
1936 */
1937
1938
1939/**
1940 * @opcode 0x17
1941 * @opcodesub !11 mr/reg
1942 * @oppfx none
1943 * @opcpuid sse
1944 * @opgroup og_sse_simdfp_datamove
1945 * @opxcpttype 5
1946 * @optest op1=1 op2=2 -> op1=2
1947 * @optest op1=0 op2=-42 -> op1=-42
1948 */
1949FNIEMOP_DEF(iemOp_movhps_Mq_Vq)
1950{
1951 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
1952 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
1953 {
1954 IEMOP_MNEMONIC2(MR_MEM, MOVHPS, movhps, Mq_WO, VqHi, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
1955
1956 IEM_MC_BEGIN(0, 2);
1957 IEM_MC_LOCAL(uint64_t, uSrc);
1958 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
1959
1960 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
1961 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
1962 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
1963 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
1964
1965 IEM_MC_FETCH_XREG_HI_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
1966 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
1967
1968 IEM_MC_ADVANCE_RIP();
1969 IEM_MC_END();
1970 return VINF_SUCCESS;
1971 }
1972
1973 /**
1974 * @opdone
1975 * @opmnemonic ud0f17m3
1976 * @opcode 0x17
1977 * @opcodesub 11 mr/reg
1978 * @oppfx none
1979 * @opunused immediate
1980 * @opcpuid sse
1981 * @optest ->
1982 */
1983 return IEMOP_RAISE_INVALID_OPCODE();
1984}
1985
1986
1987/**
1988 * @opcode 0x17
1989 * @opcodesub !11 mr/reg
1990 * @oppfx 0x66
1991 * @opcpuid sse2
1992 * @opgroup og_sse2_pcksclr_datamove
1993 * @opxcpttype 5
1994 * @optest op1=1 op2=2 -> op1=2
1995 * @optest op1=0 op2=-42 -> op1=-42
1996 */
1997FNIEMOP_DEF(iemOp_movhpd_Mq_Vq)
1998{
1999 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2000 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
2001 {
2002 IEMOP_MNEMONIC2(MR_MEM, MOVHPD, movhpd, Mq_WO, VqHi, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2003
2004 IEM_MC_BEGIN(0, 2);
2005 IEM_MC_LOCAL(uint64_t, uSrc);
2006 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2007
2008 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2009 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2010 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2011 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2012
2013 IEM_MC_FETCH_XREG_HI_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2014 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2015
2016 IEM_MC_ADVANCE_RIP();
2017 IEM_MC_END();
2018 return VINF_SUCCESS;
2019 }
2020
2021 /**
2022 * @opdone
2023 * @opmnemonic ud660f17m3
2024 * @opcode 0x17
2025 * @opcodesub 11 mr/reg
2026 * @oppfx 0x66
2027 * @opunused immediate
2028 * @opcpuid sse
2029 * @optest ->
2030 */
2031 return IEMOP_RAISE_INVALID_OPCODE();
2032}
2033
2034
2035/**
2036 * @opdone
2037 * @opmnemonic udf30f17
2038 * @opcode 0x17
2039 * @oppfx 0xf3
2040 * @opunused intel-modrm
2041 * @opcpuid sse
2042 * @optest ->
2043 * @opdone
2044 */
2045
2046/**
2047 * @opmnemonic udf20f17
2048 * @opcode 0x17
2049 * @oppfx 0xf2
2050 * @opunused intel-modrm
2051 * @opcpuid sse
2052 * @optest ->
2053 * @opdone
2054 */
2055
2056
2057/** Opcode 0x0f 0x18. */
2058FNIEMOP_DEF(iemOp_prefetch_Grp16)
2059{
2060 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2061 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
2062 {
2063 switch ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK)
2064 {
2065 case 4: /* Aliased to /0 for the time being according to AMD. */
2066 case 5: /* Aliased to /0 for the time being according to AMD. */
2067 case 6: /* Aliased to /0 for the time being according to AMD. */
2068 case 7: /* Aliased to /0 for the time being according to AMD. */
2069 case 0: IEMOP_MNEMONIC(prefetchNTA, "prefetchNTA m8"); break;
2070 case 1: IEMOP_MNEMONIC(prefetchT0, "prefetchT0 m8"); break;
2071 case 2: IEMOP_MNEMONIC(prefetchT1, "prefetchT1 m8"); break;
2072 case 3: IEMOP_MNEMONIC(prefetchT2, "prefetchT2 m8"); break;
2073 IEM_NOT_REACHED_DEFAULT_CASE_RET();
2074 }
2075
2076 IEM_MC_BEGIN(0, 1);
2077 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2078 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2079 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2080 /* Currently a NOP. */
2081 NOREF(GCPtrEffSrc);
2082 IEM_MC_ADVANCE_RIP();
2083 IEM_MC_END();
2084 return VINF_SUCCESS;
2085 }
2086
2087 return IEMOP_RAISE_INVALID_OPCODE();
2088}
2089
2090
2091/** Opcode 0x0f 0x19..0x1f. */
2092FNIEMOP_DEF(iemOp_nop_Ev)
2093{
2094 IEMOP_MNEMONIC(nop_Ev, "nop Ev");
2095 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2096 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
2097 {
2098 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2099 IEM_MC_BEGIN(0, 0);
2100 IEM_MC_ADVANCE_RIP();
2101 IEM_MC_END();
2102 }
2103 else
2104 {
2105 IEM_MC_BEGIN(0, 1);
2106 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2107 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2108 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2109 /* Currently a NOP. */
2110 NOREF(GCPtrEffSrc);
2111 IEM_MC_ADVANCE_RIP();
2112 IEM_MC_END();
2113 }
2114 return VINF_SUCCESS;
2115}
2116
2117
2118/** Opcode 0x0f 0x20. */
2119FNIEMOP_DEF(iemOp_mov_Rd_Cd)
2120{
2121 /* mod is ignored, as is operand size overrides. */
2122 IEMOP_MNEMONIC(mov_Rd_Cd, "mov Rd,Cd");
2123 IEMOP_HLP_MIN_386();
2124 if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
2125 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT;
2126 else
2127 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_32BIT;
2128
2129 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2130 uint8_t iCrReg = ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg;
2131 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK)
2132 {
2133 /* The lock prefix can be used to encode CR8 accesses on some CPUs. */
2134 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fMovCr8In32Bit)
2135 return IEMOP_RAISE_INVALID_OPCODE(); /* #UD takes precedence over #GP(), see test. */
2136 iCrReg |= 8;
2137 }
2138 switch (iCrReg)
2139 {
2140 case 0: case 2: case 3: case 4: case 8:
2141 break;
2142 default:
2143 return IEMOP_RAISE_INVALID_OPCODE();
2144 }
2145 IEMOP_HLP_DONE_DECODING();
2146
2147 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_mov_Rd_Cd, (X86_MODRM_RM_MASK & bRm) | pVCpu->iem.s.uRexB, iCrReg);
2148}
2149
2150
2151/** Opcode 0x0f 0x21. */
2152FNIEMOP_DEF(iemOp_mov_Rd_Dd)
2153{
2154 IEMOP_MNEMONIC(mov_Rd_Dd, "mov Rd,Dd");
2155 IEMOP_HLP_MIN_386();
2156 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2157 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2158 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX_R)
2159 return IEMOP_RAISE_INVALID_OPCODE();
2160 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_mov_Rd_Dd,
2161 (X86_MODRM_RM_MASK & bRm) | pVCpu->iem.s.uRexB,
2162 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK));
2163}
2164
2165
2166/** Opcode 0x0f 0x22. */
2167FNIEMOP_DEF(iemOp_mov_Cd_Rd)
2168{
2169 /* mod is ignored, as is operand size overrides. */
2170 IEMOP_MNEMONIC(mov_Cd_Rd, "mov Cd,Rd");
2171 IEMOP_HLP_MIN_386();
2172 if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
2173 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_64BIT;
2174 else
2175 pVCpu->iem.s.enmEffOpSize = pVCpu->iem.s.enmDefOpSize = IEMMODE_32BIT;
2176
2177 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2178 uint8_t iCrReg = ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg;
2179 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK)
2180 {
2181 /* The lock prefix can be used to encode CR8 accesses on some CPUs. */
2182 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fMovCr8In32Bit)
2183 return IEMOP_RAISE_INVALID_OPCODE(); /* #UD takes precedence over #GP(), see test. */
2184 iCrReg |= 8;
2185 }
2186 switch (iCrReg)
2187 {
2188 case 0: case 2: case 3: case 4: case 8:
2189 break;
2190 default:
2191 return IEMOP_RAISE_INVALID_OPCODE();
2192 }
2193 IEMOP_HLP_DONE_DECODING();
2194
2195 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_mov_Cd_Rd, iCrReg, (X86_MODRM_RM_MASK & bRm) | pVCpu->iem.s.uRexB);
2196}
2197
2198
2199/** Opcode 0x0f 0x23. */
2200FNIEMOP_DEF(iemOp_mov_Dd_Rd)
2201{
2202 IEMOP_MNEMONIC(mov_Dd_Rd, "mov Dd,Rd");
2203 IEMOP_HLP_MIN_386();
2204 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2205 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2206 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_REX_R)
2207 return IEMOP_RAISE_INVALID_OPCODE();
2208 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_mov_Dd_Rd,
2209 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK),
2210 (X86_MODRM_RM_MASK & bRm) | pVCpu->iem.s.uRexB);
2211}
2212
2213
2214/** Opcode 0x0f 0x24. */
2215FNIEMOP_DEF(iemOp_mov_Rd_Td)
2216{
2217 IEMOP_MNEMONIC(mov_Rd_Td, "mov Rd,Td");
2218 /** @todo works on 386 and 486. */
2219 /* The RM byte is not considered, see testcase. */
2220 return IEMOP_RAISE_INVALID_OPCODE();
2221}
2222
2223
2224/** Opcode 0x0f 0x26. */
2225FNIEMOP_DEF(iemOp_mov_Td_Rd)
2226{
2227 IEMOP_MNEMONIC(mov_Td_Rd, "mov Td,Rd");
2228 /** @todo works on 386 and 486. */
2229 /* The RM byte is not considered, see testcase. */
2230 return IEMOP_RAISE_INVALID_OPCODE();
2231}
2232
2233
2234/**
2235 * @opcode 0x28
2236 * @oppfx none
2237 * @opcpuid sse
2238 * @opgroup og_sse_simdfp_datamove
2239 * @opxcpttype 1
2240 * @optest op1=1 op2=2 -> op1=2
2241 * @optest op1=0 op2=-42 -> op1=-42
2242 */
2243FNIEMOP_DEF(iemOp_movaps_Vps_Wps)
2244{
2245 IEMOP_MNEMONIC2(RM, MOVAPS, movaps, Vps_WO, Wps, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2246 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2247 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
2248 {
2249 /*
2250 * Register, register.
2251 */
2252 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2253 IEM_MC_BEGIN(0, 0);
2254 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2255 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2256 IEM_MC_COPY_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg,
2257 (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
2258 IEM_MC_ADVANCE_RIP();
2259 IEM_MC_END();
2260 }
2261 else
2262 {
2263 /*
2264 * Register, memory.
2265 */
2266 IEM_MC_BEGIN(0, 2);
2267 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2268 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2269
2270 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2271 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2272 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2273 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2274
2275 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2276 IEM_MC_STORE_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
2277
2278 IEM_MC_ADVANCE_RIP();
2279 IEM_MC_END();
2280 }
2281 return VINF_SUCCESS;
2282}
2283
2284/**
2285 * @opcode 0x28
2286 * @oppfx 66
2287 * @opcpuid sse2
2288 * @opgroup og_sse2_pcksclr_datamove
2289 * @opxcpttype 1
2290 * @optest op1=1 op2=2 -> op1=2
2291 * @optest op1=0 op2=-42 -> op1=-42
2292 */
2293FNIEMOP_DEF(iemOp_movapd_Vpd_Wpd)
2294{
2295 IEMOP_MNEMONIC2(RM, MOVAPD, movapd, Vpd_WO, Wpd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2296 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2297 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
2298 {
2299 /*
2300 * Register, register.
2301 */
2302 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2303 IEM_MC_BEGIN(0, 0);
2304 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
2305 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2306 IEM_MC_COPY_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg,
2307 (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
2308 IEM_MC_ADVANCE_RIP();
2309 IEM_MC_END();
2310 }
2311 else
2312 {
2313 /*
2314 * Register, memory.
2315 */
2316 IEM_MC_BEGIN(0, 2);
2317 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2318 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2319
2320 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2321 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2322 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
2323 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2324
2325 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
2326 IEM_MC_STORE_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
2327
2328 IEM_MC_ADVANCE_RIP();
2329 IEM_MC_END();
2330 }
2331 return VINF_SUCCESS;
2332}
2333
2334/* Opcode 0xf3 0x0f 0x28 - invalid */
2335/* Opcode 0xf2 0x0f 0x28 - invalid */
2336
2337/**
2338 * @opcode 0x29
2339 * @oppfx none
2340 * @opcpuid sse
2341 * @opgroup og_sse_simdfp_datamove
2342 * @opxcpttype 1
2343 * @optest op1=1 op2=2 -> op1=2
2344 * @optest op1=0 op2=-42 -> op1=-42
2345 */
2346FNIEMOP_DEF(iemOp_movaps_Wps_Vps)
2347{
2348 IEMOP_MNEMONIC2(MR, MOVAPS, movaps, Wps_WO, Vps, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2349 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2350 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
2351 {
2352 /*
2353 * Register, register.
2354 */
2355 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2356 IEM_MC_BEGIN(0, 0);
2357 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2358 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2359 IEM_MC_COPY_XREG_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB,
2360 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2361 IEM_MC_ADVANCE_RIP();
2362 IEM_MC_END();
2363 }
2364 else
2365 {
2366 /*
2367 * Memory, register.
2368 */
2369 IEM_MC_BEGIN(0, 2);
2370 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2371 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2372
2373 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2374 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2375 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2376 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2377
2378 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2379 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2380
2381 IEM_MC_ADVANCE_RIP();
2382 IEM_MC_END();
2383 }
2384 return VINF_SUCCESS;
2385}
2386
2387/**
2388 * @opcode 0x29
2389 * @oppfx 66
2390 * @opcpuid sse2
2391 * @opgroup og_sse2_pcksclr_datamove
2392 * @opxcpttype 1
2393 * @optest op1=1 op2=2 -> op1=2
2394 * @optest op1=0 op2=-42 -> op1=-42
2395 */
2396FNIEMOP_DEF(iemOp_movapd_Wpd_Vpd)
2397{
2398 IEMOP_MNEMONIC2(MR, MOVAPD, movapd, Wpd_WO, Vpd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2399 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2400 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
2401 {
2402 /*
2403 * Register, register.
2404 */
2405 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2406 IEM_MC_BEGIN(0, 0);
2407 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
2408 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2409 IEM_MC_COPY_XREG_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB,
2410 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2411 IEM_MC_ADVANCE_RIP();
2412 IEM_MC_END();
2413 }
2414 else
2415 {
2416 /*
2417 * Memory, register.
2418 */
2419 IEM_MC_BEGIN(0, 2);
2420 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2421 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2422
2423 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2424 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2425 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
2426 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
2427
2428 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2429 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2430
2431 IEM_MC_ADVANCE_RIP();
2432 IEM_MC_END();
2433 }
2434 return VINF_SUCCESS;
2435}
2436
2437/* Opcode 0xf3 0x0f 0x29 - invalid */
2438/* Opcode 0xf2 0x0f 0x29 - invalid */
2439
2440
2441/** Opcode 0x0f 0x2a - cvtpi2ps Vps, Qpi */
2442FNIEMOP_STUB(iemOp_cvtpi2ps_Vps_Qpi); //NEXT
2443/** Opcode 0x66 0x0f 0x2a - cvtpi2pd Vpd, Qpi */
2444FNIEMOP_STUB(iemOp_cvtpi2pd_Vpd_Qpi); //NEXT
2445/** Opcode 0xf3 0x0f 0x2a - vcvtsi2ss Vss, Hss, Ey */
2446FNIEMOP_STUB(iemOp_cvtsi2ss_Vss_Ey); //NEXT
2447/** Opcode 0xf2 0x0f 0x2a - vcvtsi2sd Vsd, Hsd, Ey */
2448FNIEMOP_STUB(iemOp_cvtsi2sd_Vsd_Ey); //NEXT
2449
2450
2451/**
2452 * @opcode 0x2b
2453 * @opcodesub !11 mr/reg
2454 * @oppfx none
2455 * @opcpuid sse
2456 * @opgroup og_sse1_cachect
2457 * @opxcpttype 1
2458 * @optest op1=1 op2=2 -> op1=2
2459 * @optest op1=0 op2=-42 -> op1=-42
2460 */
2461FNIEMOP_DEF(iemOp_movntps_Mps_Vps)
2462{
2463 IEMOP_MNEMONIC2(MR_MEM, MOVNTPS, movntps, Mps_WO, Vps, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2464 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2465 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
2466 {
2467 /*
2468 * memory, register.
2469 */
2470 IEM_MC_BEGIN(0, 2);
2471 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2472 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2473
2474 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2475 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2476 IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
2477 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2478
2479 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2480 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2481
2482 IEM_MC_ADVANCE_RIP();
2483 IEM_MC_END();
2484 }
2485 /* The register, register encoding is invalid. */
2486 else
2487 return IEMOP_RAISE_INVALID_OPCODE();
2488 return VINF_SUCCESS;
2489}
2490
2491/**
2492 * @opcode 0x2b
2493 * @opcodesub !11 mr/reg
2494 * @oppfx 0x66
2495 * @opcpuid sse2
2496 * @opgroup og_sse2_cachect
2497 * @opxcpttype 1
2498 * @optest op1=1 op2=2 -> op1=2
2499 * @optest op1=0 op2=-42 -> op1=-42
2500 */
2501FNIEMOP_DEF(iemOp_movntpd_Mpd_Vpd)
2502{
2503 IEMOP_MNEMONIC2(MR_MEM, MOVNTPD, movntpd, Mpd_WO, Vpd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
2504 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
2505 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
2506 {
2507 /*
2508 * memory, register.
2509 */
2510 IEM_MC_BEGIN(0, 2);
2511 IEM_MC_LOCAL(RTUINT128U, uSrc); /** @todo optimize this one day... */
2512 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
2513
2514 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
2515 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2516 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
2517 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
2518
2519 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
2520 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
2521
2522 IEM_MC_ADVANCE_RIP();
2523 IEM_MC_END();
2524 }
2525 /* The register, register encoding is invalid. */
2526 else
2527 return IEMOP_RAISE_INVALID_OPCODE();
2528 return VINF_SUCCESS;
2529}
2530/* Opcode 0xf3 0x0f 0x2b - invalid */
2531/* Opcode 0xf2 0x0f 0x2b - invalid */
2532
2533
2534/** Opcode 0x0f 0x2c - cvttps2pi Ppi, Wps */
2535FNIEMOP_STUB(iemOp_cvttps2pi_Ppi_Wps);
2536/** Opcode 0x66 0x0f 0x2c - cvttpd2pi Ppi, Wpd */
2537FNIEMOP_STUB(iemOp_cvttpd2pi_Ppi_Wpd);
2538/** Opcode 0xf3 0x0f 0x2c - cvttss2si Gy, Wss */
2539FNIEMOP_STUB(iemOp_cvttss2si_Gy_Wss);
2540/** Opcode 0xf2 0x0f 0x2c - cvttsd2si Gy, Wsd */
2541FNIEMOP_STUB(iemOp_cvttsd2si_Gy_Wsd);
2542
2543/** Opcode 0x0f 0x2d - cvtps2pi Ppi, Wps */
2544FNIEMOP_STUB(iemOp_cvtps2pi_Ppi_Wps);
2545/** Opcode 0x66 0x0f 0x2d - cvtpd2pi Qpi, Wpd */
2546FNIEMOP_STUB(iemOp_cvtpd2pi_Qpi_Wpd);
2547/** Opcode 0xf3 0x0f 0x2d - cvtss2si Gy, Wss */
2548FNIEMOP_STUB(iemOp_cvtss2si_Gy_Wss);
2549/** Opcode 0xf2 0x0f 0x2d - cvtsd2si Gy, Wsd */
2550FNIEMOP_STUB(iemOp_cvtsd2si_Gy_Wsd);
2551
2552/** Opcode 0x0f 0x2e - ucomiss Vss, Wss */
2553FNIEMOP_STUB(iemOp_ucomiss_Vss_Wss); // NEXT
2554/** Opcode 0x66 0x0f 0x2e - ucomisd Vsd, Wsd */
2555FNIEMOP_STUB(iemOp_ucomisd_Vsd_Wsd); // NEXT
2556/* Opcode 0xf3 0x0f 0x2e - invalid */
2557/* Opcode 0xf2 0x0f 0x2e - invalid */
2558
2559/** Opcode 0x0f 0x2f - comiss Vss, Wss */
2560FNIEMOP_STUB(iemOp_comiss_Vss_Wss);
2561/** Opcode 0x66 0x0f 0x2f - comisd Vsd, Wsd */
2562FNIEMOP_STUB(iemOp_comisd_Vsd_Wsd);
2563/* Opcode 0xf3 0x0f 0x2f - invalid */
2564/* Opcode 0xf2 0x0f 0x2f - invalid */
2565
2566/** Opcode 0x0f 0x30. */
2567FNIEMOP_DEF(iemOp_wrmsr)
2568{
2569 IEMOP_MNEMONIC(wrmsr, "wrmsr");
2570 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2571 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_wrmsr);
2572}
2573
2574
2575/** Opcode 0x0f 0x31. */
2576FNIEMOP_DEF(iemOp_rdtsc)
2577{
2578 IEMOP_MNEMONIC(rdtsc, "rdtsc");
2579 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2580 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_rdtsc);
2581}
2582
2583
2584/** Opcode 0x0f 0x33. */
2585FNIEMOP_DEF(iemOp_rdmsr)
2586{
2587 IEMOP_MNEMONIC(rdmsr, "rdmsr");
2588 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2589 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_rdmsr);
2590}
2591
2592
2593/** Opcode 0x0f 0x34. */
2594FNIEMOP_DEF(iemOp_rdpmc)
2595{
2596 IEMOP_MNEMONIC(rdpmc, "rdpmc");
2597 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
2598 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_rdpmc);
2599}
2600
2601
2602/** Opcode 0x0f 0x34. */
2603FNIEMOP_STUB(iemOp_sysenter);
2604/** Opcode 0x0f 0x35. */
2605FNIEMOP_STUB(iemOp_sysexit);
2606/** Opcode 0x0f 0x37. */
2607FNIEMOP_STUB(iemOp_getsec);
2608
2609
2610/** Opcode 0x0f 0x38. */
2611FNIEMOP_DEF(iemOp_3byte_Esc_0f_38)
2612{
2613#ifdef IEM_WITH_THREE_0F_38
2614 uint8_t b; IEM_OPCODE_GET_NEXT_U8(&b);
2615 return FNIEMOP_CALL(g_apfnThreeByte0f38[(uintptr_t)b * 4 + pVCpu->iem.s.idxPrefix]);
2616#else
2617 IEMOP_BITCH_ABOUT_STUB();
2618 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
2619#endif
2620}
2621
2622
2623/** Opcode 0x0f 0x3a. */
2624FNIEMOP_DEF(iemOp_3byte_Esc_0f_3a)
2625{
2626#ifdef IEM_WITH_THREE_0F_3A
2627 uint8_t b; IEM_OPCODE_GET_NEXT_U8(&b);
2628 return FNIEMOP_CALL(g_apfnThreeByte0f3a[(uintptr_t)b * 4 + pVCpu->iem.s.idxPrefix]);
2629#else
2630 IEMOP_BITCH_ABOUT_STUB();
2631 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
2632#endif
2633}
2634
2635
2636/**
2637 * Implements a conditional move.
2638 *
2639 * Wish there was an obvious way to do this where we could share and reduce
2640 * code bloat.
2641 *
2642 * @param a_Cnd The conditional "microcode" operation.
2643 */
2644#define CMOV_X(a_Cnd) \
2645 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); \
2646 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) \
2647 { \
2648 switch (pVCpu->iem.s.enmEffOpSize) \
2649 { \
2650 case IEMMODE_16BIT: \
2651 IEM_MC_BEGIN(0, 1); \
2652 IEM_MC_LOCAL(uint16_t, u16Tmp); \
2653 a_Cnd { \
2654 IEM_MC_FETCH_GREG_U16(u16Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB); \
2655 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16Tmp); \
2656 } IEM_MC_ENDIF(); \
2657 IEM_MC_ADVANCE_RIP(); \
2658 IEM_MC_END(); \
2659 return VINF_SUCCESS; \
2660 \
2661 case IEMMODE_32BIT: \
2662 IEM_MC_BEGIN(0, 1); \
2663 IEM_MC_LOCAL(uint32_t, u32Tmp); \
2664 a_Cnd { \
2665 IEM_MC_FETCH_GREG_U32(u32Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB); \
2666 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Tmp); \
2667 } IEM_MC_ELSE() { \
2668 IEM_MC_CLEAR_HIGH_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg); \
2669 } IEM_MC_ENDIF(); \
2670 IEM_MC_ADVANCE_RIP(); \
2671 IEM_MC_END(); \
2672 return VINF_SUCCESS; \
2673 \
2674 case IEMMODE_64BIT: \
2675 IEM_MC_BEGIN(0, 1); \
2676 IEM_MC_LOCAL(uint64_t, u64Tmp); \
2677 a_Cnd { \
2678 IEM_MC_FETCH_GREG_U64(u64Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB); \
2679 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Tmp); \
2680 } IEM_MC_ENDIF(); \
2681 IEM_MC_ADVANCE_RIP(); \
2682 IEM_MC_END(); \
2683 return VINF_SUCCESS; \
2684 \
2685 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
2686 } \
2687 } \
2688 else \
2689 { \
2690 switch (pVCpu->iem.s.enmEffOpSize) \
2691 { \
2692 case IEMMODE_16BIT: \
2693 IEM_MC_BEGIN(0, 2); \
2694 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc); \
2695 IEM_MC_LOCAL(uint16_t, u16Tmp); \
2696 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0); \
2697 IEM_MC_FETCH_MEM_U16(u16Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); \
2698 a_Cnd { \
2699 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16Tmp); \
2700 } IEM_MC_ENDIF(); \
2701 IEM_MC_ADVANCE_RIP(); \
2702 IEM_MC_END(); \
2703 return VINF_SUCCESS; \
2704 \
2705 case IEMMODE_32BIT: \
2706 IEM_MC_BEGIN(0, 2); \
2707 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc); \
2708 IEM_MC_LOCAL(uint32_t, u32Tmp); \
2709 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0); \
2710 IEM_MC_FETCH_MEM_U32(u32Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); \
2711 a_Cnd { \
2712 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Tmp); \
2713 } IEM_MC_ELSE() { \
2714 IEM_MC_CLEAR_HIGH_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg); \
2715 } IEM_MC_ENDIF(); \
2716 IEM_MC_ADVANCE_RIP(); \
2717 IEM_MC_END(); \
2718 return VINF_SUCCESS; \
2719 \
2720 case IEMMODE_64BIT: \
2721 IEM_MC_BEGIN(0, 2); \
2722 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc); \
2723 IEM_MC_LOCAL(uint64_t, u64Tmp); \
2724 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0); \
2725 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); \
2726 a_Cnd { \
2727 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Tmp); \
2728 } IEM_MC_ENDIF(); \
2729 IEM_MC_ADVANCE_RIP(); \
2730 IEM_MC_END(); \
2731 return VINF_SUCCESS; \
2732 \
2733 IEM_NOT_REACHED_DEFAULT_CASE_RET(); \
2734 } \
2735 } do {} while (0)
2736
2737
2738
2739/** Opcode 0x0f 0x40. */
2740FNIEMOP_DEF(iemOp_cmovo_Gv_Ev)
2741{
2742 IEMOP_MNEMONIC(cmovo_Gv_Ev, "cmovo Gv,Ev");
2743 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF));
2744}
2745
2746
2747/** Opcode 0x0f 0x41. */
2748FNIEMOP_DEF(iemOp_cmovno_Gv_Ev)
2749{
2750 IEMOP_MNEMONIC(cmovno_Gv_Ev, "cmovno Gv,Ev");
2751 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_OF));
2752}
2753
2754
2755/** Opcode 0x0f 0x42. */
2756FNIEMOP_DEF(iemOp_cmovc_Gv_Ev)
2757{
2758 IEMOP_MNEMONIC(cmovc_Gv_Ev, "cmovc Gv,Ev");
2759 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF));
2760}
2761
2762
2763/** Opcode 0x0f 0x43. */
2764FNIEMOP_DEF(iemOp_cmovnc_Gv_Ev)
2765{
2766 IEMOP_MNEMONIC(cmovnc_Gv_Ev, "cmovnc Gv,Ev");
2767 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_CF));
2768}
2769
2770
2771/** Opcode 0x0f 0x44. */
2772FNIEMOP_DEF(iemOp_cmove_Gv_Ev)
2773{
2774 IEMOP_MNEMONIC(cmove_Gv_Ev, "cmove Gv,Ev");
2775 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF));
2776}
2777
2778
2779/** Opcode 0x0f 0x45. */
2780FNIEMOP_DEF(iemOp_cmovne_Gv_Ev)
2781{
2782 IEMOP_MNEMONIC(cmovne_Gv_Ev, "cmovne Gv,Ev");
2783 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF));
2784}
2785
2786
2787/** Opcode 0x0f 0x46. */
2788FNIEMOP_DEF(iemOp_cmovbe_Gv_Ev)
2789{
2790 IEMOP_MNEMONIC(cmovbe_Gv_Ev, "cmovbe Gv,Ev");
2791 CMOV_X(IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF));
2792}
2793
2794
2795/** Opcode 0x0f 0x47. */
2796FNIEMOP_DEF(iemOp_cmovnbe_Gv_Ev)
2797{
2798 IEMOP_MNEMONIC(cmovnbe_Gv_Ev, "cmovnbe Gv,Ev");
2799 CMOV_X(IEM_MC_IF_EFL_NO_BITS_SET(X86_EFL_CF | X86_EFL_ZF));
2800}
2801
2802
2803/** Opcode 0x0f 0x48. */
2804FNIEMOP_DEF(iemOp_cmovs_Gv_Ev)
2805{
2806 IEMOP_MNEMONIC(cmovs_Gv_Ev, "cmovs Gv,Ev");
2807 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF));
2808}
2809
2810
2811/** Opcode 0x0f 0x49. */
2812FNIEMOP_DEF(iemOp_cmovns_Gv_Ev)
2813{
2814 IEMOP_MNEMONIC(cmovns_Gv_Ev, "cmovns Gv,Ev");
2815 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_SF));
2816}
2817
2818
2819/** Opcode 0x0f 0x4a. */
2820FNIEMOP_DEF(iemOp_cmovp_Gv_Ev)
2821{
2822 IEMOP_MNEMONIC(cmovp_Gv_Ev, "cmovp Gv,Ev");
2823 CMOV_X(IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF));
2824}
2825
2826
2827/** Opcode 0x0f 0x4b. */
2828FNIEMOP_DEF(iemOp_cmovnp_Gv_Ev)
2829{
2830 IEMOP_MNEMONIC(cmovnp_Gv_Ev, "cmovnp Gv,Ev");
2831 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_PF));
2832}
2833
2834
2835/** Opcode 0x0f 0x4c. */
2836FNIEMOP_DEF(iemOp_cmovl_Gv_Ev)
2837{
2838 IEMOP_MNEMONIC(cmovl_Gv_Ev, "cmovl Gv,Ev");
2839 CMOV_X(IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF));
2840}
2841
2842
2843/** Opcode 0x0f 0x4d. */
2844FNIEMOP_DEF(iemOp_cmovnl_Gv_Ev)
2845{
2846 IEMOP_MNEMONIC(cmovnl_Gv_Ev, "cmovnl Gv,Ev");
2847 CMOV_X(IEM_MC_IF_EFL_BITS_EQ(X86_EFL_SF, X86_EFL_OF));
2848}
2849
2850
2851/** Opcode 0x0f 0x4e. */
2852FNIEMOP_DEF(iemOp_cmovle_Gv_Ev)
2853{
2854 IEMOP_MNEMONIC(cmovle_Gv_Ev, "cmovle Gv,Ev");
2855 CMOV_X(IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF));
2856}
2857
2858
2859/** Opcode 0x0f 0x4f. */
2860FNIEMOP_DEF(iemOp_cmovnle_Gv_Ev)
2861{
2862 IEMOP_MNEMONIC(cmovnle_Gv_Ev, "cmovnle Gv,Ev");
2863 CMOV_X(IEM_MC_IF_EFL_BIT_NOT_SET_AND_BITS_EQ(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF));
2864}
2865
2866#undef CMOV_X
2867
2868/** Opcode 0x0f 0x50 - movmskps Gy, Ups */
2869FNIEMOP_STUB(iemOp_movmskps_Gy_Ups);
2870/** Opcode 0x66 0x0f 0x50 - movmskpd Gy, Upd */
2871FNIEMOP_STUB(iemOp_movmskpd_Gy_Upd);
2872/* Opcode 0xf3 0x0f 0x50 - invalid */
2873/* Opcode 0xf2 0x0f 0x50 - invalid */
2874
2875/** Opcode 0x0f 0x51 - sqrtps Vps, Wps */
2876FNIEMOP_STUB(iemOp_sqrtps_Vps_Wps);
2877/** Opcode 0x66 0x0f 0x51 - sqrtpd Vpd, Wpd */
2878FNIEMOP_STUB(iemOp_sqrtpd_Vpd_Wpd);
2879/** Opcode 0xf3 0x0f 0x51 - sqrtss Vss, Wss */
2880FNIEMOP_STUB(iemOp_sqrtss_Vss_Wss);
2881/** Opcode 0xf2 0x0f 0x51 - sqrtsd Vsd, Wsd */
2882FNIEMOP_STUB(iemOp_sqrtsd_Vsd_Wsd);
2883
2884/** Opcode 0x0f 0x52 - rsqrtps Vps, Wps */
2885FNIEMOP_STUB(iemOp_rsqrtps_Vps_Wps);
2886/* Opcode 0x66 0x0f 0x52 - invalid */
2887/** Opcode 0xf3 0x0f 0x52 - rsqrtss Vss, Wss */
2888FNIEMOP_STUB(iemOp_rsqrtss_Vss_Wss);
2889/* Opcode 0xf2 0x0f 0x52 - invalid */
2890
2891/** Opcode 0x0f 0x53 - rcpps Vps, Wps */
2892FNIEMOP_STUB(iemOp_rcpps_Vps_Wps);
2893/* Opcode 0x66 0x0f 0x53 - invalid */
2894/** Opcode 0xf3 0x0f 0x53 - rcpss Vss, Wss */
2895FNIEMOP_STUB(iemOp_rcpss_Vss_Wss);
2896/* Opcode 0xf2 0x0f 0x53 - invalid */
2897
2898/** Opcode 0x0f 0x54 - andps Vps, Wps */
2899FNIEMOP_STUB(iemOp_andps_Vps_Wps);
2900/** Opcode 0x66 0x0f 0x54 - andpd Vpd, Wpd */
2901FNIEMOP_STUB(iemOp_andpd_Vpd_Wpd);
2902/* Opcode 0xf3 0x0f 0x54 - invalid */
2903/* Opcode 0xf2 0x0f 0x54 - invalid */
2904
2905/** Opcode 0x0f 0x55 - andnps Vps, Wps */
2906FNIEMOP_STUB(iemOp_andnps_Vps_Wps);
2907/** Opcode 0x66 0x0f 0x55 - andnpd Vpd, Wpd */
2908FNIEMOP_STUB(iemOp_andnpd_Vpd_Wpd);
2909/* Opcode 0xf3 0x0f 0x55 - invalid */
2910/* Opcode 0xf2 0x0f 0x55 - invalid */
2911
2912/** Opcode 0x0f 0x56 - orps Vps, Wps */
2913FNIEMOP_STUB(iemOp_orps_Vps_Wps);
2914/** Opcode 0x66 0x0f 0x56 - orpd Vpd, Wpd */
2915FNIEMOP_STUB(iemOp_orpd_Vpd_Wpd);
2916/* Opcode 0xf3 0x0f 0x56 - invalid */
2917/* Opcode 0xf2 0x0f 0x56 - invalid */
2918
2919/** Opcode 0x0f 0x57 - xorps Vps, Wps */
2920FNIEMOP_STUB(iemOp_xorps_Vps_Wps);
2921/** Opcode 0x66 0x0f 0x57 - xorpd Vpd, Wpd */
2922FNIEMOP_STUB(iemOp_xorpd_Vpd_Wpd);
2923/* Opcode 0xf3 0x0f 0x57 - invalid */
2924/* Opcode 0xf2 0x0f 0x57 - invalid */
2925
2926/** Opcode 0x0f 0x58 - addps Vps, Wps */
2927FNIEMOP_STUB(iemOp_addps_Vps_Wps);
2928/** Opcode 0x66 0x0f 0x58 - addpd Vpd, Wpd */
2929FNIEMOP_STUB(iemOp_addpd_Vpd_Wpd);
2930/** Opcode 0xf3 0x0f 0x58 - addss Vss, Wss */
2931FNIEMOP_STUB(iemOp_addss_Vss_Wss);
2932/** Opcode 0xf2 0x0f 0x58 - addsd Vsd, Wsd */
2933FNIEMOP_STUB(iemOp_addsd_Vsd_Wsd);
2934
2935/** Opcode 0x0f 0x59 - mulps Vps, Wps */
2936FNIEMOP_STUB(iemOp_mulps_Vps_Wps);
2937/** Opcode 0x66 0x0f 0x59 - mulpd Vpd, Wpd */
2938FNIEMOP_STUB(iemOp_mulpd_Vpd_Wpd);
2939/** Opcode 0xf3 0x0f 0x59 - mulss Vss, Wss */
2940FNIEMOP_STUB(iemOp_mulss_Vss_Wss);
2941/** Opcode 0xf2 0x0f 0x59 - mulsd Vsd, Wsd */
2942FNIEMOP_STUB(iemOp_mulsd_Vsd_Wsd);
2943
2944/** Opcode 0x0f 0x5a - cvtps2pd Vpd, Wps */
2945FNIEMOP_STUB(iemOp_cvtps2pd_Vpd_Wps);
2946/** Opcode 0x66 0x0f 0x5a - cvtpd2ps Vps, Wpd */
2947FNIEMOP_STUB(iemOp_cvtpd2ps_Vps_Wpd);
2948/** Opcode 0xf3 0x0f 0x5a - cvtss2sd Vsd, Wss */
2949FNIEMOP_STUB(iemOp_cvtss2sd_Vsd_Wss);
2950/** Opcode 0xf2 0x0f 0x5a - cvtsd2ss Vss, Wsd */
2951FNIEMOP_STUB(iemOp_cvtsd2ss_Vss_Wsd);
2952
2953/** Opcode 0x0f 0x5b - cvtdq2ps Vps, Wdq */
2954FNIEMOP_STUB(iemOp_cvtdq2ps_Vps_Wdq);
2955/** Opcode 0x66 0x0f 0x5b - cvtps2dq Vdq, Wps */
2956FNIEMOP_STUB(iemOp_cvtps2dq_Vdq_Wps);
2957/** Opcode 0xf3 0x0f 0x5b - cvttps2dq Vdq, Wps */
2958FNIEMOP_STUB(iemOp_cvttps2dq_Vdq_Wps);
2959/* Opcode 0xf2 0x0f 0x5b - invalid */
2960
2961/** Opcode 0x0f 0x5c - subps Vps, Wps */
2962FNIEMOP_STUB(iemOp_subps_Vps_Wps);
2963/** Opcode 0x66 0x0f 0x5c - subpd Vpd, Wpd */
2964FNIEMOP_STUB(iemOp_subpd_Vpd_Wpd);
2965/** Opcode 0xf3 0x0f 0x5c - subss Vss, Wss */
2966FNIEMOP_STUB(iemOp_subss_Vss_Wss);
2967/** Opcode 0xf2 0x0f 0x5c - subsd Vsd, Wsd */
2968FNIEMOP_STUB(iemOp_subsd_Vsd_Wsd);
2969
2970/** Opcode 0x0f 0x5d - minps Vps, Wps */
2971FNIEMOP_STUB(iemOp_minps_Vps_Wps);
2972/** Opcode 0x66 0x0f 0x5d - minpd Vpd, Wpd */
2973FNIEMOP_STUB(iemOp_minpd_Vpd_Wpd);
2974/** Opcode 0xf3 0x0f 0x5d - minss Vss, Wss */
2975FNIEMOP_STUB(iemOp_minss_Vss_Wss);
2976/** Opcode 0xf2 0x0f 0x5d - minsd Vsd, Wsd */
2977FNIEMOP_STUB(iemOp_minsd_Vsd_Wsd);
2978
2979/** Opcode 0x0f 0x5e - divps Vps, Wps */
2980FNIEMOP_STUB(iemOp_divps_Vps_Wps);
2981/** Opcode 0x66 0x0f 0x5e - divpd Vpd, Wpd */
2982FNIEMOP_STUB(iemOp_divpd_Vpd_Wpd);
2983/** Opcode 0xf3 0x0f 0x5e - divss Vss, Wss */
2984FNIEMOP_STUB(iemOp_divss_Vss_Wss);
2985/** Opcode 0xf2 0x0f 0x5e - divsd Vsd, Wsd */
2986FNIEMOP_STUB(iemOp_divsd_Vsd_Wsd);
2987
2988/** Opcode 0x0f 0x5f - maxps Vps, Wps */
2989FNIEMOP_STUB(iemOp_maxps_Vps_Wps);
2990/** Opcode 0x66 0x0f 0x5f - maxpd Vpd, Wpd */
2991FNIEMOP_STUB(iemOp_maxpd_Vpd_Wpd);
2992/** Opcode 0xf3 0x0f 0x5f - maxss Vss, Wss */
2993FNIEMOP_STUB(iemOp_maxss_Vss_Wss);
2994/** Opcode 0xf2 0x0f 0x5f - maxsd Vsd, Wsd */
2995FNIEMOP_STUB(iemOp_maxsd_Vsd_Wsd);
2996
2997/**
2998 * Common worker for MMX instructions on the forms:
2999 * pxxxx mm1, mm2/mem32
3000 *
3001 * The 2nd operand is the first half of a register, which in the memory case
3002 * means a 32-bit memory access for MMX and 128-bit aligned 64-bit or 128-bit
3003 * memory accessed for MMX.
3004 *
3005 * Exceptions type 4.
3006 */
3007FNIEMOP_DEF_1(iemOpCommonMmx_LowLow_To_Full, PCIEMOPMEDIAF1L1, pImpl)
3008{
3009 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3010 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3011 {
3012 /*
3013 * Register, register.
3014 */
3015 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3016 IEM_MC_BEGIN(2, 0);
3017 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3018 IEM_MC_ARG(uint64_t const *, pSrc, 1);
3019 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3020 IEM_MC_PREPARE_SSE_USAGE();
3021 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3022 IEM_MC_REF_XREG_U64_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3023 IEM_MC_CALL_SSE_AIMPL_2(pImpl->pfnU128, pDst, pSrc);
3024 IEM_MC_ADVANCE_RIP();
3025 IEM_MC_END();
3026 }
3027 else
3028 {
3029 /*
3030 * Register, memory.
3031 */
3032 IEM_MC_BEGIN(2, 2);
3033 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3034 IEM_MC_LOCAL(uint64_t, uSrc);
3035 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
3036 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3037
3038 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3039 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3040 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3041 IEM_MC_FETCH_MEM_U64_ALIGN_U128(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3042
3043 IEM_MC_PREPARE_SSE_USAGE();
3044 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3045 IEM_MC_CALL_SSE_AIMPL_2(pImpl->pfnU128, pDst, pSrc);
3046
3047 IEM_MC_ADVANCE_RIP();
3048 IEM_MC_END();
3049 }
3050 return VINF_SUCCESS;
3051}
3052
3053
3054/**
3055 * Common worker for SSE2 instructions on the forms:
3056 * pxxxx xmm1, xmm2/mem128
3057 *
3058 * The 2nd operand is the first half of a register, which in the memory case
3059 * means a 32-bit memory access for MMX and 128-bit aligned 64-bit or 128-bit
3060 * memory accessed for MMX.
3061 *
3062 * Exceptions type 4.
3063 */
3064FNIEMOP_DEF_1(iemOpCommonSse_LowLow_To_Full, PCIEMOPMEDIAF1L1, pImpl)
3065{
3066 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3067 if (!pImpl->pfnU64)
3068 return IEMOP_RAISE_INVALID_OPCODE();
3069 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3070 {
3071 /*
3072 * Register, register.
3073 */
3074 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
3075 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
3076 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3077 IEM_MC_BEGIN(2, 0);
3078 IEM_MC_ARG(uint64_t *, pDst, 0);
3079 IEM_MC_ARG(uint32_t const *, pSrc, 1);
3080 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3081 IEM_MC_PREPARE_FPU_USAGE();
3082 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
3083 IEM_MC_REF_MREG_U32_CONST(pSrc, bRm & X86_MODRM_RM_MASK);
3084 IEM_MC_CALL_MMX_AIMPL_2(pImpl->pfnU64, pDst, pSrc);
3085 IEM_MC_ADVANCE_RIP();
3086 IEM_MC_END();
3087 }
3088 else
3089 {
3090 /*
3091 * Register, memory.
3092 */
3093 IEM_MC_BEGIN(2, 2);
3094 IEM_MC_ARG(uint64_t *, pDst, 0);
3095 IEM_MC_LOCAL(uint32_t, uSrc);
3096 IEM_MC_ARG_LOCAL_REF(uint32_t const *, pSrc, uSrc, 1);
3097 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3098
3099 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3100 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3101 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3102 IEM_MC_FETCH_MEM_U32(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3103
3104 IEM_MC_PREPARE_FPU_USAGE();
3105 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
3106 IEM_MC_CALL_MMX_AIMPL_2(pImpl->pfnU64, pDst, pSrc);
3107
3108 IEM_MC_ADVANCE_RIP();
3109 IEM_MC_END();
3110 }
3111 return VINF_SUCCESS;
3112}
3113
3114
3115/** Opcode 0x0f 0x60 - punpcklbw Pq, Qd */
3116FNIEMOP_DEF(iemOp_punpcklbw_Pq_Qd)
3117{
3118 IEMOP_MNEMONIC(punpcklbw, "punpcklbw Pq, Qd");
3119 return FNIEMOP_CALL_1(iemOpCommonMmx_LowLow_To_Full, &g_iemAImpl_punpcklbw);
3120}
3121
3122/** Opcode 0x66 0x0f 0x60 - punpcklbw Vx, W */
3123FNIEMOP_DEF(iemOp_punpcklbw_Vx_Wx)
3124{
3125 IEMOP_MNEMONIC(vpunpcklbw_Vx_Wx, "vpunpcklbw Vx, Wx");
3126 return FNIEMOP_CALL_1(iemOpCommonSse_LowLow_To_Full, &g_iemAImpl_punpcklbw);
3127}
3128
3129/* Opcode 0xf3 0x0f 0x60 - invalid */
3130
3131
3132/** Opcode 0x0f 0x61 - punpcklwd Pq, Qd */
3133FNIEMOP_DEF(iemOp_punpcklwd_Pq_Qd)
3134{
3135 IEMOP_MNEMONIC(punpcklwd, "punpcklwd Pq, Qd"); /** @todo AMD mark the MMX version as 3DNow!. Intel says MMX CPUID req. */
3136 return FNIEMOP_CALL_1(iemOpCommonMmx_LowLow_To_Full, &g_iemAImpl_punpcklwd);
3137}
3138
3139/** Opcode 0x66 0x0f 0x61 - punpcklwd Vx, Wx */
3140FNIEMOP_DEF(iemOp_punpcklwd_Vx_Wx)
3141{
3142 IEMOP_MNEMONIC(vpunpcklwd_Vx_Wx, "punpcklwd Vx, Wx");
3143 return FNIEMOP_CALL_1(iemOpCommonSse_LowLow_To_Full, &g_iemAImpl_punpcklwd);
3144}
3145
3146/* Opcode 0xf3 0x0f 0x61 - invalid */
3147
3148
3149/** Opcode 0x0f 0x62 - punpckldq Pq, Qd */
3150FNIEMOP_DEF(iemOp_punpckldq_Pq_Qd)
3151{
3152 IEMOP_MNEMONIC(punpckldq, "punpckldq Pq, Qd");
3153 return FNIEMOP_CALL_1(iemOpCommonMmx_LowLow_To_Full, &g_iemAImpl_punpckldq);
3154}
3155
3156/** Opcode 0x66 0x0f 0x62 - punpckldq Vx, Wx */
3157FNIEMOP_DEF(iemOp_punpckldq_Vx_Wx)
3158{
3159 IEMOP_MNEMONIC(punpckldq_Vx_Wx, "punpckldq Vx, Wx");
3160 return FNIEMOP_CALL_1(iemOpCommonSse_LowLow_To_Full, &g_iemAImpl_punpckldq);
3161}
3162
3163/* Opcode 0xf3 0x0f 0x62 - invalid */
3164
3165
3166
3167/** Opcode 0x0f 0x63 - packsswb Pq, Qq */
3168FNIEMOP_STUB(iemOp_packsswb_Pq_Qq);
3169/** Opcode 0x66 0x0f 0x63 - packsswb Vx, Wx */
3170FNIEMOP_STUB(iemOp_packsswb_Vx_Wx);
3171/* Opcode 0xf3 0x0f 0x63 - invalid */
3172
3173/** Opcode 0x0f 0x64 - pcmpgtb Pq, Qq */
3174FNIEMOP_STUB(iemOp_pcmpgtb_Pq_Qq);
3175/** Opcode 0x66 0x0f 0x64 - pcmpgtb Vx, Wx */
3176FNIEMOP_STUB(iemOp_pcmpgtb_Vx_Wx);
3177/* Opcode 0xf3 0x0f 0x64 - invalid */
3178
3179/** Opcode 0x0f 0x65 - pcmpgtw Pq, Qq */
3180FNIEMOP_STUB(iemOp_pcmpgtw_Pq_Qq);
3181/** Opcode 0x66 0x0f 0x65 - pcmpgtw Vx, Wx */
3182FNIEMOP_STUB(iemOp_pcmpgtw_Vx_Wx);
3183/* Opcode 0xf3 0x0f 0x65 - invalid */
3184
3185/** Opcode 0x0f 0x66 - pcmpgtd Pq, Qq */
3186FNIEMOP_STUB(iemOp_pcmpgtd_Pq_Qq);
3187/** Opcode 0x66 0x0f 0x66 - pcmpgtd Vx, Wx */
3188FNIEMOP_STUB(iemOp_pcmpgtd_Vx_Wx);
3189/* Opcode 0xf3 0x0f 0x66 - invalid */
3190
3191/** Opcode 0x0f 0x67 - packuswb Pq, Qq */
3192FNIEMOP_STUB(iemOp_packuswb_Pq_Qq);
3193/** Opcode 0x66 0x0f 0x67 - packuswb Vx, W */
3194FNIEMOP_STUB(iemOp_packuswb_Vx_W);
3195/* Opcode 0xf3 0x0f 0x67 - invalid */
3196
3197
3198/**
3199 * Common worker for MMX instructions on the form:
3200 * pxxxx mm1, mm2/mem64
3201 *
3202 * The 2nd operand is the second half of a register, which in the memory case
3203 * means a 64-bit memory access for MMX, and for SSE a 128-bit aligned access
3204 * where it may read the full 128 bits or only the upper 64 bits.
3205 *
3206 * Exceptions type 4.
3207 */
3208FNIEMOP_DEF_1(iemOpCommonMmx_HighHigh_To_Full, PCIEMOPMEDIAF1H1, pImpl)
3209{
3210 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3211 AssertReturn(pImpl->pfnU64, IEMOP_RAISE_INVALID_OPCODE());
3212 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3213 {
3214 /*
3215 * Register, register.
3216 */
3217 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
3218 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
3219 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3220 IEM_MC_BEGIN(2, 0);
3221 IEM_MC_ARG(uint64_t *, pDst, 0);
3222 IEM_MC_ARG(uint64_t const *, pSrc, 1);
3223 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3224 IEM_MC_PREPARE_FPU_USAGE();
3225 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
3226 IEM_MC_REF_MREG_U64_CONST(pSrc, bRm & X86_MODRM_RM_MASK);
3227 IEM_MC_CALL_MMX_AIMPL_2(pImpl->pfnU64, pDst, pSrc);
3228 IEM_MC_ADVANCE_RIP();
3229 IEM_MC_END();
3230 }
3231 else
3232 {
3233 /*
3234 * Register, memory.
3235 */
3236 IEM_MC_BEGIN(2, 2);
3237 IEM_MC_ARG(uint64_t *, pDst, 0);
3238 IEM_MC_LOCAL(uint64_t, uSrc);
3239 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
3240 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3241
3242 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3243 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3244 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3245 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3246
3247 IEM_MC_PREPARE_FPU_USAGE();
3248 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
3249 IEM_MC_CALL_MMX_AIMPL_2(pImpl->pfnU64, pDst, pSrc);
3250
3251 IEM_MC_ADVANCE_RIP();
3252 IEM_MC_END();
3253 }
3254 return VINF_SUCCESS;
3255}
3256
3257
3258/**
3259 * Common worker for SSE2 instructions on the form:
3260 * pxxxx xmm1, xmm2/mem128
3261 *
3262 * The 2nd operand is the second half of a register, which in the memory case
3263 * means a 64-bit memory access for MMX, and for SSE a 128-bit aligned access
3264 * where it may read the full 128 bits or only the upper 64 bits.
3265 *
3266 * Exceptions type 4.
3267 */
3268FNIEMOP_DEF_1(iemOpCommonSse_HighHigh_To_Full, PCIEMOPMEDIAF1H1, pImpl)
3269{
3270 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3271 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3272 {
3273 /*
3274 * Register, register.
3275 */
3276 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3277 IEM_MC_BEGIN(2, 0);
3278 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3279 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
3280 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3281 IEM_MC_PREPARE_SSE_USAGE();
3282 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3283 IEM_MC_REF_XREG_U128_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3284 IEM_MC_CALL_SSE_AIMPL_2(pImpl->pfnU128, pDst, pSrc);
3285 IEM_MC_ADVANCE_RIP();
3286 IEM_MC_END();
3287 }
3288 else
3289 {
3290 /*
3291 * Register, memory.
3292 */
3293 IEM_MC_BEGIN(2, 2);
3294 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3295 IEM_MC_LOCAL(RTUINT128U, uSrc);
3296 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
3297 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3298
3299 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3300 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3301 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3302 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc); /* Most CPUs probably only right high qword */
3303
3304 IEM_MC_PREPARE_SSE_USAGE();
3305 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3306 IEM_MC_CALL_SSE_AIMPL_2(pImpl->pfnU128, pDst, pSrc);
3307
3308 IEM_MC_ADVANCE_RIP();
3309 IEM_MC_END();
3310 }
3311 return VINF_SUCCESS;
3312}
3313
3314
3315/** Opcode 0x0f 0x68 - punpckhbw Pq, Qd */
3316FNIEMOP_DEF(iemOp_punpckhbw_Pq_Qd)
3317{
3318 IEMOP_MNEMONIC(punpckhbw, "punpckhbw Pq, Qd");
3319 return FNIEMOP_CALL_1(iemOpCommonMmx_HighHigh_To_Full, &g_iemAImpl_punpckhbw);
3320}
3321
3322/** Opcode 0x66 0x0f 0x68 - punpckhbw Vx, Wx */
3323FNIEMOP_DEF(iemOp_punpckhbw_Vx_Wx)
3324{
3325 IEMOP_MNEMONIC(vpunpckhbw_Vx_Wx, "vpunpckhbw Vx, Wx");
3326 return FNIEMOP_CALL_1(iemOpCommonSse_HighHigh_To_Full, &g_iemAImpl_punpckhbw);
3327}
3328/* Opcode 0xf3 0x0f 0x68 - invalid */
3329
3330
3331/** Opcode 0x0f 0x69 - punpckhwd Pq, Qd */
3332FNIEMOP_DEF(iemOp_punpckhwd_Pq_Qd)
3333{
3334 IEMOP_MNEMONIC(punpckhwd, "punpckhwd Pq, Qd");
3335 return FNIEMOP_CALL_1(iemOpCommonMmx_HighHigh_To_Full, &g_iemAImpl_punpckhwd);
3336}
3337
3338/** Opcode 0x66 0x0f 0x69 - punpckhwd Vx, Hx, Wx */
3339FNIEMOP_DEF(iemOp_punpckhwd_Vx_Wx)
3340{
3341 IEMOP_MNEMONIC(punpckhwd_Vx_Wx, "punpckhwd Vx, Wx");
3342 return FNIEMOP_CALL_1(iemOpCommonSse_HighHigh_To_Full, &g_iemAImpl_punpckhwd);
3343
3344}
3345/* Opcode 0xf3 0x0f 0x69 - invalid */
3346
3347
3348/** Opcode 0x0f 0x6a - punpckhdq Pq, Qd */
3349FNIEMOP_DEF(iemOp_punpckhdq_Pq_Qd)
3350{
3351 IEMOP_MNEMONIC(punpckhdq, "punpckhdq Pq, Qd");
3352 return FNIEMOP_CALL_1(iemOpCommonMmx_HighHigh_To_Full, &g_iemAImpl_punpckhdq);
3353}
3354
3355/** Opcode 0x66 0x0f 0x6a - punpckhdq Vx, W */
3356FNIEMOP_DEF(iemOp_punpckhdq_Vx_W)
3357{
3358 IEMOP_MNEMONIC(punpckhdq_Vx_W, "punpckhdq Vx, W");
3359 return FNIEMOP_CALL_1(iemOpCommonSse_HighHigh_To_Full, &g_iemAImpl_punpckhdq);
3360}
3361/* Opcode 0xf3 0x0f 0x6a - invalid */
3362
3363
3364/** Opcode 0x0f 0x6b - packssdw Pq, Qd */
3365FNIEMOP_STUB(iemOp_packssdw_Pq_Qd);
3366/** Opcode 0x66 0x0f 0x6b - packssdw Vx, Wx */
3367FNIEMOP_STUB(iemOp_packssdw_Vx_Wx);
3368/* Opcode 0xf3 0x0f 0x6b - invalid */
3369
3370
3371/* Opcode 0x0f 0x6c - invalid */
3372
3373/** Opcode 0x66 0x0f 0x6c - punpcklqdq Vx, Wx */
3374FNIEMOP_DEF(iemOp_punpcklqdq_Vx_Wx)
3375{
3376 IEMOP_MNEMONIC(punpcklqdq, "punpcklqdq Vx, Wx");
3377 return FNIEMOP_CALL_1(iemOpCommonSse_LowLow_To_Full, &g_iemAImpl_punpcklqdq);
3378}
3379
3380/* Opcode 0xf3 0x0f 0x6c - invalid */
3381/* Opcode 0xf2 0x0f 0x6c - invalid */
3382
3383
3384/* Opcode 0x0f 0x6d - invalid */
3385
3386/** Opcode 0x66 0x0f 0x6d - punpckhqdq Vx, W */
3387FNIEMOP_DEF(iemOp_punpckhqdq_Vx_W)
3388{
3389 IEMOP_MNEMONIC(punpckhqdq_Vx_W, "punpckhqdq Vx,W");
3390 return FNIEMOP_CALL_1(iemOpCommonSse_HighHigh_To_Full, &g_iemAImpl_punpckhqdq);
3391}
3392
3393/* Opcode 0xf3 0x0f 0x6d - invalid */
3394
3395
3396FNIEMOP_DEF(iemOp_movd_q_Pd_Ey)
3397{
3398 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3399 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
3400 {
3401 /**
3402 * @opcode 0x6e
3403 * @opcodesub rex.w=1
3404 * @oppfx none
3405 * @opcpuid mmx
3406 * @opgroup og_mmx_datamove
3407 * @opxcpttype 5
3408 * @optest 64-bit / op1=1 op2=2 -> op1=2 ftw=0xff
3409 * @optest 64-bit / op1=0 op2=-42 -> op1=-42 ftw=0xff
3410 */
3411 IEMOP_MNEMONIC2(RM, MOVQ, movq, Pq_WO, Eq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
3412 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3413 {
3414 /* MMX, greg64 */
3415 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3416 IEM_MC_BEGIN(0, 1);
3417 IEM_MC_LOCAL(uint64_t, u64Tmp);
3418
3419 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3420 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
3421
3422 IEM_MC_FETCH_GREG_U64(u64Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3423 IEM_MC_STORE_MREG_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, u64Tmp);
3424 IEM_MC_FPU_TO_MMX_MODE();
3425
3426 IEM_MC_ADVANCE_RIP();
3427 IEM_MC_END();
3428 }
3429 else
3430 {
3431 /* MMX, [mem64] */
3432 IEM_MC_BEGIN(0, 2);
3433 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3434 IEM_MC_LOCAL(uint64_t, u64Tmp);
3435
3436 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3437 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3438 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3439 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
3440
3441 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3442 IEM_MC_STORE_MREG_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, u64Tmp);
3443 IEM_MC_FPU_TO_MMX_MODE();
3444
3445 IEM_MC_ADVANCE_RIP();
3446 IEM_MC_END();
3447 }
3448 }
3449 else
3450 {
3451 /**
3452 * @opdone
3453 * @opcode 0x6e
3454 * @opcodesub rex.w=0
3455 * @oppfx none
3456 * @opcpuid mmx
3457 * @opgroup og_mmx_datamove
3458 * @opxcpttype 5
3459 * @opfunction iemOp_movd_q_Pd_Ey
3460 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
3461 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
3462 */
3463 IEMOP_MNEMONIC2(RM, MOVD, movd, PdZx_WO, Ed, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
3464 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3465 {
3466 /* MMX, greg */
3467 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3468 IEM_MC_BEGIN(0, 1);
3469 IEM_MC_LOCAL(uint64_t, u64Tmp);
3470
3471 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3472 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
3473
3474 IEM_MC_FETCH_GREG_U32_ZX_U64(u64Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3475 IEM_MC_STORE_MREG_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, u64Tmp);
3476 IEM_MC_FPU_TO_MMX_MODE();
3477
3478 IEM_MC_ADVANCE_RIP();
3479 IEM_MC_END();
3480 }
3481 else
3482 {
3483 /* MMX, [mem] */
3484 IEM_MC_BEGIN(0, 2);
3485 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3486 IEM_MC_LOCAL(uint32_t, u32Tmp);
3487
3488 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3489 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3490 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3491 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
3492
3493 IEM_MC_FETCH_MEM_U32(u32Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3494 IEM_MC_STORE_MREG_U32_ZX_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, u32Tmp);
3495 IEM_MC_FPU_TO_MMX_MODE();
3496
3497 IEM_MC_ADVANCE_RIP();
3498 IEM_MC_END();
3499 }
3500 }
3501 return VINF_SUCCESS;
3502}
3503
3504FNIEMOP_DEF(iemOp_movd_q_Vy_Ey)
3505{
3506 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3507 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
3508 {
3509 /**
3510 * @opcode 0x6e
3511 * @opcodesub rex.w=1
3512 * @oppfx 0x66
3513 * @opcpuid sse2
3514 * @opgroup og_sse2_simdint_datamove
3515 * @opxcpttype 5
3516 * @optest 64-bit / op1=1 op2=2 -> op1=2
3517 * @optest 64-bit / op1=0 op2=-42 -> op1=-42
3518 */
3519 IEMOP_MNEMONIC2(RM, MOVQ, movq, VqZx_WO, Eq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
3520 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3521 {
3522 /* XMM, greg64 */
3523 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3524 IEM_MC_BEGIN(0, 1);
3525 IEM_MC_LOCAL(uint64_t, u64Tmp);
3526
3527 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3528 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3529
3530 IEM_MC_FETCH_GREG_U64(u64Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3531 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Tmp);
3532
3533 IEM_MC_ADVANCE_RIP();
3534 IEM_MC_END();
3535 }
3536 else
3537 {
3538 /* XMM, [mem64] */
3539 IEM_MC_BEGIN(0, 2);
3540 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3541 IEM_MC_LOCAL(uint64_t, u64Tmp);
3542
3543 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3544 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3545 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3546 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3547
3548 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3549 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Tmp);
3550
3551 IEM_MC_ADVANCE_RIP();
3552 IEM_MC_END();
3553 }
3554 }
3555 else
3556 {
3557 /**
3558 * @opdone
3559 * @opcode 0x6e
3560 * @opcodesub rex.w=0
3561 * @oppfx 0x66
3562 * @opcpuid sse2
3563 * @opgroup og_sse2_simdint_datamove
3564 * @opxcpttype 5
3565 * @opfunction iemOp_movd_q_Vy_Ey
3566 * @optest op1=1 op2=2 -> op1=2
3567 * @optest op1=0 op2=-42 -> op1=-42
3568 */
3569 IEMOP_MNEMONIC2(RM, MOVD, movd, VdZx_WO, Ed, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
3570 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3571 {
3572 /* XMM, greg32 */
3573 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3574 IEM_MC_BEGIN(0, 1);
3575 IEM_MC_LOCAL(uint32_t, u32Tmp);
3576
3577 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3578 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3579
3580 IEM_MC_FETCH_GREG_U32(u32Tmp, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3581 IEM_MC_STORE_XREG_U32_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Tmp);
3582
3583 IEM_MC_ADVANCE_RIP();
3584 IEM_MC_END();
3585 }
3586 else
3587 {
3588 /* XMM, [mem32] */
3589 IEM_MC_BEGIN(0, 2);
3590 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3591 IEM_MC_LOCAL(uint32_t, u32Tmp);
3592
3593 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3594 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3595 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3596 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3597
3598 IEM_MC_FETCH_MEM_U32(u32Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3599 IEM_MC_STORE_XREG_U32_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Tmp);
3600
3601 IEM_MC_ADVANCE_RIP();
3602 IEM_MC_END();
3603 }
3604 }
3605 return VINF_SUCCESS;
3606}
3607
3608/* Opcode 0xf3 0x0f 0x6e - invalid */
3609
3610
3611/**
3612 * @opcode 0x6f
3613 * @oppfx none
3614 * @opcpuid mmx
3615 * @opgroup og_mmx_datamove
3616 * @opxcpttype 5
3617 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
3618 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
3619 */
3620FNIEMOP_DEF(iemOp_movq_Pq_Qq)
3621{
3622 IEMOP_MNEMONIC2(RM, MOVD, movd, Pq_WO, Qq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
3623 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3624 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3625 {
3626 /*
3627 * Register, register.
3628 */
3629 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3630 IEM_MC_BEGIN(0, 1);
3631 IEM_MC_LOCAL(uint64_t, u64Tmp);
3632
3633 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3634 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
3635
3636 IEM_MC_FETCH_MREG_U64(u64Tmp, bRm & X86_MODRM_RM_MASK);
3637 IEM_MC_STORE_MREG_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, u64Tmp);
3638 IEM_MC_FPU_TO_MMX_MODE();
3639
3640 IEM_MC_ADVANCE_RIP();
3641 IEM_MC_END();
3642 }
3643 else
3644 {
3645 /*
3646 * Register, memory.
3647 */
3648 IEM_MC_BEGIN(0, 2);
3649 IEM_MC_LOCAL(uint64_t, u64Tmp);
3650 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3651
3652 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3653 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3654 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
3655 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
3656
3657 IEM_MC_FETCH_MEM_U64(u64Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3658 IEM_MC_STORE_MREG_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, u64Tmp);
3659 IEM_MC_FPU_TO_MMX_MODE();
3660
3661 IEM_MC_ADVANCE_RIP();
3662 IEM_MC_END();
3663 }
3664 return VINF_SUCCESS;
3665}
3666
3667/**
3668 * @opcode 0x6f
3669 * @oppfx 0x66
3670 * @opcpuid sse2
3671 * @opgroup og_sse2_simdint_datamove
3672 * @opxcpttype 1
3673 * @optest op1=1 op2=2 -> op1=2
3674 * @optest op1=0 op2=-42 -> op1=-42
3675 */
3676FNIEMOP_DEF(iemOp_movdqa_Vdq_Wdq)
3677{
3678 IEMOP_MNEMONIC2(RM, MOVDQA, movdqa, Vdq_WO, Wdq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
3679 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3680 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3681 {
3682 /*
3683 * Register, register.
3684 */
3685 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3686 IEM_MC_BEGIN(0, 0);
3687
3688 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3689 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3690
3691 IEM_MC_COPY_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg,
3692 (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3693 IEM_MC_ADVANCE_RIP();
3694 IEM_MC_END();
3695 }
3696 else
3697 {
3698 /*
3699 * Register, memory.
3700 */
3701 IEM_MC_BEGIN(0, 2);
3702 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
3703 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3704
3705 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3706 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3707 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3708 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3709
3710 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(u128Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3711 IEM_MC_STORE_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u128Tmp);
3712
3713 IEM_MC_ADVANCE_RIP();
3714 IEM_MC_END();
3715 }
3716 return VINF_SUCCESS;
3717}
3718
3719/**
3720 * @opcode 0x6f
3721 * @oppfx 0xf3
3722 * @opcpuid sse2
3723 * @opgroup og_sse2_simdint_datamove
3724 * @opxcpttype 4UA
3725 * @optest op1=1 op2=2 -> op1=2
3726 * @optest op1=0 op2=-42 -> op1=-42
3727 */
3728FNIEMOP_DEF(iemOp_movdqu_Vdq_Wdq)
3729{
3730 IEMOP_MNEMONIC2(RM, MOVDQU, movdqu, Vdq_WO, Wdq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
3731 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3732 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3733 {
3734 /*
3735 * Register, register.
3736 */
3737 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3738 IEM_MC_BEGIN(0, 0);
3739 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3740 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3741 IEM_MC_COPY_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg,
3742 (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3743 IEM_MC_ADVANCE_RIP();
3744 IEM_MC_END();
3745 }
3746 else
3747 {
3748 /*
3749 * Register, memory.
3750 */
3751 IEM_MC_BEGIN(0, 2);
3752 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
3753 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3754
3755 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3756 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3757 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3758 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
3759 IEM_MC_FETCH_MEM_U128(u128Tmp, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3760 IEM_MC_STORE_XREG_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u128Tmp);
3761
3762 IEM_MC_ADVANCE_RIP();
3763 IEM_MC_END();
3764 }
3765 return VINF_SUCCESS;
3766}
3767
3768
3769/** Opcode 0x0f 0x70 - pshufw Pq, Qq, Ib */
3770FNIEMOP_DEF(iemOp_pshufw_Pq_Qq_Ib)
3771{
3772 IEMOP_MNEMONIC(pshufw_Pq_Qq, "pshufw Pq,Qq,Ib");
3773 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3774 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3775 {
3776 /*
3777 * Register, register.
3778 */
3779 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3780 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3781
3782 IEM_MC_BEGIN(3, 0);
3783 IEM_MC_ARG(uint64_t *, pDst, 0);
3784 IEM_MC_ARG(uint64_t const *, pSrc, 1);
3785 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3786 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT_CHECK_SSE_OR_MMXEXT();
3787 IEM_MC_PREPARE_FPU_USAGE();
3788 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
3789 IEM_MC_REF_MREG_U64_CONST(pSrc, bRm & X86_MODRM_RM_MASK);
3790 IEM_MC_CALL_MMX_AIMPL_3(iemAImpl_pshufw, pDst, pSrc, bEvilArg);
3791 IEM_MC_ADVANCE_RIP();
3792 IEM_MC_END();
3793 }
3794 else
3795 {
3796 /*
3797 * Register, memory.
3798 */
3799 IEM_MC_BEGIN(3, 2);
3800 IEM_MC_ARG(uint64_t *, pDst, 0);
3801 IEM_MC_LOCAL(uint64_t, uSrc);
3802 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
3803 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3804
3805 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3806 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3807 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3808 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3809 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT_CHECK_SSE_OR_MMXEXT();
3810
3811 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3812 IEM_MC_PREPARE_FPU_USAGE();
3813 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
3814 IEM_MC_CALL_MMX_AIMPL_3(iemAImpl_pshufw, pDst, pSrc, bEvilArg);
3815
3816 IEM_MC_ADVANCE_RIP();
3817 IEM_MC_END();
3818 }
3819 return VINF_SUCCESS;
3820}
3821
3822/** Opcode 0x66 0x0f 0x70 - pshufd Vx, Wx, Ib */
3823FNIEMOP_DEF(iemOp_pshufd_Vx_Wx_Ib)
3824{
3825 IEMOP_MNEMONIC(pshufd_Vx_Wx_Ib, "pshufd Vx,Wx,Ib");
3826 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3827 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3828 {
3829 /*
3830 * Register, register.
3831 */
3832 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3833 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3834
3835 IEM_MC_BEGIN(3, 0);
3836 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3837 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
3838 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3839 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3840 IEM_MC_PREPARE_SSE_USAGE();
3841 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3842 IEM_MC_REF_XREG_U128_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3843 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_pshufd, pDst, pSrc, bEvilArg);
3844 IEM_MC_ADVANCE_RIP();
3845 IEM_MC_END();
3846 }
3847 else
3848 {
3849 /*
3850 * Register, memory.
3851 */
3852 IEM_MC_BEGIN(3, 2);
3853 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3854 IEM_MC_LOCAL(RTUINT128U, uSrc);
3855 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
3856 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3857
3858 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3859 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3860 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3861 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3862 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3863
3864 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3865 IEM_MC_PREPARE_SSE_USAGE();
3866 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3867 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_pshufd, pDst, pSrc, bEvilArg);
3868
3869 IEM_MC_ADVANCE_RIP();
3870 IEM_MC_END();
3871 }
3872 return VINF_SUCCESS;
3873}
3874
3875/** Opcode 0xf3 0x0f 0x70 - pshufhw Vx, Wx, Ib */
3876FNIEMOP_DEF(iemOp_pshufhw_Vx_Wx_Ib)
3877{
3878 IEMOP_MNEMONIC(pshufhw_Vx_Wx_Ib, "pshufhw Vx,Wx,Ib");
3879 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3880 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3881 {
3882 /*
3883 * Register, register.
3884 */
3885 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3886 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3887
3888 IEM_MC_BEGIN(3, 0);
3889 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3890 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
3891 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3892 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3893 IEM_MC_PREPARE_SSE_USAGE();
3894 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3895 IEM_MC_REF_XREG_U128_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3896 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_pshufhw, pDst, pSrc, bEvilArg);
3897 IEM_MC_ADVANCE_RIP();
3898 IEM_MC_END();
3899 }
3900 else
3901 {
3902 /*
3903 * Register, memory.
3904 */
3905 IEM_MC_BEGIN(3, 2);
3906 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3907 IEM_MC_LOCAL(RTUINT128U, uSrc);
3908 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
3909 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3910
3911 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3912 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3913 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3914 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3915 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3916
3917 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3918 IEM_MC_PREPARE_SSE_USAGE();
3919 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3920 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_pshufhw, pDst, pSrc, bEvilArg);
3921
3922 IEM_MC_ADVANCE_RIP();
3923 IEM_MC_END();
3924 }
3925 return VINF_SUCCESS;
3926}
3927
3928/** Opcode 0xf2 0x0f 0x70 - pshuflw Vx, Wx, Ib */
3929FNIEMOP_DEF(iemOp_pshuflw_Vx_Wx_Ib)
3930{
3931 IEMOP_MNEMONIC(pshuflw_Vx_Wx_Ib, "pshuflw Vx,Wx,Ib");
3932 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
3933 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
3934 {
3935 /*
3936 * Register, register.
3937 */
3938 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3939 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3940
3941 IEM_MC_BEGIN(3, 0);
3942 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3943 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
3944 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3945 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3946 IEM_MC_PREPARE_SSE_USAGE();
3947 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3948 IEM_MC_REF_XREG_U128_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
3949 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_pshuflw, pDst, pSrc, bEvilArg);
3950 IEM_MC_ADVANCE_RIP();
3951 IEM_MC_END();
3952 }
3953 else
3954 {
3955 /*
3956 * Register, memory.
3957 */
3958 IEM_MC_BEGIN(3, 2);
3959 IEM_MC_ARG(PRTUINT128U, pDst, 0);
3960 IEM_MC_LOCAL(RTUINT128U, uSrc);
3961 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
3962 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
3963
3964 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
3965 uint8_t bEvil; IEM_OPCODE_GET_NEXT_U8(&bEvil);
3966 IEM_MC_ARG_CONST(uint8_t, bEvilArg, /*=*/ bEvil, 2);
3967 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
3968 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
3969
3970 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
3971 IEM_MC_PREPARE_SSE_USAGE();
3972 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
3973 IEM_MC_CALL_SSE_AIMPL_3(iemAImpl_pshuflw, pDst, pSrc, bEvilArg);
3974
3975 IEM_MC_ADVANCE_RIP();
3976 IEM_MC_END();
3977 }
3978 return VINF_SUCCESS;
3979}
3980
3981
3982/** Opcode 0x0f 0x71 11/2. */
3983FNIEMOP_STUB_1(iemOp_Grp12_psrlw_Nq_Ib, uint8_t, bRm);
3984
3985/** Opcode 0x66 0x0f 0x71 11/2. */
3986FNIEMOP_STUB_1(iemOp_Grp12_psrlw_Ux_Ib, uint8_t, bRm);
3987
3988/** Opcode 0x0f 0x71 11/4. */
3989FNIEMOP_STUB_1(iemOp_Grp12_psraw_Nq_Ib, uint8_t, bRm);
3990
3991/** Opcode 0x66 0x0f 0x71 11/4. */
3992FNIEMOP_STUB_1(iemOp_Grp12_psraw_Ux_Ib, uint8_t, bRm);
3993
3994/** Opcode 0x0f 0x71 11/6. */
3995FNIEMOP_STUB_1(iemOp_Grp12_psllw_Nq_Ib, uint8_t, bRm);
3996
3997/** Opcode 0x66 0x0f 0x71 11/6. */
3998FNIEMOP_STUB_1(iemOp_Grp12_psllw_Ux_Ib, uint8_t, bRm);
3999
4000
4001/**
4002 * Group 12 jump table for register variant.
4003 */
4004IEM_STATIC const PFNIEMOPRM g_apfnGroup12RegReg[] =
4005{
4006 /* /0 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4007 /* /1 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4008 /* /2 */ iemOp_Grp12_psrlw_Nq_Ib, iemOp_Grp12_psrlw_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4009 /* /3 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4010 /* /4 */ iemOp_Grp12_psraw_Nq_Ib, iemOp_Grp12_psraw_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4011 /* /5 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4012 /* /6 */ iemOp_Grp12_psllw_Nq_Ib, iemOp_Grp12_psllw_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4013 /* /7 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8)
4014};
4015AssertCompile(RT_ELEMENTS(g_apfnGroup12RegReg) == 8*4);
4016
4017
4018/** Opcode 0x0f 0x71. */
4019FNIEMOP_DEF(iemOp_Grp12)
4020{
4021 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4022 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4023 /* register, register */
4024 return FNIEMOP_CALL_1(g_apfnGroup12RegReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
4025 + pVCpu->iem.s.idxPrefix], bRm);
4026 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedImm8, bRm);
4027}
4028
4029
4030/** Opcode 0x0f 0x72 11/2. */
4031FNIEMOP_STUB_1(iemOp_Grp13_psrld_Nq_Ib, uint8_t, bRm);
4032
4033/** Opcode 0x66 0x0f 0x72 11/2. */
4034FNIEMOP_STUB_1(iemOp_Grp13_psrld_Ux_Ib, uint8_t, bRm);
4035
4036/** Opcode 0x0f 0x72 11/4. */
4037FNIEMOP_STUB_1(iemOp_Grp13_psrad_Nq_Ib, uint8_t, bRm);
4038
4039/** Opcode 0x66 0x0f 0x72 11/4. */
4040FNIEMOP_STUB_1(iemOp_Grp13_psrad_Ux_Ib, uint8_t, bRm);
4041
4042/** Opcode 0x0f 0x72 11/6. */
4043FNIEMOP_STUB_1(iemOp_Grp13_pslld_Nq_Ib, uint8_t, bRm);
4044
4045/** Opcode 0x66 0x0f 0x72 11/6. */
4046FNIEMOP_STUB_1(iemOp_Grp13_pslld_Ux_Ib, uint8_t, bRm);
4047
4048
4049/**
4050 * Group 13 jump table for register variant.
4051 */
4052IEM_STATIC const PFNIEMOPRM g_apfnGroup13RegReg[] =
4053{
4054 /* /0 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4055 /* /1 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4056 /* /2 */ iemOp_Grp13_psrld_Nq_Ib, iemOp_Grp13_psrld_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4057 /* /3 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4058 /* /4 */ iemOp_Grp13_psrad_Nq_Ib, iemOp_Grp13_psrad_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4059 /* /5 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4060 /* /6 */ iemOp_Grp13_pslld_Nq_Ib, iemOp_Grp13_pslld_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4061 /* /7 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8)
4062};
4063AssertCompile(RT_ELEMENTS(g_apfnGroup13RegReg) == 8*4);
4064
4065/** Opcode 0x0f 0x72. */
4066FNIEMOP_DEF(iemOp_Grp13)
4067{
4068 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4069 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4070 /* register, register */
4071 return FNIEMOP_CALL_1(g_apfnGroup13RegReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
4072 + pVCpu->iem.s.idxPrefix], bRm);
4073 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedImm8, bRm);
4074}
4075
4076
4077/** Opcode 0x0f 0x73 11/2. */
4078FNIEMOP_STUB_1(iemOp_Grp14_psrlq_Nq_Ib, uint8_t, bRm);
4079
4080/** Opcode 0x66 0x0f 0x73 11/2. */
4081FNIEMOP_STUB_1(iemOp_Grp14_psrlq_Ux_Ib, uint8_t, bRm);
4082
4083/** Opcode 0x66 0x0f 0x73 11/3. */
4084FNIEMOP_STUB_1(iemOp_Grp14_psrldq_Ux_Ib, uint8_t, bRm); //NEXT
4085
4086/** Opcode 0x0f 0x73 11/6. */
4087FNIEMOP_STUB_1(iemOp_Grp14_psllq_Nq_Ib, uint8_t, bRm);
4088
4089/** Opcode 0x66 0x0f 0x73 11/6. */
4090FNIEMOP_STUB_1(iemOp_Grp14_psllq_Ux_Ib, uint8_t, bRm);
4091
4092/** Opcode 0x66 0x0f 0x73 11/7. */
4093FNIEMOP_STUB_1(iemOp_Grp14_pslldq_Ux_Ib, uint8_t, bRm); //NEXT
4094
4095/**
4096 * Group 14 jump table for register variant.
4097 */
4098IEM_STATIC const PFNIEMOPRM g_apfnGroup14RegReg[] =
4099{
4100 /* /0 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4101 /* /1 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4102 /* /2 */ iemOp_Grp14_psrlq_Nq_Ib, iemOp_Grp14_psrlq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4103 /* /3 */ iemOp_InvalidWithRMNeedImm8, iemOp_Grp14_psrldq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4104 /* /4 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4105 /* /5 */ IEMOP_X4(iemOp_InvalidWithRMNeedImm8),
4106 /* /6 */ iemOp_Grp14_psllq_Nq_Ib, iemOp_Grp14_psllq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4107 /* /7 */ iemOp_InvalidWithRMNeedImm8, iemOp_Grp14_pslldq_Ux_Ib, iemOp_InvalidWithRMNeedImm8, iemOp_InvalidWithRMNeedImm8,
4108};
4109AssertCompile(RT_ELEMENTS(g_apfnGroup14RegReg) == 8*4);
4110
4111
4112/** Opcode 0x0f 0x73. */
4113FNIEMOP_DEF(iemOp_Grp14)
4114{
4115 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4116 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4117 /* register, register */
4118 return FNIEMOP_CALL_1(g_apfnGroup14RegReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
4119 + pVCpu->iem.s.idxPrefix], bRm);
4120 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedImm8, bRm);
4121}
4122
4123
4124/**
4125 * Common worker for MMX instructions on the form:
4126 * pxxx mm1, mm2/mem64
4127 */
4128FNIEMOP_DEF_1(iemOpCommonMmx_FullFull_To_Full, PCIEMOPMEDIAF2, pImpl)
4129{
4130 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4131 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4132 {
4133 /*
4134 * Register, register.
4135 */
4136 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
4137 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
4138 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4139 IEM_MC_BEGIN(2, 0);
4140 IEM_MC_ARG(uint64_t *, pDst, 0);
4141 IEM_MC_ARG(uint64_t const *, pSrc, 1);
4142 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4143 IEM_MC_PREPARE_FPU_USAGE();
4144 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4145 IEM_MC_REF_MREG_U64_CONST(pSrc, bRm & X86_MODRM_RM_MASK);
4146 IEM_MC_CALL_MMX_AIMPL_2(pImpl->pfnU64, pDst, pSrc);
4147 IEM_MC_ADVANCE_RIP();
4148 IEM_MC_END();
4149 }
4150 else
4151 {
4152 /*
4153 * Register, memory.
4154 */
4155 IEM_MC_BEGIN(2, 2);
4156 IEM_MC_ARG(uint64_t *, pDst, 0);
4157 IEM_MC_LOCAL(uint64_t, uSrc);
4158 IEM_MC_ARG_LOCAL_REF(uint64_t const *, pSrc, uSrc, 1);
4159 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4160
4161 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4162 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4163 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4164 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4165
4166 IEM_MC_PREPARE_FPU_USAGE();
4167 IEM_MC_REF_MREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4168 IEM_MC_CALL_MMX_AIMPL_2(pImpl->pfnU64, pDst, pSrc);
4169
4170 IEM_MC_ADVANCE_RIP();
4171 IEM_MC_END();
4172 }
4173 return VINF_SUCCESS;
4174}
4175
4176
4177/**
4178 * Common worker for SSE2 instructions on the forms:
4179 * pxxx xmm1, xmm2/mem128
4180 *
4181 * Proper alignment of the 128-bit operand is enforced.
4182 * Exceptions type 4. SSE2 cpuid checks.
4183 */
4184FNIEMOP_DEF_1(iemOpCommonSse2_FullFull_To_Full, PCIEMOPMEDIAF2, pImpl)
4185{
4186 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4187 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4188 {
4189 /*
4190 * Register, register.
4191 */
4192 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4193 IEM_MC_BEGIN(2, 0);
4194 IEM_MC_ARG(PRTUINT128U, pDst, 0);
4195 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
4196 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4197 IEM_MC_PREPARE_SSE_USAGE();
4198 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4199 IEM_MC_REF_XREG_U128_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
4200 IEM_MC_CALL_SSE_AIMPL_2(pImpl->pfnU128, pDst, pSrc);
4201 IEM_MC_ADVANCE_RIP();
4202 IEM_MC_END();
4203 }
4204 else
4205 {
4206 /*
4207 * Register, memory.
4208 */
4209 IEM_MC_BEGIN(2, 2);
4210 IEM_MC_ARG(PRTUINT128U, pDst, 0);
4211 IEM_MC_LOCAL(RTUINT128U, uSrc);
4212 IEM_MC_ARG_LOCAL_REF(PCRTUINT128U, pSrc, uSrc, 1);
4213 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4214
4215 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4216 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4217 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4218 IEM_MC_FETCH_MEM_U128_ALIGN_SSE(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4219
4220 IEM_MC_PREPARE_SSE_USAGE();
4221 IEM_MC_REF_XREG_U128(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4222 IEM_MC_CALL_SSE_AIMPL_2(pImpl->pfnU128, pDst, pSrc);
4223
4224 IEM_MC_ADVANCE_RIP();
4225 IEM_MC_END();
4226 }
4227 return VINF_SUCCESS;
4228}
4229
4230
4231/** Opcode 0x0f 0x74 - pcmpeqb Pq, Qq */
4232FNIEMOP_DEF(iemOp_pcmpeqb_Pq_Qq)
4233{
4234 IEMOP_MNEMONIC(pcmpeqb, "pcmpeqb");
4235 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, &g_iemAImpl_pcmpeqb);
4236}
4237
4238/** Opcode 0x66 0x0f 0x74 - pcmpeqb Vx, Wx */
4239FNIEMOP_DEF(iemOp_pcmpeqb_Vx_Wx)
4240{
4241 IEMOP_MNEMONIC(vpcmpeqb_Vx_Wx, "pcmpeqb");
4242 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, &g_iemAImpl_pcmpeqb);
4243}
4244
4245/* Opcode 0xf3 0x0f 0x74 - invalid */
4246/* Opcode 0xf2 0x0f 0x74 - invalid */
4247
4248
4249/** Opcode 0x0f 0x75 - pcmpeqw Pq, Qq */
4250FNIEMOP_DEF(iemOp_pcmpeqw_Pq_Qq)
4251{
4252 IEMOP_MNEMONIC(pcmpeqw, "pcmpeqw");
4253 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, &g_iemAImpl_pcmpeqw);
4254}
4255
4256/** Opcode 0x66 0x0f 0x75 - pcmpeqw Vx, Wx */
4257FNIEMOP_DEF(iemOp_pcmpeqw_Vx_Wx)
4258{
4259 IEMOP_MNEMONIC(pcmpeqw_Vx_Wx, "pcmpeqw");
4260 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, &g_iemAImpl_pcmpeqw);
4261}
4262
4263/* Opcode 0xf3 0x0f 0x75 - invalid */
4264/* Opcode 0xf2 0x0f 0x75 - invalid */
4265
4266
4267/** Opcode 0x0f 0x76 - pcmpeqd Pq, Qq */
4268FNIEMOP_DEF(iemOp_pcmpeqd_Pq_Qq)
4269{
4270 IEMOP_MNEMONIC(pcmpeqd, "pcmpeqd");
4271 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, &g_iemAImpl_pcmpeqd);
4272}
4273
4274/** Opcode 0x66 0x0f 0x76 - pcmpeqd Vx, Wx */
4275FNIEMOP_DEF(iemOp_pcmpeqd_Vx_Wx)
4276{
4277 IEMOP_MNEMONIC(pcmpeqd_Vx_Wx, "vpcmpeqd");
4278 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, &g_iemAImpl_pcmpeqd);
4279}
4280
4281/* Opcode 0xf3 0x0f 0x76 - invalid */
4282/* Opcode 0xf2 0x0f 0x76 - invalid */
4283
4284
4285/** Opcode 0x0f 0x77 - emms (vex has vzeroall and vzeroupper here) */
4286FNIEMOP_DEF(iemOp_emms)
4287{
4288 IEMOP_MNEMONIC(emms, "emms");
4289 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4290
4291 IEM_MC_BEGIN(0,0);
4292 IEM_MC_MAYBE_RAISE_DEVICE_NOT_AVAILABLE();
4293 IEM_MC_MAYBE_RAISE_FPU_XCPT();
4294 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
4295 IEM_MC_FPU_FROM_MMX_MODE();
4296 IEM_MC_ADVANCE_RIP();
4297 IEM_MC_END();
4298 return VINF_SUCCESS;
4299}
4300
4301/* Opcode 0x66 0x0f 0x77 - invalid */
4302/* Opcode 0xf3 0x0f 0x77 - invalid */
4303/* Opcode 0xf2 0x0f 0x77 - invalid */
4304
4305/** Opcode 0x0f 0x78 - VMREAD Ey, Gy */
4306#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
4307FNIEMOP_DEF(iemOp_vmread_Ey_Gy)
4308{
4309 IEMOP_MNEMONIC(vmread, "vmread Ey,Gy");
4310 IEMOP_HLP_IN_VMX_OPERATION("vmread", kVmxVDiag_Vmread);
4311 IEMOP_HLP_VMX_INSTR("vmread", kVmxVDiag_Vmread);
4312 IEMMODE const enmEffOpSize = pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT ? IEMMODE_64BIT : IEMMODE_32BIT;
4313
4314 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4315 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4316 {
4317 /*
4318 * Register, register.
4319 */
4320 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
4321 if (enmEffOpSize == IEMMODE_64BIT)
4322 {
4323 IEM_MC_BEGIN(2, 0);
4324 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
4325 IEM_MC_ARG(uint64_t, u64Enc, 1);
4326 IEM_MC_FETCH_GREG_U64(u64Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4327 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
4328 IEM_MC_CALL_CIMPL_2(iemCImpl_vmread_reg64, pu64Dst, u64Enc);
4329 IEM_MC_END();
4330 }
4331 else
4332 {
4333 IEM_MC_BEGIN(2, 0);
4334 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
4335 IEM_MC_ARG(uint32_t, u32Enc, 1);
4336 IEM_MC_FETCH_GREG_U32(u32Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4337 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
4338 IEM_MC_CALL_CIMPL_2(iemCImpl_vmread_reg32, pu32Dst, u32Enc);
4339 IEM_MC_END();
4340 }
4341 }
4342 else
4343 {
4344 /*
4345 * Memory, register.
4346 */
4347 if (enmEffOpSize == IEMMODE_64BIT)
4348 {
4349 IEM_MC_BEGIN(3, 0);
4350 IEM_MC_ARG(uint8_t, iEffSeg, 0);
4351 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
4352 IEM_MC_ARG(uint64_t, u64Enc, 2);
4353 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
4354 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
4355 IEM_MC_FETCH_GREG_U64(u64Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4356 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
4357 IEM_MC_CALL_CIMPL_3(iemCImpl_vmread_mem_reg64, iEffSeg, GCPtrVal, u64Enc);
4358 IEM_MC_END();
4359 }
4360 else
4361 {
4362 IEM_MC_BEGIN(3, 0);
4363 IEM_MC_ARG(uint8_t, iEffSeg, 0);
4364 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
4365 IEM_MC_ARG(uint32_t, u32Enc, 2);
4366 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
4367 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
4368 IEM_MC_FETCH_GREG_U32(u32Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4369 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
4370 IEM_MC_CALL_CIMPL_3(iemCImpl_vmread_mem_reg32, iEffSeg, GCPtrVal, u32Enc);
4371 IEM_MC_END();
4372 }
4373 }
4374 return VINF_SUCCESS;
4375}
4376#else
4377FNIEMOP_STUB(iemOp_vmread_Ey_Gy);
4378#endif
4379
4380/* Opcode 0x66 0x0f 0x78 - AMD Group 17 */
4381FNIEMOP_STUB(iemOp_AmdGrp17);
4382/* Opcode 0xf3 0x0f 0x78 - invalid */
4383/* Opcode 0xf2 0x0f 0x78 - invalid */
4384
4385/** Opcode 0x0f 0x79 - VMWRITE Gy, Ey */
4386#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
4387FNIEMOP_DEF(iemOp_vmwrite_Gy_Ey)
4388{
4389 IEMOP_MNEMONIC(vmwrite, "vmwrite Gy,Ey");
4390 IEMOP_HLP_IN_VMX_OPERATION("vmwrite", kVmxVDiag_Vmwrite);
4391 IEMOP_HLP_VMX_INSTR("vmwrite", kVmxVDiag_Vmwrite);
4392 IEMMODE const enmEffOpSize = pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT ? IEMMODE_64BIT : IEMMODE_32BIT;
4393
4394 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4395 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4396 {
4397 /*
4398 * Register, register.
4399 */
4400 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
4401 if (enmEffOpSize == IEMMODE_64BIT)
4402 {
4403 IEM_MC_BEGIN(2, 0);
4404 IEM_MC_ARG(uint64_t, u64Val, 0);
4405 IEM_MC_ARG(uint64_t, u64Enc, 1);
4406 IEM_MC_FETCH_GREG_U64(u64Val, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
4407 IEM_MC_FETCH_GREG_U64(u64Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4408 IEM_MC_CALL_CIMPL_2(iemCImpl_vmwrite_reg, u64Val, u64Enc);
4409 IEM_MC_END();
4410 }
4411 else
4412 {
4413 IEM_MC_BEGIN(2, 0);
4414 IEM_MC_ARG(uint32_t, u32Val, 0);
4415 IEM_MC_ARG(uint32_t, u32Enc, 1);
4416 IEM_MC_FETCH_GREG_U32(u32Val, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
4417 IEM_MC_FETCH_GREG_U32(u32Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4418 IEM_MC_CALL_CIMPL_2(iemCImpl_vmwrite_reg, u32Val, u32Enc);
4419 IEM_MC_END();
4420 }
4421 }
4422 else
4423 {
4424 /*
4425 * Register, memory.
4426 */
4427 if (enmEffOpSize == IEMMODE_64BIT)
4428 {
4429 IEM_MC_BEGIN(3, 0);
4430 IEM_MC_ARG(uint8_t, iEffSeg, 0);
4431 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
4432 IEM_MC_ARG(uint64_t, u64Enc, 2);
4433 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
4434 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
4435 IEM_MC_FETCH_GREG_U64(u64Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4436 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
4437 IEM_MC_CALL_CIMPL_3(iemCImpl_vmwrite_mem, iEffSeg, GCPtrVal, u64Enc);
4438 IEM_MC_END();
4439 }
4440 else
4441 {
4442 IEM_MC_BEGIN(3, 0);
4443 IEM_MC_ARG(uint8_t, iEffSeg, 0);
4444 IEM_MC_ARG(RTGCPTR, GCPtrVal, 1);
4445 IEM_MC_ARG(uint32_t, u32Enc, 2);
4446 IEM_MC_CALC_RM_EFF_ADDR(GCPtrVal, bRm, 0);
4447 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
4448 IEM_MC_FETCH_GREG_U32(u32Enc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4449 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
4450 IEM_MC_CALL_CIMPL_3(iemCImpl_vmwrite_mem, iEffSeg, GCPtrVal, u32Enc);
4451 IEM_MC_END();
4452 }
4453 }
4454 return VINF_SUCCESS;
4455}
4456#else
4457FNIEMOP_STUB(iemOp_vmwrite_Gy_Ey);
4458#endif
4459/* Opcode 0x66 0x0f 0x79 - invalid */
4460/* Opcode 0xf3 0x0f 0x79 - invalid */
4461/* Opcode 0xf2 0x0f 0x79 - invalid */
4462
4463/* Opcode 0x0f 0x7a - invalid */
4464/* Opcode 0x66 0x0f 0x7a - invalid */
4465/* Opcode 0xf3 0x0f 0x7a - invalid */
4466/* Opcode 0xf2 0x0f 0x7a - invalid */
4467
4468/* Opcode 0x0f 0x7b - invalid */
4469/* Opcode 0x66 0x0f 0x7b - invalid */
4470/* Opcode 0xf3 0x0f 0x7b - invalid */
4471/* Opcode 0xf2 0x0f 0x7b - invalid */
4472
4473/* Opcode 0x0f 0x7c - invalid */
4474/** Opcode 0x66 0x0f 0x7c - haddpd Vpd, Wpd */
4475FNIEMOP_STUB(iemOp_haddpd_Vpd_Wpd);
4476/* Opcode 0xf3 0x0f 0x7c - invalid */
4477/** Opcode 0xf2 0x0f 0x7c - haddps Vps, Wps */
4478FNIEMOP_STUB(iemOp_haddps_Vps_Wps);
4479
4480/* Opcode 0x0f 0x7d - invalid */
4481/** Opcode 0x66 0x0f 0x7d - hsubpd Vpd, Wpd */
4482FNIEMOP_STUB(iemOp_hsubpd_Vpd_Wpd);
4483/* Opcode 0xf3 0x0f 0x7d - invalid */
4484/** Opcode 0xf2 0x0f 0x7d - hsubps Vps, Wps */
4485FNIEMOP_STUB(iemOp_hsubps_Vps_Wps);
4486
4487
4488/** Opcode 0x0f 0x7e - movd_q Ey, Pd */
4489FNIEMOP_DEF(iemOp_movd_q_Ey_Pd)
4490{
4491 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4492 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
4493 {
4494 /**
4495 * @opcode 0x7e
4496 * @opcodesub rex.w=1
4497 * @oppfx none
4498 * @opcpuid mmx
4499 * @opgroup og_mmx_datamove
4500 * @opxcpttype 5
4501 * @optest 64-bit / op1=1 op2=2 -> op1=2 ftw=0xff
4502 * @optest 64-bit / op1=0 op2=-42 -> op1=-42 ftw=0xff
4503 */
4504 IEMOP_MNEMONIC2(MR, MOVQ, movq, Eq_WO, Pq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
4505 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4506 {
4507 /* greg64, MMX */
4508 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4509 IEM_MC_BEGIN(0, 1);
4510 IEM_MC_LOCAL(uint64_t, u64Tmp);
4511
4512 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4513 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
4514
4515 IEM_MC_FETCH_MREG_U64(u64Tmp, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4516 IEM_MC_STORE_GREG_U64((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u64Tmp);
4517 IEM_MC_FPU_TO_MMX_MODE();
4518
4519 IEM_MC_ADVANCE_RIP();
4520 IEM_MC_END();
4521 }
4522 else
4523 {
4524 /* [mem64], MMX */
4525 IEM_MC_BEGIN(0, 2);
4526 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4527 IEM_MC_LOCAL(uint64_t, u64Tmp);
4528
4529 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4530 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4531 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4532 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
4533
4534 IEM_MC_FETCH_MREG_U64(u64Tmp, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4535 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u64Tmp);
4536 IEM_MC_FPU_TO_MMX_MODE();
4537
4538 IEM_MC_ADVANCE_RIP();
4539 IEM_MC_END();
4540 }
4541 }
4542 else
4543 {
4544 /**
4545 * @opdone
4546 * @opcode 0x7e
4547 * @opcodesub rex.w=0
4548 * @oppfx none
4549 * @opcpuid mmx
4550 * @opgroup og_mmx_datamove
4551 * @opxcpttype 5
4552 * @opfunction iemOp_movd_q_Pd_Ey
4553 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
4554 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
4555 */
4556 IEMOP_MNEMONIC2(MR, MOVD, movd, Ed_WO, Pd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
4557 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4558 {
4559 /* greg32, MMX */
4560 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4561 IEM_MC_BEGIN(0, 1);
4562 IEM_MC_LOCAL(uint32_t, u32Tmp);
4563
4564 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4565 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
4566
4567 IEM_MC_FETCH_MREG_U32(u32Tmp, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4568 IEM_MC_STORE_GREG_U32((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u32Tmp);
4569 IEM_MC_FPU_TO_MMX_MODE();
4570
4571 IEM_MC_ADVANCE_RIP();
4572 IEM_MC_END();
4573 }
4574 else
4575 {
4576 /* [mem32], MMX */
4577 IEM_MC_BEGIN(0, 2);
4578 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4579 IEM_MC_LOCAL(uint32_t, u32Tmp);
4580
4581 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4582 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4583 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4584 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
4585
4586 IEM_MC_FETCH_MREG_U32(u32Tmp, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4587 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u32Tmp);
4588 IEM_MC_FPU_TO_MMX_MODE();
4589
4590 IEM_MC_ADVANCE_RIP();
4591 IEM_MC_END();
4592 }
4593 }
4594 return VINF_SUCCESS;
4595
4596}
4597
4598
4599FNIEMOP_DEF(iemOp_movd_q_Ey_Vy)
4600{
4601 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4602 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
4603 {
4604 /**
4605 * @opcode 0x7e
4606 * @opcodesub rex.w=1
4607 * @oppfx 0x66
4608 * @opcpuid sse2
4609 * @opgroup og_sse2_simdint_datamove
4610 * @opxcpttype 5
4611 * @optest 64-bit / op1=1 op2=2 -> op1=2
4612 * @optest 64-bit / op1=0 op2=-42 -> op1=-42
4613 */
4614 IEMOP_MNEMONIC2(MR, MOVQ, movq, Eq_WO, Vq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
4615 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4616 {
4617 /* greg64, XMM */
4618 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4619 IEM_MC_BEGIN(0, 1);
4620 IEM_MC_LOCAL(uint64_t, u64Tmp);
4621
4622 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4623 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
4624
4625 IEM_MC_FETCH_XREG_U64(u64Tmp, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4626 IEM_MC_STORE_GREG_U64((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u64Tmp);
4627
4628 IEM_MC_ADVANCE_RIP();
4629 IEM_MC_END();
4630 }
4631 else
4632 {
4633 /* [mem64], XMM */
4634 IEM_MC_BEGIN(0, 2);
4635 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4636 IEM_MC_LOCAL(uint64_t, u64Tmp);
4637
4638 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4639 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4640 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4641 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
4642
4643 IEM_MC_FETCH_XREG_U64(u64Tmp, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4644 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u64Tmp);
4645
4646 IEM_MC_ADVANCE_RIP();
4647 IEM_MC_END();
4648 }
4649 }
4650 else
4651 {
4652 /**
4653 * @opdone
4654 * @opcode 0x7e
4655 * @opcodesub rex.w=0
4656 * @oppfx 0x66
4657 * @opcpuid sse2
4658 * @opgroup og_sse2_simdint_datamove
4659 * @opxcpttype 5
4660 * @opfunction iemOp_movd_q_Vy_Ey
4661 * @optest op1=1 op2=2 -> op1=2
4662 * @optest op1=0 op2=-42 -> op1=-42
4663 */
4664 IEMOP_MNEMONIC2(MR, MOVD, movd, Ed_WO, Vd, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OZ_PFX);
4665 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4666 {
4667 /* greg32, XMM */
4668 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4669 IEM_MC_BEGIN(0, 1);
4670 IEM_MC_LOCAL(uint32_t, u32Tmp);
4671
4672 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4673 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
4674
4675 IEM_MC_FETCH_XREG_U32(u32Tmp, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4676 IEM_MC_STORE_GREG_U32((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u32Tmp);
4677
4678 IEM_MC_ADVANCE_RIP();
4679 IEM_MC_END();
4680 }
4681 else
4682 {
4683 /* [mem32], XMM */
4684 IEM_MC_BEGIN(0, 2);
4685 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4686 IEM_MC_LOCAL(uint32_t, u32Tmp);
4687
4688 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4689 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4690 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4691 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
4692
4693 IEM_MC_FETCH_XREG_U32(u32Tmp, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4694 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u32Tmp);
4695
4696 IEM_MC_ADVANCE_RIP();
4697 IEM_MC_END();
4698 }
4699 }
4700 return VINF_SUCCESS;
4701
4702}
4703
4704/**
4705 * @opcode 0x7e
4706 * @oppfx 0xf3
4707 * @opcpuid sse2
4708 * @opgroup og_sse2_pcksclr_datamove
4709 * @opxcpttype none
4710 * @optest op1=1 op2=2 -> op1=2
4711 * @optest op1=0 op2=-42 -> op1=-42
4712 */
4713FNIEMOP_DEF(iemOp_movq_Vq_Wq)
4714{
4715 IEMOP_MNEMONIC2(RM, MOVQ, movq, VqZx_WO, Wq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
4716 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4717 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4718 {
4719 /*
4720 * Register, register.
4721 */
4722 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4723 IEM_MC_BEGIN(0, 2);
4724 IEM_MC_LOCAL(uint64_t, uSrc);
4725
4726 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4727 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
4728
4729 IEM_MC_FETCH_XREG_U64(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
4730 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
4731
4732 IEM_MC_ADVANCE_RIP();
4733 IEM_MC_END();
4734 }
4735 else
4736 {
4737 /*
4738 * Memory, register.
4739 */
4740 IEM_MC_BEGIN(0, 2);
4741 IEM_MC_LOCAL(uint64_t, uSrc);
4742 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4743
4744 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4745 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4746 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4747 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
4748
4749 IEM_MC_FETCH_MEM_U64(uSrc, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
4750 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
4751
4752 IEM_MC_ADVANCE_RIP();
4753 IEM_MC_END();
4754 }
4755 return VINF_SUCCESS;
4756}
4757
4758/* Opcode 0xf2 0x0f 0x7e - invalid */
4759
4760
4761/** Opcode 0x0f 0x7f - movq Qq, Pq */
4762FNIEMOP_DEF(iemOp_movq_Qq_Pq)
4763{
4764 IEMOP_MNEMONIC(movq_Qq_Pq, "movq Qq,Pq");
4765 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4766 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4767 {
4768 /*
4769 * Register, register.
4770 */
4771 /** @todo testcase: REX.B / REX.R and MMX register indexing. Ignored? */
4772 /** @todo testcase: REX.B / REX.R and segment register indexing. Ignored? */
4773 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4774 IEM_MC_BEGIN(0, 1);
4775 IEM_MC_LOCAL(uint64_t, u64Tmp);
4776 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4777 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
4778 IEM_MC_FETCH_MREG_U64(u64Tmp, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4779 IEM_MC_STORE_MREG_U64(bRm & X86_MODRM_RM_MASK, u64Tmp);
4780 IEM_MC_ADVANCE_RIP();
4781 IEM_MC_END();
4782 }
4783 else
4784 {
4785 /*
4786 * Register, memory.
4787 */
4788 IEM_MC_BEGIN(0, 2);
4789 IEM_MC_LOCAL(uint64_t, u64Tmp);
4790 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4791
4792 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4793 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4794 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
4795 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
4796
4797 IEM_MC_FETCH_MREG_U64(u64Tmp, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
4798 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u64Tmp);
4799
4800 IEM_MC_ADVANCE_RIP();
4801 IEM_MC_END();
4802 }
4803 return VINF_SUCCESS;
4804}
4805
4806/** Opcode 0x66 0x0f 0x7f - movdqa Wx,Vx */
4807FNIEMOP_DEF(iemOp_movdqa_Wx_Vx)
4808{
4809 IEMOP_MNEMONIC(movdqa_Wdq_Vdq, "movdqa Wx,Vx");
4810 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4811 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4812 {
4813 /*
4814 * Register, register.
4815 */
4816 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4817 IEM_MC_BEGIN(0, 0);
4818 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4819 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
4820 IEM_MC_COPY_XREG_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB,
4821 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4822 IEM_MC_ADVANCE_RIP();
4823 IEM_MC_END();
4824 }
4825 else
4826 {
4827 /*
4828 * Register, memory.
4829 */
4830 IEM_MC_BEGIN(0, 2);
4831 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
4832 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4833
4834 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4835 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4836 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4837 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
4838
4839 IEM_MC_FETCH_XREG_U128(u128Tmp, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4840 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u128Tmp);
4841
4842 IEM_MC_ADVANCE_RIP();
4843 IEM_MC_END();
4844 }
4845 return VINF_SUCCESS;
4846}
4847
4848/** Opcode 0xf3 0x0f 0x7f - movdqu Wx,Vx */
4849FNIEMOP_DEF(iemOp_movdqu_Wx_Vx)
4850{
4851 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
4852 IEMOP_MNEMONIC(movdqu_Wdq_Vdq, "movdqu Wx,Vx");
4853 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
4854 {
4855 /*
4856 * Register, register.
4857 */
4858 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4859 IEM_MC_BEGIN(0, 0);
4860 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4861 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
4862 IEM_MC_COPY_XREG_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB,
4863 ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4864 IEM_MC_ADVANCE_RIP();
4865 IEM_MC_END();
4866 }
4867 else
4868 {
4869 /*
4870 * Register, memory.
4871 */
4872 IEM_MC_BEGIN(0, 2);
4873 IEM_MC_LOCAL(RTUINT128U, u128Tmp);
4874 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
4875
4876 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
4877 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4878 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
4879 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
4880
4881 IEM_MC_FETCH_XREG_U128(u128Tmp, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
4882 IEM_MC_STORE_MEM_U128(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, u128Tmp);
4883
4884 IEM_MC_ADVANCE_RIP();
4885 IEM_MC_END();
4886 }
4887 return VINF_SUCCESS;
4888}
4889
4890/* Opcode 0xf2 0x0f 0x7f - invalid */
4891
4892
4893
4894/** Opcode 0x0f 0x80. */
4895FNIEMOP_DEF(iemOp_jo_Jv)
4896{
4897 IEMOP_MNEMONIC(jo_Jv, "jo Jv");
4898 IEMOP_HLP_MIN_386();
4899 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
4900 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
4901 {
4902 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
4903 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4904
4905 IEM_MC_BEGIN(0, 0);
4906 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
4907 IEM_MC_REL_JMP_S16(i16Imm);
4908 } IEM_MC_ELSE() {
4909 IEM_MC_ADVANCE_RIP();
4910 } IEM_MC_ENDIF();
4911 IEM_MC_END();
4912 }
4913 else
4914 {
4915 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
4916 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4917
4918 IEM_MC_BEGIN(0, 0);
4919 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
4920 IEM_MC_REL_JMP_S32(i32Imm);
4921 } IEM_MC_ELSE() {
4922 IEM_MC_ADVANCE_RIP();
4923 } IEM_MC_ENDIF();
4924 IEM_MC_END();
4925 }
4926 return VINF_SUCCESS;
4927}
4928
4929
4930/** Opcode 0x0f 0x81. */
4931FNIEMOP_DEF(iemOp_jno_Jv)
4932{
4933 IEMOP_MNEMONIC(jno_Jv, "jno Jv");
4934 IEMOP_HLP_MIN_386();
4935 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
4936 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
4937 {
4938 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
4939 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4940
4941 IEM_MC_BEGIN(0, 0);
4942 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
4943 IEM_MC_ADVANCE_RIP();
4944 } IEM_MC_ELSE() {
4945 IEM_MC_REL_JMP_S16(i16Imm);
4946 } IEM_MC_ENDIF();
4947 IEM_MC_END();
4948 }
4949 else
4950 {
4951 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
4952 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4953
4954 IEM_MC_BEGIN(0, 0);
4955 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
4956 IEM_MC_ADVANCE_RIP();
4957 } IEM_MC_ELSE() {
4958 IEM_MC_REL_JMP_S32(i32Imm);
4959 } IEM_MC_ENDIF();
4960 IEM_MC_END();
4961 }
4962 return VINF_SUCCESS;
4963}
4964
4965
4966/** Opcode 0x0f 0x82. */
4967FNIEMOP_DEF(iemOp_jc_Jv)
4968{
4969 IEMOP_MNEMONIC(jc_Jv, "jc/jb/jnae Jv");
4970 IEMOP_HLP_MIN_386();
4971 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
4972 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
4973 {
4974 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
4975 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4976
4977 IEM_MC_BEGIN(0, 0);
4978 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
4979 IEM_MC_REL_JMP_S16(i16Imm);
4980 } IEM_MC_ELSE() {
4981 IEM_MC_ADVANCE_RIP();
4982 } IEM_MC_ENDIF();
4983 IEM_MC_END();
4984 }
4985 else
4986 {
4987 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
4988 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
4989
4990 IEM_MC_BEGIN(0, 0);
4991 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
4992 IEM_MC_REL_JMP_S32(i32Imm);
4993 } IEM_MC_ELSE() {
4994 IEM_MC_ADVANCE_RIP();
4995 } IEM_MC_ENDIF();
4996 IEM_MC_END();
4997 }
4998 return VINF_SUCCESS;
4999}
5000
5001
5002/** Opcode 0x0f 0x83. */
5003FNIEMOP_DEF(iemOp_jnc_Jv)
5004{
5005 IEMOP_MNEMONIC(jnc_Jv, "jnc/jnb/jae Jv");
5006 IEMOP_HLP_MIN_386();
5007 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5008 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5009 {
5010 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5011 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5012
5013 IEM_MC_BEGIN(0, 0);
5014 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
5015 IEM_MC_ADVANCE_RIP();
5016 } IEM_MC_ELSE() {
5017 IEM_MC_REL_JMP_S16(i16Imm);
5018 } IEM_MC_ENDIF();
5019 IEM_MC_END();
5020 }
5021 else
5022 {
5023 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5024 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5025
5026 IEM_MC_BEGIN(0, 0);
5027 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
5028 IEM_MC_ADVANCE_RIP();
5029 } IEM_MC_ELSE() {
5030 IEM_MC_REL_JMP_S32(i32Imm);
5031 } IEM_MC_ENDIF();
5032 IEM_MC_END();
5033 }
5034 return VINF_SUCCESS;
5035}
5036
5037
5038/** Opcode 0x0f 0x84. */
5039FNIEMOP_DEF(iemOp_je_Jv)
5040{
5041 IEMOP_MNEMONIC(je_Jv, "je/jz Jv");
5042 IEMOP_HLP_MIN_386();
5043 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5044 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5045 {
5046 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5047 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5048
5049 IEM_MC_BEGIN(0, 0);
5050 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5051 IEM_MC_REL_JMP_S16(i16Imm);
5052 } IEM_MC_ELSE() {
5053 IEM_MC_ADVANCE_RIP();
5054 } IEM_MC_ENDIF();
5055 IEM_MC_END();
5056 }
5057 else
5058 {
5059 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5060 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5061
5062 IEM_MC_BEGIN(0, 0);
5063 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5064 IEM_MC_REL_JMP_S32(i32Imm);
5065 } IEM_MC_ELSE() {
5066 IEM_MC_ADVANCE_RIP();
5067 } IEM_MC_ENDIF();
5068 IEM_MC_END();
5069 }
5070 return VINF_SUCCESS;
5071}
5072
5073
5074/** Opcode 0x0f 0x85. */
5075FNIEMOP_DEF(iemOp_jne_Jv)
5076{
5077 IEMOP_MNEMONIC(jne_Jv, "jne/jnz Jv");
5078 IEMOP_HLP_MIN_386();
5079 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5080 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5081 {
5082 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5083 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5084
5085 IEM_MC_BEGIN(0, 0);
5086 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5087 IEM_MC_ADVANCE_RIP();
5088 } IEM_MC_ELSE() {
5089 IEM_MC_REL_JMP_S16(i16Imm);
5090 } IEM_MC_ENDIF();
5091 IEM_MC_END();
5092 }
5093 else
5094 {
5095 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5096 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5097
5098 IEM_MC_BEGIN(0, 0);
5099 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5100 IEM_MC_ADVANCE_RIP();
5101 } IEM_MC_ELSE() {
5102 IEM_MC_REL_JMP_S32(i32Imm);
5103 } IEM_MC_ENDIF();
5104 IEM_MC_END();
5105 }
5106 return VINF_SUCCESS;
5107}
5108
5109
5110/** Opcode 0x0f 0x86. */
5111FNIEMOP_DEF(iemOp_jbe_Jv)
5112{
5113 IEMOP_MNEMONIC(jbe_Jv, "jbe/jna Jv");
5114 IEMOP_HLP_MIN_386();
5115 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5116 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5117 {
5118 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5119 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5120
5121 IEM_MC_BEGIN(0, 0);
5122 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5123 IEM_MC_REL_JMP_S16(i16Imm);
5124 } IEM_MC_ELSE() {
5125 IEM_MC_ADVANCE_RIP();
5126 } IEM_MC_ENDIF();
5127 IEM_MC_END();
5128 }
5129 else
5130 {
5131 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5132 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5133
5134 IEM_MC_BEGIN(0, 0);
5135 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5136 IEM_MC_REL_JMP_S32(i32Imm);
5137 } IEM_MC_ELSE() {
5138 IEM_MC_ADVANCE_RIP();
5139 } IEM_MC_ENDIF();
5140 IEM_MC_END();
5141 }
5142 return VINF_SUCCESS;
5143}
5144
5145
5146/** Opcode 0x0f 0x87. */
5147FNIEMOP_DEF(iemOp_jnbe_Jv)
5148{
5149 IEMOP_MNEMONIC(ja_Jv, "jnbe/ja Jv");
5150 IEMOP_HLP_MIN_386();
5151 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5152 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5153 {
5154 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5155 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5156
5157 IEM_MC_BEGIN(0, 0);
5158 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5159 IEM_MC_ADVANCE_RIP();
5160 } IEM_MC_ELSE() {
5161 IEM_MC_REL_JMP_S16(i16Imm);
5162 } IEM_MC_ENDIF();
5163 IEM_MC_END();
5164 }
5165 else
5166 {
5167 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5168 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5169
5170 IEM_MC_BEGIN(0, 0);
5171 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5172 IEM_MC_ADVANCE_RIP();
5173 } IEM_MC_ELSE() {
5174 IEM_MC_REL_JMP_S32(i32Imm);
5175 } IEM_MC_ENDIF();
5176 IEM_MC_END();
5177 }
5178 return VINF_SUCCESS;
5179}
5180
5181
5182/** Opcode 0x0f 0x88. */
5183FNIEMOP_DEF(iemOp_js_Jv)
5184{
5185 IEMOP_MNEMONIC(js_Jv, "js Jv");
5186 IEMOP_HLP_MIN_386();
5187 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5188 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5189 {
5190 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5191 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5192
5193 IEM_MC_BEGIN(0, 0);
5194 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5195 IEM_MC_REL_JMP_S16(i16Imm);
5196 } IEM_MC_ELSE() {
5197 IEM_MC_ADVANCE_RIP();
5198 } IEM_MC_ENDIF();
5199 IEM_MC_END();
5200 }
5201 else
5202 {
5203 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5204 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5205
5206 IEM_MC_BEGIN(0, 0);
5207 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5208 IEM_MC_REL_JMP_S32(i32Imm);
5209 } IEM_MC_ELSE() {
5210 IEM_MC_ADVANCE_RIP();
5211 } IEM_MC_ENDIF();
5212 IEM_MC_END();
5213 }
5214 return VINF_SUCCESS;
5215}
5216
5217
5218/** Opcode 0x0f 0x89. */
5219FNIEMOP_DEF(iemOp_jns_Jv)
5220{
5221 IEMOP_MNEMONIC(jns_Jv, "jns Jv");
5222 IEMOP_HLP_MIN_386();
5223 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5224 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5225 {
5226 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5227 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5228
5229 IEM_MC_BEGIN(0, 0);
5230 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5231 IEM_MC_ADVANCE_RIP();
5232 } IEM_MC_ELSE() {
5233 IEM_MC_REL_JMP_S16(i16Imm);
5234 } IEM_MC_ENDIF();
5235 IEM_MC_END();
5236 }
5237 else
5238 {
5239 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5240 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5241
5242 IEM_MC_BEGIN(0, 0);
5243 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5244 IEM_MC_ADVANCE_RIP();
5245 } IEM_MC_ELSE() {
5246 IEM_MC_REL_JMP_S32(i32Imm);
5247 } IEM_MC_ENDIF();
5248 IEM_MC_END();
5249 }
5250 return VINF_SUCCESS;
5251}
5252
5253
5254/** Opcode 0x0f 0x8a. */
5255FNIEMOP_DEF(iemOp_jp_Jv)
5256{
5257 IEMOP_MNEMONIC(jp_Jv, "jp Jv");
5258 IEMOP_HLP_MIN_386();
5259 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5260 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5261 {
5262 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5263 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5264
5265 IEM_MC_BEGIN(0, 0);
5266 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5267 IEM_MC_REL_JMP_S16(i16Imm);
5268 } IEM_MC_ELSE() {
5269 IEM_MC_ADVANCE_RIP();
5270 } IEM_MC_ENDIF();
5271 IEM_MC_END();
5272 }
5273 else
5274 {
5275 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5276 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5277
5278 IEM_MC_BEGIN(0, 0);
5279 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5280 IEM_MC_REL_JMP_S32(i32Imm);
5281 } IEM_MC_ELSE() {
5282 IEM_MC_ADVANCE_RIP();
5283 } IEM_MC_ENDIF();
5284 IEM_MC_END();
5285 }
5286 return VINF_SUCCESS;
5287}
5288
5289
5290/** Opcode 0x0f 0x8b. */
5291FNIEMOP_DEF(iemOp_jnp_Jv)
5292{
5293 IEMOP_MNEMONIC(jnp_Jv, "jnp Jv");
5294 IEMOP_HLP_MIN_386();
5295 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5296 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5297 {
5298 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5299 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5300
5301 IEM_MC_BEGIN(0, 0);
5302 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5303 IEM_MC_ADVANCE_RIP();
5304 } IEM_MC_ELSE() {
5305 IEM_MC_REL_JMP_S16(i16Imm);
5306 } IEM_MC_ENDIF();
5307 IEM_MC_END();
5308 }
5309 else
5310 {
5311 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5312 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5313
5314 IEM_MC_BEGIN(0, 0);
5315 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5316 IEM_MC_ADVANCE_RIP();
5317 } IEM_MC_ELSE() {
5318 IEM_MC_REL_JMP_S32(i32Imm);
5319 } IEM_MC_ENDIF();
5320 IEM_MC_END();
5321 }
5322 return VINF_SUCCESS;
5323}
5324
5325
5326/** Opcode 0x0f 0x8c. */
5327FNIEMOP_DEF(iemOp_jl_Jv)
5328{
5329 IEMOP_MNEMONIC(jl_Jv, "jl/jnge Jv");
5330 IEMOP_HLP_MIN_386();
5331 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5332 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5333 {
5334 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5335 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5336
5337 IEM_MC_BEGIN(0, 0);
5338 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
5339 IEM_MC_REL_JMP_S16(i16Imm);
5340 } IEM_MC_ELSE() {
5341 IEM_MC_ADVANCE_RIP();
5342 } IEM_MC_ENDIF();
5343 IEM_MC_END();
5344 }
5345 else
5346 {
5347 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5348 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5349
5350 IEM_MC_BEGIN(0, 0);
5351 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
5352 IEM_MC_REL_JMP_S32(i32Imm);
5353 } IEM_MC_ELSE() {
5354 IEM_MC_ADVANCE_RIP();
5355 } IEM_MC_ENDIF();
5356 IEM_MC_END();
5357 }
5358 return VINF_SUCCESS;
5359}
5360
5361
5362/** Opcode 0x0f 0x8d. */
5363FNIEMOP_DEF(iemOp_jnl_Jv)
5364{
5365 IEMOP_MNEMONIC(jge_Jv, "jnl/jge Jv");
5366 IEMOP_HLP_MIN_386();
5367 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5368 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5369 {
5370 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5371 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5372
5373 IEM_MC_BEGIN(0, 0);
5374 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
5375 IEM_MC_ADVANCE_RIP();
5376 } IEM_MC_ELSE() {
5377 IEM_MC_REL_JMP_S16(i16Imm);
5378 } IEM_MC_ENDIF();
5379 IEM_MC_END();
5380 }
5381 else
5382 {
5383 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5384 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5385
5386 IEM_MC_BEGIN(0, 0);
5387 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
5388 IEM_MC_ADVANCE_RIP();
5389 } IEM_MC_ELSE() {
5390 IEM_MC_REL_JMP_S32(i32Imm);
5391 } IEM_MC_ENDIF();
5392 IEM_MC_END();
5393 }
5394 return VINF_SUCCESS;
5395}
5396
5397
5398/** Opcode 0x0f 0x8e. */
5399FNIEMOP_DEF(iemOp_jle_Jv)
5400{
5401 IEMOP_MNEMONIC(jle_Jv, "jle/jng Jv");
5402 IEMOP_HLP_MIN_386();
5403 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5404 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5405 {
5406 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5407 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5408
5409 IEM_MC_BEGIN(0, 0);
5410 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
5411 IEM_MC_REL_JMP_S16(i16Imm);
5412 } IEM_MC_ELSE() {
5413 IEM_MC_ADVANCE_RIP();
5414 } IEM_MC_ENDIF();
5415 IEM_MC_END();
5416 }
5417 else
5418 {
5419 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5420 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5421
5422 IEM_MC_BEGIN(0, 0);
5423 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
5424 IEM_MC_REL_JMP_S32(i32Imm);
5425 } IEM_MC_ELSE() {
5426 IEM_MC_ADVANCE_RIP();
5427 } IEM_MC_ENDIF();
5428 IEM_MC_END();
5429 }
5430 return VINF_SUCCESS;
5431}
5432
5433
5434/** Opcode 0x0f 0x8f. */
5435FNIEMOP_DEF(iemOp_jnle_Jv)
5436{
5437 IEMOP_MNEMONIC(jg_Jv, "jnle/jg Jv");
5438 IEMOP_HLP_MIN_386();
5439 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
5440 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_16BIT)
5441 {
5442 int16_t i16Imm; IEM_OPCODE_GET_NEXT_S16(&i16Imm);
5443 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5444
5445 IEM_MC_BEGIN(0, 0);
5446 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
5447 IEM_MC_ADVANCE_RIP();
5448 } IEM_MC_ELSE() {
5449 IEM_MC_REL_JMP_S16(i16Imm);
5450 } IEM_MC_ENDIF();
5451 IEM_MC_END();
5452 }
5453 else
5454 {
5455 int32_t i32Imm; IEM_OPCODE_GET_NEXT_S32(&i32Imm);
5456 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5457
5458 IEM_MC_BEGIN(0, 0);
5459 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
5460 IEM_MC_ADVANCE_RIP();
5461 } IEM_MC_ELSE() {
5462 IEM_MC_REL_JMP_S32(i32Imm);
5463 } IEM_MC_ENDIF();
5464 IEM_MC_END();
5465 }
5466 return VINF_SUCCESS;
5467}
5468
5469
5470/** Opcode 0x0f 0x90. */
5471FNIEMOP_DEF(iemOp_seto_Eb)
5472{
5473 IEMOP_MNEMONIC(seto_Eb, "seto Eb");
5474 IEMOP_HLP_MIN_386();
5475 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5476
5477 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5478 * any way. AMD says it's "unused", whatever that means. We're
5479 * ignoring for now. */
5480 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5481 {
5482 /* register target */
5483 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5484 IEM_MC_BEGIN(0, 0);
5485 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
5486 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5487 } IEM_MC_ELSE() {
5488 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5489 } IEM_MC_ENDIF();
5490 IEM_MC_ADVANCE_RIP();
5491 IEM_MC_END();
5492 }
5493 else
5494 {
5495 /* memory target */
5496 IEM_MC_BEGIN(0, 1);
5497 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5498 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5499 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5500 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
5501 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5502 } IEM_MC_ELSE() {
5503 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5504 } IEM_MC_ENDIF();
5505 IEM_MC_ADVANCE_RIP();
5506 IEM_MC_END();
5507 }
5508 return VINF_SUCCESS;
5509}
5510
5511
5512/** Opcode 0x0f 0x91. */
5513FNIEMOP_DEF(iemOp_setno_Eb)
5514{
5515 IEMOP_MNEMONIC(setno_Eb, "setno Eb");
5516 IEMOP_HLP_MIN_386();
5517 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5518
5519 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5520 * any way. AMD says it's "unused", whatever that means. We're
5521 * ignoring for now. */
5522 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5523 {
5524 /* register target */
5525 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5526 IEM_MC_BEGIN(0, 0);
5527 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
5528 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5529 } IEM_MC_ELSE() {
5530 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5531 } IEM_MC_ENDIF();
5532 IEM_MC_ADVANCE_RIP();
5533 IEM_MC_END();
5534 }
5535 else
5536 {
5537 /* memory target */
5538 IEM_MC_BEGIN(0, 1);
5539 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5540 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5541 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5542 IEM_MC_IF_EFL_BIT_SET(X86_EFL_OF) {
5543 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5544 } IEM_MC_ELSE() {
5545 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5546 } IEM_MC_ENDIF();
5547 IEM_MC_ADVANCE_RIP();
5548 IEM_MC_END();
5549 }
5550 return VINF_SUCCESS;
5551}
5552
5553
5554/** Opcode 0x0f 0x92. */
5555FNIEMOP_DEF(iemOp_setc_Eb)
5556{
5557 IEMOP_MNEMONIC(setc_Eb, "setc Eb");
5558 IEMOP_HLP_MIN_386();
5559 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5560
5561 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5562 * any way. AMD says it's "unused", whatever that means. We're
5563 * ignoring for now. */
5564 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5565 {
5566 /* register target */
5567 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5568 IEM_MC_BEGIN(0, 0);
5569 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
5570 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5571 } IEM_MC_ELSE() {
5572 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5573 } IEM_MC_ENDIF();
5574 IEM_MC_ADVANCE_RIP();
5575 IEM_MC_END();
5576 }
5577 else
5578 {
5579 /* memory target */
5580 IEM_MC_BEGIN(0, 1);
5581 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5582 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5583 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5584 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
5585 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5586 } IEM_MC_ELSE() {
5587 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5588 } IEM_MC_ENDIF();
5589 IEM_MC_ADVANCE_RIP();
5590 IEM_MC_END();
5591 }
5592 return VINF_SUCCESS;
5593}
5594
5595
5596/** Opcode 0x0f 0x93. */
5597FNIEMOP_DEF(iemOp_setnc_Eb)
5598{
5599 IEMOP_MNEMONIC(setnc_Eb, "setnc Eb");
5600 IEMOP_HLP_MIN_386();
5601 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5602
5603 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5604 * any way. AMD says it's "unused", whatever that means. We're
5605 * ignoring for now. */
5606 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5607 {
5608 /* register target */
5609 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5610 IEM_MC_BEGIN(0, 0);
5611 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
5612 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5613 } IEM_MC_ELSE() {
5614 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5615 } IEM_MC_ENDIF();
5616 IEM_MC_ADVANCE_RIP();
5617 IEM_MC_END();
5618 }
5619 else
5620 {
5621 /* memory target */
5622 IEM_MC_BEGIN(0, 1);
5623 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5624 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5625 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5626 IEM_MC_IF_EFL_BIT_SET(X86_EFL_CF) {
5627 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5628 } IEM_MC_ELSE() {
5629 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5630 } IEM_MC_ENDIF();
5631 IEM_MC_ADVANCE_RIP();
5632 IEM_MC_END();
5633 }
5634 return VINF_SUCCESS;
5635}
5636
5637
5638/** Opcode 0x0f 0x94. */
5639FNIEMOP_DEF(iemOp_sete_Eb)
5640{
5641 IEMOP_MNEMONIC(sete_Eb, "sete Eb");
5642 IEMOP_HLP_MIN_386();
5643 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5644
5645 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5646 * any way. AMD says it's "unused", whatever that means. We're
5647 * ignoring for now. */
5648 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5649 {
5650 /* register target */
5651 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5652 IEM_MC_BEGIN(0, 0);
5653 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5654 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5655 } IEM_MC_ELSE() {
5656 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5657 } IEM_MC_ENDIF();
5658 IEM_MC_ADVANCE_RIP();
5659 IEM_MC_END();
5660 }
5661 else
5662 {
5663 /* memory target */
5664 IEM_MC_BEGIN(0, 1);
5665 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5666 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5667 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5668 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5669 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5670 } IEM_MC_ELSE() {
5671 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5672 } IEM_MC_ENDIF();
5673 IEM_MC_ADVANCE_RIP();
5674 IEM_MC_END();
5675 }
5676 return VINF_SUCCESS;
5677}
5678
5679
5680/** Opcode 0x0f 0x95. */
5681FNIEMOP_DEF(iemOp_setne_Eb)
5682{
5683 IEMOP_MNEMONIC(setne_Eb, "setne Eb");
5684 IEMOP_HLP_MIN_386();
5685 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5686
5687 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5688 * any way. AMD says it's "unused", whatever that means. We're
5689 * ignoring for now. */
5690 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5691 {
5692 /* register target */
5693 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5694 IEM_MC_BEGIN(0, 0);
5695 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5696 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5697 } IEM_MC_ELSE() {
5698 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5699 } IEM_MC_ENDIF();
5700 IEM_MC_ADVANCE_RIP();
5701 IEM_MC_END();
5702 }
5703 else
5704 {
5705 /* memory target */
5706 IEM_MC_BEGIN(0, 1);
5707 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5708 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5709 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5710 IEM_MC_IF_EFL_BIT_SET(X86_EFL_ZF) {
5711 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5712 } IEM_MC_ELSE() {
5713 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5714 } IEM_MC_ENDIF();
5715 IEM_MC_ADVANCE_RIP();
5716 IEM_MC_END();
5717 }
5718 return VINF_SUCCESS;
5719}
5720
5721
5722/** Opcode 0x0f 0x96. */
5723FNIEMOP_DEF(iemOp_setbe_Eb)
5724{
5725 IEMOP_MNEMONIC(setbe_Eb, "setbe Eb");
5726 IEMOP_HLP_MIN_386();
5727 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5728
5729 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5730 * any way. AMD says it's "unused", whatever that means. We're
5731 * ignoring for now. */
5732 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5733 {
5734 /* register target */
5735 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5736 IEM_MC_BEGIN(0, 0);
5737 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5738 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5739 } IEM_MC_ELSE() {
5740 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5741 } IEM_MC_ENDIF();
5742 IEM_MC_ADVANCE_RIP();
5743 IEM_MC_END();
5744 }
5745 else
5746 {
5747 /* memory target */
5748 IEM_MC_BEGIN(0, 1);
5749 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5750 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5751 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5752 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5753 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5754 } IEM_MC_ELSE() {
5755 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5756 } IEM_MC_ENDIF();
5757 IEM_MC_ADVANCE_RIP();
5758 IEM_MC_END();
5759 }
5760 return VINF_SUCCESS;
5761}
5762
5763
5764/** Opcode 0x0f 0x97. */
5765FNIEMOP_DEF(iemOp_setnbe_Eb)
5766{
5767 IEMOP_MNEMONIC(setnbe_Eb, "setnbe Eb");
5768 IEMOP_HLP_MIN_386();
5769 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5770
5771 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5772 * any way. AMD says it's "unused", whatever that means. We're
5773 * ignoring for now. */
5774 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5775 {
5776 /* register target */
5777 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5778 IEM_MC_BEGIN(0, 0);
5779 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5780 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5781 } IEM_MC_ELSE() {
5782 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5783 } IEM_MC_ENDIF();
5784 IEM_MC_ADVANCE_RIP();
5785 IEM_MC_END();
5786 }
5787 else
5788 {
5789 /* memory target */
5790 IEM_MC_BEGIN(0, 1);
5791 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5792 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5793 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5794 IEM_MC_IF_EFL_ANY_BITS_SET(X86_EFL_CF | X86_EFL_ZF) {
5795 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5796 } IEM_MC_ELSE() {
5797 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5798 } IEM_MC_ENDIF();
5799 IEM_MC_ADVANCE_RIP();
5800 IEM_MC_END();
5801 }
5802 return VINF_SUCCESS;
5803}
5804
5805
5806/** Opcode 0x0f 0x98. */
5807FNIEMOP_DEF(iemOp_sets_Eb)
5808{
5809 IEMOP_MNEMONIC(sets_Eb, "sets Eb");
5810 IEMOP_HLP_MIN_386();
5811 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5812
5813 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5814 * any way. AMD says it's "unused", whatever that means. We're
5815 * ignoring for now. */
5816 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5817 {
5818 /* register target */
5819 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5820 IEM_MC_BEGIN(0, 0);
5821 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5822 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5823 } IEM_MC_ELSE() {
5824 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5825 } IEM_MC_ENDIF();
5826 IEM_MC_ADVANCE_RIP();
5827 IEM_MC_END();
5828 }
5829 else
5830 {
5831 /* memory target */
5832 IEM_MC_BEGIN(0, 1);
5833 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5834 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5835 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5836 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5837 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5838 } IEM_MC_ELSE() {
5839 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5840 } IEM_MC_ENDIF();
5841 IEM_MC_ADVANCE_RIP();
5842 IEM_MC_END();
5843 }
5844 return VINF_SUCCESS;
5845}
5846
5847
5848/** Opcode 0x0f 0x99. */
5849FNIEMOP_DEF(iemOp_setns_Eb)
5850{
5851 IEMOP_MNEMONIC(setns_Eb, "setns Eb");
5852 IEMOP_HLP_MIN_386();
5853 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5854
5855 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5856 * any way. AMD says it's "unused", whatever that means. We're
5857 * ignoring for now. */
5858 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5859 {
5860 /* register target */
5861 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5862 IEM_MC_BEGIN(0, 0);
5863 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5864 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5865 } IEM_MC_ELSE() {
5866 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5867 } IEM_MC_ENDIF();
5868 IEM_MC_ADVANCE_RIP();
5869 IEM_MC_END();
5870 }
5871 else
5872 {
5873 /* memory target */
5874 IEM_MC_BEGIN(0, 1);
5875 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5876 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5877 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5878 IEM_MC_IF_EFL_BIT_SET(X86_EFL_SF) {
5879 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5880 } IEM_MC_ELSE() {
5881 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5882 } IEM_MC_ENDIF();
5883 IEM_MC_ADVANCE_RIP();
5884 IEM_MC_END();
5885 }
5886 return VINF_SUCCESS;
5887}
5888
5889
5890/** Opcode 0x0f 0x9a. */
5891FNIEMOP_DEF(iemOp_setp_Eb)
5892{
5893 IEMOP_MNEMONIC(setp_Eb, "setp Eb");
5894 IEMOP_HLP_MIN_386();
5895 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5896
5897 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5898 * any way. AMD says it's "unused", whatever that means. We're
5899 * ignoring for now. */
5900 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5901 {
5902 /* register target */
5903 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5904 IEM_MC_BEGIN(0, 0);
5905 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5906 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5907 } IEM_MC_ELSE() {
5908 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5909 } IEM_MC_ENDIF();
5910 IEM_MC_ADVANCE_RIP();
5911 IEM_MC_END();
5912 }
5913 else
5914 {
5915 /* memory target */
5916 IEM_MC_BEGIN(0, 1);
5917 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5918 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5919 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5920 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5921 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5922 } IEM_MC_ELSE() {
5923 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5924 } IEM_MC_ENDIF();
5925 IEM_MC_ADVANCE_RIP();
5926 IEM_MC_END();
5927 }
5928 return VINF_SUCCESS;
5929}
5930
5931
5932/** Opcode 0x0f 0x9b. */
5933FNIEMOP_DEF(iemOp_setnp_Eb)
5934{
5935 IEMOP_MNEMONIC(setnp_Eb, "setnp Eb");
5936 IEMOP_HLP_MIN_386();
5937 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5938
5939 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5940 * any way. AMD says it's "unused", whatever that means. We're
5941 * ignoring for now. */
5942 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5943 {
5944 /* register target */
5945 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5946 IEM_MC_BEGIN(0, 0);
5947 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5948 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5949 } IEM_MC_ELSE() {
5950 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5951 } IEM_MC_ENDIF();
5952 IEM_MC_ADVANCE_RIP();
5953 IEM_MC_END();
5954 }
5955 else
5956 {
5957 /* memory target */
5958 IEM_MC_BEGIN(0, 1);
5959 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
5960 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
5961 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5962 IEM_MC_IF_EFL_BIT_SET(X86_EFL_PF) {
5963 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
5964 } IEM_MC_ELSE() {
5965 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
5966 } IEM_MC_ENDIF();
5967 IEM_MC_ADVANCE_RIP();
5968 IEM_MC_END();
5969 }
5970 return VINF_SUCCESS;
5971}
5972
5973
5974/** Opcode 0x0f 0x9c. */
5975FNIEMOP_DEF(iemOp_setl_Eb)
5976{
5977 IEMOP_MNEMONIC(setl_Eb, "setl Eb");
5978 IEMOP_HLP_MIN_386();
5979 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
5980
5981 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
5982 * any way. AMD says it's "unused", whatever that means. We're
5983 * ignoring for now. */
5984 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
5985 {
5986 /* register target */
5987 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
5988 IEM_MC_BEGIN(0, 0);
5989 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
5990 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
5991 } IEM_MC_ELSE() {
5992 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
5993 } IEM_MC_ENDIF();
5994 IEM_MC_ADVANCE_RIP();
5995 IEM_MC_END();
5996 }
5997 else
5998 {
5999 /* memory target */
6000 IEM_MC_BEGIN(0, 1);
6001 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6002 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6003 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6004 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
6005 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
6006 } IEM_MC_ELSE() {
6007 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6008 } IEM_MC_ENDIF();
6009 IEM_MC_ADVANCE_RIP();
6010 IEM_MC_END();
6011 }
6012 return VINF_SUCCESS;
6013}
6014
6015
6016/** Opcode 0x0f 0x9d. */
6017FNIEMOP_DEF(iemOp_setnl_Eb)
6018{
6019 IEMOP_MNEMONIC(setnl_Eb, "setnl Eb");
6020 IEMOP_HLP_MIN_386();
6021 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6022
6023 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
6024 * any way. AMD says it's "unused", whatever that means. We're
6025 * ignoring for now. */
6026 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
6027 {
6028 /* register target */
6029 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6030 IEM_MC_BEGIN(0, 0);
6031 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
6032 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
6033 } IEM_MC_ELSE() {
6034 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
6035 } IEM_MC_ENDIF();
6036 IEM_MC_ADVANCE_RIP();
6037 IEM_MC_END();
6038 }
6039 else
6040 {
6041 /* memory target */
6042 IEM_MC_BEGIN(0, 1);
6043 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6044 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6045 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6046 IEM_MC_IF_EFL_BITS_NE(X86_EFL_SF, X86_EFL_OF) {
6047 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6048 } IEM_MC_ELSE() {
6049 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
6050 } IEM_MC_ENDIF();
6051 IEM_MC_ADVANCE_RIP();
6052 IEM_MC_END();
6053 }
6054 return VINF_SUCCESS;
6055}
6056
6057
6058/** Opcode 0x0f 0x9e. */
6059FNIEMOP_DEF(iemOp_setle_Eb)
6060{
6061 IEMOP_MNEMONIC(setle_Eb, "setle Eb");
6062 IEMOP_HLP_MIN_386();
6063 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6064
6065 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
6066 * any way. AMD says it's "unused", whatever that means. We're
6067 * ignoring for now. */
6068 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
6069 {
6070 /* register target */
6071 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6072 IEM_MC_BEGIN(0, 0);
6073 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
6074 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
6075 } IEM_MC_ELSE() {
6076 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
6077 } IEM_MC_ENDIF();
6078 IEM_MC_ADVANCE_RIP();
6079 IEM_MC_END();
6080 }
6081 else
6082 {
6083 /* memory target */
6084 IEM_MC_BEGIN(0, 1);
6085 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6086 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6087 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6088 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
6089 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
6090 } IEM_MC_ELSE() {
6091 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6092 } IEM_MC_ENDIF();
6093 IEM_MC_ADVANCE_RIP();
6094 IEM_MC_END();
6095 }
6096 return VINF_SUCCESS;
6097}
6098
6099
6100/** Opcode 0x0f 0x9f. */
6101FNIEMOP_DEF(iemOp_setnle_Eb)
6102{
6103 IEMOP_MNEMONIC(setnle_Eb, "setnle Eb");
6104 IEMOP_HLP_MIN_386();
6105 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6106
6107 /** @todo Encoding test: Check if the 'reg' field is ignored or decoded in
6108 * any way. AMD says it's "unused", whatever that means. We're
6109 * ignoring for now. */
6110 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
6111 {
6112 /* register target */
6113 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6114 IEM_MC_BEGIN(0, 0);
6115 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
6116 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 0);
6117 } IEM_MC_ELSE() {
6118 IEM_MC_STORE_GREG_U8_CONST((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, 1);
6119 } IEM_MC_ENDIF();
6120 IEM_MC_ADVANCE_RIP();
6121 IEM_MC_END();
6122 }
6123 else
6124 {
6125 /* memory target */
6126 IEM_MC_BEGIN(0, 1);
6127 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6128 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6129 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6130 IEM_MC_IF_EFL_BIT_SET_OR_BITS_NE(X86_EFL_ZF, X86_EFL_SF, X86_EFL_OF) {
6131 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6132 } IEM_MC_ELSE() {
6133 IEM_MC_STORE_MEM_U8_CONST(pVCpu->iem.s.iEffSeg, GCPtrEffDst, 1);
6134 } IEM_MC_ENDIF();
6135 IEM_MC_ADVANCE_RIP();
6136 IEM_MC_END();
6137 }
6138 return VINF_SUCCESS;
6139}
6140
6141
6142/**
6143 * Common 'push segment-register' helper.
6144 */
6145FNIEMOP_DEF_1(iemOpCommonPushSReg, uint8_t, iReg)
6146{
6147 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6148 Assert(iReg < X86_SREG_FS || pVCpu->iem.s.enmCpuMode != IEMMODE_64BIT);
6149 IEMOP_HLP_DEFAULT_64BIT_OP_SIZE();
6150
6151 switch (pVCpu->iem.s.enmEffOpSize)
6152 {
6153 case IEMMODE_16BIT:
6154 IEM_MC_BEGIN(0, 1);
6155 IEM_MC_LOCAL(uint16_t, u16Value);
6156 IEM_MC_FETCH_SREG_U16(u16Value, iReg);
6157 IEM_MC_PUSH_U16(u16Value);
6158 IEM_MC_ADVANCE_RIP();
6159 IEM_MC_END();
6160 break;
6161
6162 case IEMMODE_32BIT:
6163 IEM_MC_BEGIN(0, 1);
6164 IEM_MC_LOCAL(uint32_t, u32Value);
6165 IEM_MC_FETCH_SREG_ZX_U32(u32Value, iReg);
6166 IEM_MC_PUSH_U32_SREG(u32Value);
6167 IEM_MC_ADVANCE_RIP();
6168 IEM_MC_END();
6169 break;
6170
6171 case IEMMODE_64BIT:
6172 IEM_MC_BEGIN(0, 1);
6173 IEM_MC_LOCAL(uint64_t, u64Value);
6174 IEM_MC_FETCH_SREG_ZX_U64(u64Value, iReg);
6175 IEM_MC_PUSH_U64(u64Value);
6176 IEM_MC_ADVANCE_RIP();
6177 IEM_MC_END();
6178 break;
6179 }
6180
6181 return VINF_SUCCESS;
6182}
6183
6184
6185/** Opcode 0x0f 0xa0. */
6186FNIEMOP_DEF(iemOp_push_fs)
6187{
6188 IEMOP_MNEMONIC(push_fs, "push fs");
6189 IEMOP_HLP_MIN_386();
6190 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6191 return FNIEMOP_CALL_1(iemOpCommonPushSReg, X86_SREG_FS);
6192}
6193
6194
6195/** Opcode 0x0f 0xa1. */
6196FNIEMOP_DEF(iemOp_pop_fs)
6197{
6198 IEMOP_MNEMONIC(pop_fs, "pop fs");
6199 IEMOP_HLP_MIN_386();
6200 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6201 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_pop_Sreg, X86_SREG_FS, pVCpu->iem.s.enmEffOpSize);
6202}
6203
6204
6205/** Opcode 0x0f 0xa2. */
6206FNIEMOP_DEF(iemOp_cpuid)
6207{
6208 IEMOP_MNEMONIC(cpuid, "cpuid");
6209 IEMOP_HLP_MIN_486(); /* not all 486es. */
6210 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6211 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_cpuid);
6212}
6213
6214
6215/**
6216 * Common worker for iemOp_bt_Ev_Gv, iemOp_btc_Ev_Gv, iemOp_btr_Ev_Gv and
6217 * iemOp_bts_Ev_Gv.
6218 */
6219FNIEMOP_DEF_1(iemOpCommonBit_Ev_Gv, PCIEMOPBINSIZES, pImpl)
6220{
6221 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6222 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF);
6223
6224 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
6225 {
6226 /* register destination. */
6227 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6228 switch (pVCpu->iem.s.enmEffOpSize)
6229 {
6230 case IEMMODE_16BIT:
6231 IEM_MC_BEGIN(3, 0);
6232 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
6233 IEM_MC_ARG(uint16_t, u16Src, 1);
6234 IEM_MC_ARG(uint32_t *, pEFlags, 2);
6235
6236 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6237 IEM_MC_AND_LOCAL_U16(u16Src, 0xf);
6238 IEM_MC_REF_GREG_U16(pu16Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6239 IEM_MC_REF_EFLAGS(pEFlags);
6240 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU16, pu16Dst, u16Src, pEFlags);
6241
6242 IEM_MC_ADVANCE_RIP();
6243 IEM_MC_END();
6244 return VINF_SUCCESS;
6245
6246 case IEMMODE_32BIT:
6247 IEM_MC_BEGIN(3, 0);
6248 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
6249 IEM_MC_ARG(uint32_t, u32Src, 1);
6250 IEM_MC_ARG(uint32_t *, pEFlags, 2);
6251
6252 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6253 IEM_MC_AND_LOCAL_U32(u32Src, 0x1f);
6254 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6255 IEM_MC_REF_EFLAGS(pEFlags);
6256 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU32, pu32Dst, u32Src, pEFlags);
6257
6258 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
6259 IEM_MC_ADVANCE_RIP();
6260 IEM_MC_END();
6261 return VINF_SUCCESS;
6262
6263 case IEMMODE_64BIT:
6264 IEM_MC_BEGIN(3, 0);
6265 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
6266 IEM_MC_ARG(uint64_t, u64Src, 1);
6267 IEM_MC_ARG(uint32_t *, pEFlags, 2);
6268
6269 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6270 IEM_MC_AND_LOCAL_U64(u64Src, 0x3f);
6271 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6272 IEM_MC_REF_EFLAGS(pEFlags);
6273 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU64, pu64Dst, u64Src, pEFlags);
6274
6275 IEM_MC_ADVANCE_RIP();
6276 IEM_MC_END();
6277 return VINF_SUCCESS;
6278
6279 IEM_NOT_REACHED_DEFAULT_CASE_RET();
6280 }
6281 }
6282 else
6283 {
6284 /* memory destination. */
6285
6286 uint32_t fAccess;
6287 if (pImpl->pfnLockedU16)
6288 fAccess = IEM_ACCESS_DATA_RW;
6289 else /* BT */
6290 fAccess = IEM_ACCESS_DATA_R;
6291
6292 /** @todo test negative bit offsets! */
6293 switch (pVCpu->iem.s.enmEffOpSize)
6294 {
6295 case IEMMODE_16BIT:
6296 IEM_MC_BEGIN(3, 2);
6297 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
6298 IEM_MC_ARG(uint16_t, u16Src, 1);
6299 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2);
6300 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6301 IEM_MC_LOCAL(int16_t, i16AddrAdj);
6302
6303 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6304 if (pImpl->pfnLockedU16)
6305 IEMOP_HLP_DONE_DECODING();
6306 else
6307 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6308 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6309 IEM_MC_ASSIGN(i16AddrAdj, u16Src);
6310 IEM_MC_AND_ARG_U16(u16Src, 0x0f);
6311 IEM_MC_SAR_LOCAL_S16(i16AddrAdj, 4);
6312 IEM_MC_SHL_LOCAL_S16(i16AddrAdj, 1);
6313 IEM_MC_ADD_LOCAL_S16_TO_EFF_ADDR(GCPtrEffDst, i16AddrAdj);
6314 IEM_MC_FETCH_EFLAGS(EFlags);
6315
6316 IEM_MC_MEM_MAP(pu16Dst, fAccess, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6317 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
6318 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU16, pu16Dst, u16Src, pEFlags);
6319 else
6320 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnLockedU16, pu16Dst, u16Src, pEFlags);
6321 IEM_MC_MEM_COMMIT_AND_UNMAP(pu16Dst, fAccess);
6322
6323 IEM_MC_COMMIT_EFLAGS(EFlags);
6324 IEM_MC_ADVANCE_RIP();
6325 IEM_MC_END();
6326 return VINF_SUCCESS;
6327
6328 case IEMMODE_32BIT:
6329 IEM_MC_BEGIN(3, 2);
6330 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
6331 IEM_MC_ARG(uint32_t, u32Src, 1);
6332 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2);
6333 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6334 IEM_MC_LOCAL(int32_t, i32AddrAdj);
6335
6336 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6337 if (pImpl->pfnLockedU16)
6338 IEMOP_HLP_DONE_DECODING();
6339 else
6340 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6341 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6342 IEM_MC_ASSIGN(i32AddrAdj, u32Src);
6343 IEM_MC_AND_ARG_U32(u32Src, 0x1f);
6344 IEM_MC_SAR_LOCAL_S32(i32AddrAdj, 5);
6345 IEM_MC_SHL_LOCAL_S32(i32AddrAdj, 2);
6346 IEM_MC_ADD_LOCAL_S32_TO_EFF_ADDR(GCPtrEffDst, i32AddrAdj);
6347 IEM_MC_FETCH_EFLAGS(EFlags);
6348
6349 IEM_MC_MEM_MAP(pu32Dst, fAccess, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6350 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
6351 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU32, pu32Dst, u32Src, pEFlags);
6352 else
6353 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnLockedU32, pu32Dst, u32Src, pEFlags);
6354 IEM_MC_MEM_COMMIT_AND_UNMAP(pu32Dst, fAccess);
6355
6356 IEM_MC_COMMIT_EFLAGS(EFlags);
6357 IEM_MC_ADVANCE_RIP();
6358 IEM_MC_END();
6359 return VINF_SUCCESS;
6360
6361 case IEMMODE_64BIT:
6362 IEM_MC_BEGIN(3, 2);
6363 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
6364 IEM_MC_ARG(uint64_t, u64Src, 1);
6365 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2);
6366 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6367 IEM_MC_LOCAL(int64_t, i64AddrAdj);
6368
6369 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6370 if (pImpl->pfnLockedU16)
6371 IEMOP_HLP_DONE_DECODING();
6372 else
6373 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6374 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6375 IEM_MC_ASSIGN(i64AddrAdj, u64Src);
6376 IEM_MC_AND_ARG_U64(u64Src, 0x3f);
6377 IEM_MC_SAR_LOCAL_S64(i64AddrAdj, 6);
6378 IEM_MC_SHL_LOCAL_S64(i64AddrAdj, 3);
6379 IEM_MC_ADD_LOCAL_S64_TO_EFF_ADDR(GCPtrEffDst, i64AddrAdj);
6380 IEM_MC_FETCH_EFLAGS(EFlags);
6381
6382 IEM_MC_MEM_MAP(pu64Dst, fAccess, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6383 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
6384 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU64, pu64Dst, u64Src, pEFlags);
6385 else
6386 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnLockedU64, pu64Dst, u64Src, pEFlags);
6387 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64Dst, fAccess);
6388
6389 IEM_MC_COMMIT_EFLAGS(EFlags);
6390 IEM_MC_ADVANCE_RIP();
6391 IEM_MC_END();
6392 return VINF_SUCCESS;
6393
6394 IEM_NOT_REACHED_DEFAULT_CASE_RET();
6395 }
6396 }
6397}
6398
6399
6400/** Opcode 0x0f 0xa3. */
6401FNIEMOP_DEF(iemOp_bt_Ev_Gv)
6402{
6403 IEMOP_MNEMONIC(bt_Ev_Gv, "bt Ev,Gv");
6404 IEMOP_HLP_MIN_386();
6405 return FNIEMOP_CALL_1(iemOpCommonBit_Ev_Gv, &g_iemAImpl_bt);
6406}
6407
6408
6409/**
6410 * Common worker for iemOp_shrd_Ev_Gv_Ib and iemOp_shld_Ev_Gv_Ib.
6411 */
6412FNIEMOP_DEF_1(iemOpCommonShldShrd_Ib, PCIEMOPSHIFTDBLSIZES, pImpl)
6413{
6414 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6415 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_AF | X86_EFL_OF);
6416
6417 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
6418 {
6419 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
6420 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6421
6422 switch (pVCpu->iem.s.enmEffOpSize)
6423 {
6424 case IEMMODE_16BIT:
6425 IEM_MC_BEGIN(4, 0);
6426 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
6427 IEM_MC_ARG(uint16_t, u16Src, 1);
6428 IEM_MC_ARG_CONST(uint8_t, cShiftArg, /*=*/cShift, 2);
6429 IEM_MC_ARG(uint32_t *, pEFlags, 3);
6430
6431 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6432 IEM_MC_REF_GREG_U16(pu16Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6433 IEM_MC_REF_EFLAGS(pEFlags);
6434 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
6435
6436 IEM_MC_ADVANCE_RIP();
6437 IEM_MC_END();
6438 return VINF_SUCCESS;
6439
6440 case IEMMODE_32BIT:
6441 IEM_MC_BEGIN(4, 0);
6442 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
6443 IEM_MC_ARG(uint32_t, u32Src, 1);
6444 IEM_MC_ARG_CONST(uint8_t, cShiftArg, /*=*/cShift, 2);
6445 IEM_MC_ARG(uint32_t *, pEFlags, 3);
6446
6447 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6448 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6449 IEM_MC_REF_EFLAGS(pEFlags);
6450 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
6451
6452 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
6453 IEM_MC_ADVANCE_RIP();
6454 IEM_MC_END();
6455 return VINF_SUCCESS;
6456
6457 case IEMMODE_64BIT:
6458 IEM_MC_BEGIN(4, 0);
6459 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
6460 IEM_MC_ARG(uint64_t, u64Src, 1);
6461 IEM_MC_ARG_CONST(uint8_t, cShiftArg, /*=*/cShift, 2);
6462 IEM_MC_ARG(uint32_t *, pEFlags, 3);
6463
6464 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6465 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6466 IEM_MC_REF_EFLAGS(pEFlags);
6467 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
6468
6469 IEM_MC_ADVANCE_RIP();
6470 IEM_MC_END();
6471 return VINF_SUCCESS;
6472
6473 IEM_NOT_REACHED_DEFAULT_CASE_RET();
6474 }
6475 }
6476 else
6477 {
6478 switch (pVCpu->iem.s.enmEffOpSize)
6479 {
6480 case IEMMODE_16BIT:
6481 IEM_MC_BEGIN(4, 2);
6482 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
6483 IEM_MC_ARG(uint16_t, u16Src, 1);
6484 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6485 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
6486 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6487
6488 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
6489 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
6490 IEM_MC_ASSIGN(cShiftArg, cShift);
6491 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6492 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6493 IEM_MC_FETCH_EFLAGS(EFlags);
6494 IEM_MC_MEM_MAP(pu16Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6495 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
6496
6497 IEM_MC_MEM_COMMIT_AND_UNMAP(pu16Dst, IEM_ACCESS_DATA_RW);
6498 IEM_MC_COMMIT_EFLAGS(EFlags);
6499 IEM_MC_ADVANCE_RIP();
6500 IEM_MC_END();
6501 return VINF_SUCCESS;
6502
6503 case IEMMODE_32BIT:
6504 IEM_MC_BEGIN(4, 2);
6505 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
6506 IEM_MC_ARG(uint32_t, u32Src, 1);
6507 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6508 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
6509 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6510
6511 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
6512 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
6513 IEM_MC_ASSIGN(cShiftArg, cShift);
6514 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6515 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6516 IEM_MC_FETCH_EFLAGS(EFlags);
6517 IEM_MC_MEM_MAP(pu32Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6518 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
6519
6520 IEM_MC_MEM_COMMIT_AND_UNMAP(pu32Dst, IEM_ACCESS_DATA_RW);
6521 IEM_MC_COMMIT_EFLAGS(EFlags);
6522 IEM_MC_ADVANCE_RIP();
6523 IEM_MC_END();
6524 return VINF_SUCCESS;
6525
6526 case IEMMODE_64BIT:
6527 IEM_MC_BEGIN(4, 2);
6528 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
6529 IEM_MC_ARG(uint64_t, u64Src, 1);
6530 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6531 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
6532 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6533
6534 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
6535 uint8_t cShift; IEM_OPCODE_GET_NEXT_U8(&cShift);
6536 IEM_MC_ASSIGN(cShiftArg, cShift);
6537 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6538 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6539 IEM_MC_FETCH_EFLAGS(EFlags);
6540 IEM_MC_MEM_MAP(pu64Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6541 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
6542
6543 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64Dst, IEM_ACCESS_DATA_RW);
6544 IEM_MC_COMMIT_EFLAGS(EFlags);
6545 IEM_MC_ADVANCE_RIP();
6546 IEM_MC_END();
6547 return VINF_SUCCESS;
6548
6549 IEM_NOT_REACHED_DEFAULT_CASE_RET();
6550 }
6551 }
6552}
6553
6554
6555/**
6556 * Common worker for iemOp_shrd_Ev_Gv_CL and iemOp_shld_Ev_Gv_CL.
6557 */
6558FNIEMOP_DEF_1(iemOpCommonShldShrd_CL, PCIEMOPSHIFTDBLSIZES, pImpl)
6559{
6560 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
6561 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_AF | X86_EFL_OF);
6562
6563 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
6564 {
6565 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6566
6567 switch (pVCpu->iem.s.enmEffOpSize)
6568 {
6569 case IEMMODE_16BIT:
6570 IEM_MC_BEGIN(4, 0);
6571 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
6572 IEM_MC_ARG(uint16_t, u16Src, 1);
6573 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6574 IEM_MC_ARG(uint32_t *, pEFlags, 3);
6575
6576 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6577 IEM_MC_REF_GREG_U16(pu16Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6578 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
6579 IEM_MC_REF_EFLAGS(pEFlags);
6580 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
6581
6582 IEM_MC_ADVANCE_RIP();
6583 IEM_MC_END();
6584 return VINF_SUCCESS;
6585
6586 case IEMMODE_32BIT:
6587 IEM_MC_BEGIN(4, 0);
6588 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
6589 IEM_MC_ARG(uint32_t, u32Src, 1);
6590 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6591 IEM_MC_ARG(uint32_t *, pEFlags, 3);
6592
6593 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6594 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6595 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
6596 IEM_MC_REF_EFLAGS(pEFlags);
6597 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
6598
6599 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
6600 IEM_MC_ADVANCE_RIP();
6601 IEM_MC_END();
6602 return VINF_SUCCESS;
6603
6604 case IEMMODE_64BIT:
6605 IEM_MC_BEGIN(4, 0);
6606 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
6607 IEM_MC_ARG(uint64_t, u64Src, 1);
6608 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6609 IEM_MC_ARG(uint32_t *, pEFlags, 3);
6610
6611 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6612 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
6613 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
6614 IEM_MC_REF_EFLAGS(pEFlags);
6615 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
6616
6617 IEM_MC_ADVANCE_RIP();
6618 IEM_MC_END();
6619 return VINF_SUCCESS;
6620
6621 IEM_NOT_REACHED_DEFAULT_CASE_RET();
6622 }
6623 }
6624 else
6625 {
6626 switch (pVCpu->iem.s.enmEffOpSize)
6627 {
6628 case IEMMODE_16BIT:
6629 IEM_MC_BEGIN(4, 2);
6630 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
6631 IEM_MC_ARG(uint16_t, u16Src, 1);
6632 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6633 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
6634 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6635
6636 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6637 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6638 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6639 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
6640 IEM_MC_FETCH_EFLAGS(EFlags);
6641 IEM_MC_MEM_MAP(pu16Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6642 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU16, pu16Dst, u16Src, cShiftArg, pEFlags);
6643
6644 IEM_MC_MEM_COMMIT_AND_UNMAP(pu16Dst, IEM_ACCESS_DATA_RW);
6645 IEM_MC_COMMIT_EFLAGS(EFlags);
6646 IEM_MC_ADVANCE_RIP();
6647 IEM_MC_END();
6648 return VINF_SUCCESS;
6649
6650 case IEMMODE_32BIT:
6651 IEM_MC_BEGIN(4, 2);
6652 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
6653 IEM_MC_ARG(uint32_t, u32Src, 1);
6654 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6655 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
6656 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6657
6658 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6659 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6660 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6661 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
6662 IEM_MC_FETCH_EFLAGS(EFlags);
6663 IEM_MC_MEM_MAP(pu32Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6664 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU32, pu32Dst, u32Src, cShiftArg, pEFlags);
6665
6666 IEM_MC_MEM_COMMIT_AND_UNMAP(pu32Dst, IEM_ACCESS_DATA_RW);
6667 IEM_MC_COMMIT_EFLAGS(EFlags);
6668 IEM_MC_ADVANCE_RIP();
6669 IEM_MC_END();
6670 return VINF_SUCCESS;
6671
6672 case IEMMODE_64BIT:
6673 IEM_MC_BEGIN(4, 2);
6674 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
6675 IEM_MC_ARG(uint64_t, u64Src, 1);
6676 IEM_MC_ARG(uint8_t, cShiftArg, 2);
6677 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
6678 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
6679
6680 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
6681 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6682 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
6683 IEM_MC_FETCH_GREG_U8(cShiftArg, X86_GREG_xCX);
6684 IEM_MC_FETCH_EFLAGS(EFlags);
6685 IEM_MC_MEM_MAP(pu64Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
6686 IEM_MC_CALL_VOID_AIMPL_4(pImpl->pfnNormalU64, pu64Dst, u64Src, cShiftArg, pEFlags);
6687
6688 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64Dst, IEM_ACCESS_DATA_RW);
6689 IEM_MC_COMMIT_EFLAGS(EFlags);
6690 IEM_MC_ADVANCE_RIP();
6691 IEM_MC_END();
6692 return VINF_SUCCESS;
6693
6694 IEM_NOT_REACHED_DEFAULT_CASE_RET();
6695 }
6696 }
6697}
6698
6699
6700
6701/** Opcode 0x0f 0xa4. */
6702FNIEMOP_DEF(iemOp_shld_Ev_Gv_Ib)
6703{
6704 IEMOP_MNEMONIC(shld_Ev_Gv_Ib, "shld Ev,Gv,Ib");
6705 IEMOP_HLP_MIN_386();
6706 return FNIEMOP_CALL_1(iemOpCommonShldShrd_Ib, &g_iemAImpl_shld);
6707}
6708
6709
6710/** Opcode 0x0f 0xa5. */
6711FNIEMOP_DEF(iemOp_shld_Ev_Gv_CL)
6712{
6713 IEMOP_MNEMONIC(shld_Ev_Gv_CL, "shld Ev,Gv,CL");
6714 IEMOP_HLP_MIN_386();
6715 return FNIEMOP_CALL_1(iemOpCommonShldShrd_CL, &g_iemAImpl_shld);
6716}
6717
6718
6719/** Opcode 0x0f 0xa8. */
6720FNIEMOP_DEF(iemOp_push_gs)
6721{
6722 IEMOP_MNEMONIC(push_gs, "push gs");
6723 IEMOP_HLP_MIN_386();
6724 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6725 return FNIEMOP_CALL_1(iemOpCommonPushSReg, X86_SREG_GS);
6726}
6727
6728
6729/** Opcode 0x0f 0xa9. */
6730FNIEMOP_DEF(iemOp_pop_gs)
6731{
6732 IEMOP_MNEMONIC(pop_gs, "pop gs");
6733 IEMOP_HLP_MIN_386();
6734 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6735 return IEM_MC_DEFER_TO_CIMPL_2(iemCImpl_pop_Sreg, X86_SREG_GS, pVCpu->iem.s.enmEffOpSize);
6736}
6737
6738
6739/** Opcode 0x0f 0xaa. */
6740FNIEMOP_DEF(iemOp_rsm)
6741{
6742 IEMOP_MNEMONIC0(FIXED, RSM, rsm, DISOPTYPE_HARMLESS, 0);
6743 IEMOP_HLP_MIN_386(); /* 386SL and later. */
6744 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6745 return IEM_MC_DEFER_TO_CIMPL_0(iemCImpl_rsm);
6746}
6747
6748
6749
6750/** Opcode 0x0f 0xab. */
6751FNIEMOP_DEF(iemOp_bts_Ev_Gv)
6752{
6753 IEMOP_MNEMONIC(bts_Ev_Gv, "bts Ev,Gv");
6754 IEMOP_HLP_MIN_386();
6755 return FNIEMOP_CALL_1(iemOpCommonBit_Ev_Gv, &g_iemAImpl_bts);
6756}
6757
6758
6759/** Opcode 0x0f 0xac. */
6760FNIEMOP_DEF(iemOp_shrd_Ev_Gv_Ib)
6761{
6762 IEMOP_MNEMONIC(shrd_Ev_Gv_Ib, "shrd Ev,Gv,Ib");
6763 IEMOP_HLP_MIN_386();
6764 return FNIEMOP_CALL_1(iemOpCommonShldShrd_Ib, &g_iemAImpl_shrd);
6765}
6766
6767
6768/** Opcode 0x0f 0xad. */
6769FNIEMOP_DEF(iemOp_shrd_Ev_Gv_CL)
6770{
6771 IEMOP_MNEMONIC(shrd_Ev_Gv_CL, "shrd Ev,Gv,CL");
6772 IEMOP_HLP_MIN_386();
6773 return FNIEMOP_CALL_1(iemOpCommonShldShrd_CL, &g_iemAImpl_shrd);
6774}
6775
6776
6777/** Opcode 0x0f 0xae mem/0. */
6778FNIEMOP_DEF_1(iemOp_Grp15_fxsave, uint8_t, bRm)
6779{
6780 IEMOP_MNEMONIC(fxsave, "fxsave m512");
6781 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fFxSaveRstor)
6782 return IEMOP_RAISE_INVALID_OPCODE();
6783
6784 IEM_MC_BEGIN(3, 1);
6785 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6786 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6787 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 2);
6788 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6789 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6790 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
6791 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6792 IEM_MC_CALL_CIMPL_3(iemCImpl_fxsave, iEffSeg, GCPtrEff, enmEffOpSize);
6793 IEM_MC_END();
6794 return VINF_SUCCESS;
6795}
6796
6797
6798/** Opcode 0x0f 0xae mem/1. */
6799FNIEMOP_DEF_1(iemOp_Grp15_fxrstor, uint8_t, bRm)
6800{
6801 IEMOP_MNEMONIC(fxrstor, "fxrstor m512");
6802 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fFxSaveRstor)
6803 return IEMOP_RAISE_INVALID_OPCODE();
6804
6805 IEM_MC_BEGIN(3, 1);
6806 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6807 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6808 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 2);
6809 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6810 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6811 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
6812 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6813 IEM_MC_CALL_CIMPL_3(iemCImpl_fxrstor, iEffSeg, GCPtrEff, enmEffOpSize);
6814 IEM_MC_END();
6815 return VINF_SUCCESS;
6816}
6817
6818
6819/**
6820 * @opmaps grp15
6821 * @opcode !11/2
6822 * @oppfx none
6823 * @opcpuid sse
6824 * @opgroup og_sse_mxcsrsm
6825 * @opxcpttype 5
6826 * @optest op1=0 -> mxcsr=0
6827 * @optest op1=0x2083 -> mxcsr=0x2083
6828 * @optest op1=0xfffffffe -> value.xcpt=0xd
6829 * @optest op1=0x2083 cr0|=ts -> value.xcpt=0x7
6830 * @optest op1=0x2083 cr0|=em -> value.xcpt=0x6
6831 * @optest op1=0x2083 cr0|=mp -> mxcsr=0x2083
6832 * @optest op1=0x2083 cr4&~=osfxsr -> value.xcpt=0x6
6833 * @optest op1=0x2083 cr0|=ts,em -> value.xcpt=0x6
6834 * @optest op1=0x2083 cr0|=em cr4&~=osfxsr -> value.xcpt=0x6
6835 * @optest op1=0x2083 cr0|=ts,em cr4&~=osfxsr -> value.xcpt=0x6
6836 * @optest op1=0x2083 cr0|=ts,em,mp cr4&~=osfxsr -> value.xcpt=0x6
6837 */
6838FNIEMOP_DEF_1(iemOp_Grp15_ldmxcsr, uint8_t, bRm)
6839{
6840 IEMOP_MNEMONIC1(M_MEM, LDMXCSR, ldmxcsr, Md_RO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6841 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse)
6842 return IEMOP_RAISE_INVALID_OPCODE();
6843
6844 IEM_MC_BEGIN(2, 0);
6845 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6846 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6847 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6848 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6849 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
6850 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6851 IEM_MC_CALL_CIMPL_2(iemCImpl_ldmxcsr, iEffSeg, GCPtrEff);
6852 IEM_MC_END();
6853 return VINF_SUCCESS;
6854}
6855
6856
6857/**
6858 * @opmaps grp15
6859 * @opcode !11/3
6860 * @oppfx none
6861 * @opcpuid sse
6862 * @opgroup og_sse_mxcsrsm
6863 * @opxcpttype 5
6864 * @optest mxcsr=0 -> op1=0
6865 * @optest mxcsr=0x2083 -> op1=0x2083
6866 * @optest mxcsr=0x2084 cr0|=ts -> value.xcpt=0x7
6867 * @optest mxcsr=0x2085 cr0|=em -> value.xcpt=0x6
6868 * @optest mxcsr=0x2086 cr0|=mp -> op1=0x2086
6869 * @optest mxcsr=0x2087 cr4&~=osfxsr -> value.xcpt=0x6
6870 * @optest mxcsr=0x2088 cr0|=ts,em -> value.xcpt=0x6
6871 * @optest mxcsr=0x2089 cr0|=em cr4&~=osfxsr -> value.xcpt=0x6
6872 * @optest mxcsr=0x208a cr0|=ts,em cr4&~=osfxsr -> value.xcpt=0x6
6873 * @optest mxcsr=0x208b cr0|=ts,em,mp cr4&~=osfxsr -> value.xcpt=0x6
6874 */
6875FNIEMOP_DEF_1(iemOp_Grp15_stmxcsr, uint8_t, bRm)
6876{
6877 IEMOP_MNEMONIC1(M_MEM, STMXCSR, stmxcsr, Md_WO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6878 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse)
6879 return IEMOP_RAISE_INVALID_OPCODE();
6880
6881 IEM_MC_BEGIN(2, 0);
6882 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6883 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6884 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6885 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6886 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
6887 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6888 IEM_MC_CALL_CIMPL_2(iemCImpl_stmxcsr, iEffSeg, GCPtrEff);
6889 IEM_MC_END();
6890 return VINF_SUCCESS;
6891}
6892
6893
6894/**
6895 * @opmaps grp15
6896 * @opcode !11/4
6897 * @oppfx none
6898 * @opcpuid xsave
6899 * @opgroup og_system
6900 * @opxcpttype none
6901 */
6902FNIEMOP_DEF_1(iemOp_Grp15_xsave, uint8_t, bRm)
6903{
6904 IEMOP_MNEMONIC1(M_MEM, XSAVE, xsave, M_RW, DISOPTYPE_HARMLESS, 0);
6905 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
6906 return IEMOP_RAISE_INVALID_OPCODE();
6907
6908 IEM_MC_BEGIN(3, 0);
6909 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6910 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6911 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 2);
6912 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6913 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6914 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
6915 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6916 IEM_MC_CALL_CIMPL_3(iemCImpl_xsave, iEffSeg, GCPtrEff, enmEffOpSize);
6917 IEM_MC_END();
6918 return VINF_SUCCESS;
6919}
6920
6921
6922/**
6923 * @opmaps grp15
6924 * @opcode !11/5
6925 * @oppfx none
6926 * @opcpuid xsave
6927 * @opgroup og_system
6928 * @opxcpttype none
6929 */
6930FNIEMOP_DEF_1(iemOp_Grp15_xrstor, uint8_t, bRm)
6931{
6932 IEMOP_MNEMONIC1(M_MEM, XRSTOR, xrstor, M_RO, DISOPTYPE_HARMLESS, 0);
6933 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fXSaveRstor)
6934 return IEMOP_RAISE_INVALID_OPCODE();
6935
6936 IEM_MC_BEGIN(3, 0);
6937 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6938 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6939 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 2);
6940 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6941 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6942 IEM_MC_ACTUALIZE_FPU_STATE_FOR_READ();
6943 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6944 IEM_MC_CALL_CIMPL_3(iemCImpl_xrstor, iEffSeg, GCPtrEff, enmEffOpSize);
6945 IEM_MC_END();
6946 return VINF_SUCCESS;
6947}
6948
6949/** Opcode 0x0f 0xae mem/6. */
6950FNIEMOP_UD_STUB_1(iemOp_Grp15_xsaveopt, uint8_t, bRm);
6951
6952/**
6953 * @opmaps grp15
6954 * @opcode !11/7
6955 * @oppfx none
6956 * @opcpuid clfsh
6957 * @opgroup og_cachectl
6958 * @optest op1=1 ->
6959 */
6960FNIEMOP_DEF_1(iemOp_Grp15_clflush, uint8_t, bRm)
6961{
6962 IEMOP_MNEMONIC1(M_MEM, CLFLUSH, clflush, Mb_RO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6963 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fClFlush)
6964 return FNIEMOP_CALL_1(iemOp_InvalidWithRMAllNeeded, bRm);
6965
6966 IEM_MC_BEGIN(2, 0);
6967 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6968 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6969 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6970 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6971 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6972 IEM_MC_CALL_CIMPL_2(iemCImpl_clflush_clflushopt, iEffSeg, GCPtrEff);
6973 IEM_MC_END();
6974 return VINF_SUCCESS;
6975}
6976
6977/**
6978 * @opmaps grp15
6979 * @opcode !11/7
6980 * @oppfx 0x66
6981 * @opcpuid clflushopt
6982 * @opgroup og_cachectl
6983 * @optest op1=1 ->
6984 */
6985FNIEMOP_DEF_1(iemOp_Grp15_clflushopt, uint8_t, bRm)
6986{
6987 IEMOP_MNEMONIC1(M_MEM, CLFLUSHOPT, clflushopt, Mb_RO, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
6988 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fClFlushOpt)
6989 return FNIEMOP_CALL_1(iemOp_InvalidWithRMAllNeeded, bRm);
6990
6991 IEM_MC_BEGIN(2, 0);
6992 IEM_MC_ARG(uint8_t, iEffSeg, 0);
6993 IEM_MC_ARG(RTGCPTR, GCPtrEff, 1);
6994 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
6995 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
6996 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
6997 IEM_MC_CALL_CIMPL_2(iemCImpl_clflush_clflushopt, iEffSeg, GCPtrEff);
6998 IEM_MC_END();
6999 return VINF_SUCCESS;
7000}
7001
7002
7003/** Opcode 0x0f 0xae 11b/5. */
7004FNIEMOP_DEF_1(iemOp_Grp15_lfence, uint8_t, bRm)
7005{
7006 RT_NOREF_PV(bRm);
7007 IEMOP_MNEMONIC(lfence, "lfence");
7008 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7009 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse2)
7010 return IEMOP_RAISE_INVALID_OPCODE();
7011
7012 IEM_MC_BEGIN(0, 0);
7013 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fSse2)
7014 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_lfence);
7015 else
7016 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_alt_mem_fence);
7017 IEM_MC_ADVANCE_RIP();
7018 IEM_MC_END();
7019 return VINF_SUCCESS;
7020}
7021
7022
7023/** Opcode 0x0f 0xae 11b/6. */
7024FNIEMOP_DEF_1(iemOp_Grp15_mfence, uint8_t, bRm)
7025{
7026 RT_NOREF_PV(bRm);
7027 IEMOP_MNEMONIC(mfence, "mfence");
7028 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7029 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse2)
7030 return IEMOP_RAISE_INVALID_OPCODE();
7031
7032 IEM_MC_BEGIN(0, 0);
7033 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fSse2)
7034 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_mfence);
7035 else
7036 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_alt_mem_fence);
7037 IEM_MC_ADVANCE_RIP();
7038 IEM_MC_END();
7039 return VINF_SUCCESS;
7040}
7041
7042
7043/** Opcode 0x0f 0xae 11b/7. */
7044FNIEMOP_DEF_1(iemOp_Grp15_sfence, uint8_t, bRm)
7045{
7046 RT_NOREF_PV(bRm);
7047 IEMOP_MNEMONIC(sfence, "sfence");
7048 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7049 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse2)
7050 return IEMOP_RAISE_INVALID_OPCODE();
7051
7052 IEM_MC_BEGIN(0, 0);
7053 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fSse2)
7054 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_sfence);
7055 else
7056 IEM_MC_CALL_VOID_AIMPL_0(iemAImpl_alt_mem_fence);
7057 IEM_MC_ADVANCE_RIP();
7058 IEM_MC_END();
7059 return VINF_SUCCESS;
7060}
7061
7062
7063/** Opcode 0xf3 0x0f 0xae 11b/0. */
7064FNIEMOP_DEF_1(iemOp_Grp15_rdfsbase, uint8_t, bRm)
7065{
7066 IEMOP_MNEMONIC(rdfsbase, "rdfsbase Ry");
7067 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7068 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
7069 {
7070 IEM_MC_BEGIN(1, 0);
7071 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7072 IEM_MC_ARG(uint64_t, u64Dst, 0);
7073 IEM_MC_FETCH_SREG_BASE_U64(u64Dst, X86_SREG_FS);
7074 IEM_MC_STORE_GREG_U64((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u64Dst);
7075 IEM_MC_ADVANCE_RIP();
7076 IEM_MC_END();
7077 }
7078 else
7079 {
7080 IEM_MC_BEGIN(1, 0);
7081 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7082 IEM_MC_ARG(uint32_t, u32Dst, 0);
7083 IEM_MC_FETCH_SREG_BASE_U32(u32Dst, X86_SREG_FS);
7084 IEM_MC_STORE_GREG_U32((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u32Dst);
7085 IEM_MC_ADVANCE_RIP();
7086 IEM_MC_END();
7087 }
7088 return VINF_SUCCESS;
7089}
7090
7091
7092/** Opcode 0xf3 0x0f 0xae 11b/1. */
7093FNIEMOP_DEF_1(iemOp_Grp15_rdgsbase, uint8_t, bRm)
7094{
7095 IEMOP_MNEMONIC(rdgsbase, "rdgsbase Ry");
7096 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7097 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
7098 {
7099 IEM_MC_BEGIN(1, 0);
7100 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7101 IEM_MC_ARG(uint64_t, u64Dst, 0);
7102 IEM_MC_FETCH_SREG_BASE_U64(u64Dst, X86_SREG_GS);
7103 IEM_MC_STORE_GREG_U64((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u64Dst);
7104 IEM_MC_ADVANCE_RIP();
7105 IEM_MC_END();
7106 }
7107 else
7108 {
7109 IEM_MC_BEGIN(1, 0);
7110 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7111 IEM_MC_ARG(uint32_t, u32Dst, 0);
7112 IEM_MC_FETCH_SREG_BASE_U32(u32Dst, X86_SREG_GS);
7113 IEM_MC_STORE_GREG_U32((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, u32Dst);
7114 IEM_MC_ADVANCE_RIP();
7115 IEM_MC_END();
7116 }
7117 return VINF_SUCCESS;
7118}
7119
7120
7121/** Opcode 0xf3 0x0f 0xae 11b/2. */
7122FNIEMOP_DEF_1(iemOp_Grp15_wrfsbase, uint8_t, bRm)
7123{
7124 IEMOP_MNEMONIC(wrfsbase, "wrfsbase Ry");
7125 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7126 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
7127 {
7128 IEM_MC_BEGIN(1, 0);
7129 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7130 IEM_MC_ARG(uint64_t, u64Dst, 0);
7131 IEM_MC_FETCH_GREG_U64(u64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7132 IEM_MC_MAYBE_RAISE_NON_CANONICAL_ADDR_GP0(u64Dst);
7133 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_FS, u64Dst);
7134 IEM_MC_ADVANCE_RIP();
7135 IEM_MC_END();
7136 }
7137 else
7138 {
7139 IEM_MC_BEGIN(1, 0);
7140 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7141 IEM_MC_ARG(uint32_t, u32Dst, 0);
7142 IEM_MC_FETCH_GREG_U32(u32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7143 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_FS, u32Dst);
7144 IEM_MC_ADVANCE_RIP();
7145 IEM_MC_END();
7146 }
7147 return VINF_SUCCESS;
7148}
7149
7150
7151/** Opcode 0xf3 0x0f 0xae 11b/3. */
7152FNIEMOP_DEF_1(iemOp_Grp15_wrgsbase, uint8_t, bRm)
7153{
7154 IEMOP_MNEMONIC(wrgsbase, "wrgsbase Ry");
7155 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7156 if (pVCpu->iem.s.enmEffOpSize == IEMMODE_64BIT)
7157 {
7158 IEM_MC_BEGIN(1, 0);
7159 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7160 IEM_MC_ARG(uint64_t, u64Dst, 0);
7161 IEM_MC_FETCH_GREG_U64(u64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7162 IEM_MC_MAYBE_RAISE_NON_CANONICAL_ADDR_GP0(u64Dst);
7163 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_GS, u64Dst);
7164 IEM_MC_ADVANCE_RIP();
7165 IEM_MC_END();
7166 }
7167 else
7168 {
7169 IEM_MC_BEGIN(1, 0);
7170 IEM_MC_MAYBE_RAISE_FSGSBASE_XCPT();
7171 IEM_MC_ARG(uint32_t, u32Dst, 0);
7172 IEM_MC_FETCH_GREG_U32(u32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7173 IEM_MC_STORE_SREG_BASE_U64(X86_SREG_GS, u32Dst);
7174 IEM_MC_ADVANCE_RIP();
7175 IEM_MC_END();
7176 }
7177 return VINF_SUCCESS;
7178}
7179
7180
7181/**
7182 * Group 15 jump table for register variant.
7183 */
7184IEM_STATIC const PFNIEMOPRM g_apfnGroup15RegReg[] =
7185{ /* pfx: none, 066h, 0f3h, 0f2h */
7186 /* /0 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_rdfsbase, iemOp_InvalidWithRM,
7187 /* /1 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_rdgsbase, iemOp_InvalidWithRM,
7188 /* /2 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_wrfsbase, iemOp_InvalidWithRM,
7189 /* /3 */ iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_Grp15_wrgsbase, iemOp_InvalidWithRM,
7190 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM),
7191 /* /5 */ iemOp_Grp15_lfence, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7192 /* /6 */ iemOp_Grp15_mfence, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7193 /* /7 */ iemOp_Grp15_sfence, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7194};
7195AssertCompile(RT_ELEMENTS(g_apfnGroup15RegReg) == 8*4);
7196
7197
7198/**
7199 * Group 15 jump table for memory variant.
7200 */
7201IEM_STATIC const PFNIEMOPRM g_apfnGroup15MemReg[] =
7202{ /* pfx: none, 066h, 0f3h, 0f2h */
7203 /* /0 */ iemOp_Grp15_fxsave, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7204 /* /1 */ iemOp_Grp15_fxrstor, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7205 /* /2 */ iemOp_Grp15_ldmxcsr, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7206 /* /3 */ iemOp_Grp15_stmxcsr, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7207 /* /4 */ iemOp_Grp15_xsave, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7208 /* /5 */ iemOp_Grp15_xrstor, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7209 /* /6 */ iemOp_Grp15_xsaveopt, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7210 /* /7 */ iemOp_Grp15_clflush, iemOp_Grp15_clflushopt, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
7211};
7212AssertCompile(RT_ELEMENTS(g_apfnGroup15MemReg) == 8*4);
7213
7214
7215/** Opcode 0x0f 0xae. */
7216FNIEMOP_DEF(iemOp_Grp15)
7217{
7218 IEMOP_HLP_MIN_586(); /* Not entirely accurate nor needed, but useful for debugging 286 code. */
7219 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7220 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7221 /* register, register */
7222 return FNIEMOP_CALL_1(g_apfnGroup15RegReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
7223 + pVCpu->iem.s.idxPrefix], bRm);
7224 /* memory, register */
7225 return FNIEMOP_CALL_1(g_apfnGroup15MemReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
7226 + pVCpu->iem.s.idxPrefix], bRm);
7227}
7228
7229
7230/** Opcode 0x0f 0xaf. */
7231FNIEMOP_DEF(iemOp_imul_Gv_Ev)
7232{
7233 IEMOP_MNEMONIC(imul_Gv_Ev, "imul Gv,Ev");
7234 IEMOP_HLP_MIN_386();
7235 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF);
7236 return FNIEMOP_CALL_1(iemOpHlpBinaryOperator_rv_rm, &g_iemAImpl_imul_two);
7237}
7238
7239
7240/** Opcode 0x0f 0xb0. */
7241FNIEMOP_DEF(iemOp_cmpxchg_Eb_Gb)
7242{
7243 IEMOP_MNEMONIC(cmpxchg_Eb_Gb, "cmpxchg Eb,Gb");
7244 IEMOP_HLP_MIN_486();
7245 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7246
7247 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7248 {
7249 IEMOP_HLP_DONE_DECODING();
7250 IEM_MC_BEGIN(4, 0);
7251 IEM_MC_ARG(uint8_t *, pu8Dst, 0);
7252 IEM_MC_ARG(uint8_t *, pu8Al, 1);
7253 IEM_MC_ARG(uint8_t, u8Src, 2);
7254 IEM_MC_ARG(uint32_t *, pEFlags, 3);
7255
7256 IEM_MC_FETCH_GREG_U8(u8Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7257 IEM_MC_REF_GREG_U8(pu8Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7258 IEM_MC_REF_GREG_U8(pu8Al, X86_GREG_xAX);
7259 IEM_MC_REF_EFLAGS(pEFlags);
7260 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7261 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u8, pu8Dst, pu8Al, u8Src, pEFlags);
7262 else
7263 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u8_locked, pu8Dst, pu8Al, u8Src, pEFlags);
7264
7265 IEM_MC_ADVANCE_RIP();
7266 IEM_MC_END();
7267 }
7268 else
7269 {
7270 IEM_MC_BEGIN(4, 3);
7271 IEM_MC_ARG(uint8_t *, pu8Dst, 0);
7272 IEM_MC_ARG(uint8_t *, pu8Al, 1);
7273 IEM_MC_ARG(uint8_t, u8Src, 2);
7274 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
7275 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7276 IEM_MC_LOCAL(uint8_t, u8Al);
7277
7278 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7279 IEMOP_HLP_DONE_DECODING();
7280 IEM_MC_MEM_MAP(pu8Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7281 IEM_MC_FETCH_GREG_U8(u8Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7282 IEM_MC_FETCH_GREG_U8(u8Al, X86_GREG_xAX);
7283 IEM_MC_FETCH_EFLAGS(EFlags);
7284 IEM_MC_REF_LOCAL(pu8Al, u8Al);
7285 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7286 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u8, pu8Dst, pu8Al, u8Src, pEFlags);
7287 else
7288 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u8_locked, pu8Dst, pu8Al, u8Src, pEFlags);
7289
7290 IEM_MC_MEM_COMMIT_AND_UNMAP(pu8Dst, IEM_ACCESS_DATA_RW);
7291 IEM_MC_COMMIT_EFLAGS(EFlags);
7292 IEM_MC_STORE_GREG_U8(X86_GREG_xAX, u8Al);
7293 IEM_MC_ADVANCE_RIP();
7294 IEM_MC_END();
7295 }
7296 return VINF_SUCCESS;
7297}
7298
7299/** Opcode 0x0f 0xb1. */
7300FNIEMOP_DEF(iemOp_cmpxchg_Ev_Gv)
7301{
7302 IEMOP_MNEMONIC(cmpxchg_Ev_Gv, "cmpxchg Ev,Gv");
7303 IEMOP_HLP_MIN_486();
7304 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7305
7306 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7307 {
7308 IEMOP_HLP_DONE_DECODING();
7309 switch (pVCpu->iem.s.enmEffOpSize)
7310 {
7311 case IEMMODE_16BIT:
7312 IEM_MC_BEGIN(4, 0);
7313 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
7314 IEM_MC_ARG(uint16_t *, pu16Ax, 1);
7315 IEM_MC_ARG(uint16_t, u16Src, 2);
7316 IEM_MC_ARG(uint32_t *, pEFlags, 3);
7317
7318 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7319 IEM_MC_REF_GREG_U16(pu16Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7320 IEM_MC_REF_GREG_U16(pu16Ax, X86_GREG_xAX);
7321 IEM_MC_REF_EFLAGS(pEFlags);
7322 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7323 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u16, pu16Dst, pu16Ax, u16Src, pEFlags);
7324 else
7325 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u16_locked, pu16Dst, pu16Ax, u16Src, pEFlags);
7326
7327 IEM_MC_ADVANCE_RIP();
7328 IEM_MC_END();
7329 return VINF_SUCCESS;
7330
7331 case IEMMODE_32BIT:
7332 IEM_MC_BEGIN(4, 0);
7333 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
7334 IEM_MC_ARG(uint32_t *, pu32Eax, 1);
7335 IEM_MC_ARG(uint32_t, u32Src, 2);
7336 IEM_MC_ARG(uint32_t *, pEFlags, 3);
7337
7338 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7339 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7340 IEM_MC_REF_GREG_U32(pu32Eax, X86_GREG_xAX);
7341 IEM_MC_REF_EFLAGS(pEFlags);
7342 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7343 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u32, pu32Dst, pu32Eax, u32Src, pEFlags);
7344 else
7345 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u32_locked, pu32Dst, pu32Eax, u32Src, pEFlags);
7346
7347 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Eax);
7348 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
7349 IEM_MC_ADVANCE_RIP();
7350 IEM_MC_END();
7351 return VINF_SUCCESS;
7352
7353 case IEMMODE_64BIT:
7354 IEM_MC_BEGIN(4, 0);
7355 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
7356 IEM_MC_ARG(uint64_t *, pu64Rax, 1);
7357#ifdef RT_ARCH_X86
7358 IEM_MC_ARG(uint64_t *, pu64Src, 2);
7359#else
7360 IEM_MC_ARG(uint64_t, u64Src, 2);
7361#endif
7362 IEM_MC_ARG(uint32_t *, pEFlags, 3);
7363
7364 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7365 IEM_MC_REF_GREG_U64(pu64Rax, X86_GREG_xAX);
7366 IEM_MC_REF_EFLAGS(pEFlags);
7367#ifdef RT_ARCH_X86
7368 IEM_MC_REF_GREG_U64(pu64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7369 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7370 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64, pu64Dst, pu64Rax, pu64Src, pEFlags);
7371 else
7372 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64_locked, pu64Dst, pu64Rax, pu64Src, pEFlags);
7373#else
7374 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7375 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7376 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64, pu64Dst, pu64Rax, u64Src, pEFlags);
7377 else
7378 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64_locked, pu64Dst, pu64Rax, u64Src, pEFlags);
7379#endif
7380
7381 IEM_MC_ADVANCE_RIP();
7382 IEM_MC_END();
7383 return VINF_SUCCESS;
7384
7385 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7386 }
7387 }
7388 else
7389 {
7390 switch (pVCpu->iem.s.enmEffOpSize)
7391 {
7392 case IEMMODE_16BIT:
7393 IEM_MC_BEGIN(4, 3);
7394 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
7395 IEM_MC_ARG(uint16_t *, pu16Ax, 1);
7396 IEM_MC_ARG(uint16_t, u16Src, 2);
7397 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
7398 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7399 IEM_MC_LOCAL(uint16_t, u16Ax);
7400
7401 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7402 IEMOP_HLP_DONE_DECODING();
7403 IEM_MC_MEM_MAP(pu16Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7404 IEM_MC_FETCH_GREG_U16(u16Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7405 IEM_MC_FETCH_GREG_U16(u16Ax, X86_GREG_xAX);
7406 IEM_MC_FETCH_EFLAGS(EFlags);
7407 IEM_MC_REF_LOCAL(pu16Ax, u16Ax);
7408 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7409 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u16, pu16Dst, pu16Ax, u16Src, pEFlags);
7410 else
7411 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u16_locked, pu16Dst, pu16Ax, u16Src, pEFlags);
7412
7413 IEM_MC_MEM_COMMIT_AND_UNMAP(pu16Dst, IEM_ACCESS_DATA_RW);
7414 IEM_MC_COMMIT_EFLAGS(EFlags);
7415 IEM_MC_STORE_GREG_U16(X86_GREG_xAX, u16Ax);
7416 IEM_MC_ADVANCE_RIP();
7417 IEM_MC_END();
7418 return VINF_SUCCESS;
7419
7420 case IEMMODE_32BIT:
7421 IEM_MC_BEGIN(4, 3);
7422 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
7423 IEM_MC_ARG(uint32_t *, pu32Eax, 1);
7424 IEM_MC_ARG(uint32_t, u32Src, 2);
7425 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
7426 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7427 IEM_MC_LOCAL(uint32_t, u32Eax);
7428
7429 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7430 IEMOP_HLP_DONE_DECODING();
7431 IEM_MC_MEM_MAP(pu32Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7432 IEM_MC_FETCH_GREG_U32(u32Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7433 IEM_MC_FETCH_GREG_U32(u32Eax, X86_GREG_xAX);
7434 IEM_MC_FETCH_EFLAGS(EFlags);
7435 IEM_MC_REF_LOCAL(pu32Eax, u32Eax);
7436 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7437 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u32, pu32Dst, pu32Eax, u32Src, pEFlags);
7438 else
7439 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u32_locked, pu32Dst, pu32Eax, u32Src, pEFlags);
7440
7441 IEM_MC_MEM_COMMIT_AND_UNMAP(pu32Dst, IEM_ACCESS_DATA_RW);
7442 IEM_MC_COMMIT_EFLAGS(EFlags);
7443 IEM_MC_STORE_GREG_U32(X86_GREG_xAX, u32Eax);
7444 IEM_MC_ADVANCE_RIP();
7445 IEM_MC_END();
7446 return VINF_SUCCESS;
7447
7448 case IEMMODE_64BIT:
7449 IEM_MC_BEGIN(4, 3);
7450 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
7451 IEM_MC_ARG(uint64_t *, pu64Rax, 1);
7452#ifdef RT_ARCH_X86
7453 IEM_MC_ARG(uint64_t *, pu64Src, 2);
7454#else
7455 IEM_MC_ARG(uint64_t, u64Src, 2);
7456#endif
7457 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 3);
7458 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7459 IEM_MC_LOCAL(uint64_t, u64Rax);
7460
7461 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7462 IEMOP_HLP_DONE_DECODING();
7463 IEM_MC_MEM_MAP(pu64Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7464 IEM_MC_FETCH_GREG_U64(u64Rax, X86_GREG_xAX);
7465 IEM_MC_FETCH_EFLAGS(EFlags);
7466 IEM_MC_REF_LOCAL(pu64Rax, u64Rax);
7467#ifdef RT_ARCH_X86
7468 IEM_MC_REF_GREG_U64(pu64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7469 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7470 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64, pu64Dst, pu64Rax, pu64Src, pEFlags);
7471 else
7472 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64_locked, pu64Dst, pu64Rax, pu64Src, pEFlags);
7473#else
7474 IEM_MC_FETCH_GREG_U64(u64Src, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
7475 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7476 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64, pu64Dst, pu64Rax, u64Src, pEFlags);
7477 else
7478 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg_u64_locked, pu64Dst, pu64Rax, u64Src, pEFlags);
7479#endif
7480
7481 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64Dst, IEM_ACCESS_DATA_RW);
7482 IEM_MC_COMMIT_EFLAGS(EFlags);
7483 IEM_MC_STORE_GREG_U64(X86_GREG_xAX, u64Rax);
7484 IEM_MC_ADVANCE_RIP();
7485 IEM_MC_END();
7486 return VINF_SUCCESS;
7487
7488 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7489 }
7490 }
7491}
7492
7493
7494FNIEMOP_DEF_2(iemOpCommonLoadSRegAndGreg, uint8_t, iSegReg, uint8_t, bRm)
7495{
7496 Assert((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT)); /* Caller checks this */
7497 uint8_t const iGReg = ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg;
7498
7499 switch (pVCpu->iem.s.enmEffOpSize)
7500 {
7501 case IEMMODE_16BIT:
7502 IEM_MC_BEGIN(5, 1);
7503 IEM_MC_ARG(uint16_t, uSel, 0);
7504 IEM_MC_ARG(uint16_t, offSeg, 1);
7505 IEM_MC_ARG_CONST(uint8_t, iSegRegArg,/*=*/iSegReg, 2);
7506 IEM_MC_ARG_CONST(uint8_t, iGRegArg, /*=*/iGReg, 3);
7507 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 4);
7508 IEM_MC_LOCAL(RTGCPTR, GCPtrEff);
7509 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
7510 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7511 IEM_MC_FETCH_MEM_U16(offSeg, pVCpu->iem.s.iEffSeg, GCPtrEff);
7512 IEM_MC_FETCH_MEM_U16_DISP(uSel, pVCpu->iem.s.iEffSeg, GCPtrEff, 2);
7513 IEM_MC_CALL_CIMPL_5(iemCImpl_load_SReg_Greg, uSel, offSeg, iSegRegArg, iGRegArg, enmEffOpSize);
7514 IEM_MC_END();
7515 return VINF_SUCCESS;
7516
7517 case IEMMODE_32BIT:
7518 IEM_MC_BEGIN(5, 1);
7519 IEM_MC_ARG(uint16_t, uSel, 0);
7520 IEM_MC_ARG(uint32_t, offSeg, 1);
7521 IEM_MC_ARG_CONST(uint8_t, iSegRegArg,/*=*/iSegReg, 2);
7522 IEM_MC_ARG_CONST(uint8_t, iGRegArg, /*=*/iGReg, 3);
7523 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 4);
7524 IEM_MC_LOCAL(RTGCPTR, GCPtrEff);
7525 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
7526 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7527 IEM_MC_FETCH_MEM_U32(offSeg, pVCpu->iem.s.iEffSeg, GCPtrEff);
7528 IEM_MC_FETCH_MEM_U16_DISP(uSel, pVCpu->iem.s.iEffSeg, GCPtrEff, 4);
7529 IEM_MC_CALL_CIMPL_5(iemCImpl_load_SReg_Greg, uSel, offSeg, iSegRegArg, iGRegArg, enmEffOpSize);
7530 IEM_MC_END();
7531 return VINF_SUCCESS;
7532
7533 case IEMMODE_64BIT:
7534 IEM_MC_BEGIN(5, 1);
7535 IEM_MC_ARG(uint16_t, uSel, 0);
7536 IEM_MC_ARG(uint64_t, offSeg, 1);
7537 IEM_MC_ARG_CONST(uint8_t, iSegRegArg,/*=*/iSegReg, 2);
7538 IEM_MC_ARG_CONST(uint8_t, iGRegArg, /*=*/iGReg, 3);
7539 IEM_MC_ARG_CONST(IEMMODE, enmEffOpSize,/*=*/pVCpu->iem.s.enmEffOpSize, 4);
7540 IEM_MC_LOCAL(RTGCPTR, GCPtrEff);
7541 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEff, bRm, 0);
7542 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7543 if (IEM_IS_GUEST_CPU_AMD(pVCpu)) /** @todo testcase: rev 3.15 of the amd manuals claims it only loads a 32-bit greg. */
7544 IEM_MC_FETCH_MEM_U32_SX_U64(offSeg, pVCpu->iem.s.iEffSeg, GCPtrEff);
7545 else
7546 IEM_MC_FETCH_MEM_U64(offSeg, pVCpu->iem.s.iEffSeg, GCPtrEff);
7547 IEM_MC_FETCH_MEM_U16_DISP(uSel, pVCpu->iem.s.iEffSeg, GCPtrEff, 8);
7548 IEM_MC_CALL_CIMPL_5(iemCImpl_load_SReg_Greg, uSel, offSeg, iSegRegArg, iGRegArg, enmEffOpSize);
7549 IEM_MC_END();
7550 return VINF_SUCCESS;
7551
7552 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7553 }
7554}
7555
7556
7557/** Opcode 0x0f 0xb2. */
7558FNIEMOP_DEF(iemOp_lss_Gv_Mp)
7559{
7560 IEMOP_MNEMONIC(lss_Gv_Mp, "lss Gv,Mp");
7561 IEMOP_HLP_MIN_386();
7562 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7563 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7564 return IEMOP_RAISE_INVALID_OPCODE();
7565 return FNIEMOP_CALL_2(iemOpCommonLoadSRegAndGreg, X86_SREG_SS, bRm);
7566}
7567
7568
7569/** Opcode 0x0f 0xb3. */
7570FNIEMOP_DEF(iemOp_btr_Ev_Gv)
7571{
7572 IEMOP_MNEMONIC(btr_Ev_Gv, "btr Ev,Gv");
7573 IEMOP_HLP_MIN_386();
7574 return FNIEMOP_CALL_1(iemOpCommonBit_Ev_Gv, &g_iemAImpl_btr);
7575}
7576
7577
7578/** Opcode 0x0f 0xb4. */
7579FNIEMOP_DEF(iemOp_lfs_Gv_Mp)
7580{
7581 IEMOP_MNEMONIC(lfs_Gv_Mp, "lfs Gv,Mp");
7582 IEMOP_HLP_MIN_386();
7583 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7584 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7585 return IEMOP_RAISE_INVALID_OPCODE();
7586 return FNIEMOP_CALL_2(iemOpCommonLoadSRegAndGreg, X86_SREG_FS, bRm);
7587}
7588
7589
7590/** Opcode 0x0f 0xb5. */
7591FNIEMOP_DEF(iemOp_lgs_Gv_Mp)
7592{
7593 IEMOP_MNEMONIC(lgs_Gv_Mp, "lgs Gv,Mp");
7594 IEMOP_HLP_MIN_386();
7595 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7596 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7597 return IEMOP_RAISE_INVALID_OPCODE();
7598 return FNIEMOP_CALL_2(iemOpCommonLoadSRegAndGreg, X86_SREG_GS, bRm);
7599}
7600
7601
7602/** Opcode 0x0f 0xb6. */
7603FNIEMOP_DEF(iemOp_movzx_Gv_Eb)
7604{
7605 IEMOP_MNEMONIC(movzx_Gv_Eb, "movzx Gv,Eb");
7606 IEMOP_HLP_MIN_386();
7607
7608 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7609
7610 /*
7611 * If rm is denoting a register, no more instruction bytes.
7612 */
7613 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7614 {
7615 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7616 switch (pVCpu->iem.s.enmEffOpSize)
7617 {
7618 case IEMMODE_16BIT:
7619 IEM_MC_BEGIN(0, 1);
7620 IEM_MC_LOCAL(uint16_t, u16Value);
7621 IEM_MC_FETCH_GREG_U8_ZX_U16(u16Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7622 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16Value);
7623 IEM_MC_ADVANCE_RIP();
7624 IEM_MC_END();
7625 return VINF_SUCCESS;
7626
7627 case IEMMODE_32BIT:
7628 IEM_MC_BEGIN(0, 1);
7629 IEM_MC_LOCAL(uint32_t, u32Value);
7630 IEM_MC_FETCH_GREG_U8_ZX_U32(u32Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7631 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
7632 IEM_MC_ADVANCE_RIP();
7633 IEM_MC_END();
7634 return VINF_SUCCESS;
7635
7636 case IEMMODE_64BIT:
7637 IEM_MC_BEGIN(0, 1);
7638 IEM_MC_LOCAL(uint64_t, u64Value);
7639 IEM_MC_FETCH_GREG_U8_ZX_U64(u64Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7640 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
7641 IEM_MC_ADVANCE_RIP();
7642 IEM_MC_END();
7643 return VINF_SUCCESS;
7644
7645 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7646 }
7647 }
7648 else
7649 {
7650 /*
7651 * We're loading a register from memory.
7652 */
7653 switch (pVCpu->iem.s.enmEffOpSize)
7654 {
7655 case IEMMODE_16BIT:
7656 IEM_MC_BEGIN(0, 2);
7657 IEM_MC_LOCAL(uint16_t, u16Value);
7658 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7659 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7660 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7661 IEM_MC_FETCH_MEM_U8_ZX_U16(u16Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
7662 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16Value);
7663 IEM_MC_ADVANCE_RIP();
7664 IEM_MC_END();
7665 return VINF_SUCCESS;
7666
7667 case IEMMODE_32BIT:
7668 IEM_MC_BEGIN(0, 2);
7669 IEM_MC_LOCAL(uint32_t, u32Value);
7670 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7671 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7672 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7673 IEM_MC_FETCH_MEM_U8_ZX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
7674 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
7675 IEM_MC_ADVANCE_RIP();
7676 IEM_MC_END();
7677 return VINF_SUCCESS;
7678
7679 case IEMMODE_64BIT:
7680 IEM_MC_BEGIN(0, 2);
7681 IEM_MC_LOCAL(uint64_t, u64Value);
7682 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7683 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7684 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7685 IEM_MC_FETCH_MEM_U8_ZX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
7686 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
7687 IEM_MC_ADVANCE_RIP();
7688 IEM_MC_END();
7689 return VINF_SUCCESS;
7690
7691 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7692 }
7693 }
7694}
7695
7696
7697/** Opcode 0x0f 0xb7. */
7698FNIEMOP_DEF(iemOp_movzx_Gv_Ew)
7699{
7700 IEMOP_MNEMONIC(movzx_Gv_Ew, "movzx Gv,Ew");
7701 IEMOP_HLP_MIN_386();
7702
7703 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7704
7705 /** @todo Not entirely sure how the operand size prefix is handled here,
7706 * assuming that it will be ignored. Would be nice to have a few
7707 * test for this. */
7708 /*
7709 * If rm is denoting a register, no more instruction bytes.
7710 */
7711 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7712 {
7713 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7714 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
7715 {
7716 IEM_MC_BEGIN(0, 1);
7717 IEM_MC_LOCAL(uint32_t, u32Value);
7718 IEM_MC_FETCH_GREG_U16_ZX_U32(u32Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7719 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
7720 IEM_MC_ADVANCE_RIP();
7721 IEM_MC_END();
7722 }
7723 else
7724 {
7725 IEM_MC_BEGIN(0, 1);
7726 IEM_MC_LOCAL(uint64_t, u64Value);
7727 IEM_MC_FETCH_GREG_U16_ZX_U64(u64Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7728 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
7729 IEM_MC_ADVANCE_RIP();
7730 IEM_MC_END();
7731 }
7732 }
7733 else
7734 {
7735 /*
7736 * We're loading a register from memory.
7737 */
7738 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
7739 {
7740 IEM_MC_BEGIN(0, 2);
7741 IEM_MC_LOCAL(uint32_t, u32Value);
7742 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7743 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7744 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7745 IEM_MC_FETCH_MEM_U16_ZX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
7746 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
7747 IEM_MC_ADVANCE_RIP();
7748 IEM_MC_END();
7749 }
7750 else
7751 {
7752 IEM_MC_BEGIN(0, 2);
7753 IEM_MC_LOCAL(uint64_t, u64Value);
7754 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7755 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
7756 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7757 IEM_MC_FETCH_MEM_U16_ZX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
7758 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
7759 IEM_MC_ADVANCE_RIP();
7760 IEM_MC_END();
7761 }
7762 }
7763 return VINF_SUCCESS;
7764}
7765
7766
7767/** Opcode 0x0f 0xb8 - JMPE (reserved for emulator on IPF) */
7768FNIEMOP_UD_STUB(iemOp_jmpe);
7769/** Opcode 0xf3 0x0f 0xb8 - POPCNT Gv, Ev */
7770FNIEMOP_STUB(iemOp_popcnt_Gv_Ev);
7771
7772
7773/**
7774 * @opcode 0xb9
7775 * @opinvalid intel-modrm
7776 * @optest ->
7777 */
7778FNIEMOP_DEF(iemOp_Grp10)
7779{
7780 /*
7781 * AMD does not decode beyond the 0xb9 whereas intel does the modr/m bit
7782 * too. See bs3-cpu-decoder-1.c32. So, we can forward to iemOp_InvalidNeedRM.
7783 */
7784 Log(("iemOp_Grp10 aka UD1 -> #UD\n"));
7785 IEMOP_MNEMONIC2EX(ud1, "ud1", RM, UD1, ud1, Gb, Eb, DISOPTYPE_INVALID, IEMOPHINT_IGNORES_OP_SIZES); /* just picked Gb,Eb here. */
7786 return FNIEMOP_CALL(iemOp_InvalidNeedRM);
7787}
7788
7789
7790/** Opcode 0x0f 0xba. */
7791FNIEMOP_DEF(iemOp_Grp8)
7792{
7793 IEMOP_HLP_MIN_386();
7794 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
7795 PCIEMOPBINSIZES pImpl;
7796 switch ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK)
7797 {
7798 case 0: case 1: case 2: case 3:
7799 /* Both AMD and Intel want full modr/m decoding and imm8. */
7800 return FNIEMOP_CALL_1(iemOp_InvalidWithRMAllNeedImm8, bRm);
7801 case 4: pImpl = &g_iemAImpl_bt; IEMOP_MNEMONIC(bt_Ev_Ib, "bt Ev,Ib"); break;
7802 case 5: pImpl = &g_iemAImpl_bts; IEMOP_MNEMONIC(bts_Ev_Ib, "bts Ev,Ib"); break;
7803 case 6: pImpl = &g_iemAImpl_btr; IEMOP_MNEMONIC(btr_Ev_Ib, "btr Ev,Ib"); break;
7804 case 7: pImpl = &g_iemAImpl_btc; IEMOP_MNEMONIC(btc_Ev_Ib, "btc Ev,Ib"); break;
7805 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7806 }
7807 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_ZF | X86_EFL_AF | X86_EFL_PF);
7808
7809 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
7810 {
7811 /* register destination. */
7812 uint8_t u8Bit; IEM_OPCODE_GET_NEXT_U8(&u8Bit);
7813 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7814
7815 switch (pVCpu->iem.s.enmEffOpSize)
7816 {
7817 case IEMMODE_16BIT:
7818 IEM_MC_BEGIN(3, 0);
7819 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
7820 IEM_MC_ARG_CONST(uint16_t, u16Src, /*=*/ u8Bit & 0x0f, 1);
7821 IEM_MC_ARG(uint32_t *, pEFlags, 2);
7822
7823 IEM_MC_REF_GREG_U16(pu16Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7824 IEM_MC_REF_EFLAGS(pEFlags);
7825 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU16, pu16Dst, u16Src, pEFlags);
7826
7827 IEM_MC_ADVANCE_RIP();
7828 IEM_MC_END();
7829 return VINF_SUCCESS;
7830
7831 case IEMMODE_32BIT:
7832 IEM_MC_BEGIN(3, 0);
7833 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
7834 IEM_MC_ARG_CONST(uint32_t, u32Src, /*=*/ u8Bit & 0x1f, 1);
7835 IEM_MC_ARG(uint32_t *, pEFlags, 2);
7836
7837 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7838 IEM_MC_REF_EFLAGS(pEFlags);
7839 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU32, pu32Dst, u32Src, pEFlags);
7840
7841 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
7842 IEM_MC_ADVANCE_RIP();
7843 IEM_MC_END();
7844 return VINF_SUCCESS;
7845
7846 case IEMMODE_64BIT:
7847 IEM_MC_BEGIN(3, 0);
7848 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
7849 IEM_MC_ARG_CONST(uint64_t, u64Src, /*=*/ u8Bit & 0x3f, 1);
7850 IEM_MC_ARG(uint32_t *, pEFlags, 2);
7851
7852 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
7853 IEM_MC_REF_EFLAGS(pEFlags);
7854 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU64, pu64Dst, u64Src, pEFlags);
7855
7856 IEM_MC_ADVANCE_RIP();
7857 IEM_MC_END();
7858 return VINF_SUCCESS;
7859
7860 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7861 }
7862 }
7863 else
7864 {
7865 /* memory destination. */
7866
7867 uint32_t fAccess;
7868 if (pImpl->pfnLockedU16)
7869 fAccess = IEM_ACCESS_DATA_RW;
7870 else /* BT */
7871 fAccess = IEM_ACCESS_DATA_R;
7872
7873 /** @todo test negative bit offsets! */
7874 switch (pVCpu->iem.s.enmEffOpSize)
7875 {
7876 case IEMMODE_16BIT:
7877 IEM_MC_BEGIN(3, 1);
7878 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
7879 IEM_MC_ARG(uint16_t, u16Src, 1);
7880 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2);
7881 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7882
7883 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
7884 uint8_t u8Bit; IEM_OPCODE_GET_NEXT_U8(&u8Bit);
7885 IEM_MC_ASSIGN(u16Src, u8Bit & 0x0f);
7886 if (pImpl->pfnLockedU16)
7887 IEMOP_HLP_DONE_DECODING();
7888 else
7889 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7890 IEM_MC_FETCH_EFLAGS(EFlags);
7891 IEM_MC_MEM_MAP(pu16Dst, fAccess, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7892 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7893 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU16, pu16Dst, u16Src, pEFlags);
7894 else
7895 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnLockedU16, pu16Dst, u16Src, pEFlags);
7896 IEM_MC_MEM_COMMIT_AND_UNMAP(pu16Dst, fAccess);
7897
7898 IEM_MC_COMMIT_EFLAGS(EFlags);
7899 IEM_MC_ADVANCE_RIP();
7900 IEM_MC_END();
7901 return VINF_SUCCESS;
7902
7903 case IEMMODE_32BIT:
7904 IEM_MC_BEGIN(3, 1);
7905 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
7906 IEM_MC_ARG(uint32_t, u32Src, 1);
7907 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2);
7908 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7909
7910 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
7911 uint8_t u8Bit; IEM_OPCODE_GET_NEXT_U8(&u8Bit);
7912 IEM_MC_ASSIGN(u32Src, u8Bit & 0x1f);
7913 if (pImpl->pfnLockedU16)
7914 IEMOP_HLP_DONE_DECODING();
7915 else
7916 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7917 IEM_MC_FETCH_EFLAGS(EFlags);
7918 IEM_MC_MEM_MAP(pu32Dst, fAccess, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7919 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7920 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU32, pu32Dst, u32Src, pEFlags);
7921 else
7922 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnLockedU32, pu32Dst, u32Src, pEFlags);
7923 IEM_MC_MEM_COMMIT_AND_UNMAP(pu32Dst, fAccess);
7924
7925 IEM_MC_COMMIT_EFLAGS(EFlags);
7926 IEM_MC_ADVANCE_RIP();
7927 IEM_MC_END();
7928 return VINF_SUCCESS;
7929
7930 case IEMMODE_64BIT:
7931 IEM_MC_BEGIN(3, 1);
7932 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
7933 IEM_MC_ARG(uint64_t, u64Src, 1);
7934 IEM_MC_ARG_LOCAL_EFLAGS( pEFlags, EFlags, 2);
7935 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
7936
7937 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 1);
7938 uint8_t u8Bit; IEM_OPCODE_GET_NEXT_U8(&u8Bit);
7939 IEM_MC_ASSIGN(u64Src, u8Bit & 0x3f);
7940 if (pImpl->pfnLockedU16)
7941 IEMOP_HLP_DONE_DECODING();
7942 else
7943 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
7944 IEM_MC_FETCH_EFLAGS(EFlags);
7945 IEM_MC_MEM_MAP(pu64Dst, fAccess, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0);
7946 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
7947 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnNormalU64, pu64Dst, u64Src, pEFlags);
7948 else
7949 IEM_MC_CALL_VOID_AIMPL_3(pImpl->pfnLockedU64, pu64Dst, u64Src, pEFlags);
7950 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64Dst, fAccess);
7951
7952 IEM_MC_COMMIT_EFLAGS(EFlags);
7953 IEM_MC_ADVANCE_RIP();
7954 IEM_MC_END();
7955 return VINF_SUCCESS;
7956
7957 IEM_NOT_REACHED_DEFAULT_CASE_RET();
7958 }
7959 }
7960}
7961
7962
7963/** Opcode 0x0f 0xbb. */
7964FNIEMOP_DEF(iemOp_btc_Ev_Gv)
7965{
7966 IEMOP_MNEMONIC(btc_Ev_Gv, "btc Ev,Gv");
7967 IEMOP_HLP_MIN_386();
7968 return FNIEMOP_CALL_1(iemOpCommonBit_Ev_Gv, &g_iemAImpl_btc);
7969}
7970
7971
7972/** Opcode 0x0f 0xbc. */
7973FNIEMOP_DEF(iemOp_bsf_Gv_Ev)
7974{
7975 IEMOP_MNEMONIC(bsf_Gv_Ev, "bsf Gv,Ev");
7976 IEMOP_HLP_MIN_386();
7977 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_AF | X86_EFL_PF | X86_EFL_CF);
7978 return FNIEMOP_CALL_1(iemOpHlpBinaryOperator_rv_rm, &g_iemAImpl_bsf);
7979}
7980
7981
7982/** Opcode 0xf3 0x0f 0xbc - TZCNT Gv, Ev */
7983FNIEMOP_STUB(iemOp_tzcnt_Gv_Ev);
7984
7985
7986/** Opcode 0x0f 0xbd. */
7987FNIEMOP_DEF(iemOp_bsr_Gv_Ev)
7988{
7989 IEMOP_MNEMONIC(bsr_Gv_Ev, "bsr Gv,Ev");
7990 IEMOP_HLP_MIN_386();
7991 IEMOP_VERIFICATION_UNDEFINED_EFLAGS(X86_EFL_OF | X86_EFL_SF | X86_EFL_AF | X86_EFL_PF | X86_EFL_CF);
7992 return FNIEMOP_CALL_1(iemOpHlpBinaryOperator_rv_rm, &g_iemAImpl_bsr);
7993}
7994
7995
7996/** Opcode 0xf3 0x0f 0xbd - LZCNT Gv, Ev */
7997FNIEMOP_STUB(iemOp_lzcnt_Gv_Ev);
7998
7999
8000/** Opcode 0x0f 0xbe. */
8001FNIEMOP_DEF(iemOp_movsx_Gv_Eb)
8002{
8003 IEMOP_MNEMONIC(movsx_Gv_Eb, "movsx Gv,Eb");
8004 IEMOP_HLP_MIN_386();
8005
8006 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8007
8008 /*
8009 * If rm is denoting a register, no more instruction bytes.
8010 */
8011 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8012 {
8013 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8014 switch (pVCpu->iem.s.enmEffOpSize)
8015 {
8016 case IEMMODE_16BIT:
8017 IEM_MC_BEGIN(0, 1);
8018 IEM_MC_LOCAL(uint16_t, u16Value);
8019 IEM_MC_FETCH_GREG_U8_SX_U16(u16Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8020 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16Value);
8021 IEM_MC_ADVANCE_RIP();
8022 IEM_MC_END();
8023 return VINF_SUCCESS;
8024
8025 case IEMMODE_32BIT:
8026 IEM_MC_BEGIN(0, 1);
8027 IEM_MC_LOCAL(uint32_t, u32Value);
8028 IEM_MC_FETCH_GREG_U8_SX_U32(u32Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8029 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
8030 IEM_MC_ADVANCE_RIP();
8031 IEM_MC_END();
8032 return VINF_SUCCESS;
8033
8034 case IEMMODE_64BIT:
8035 IEM_MC_BEGIN(0, 1);
8036 IEM_MC_LOCAL(uint64_t, u64Value);
8037 IEM_MC_FETCH_GREG_U8_SX_U64(u64Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8038 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
8039 IEM_MC_ADVANCE_RIP();
8040 IEM_MC_END();
8041 return VINF_SUCCESS;
8042
8043 IEM_NOT_REACHED_DEFAULT_CASE_RET();
8044 }
8045 }
8046 else
8047 {
8048 /*
8049 * We're loading a register from memory.
8050 */
8051 switch (pVCpu->iem.s.enmEffOpSize)
8052 {
8053 case IEMMODE_16BIT:
8054 IEM_MC_BEGIN(0, 2);
8055 IEM_MC_LOCAL(uint16_t, u16Value);
8056 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8057 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8058 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8059 IEM_MC_FETCH_MEM_U8_SX_U16(u16Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
8060 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16Value);
8061 IEM_MC_ADVANCE_RIP();
8062 IEM_MC_END();
8063 return VINF_SUCCESS;
8064
8065 case IEMMODE_32BIT:
8066 IEM_MC_BEGIN(0, 2);
8067 IEM_MC_LOCAL(uint32_t, u32Value);
8068 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8069 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8070 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8071 IEM_MC_FETCH_MEM_U8_SX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
8072 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
8073 IEM_MC_ADVANCE_RIP();
8074 IEM_MC_END();
8075 return VINF_SUCCESS;
8076
8077 case IEMMODE_64BIT:
8078 IEM_MC_BEGIN(0, 2);
8079 IEM_MC_LOCAL(uint64_t, u64Value);
8080 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8081 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8082 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8083 IEM_MC_FETCH_MEM_U8_SX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
8084 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
8085 IEM_MC_ADVANCE_RIP();
8086 IEM_MC_END();
8087 return VINF_SUCCESS;
8088
8089 IEM_NOT_REACHED_DEFAULT_CASE_RET();
8090 }
8091 }
8092}
8093
8094
8095/** Opcode 0x0f 0xbf. */
8096FNIEMOP_DEF(iemOp_movsx_Gv_Ew)
8097{
8098 IEMOP_MNEMONIC(movsx_Gv_Ew, "movsx Gv,Ew");
8099 IEMOP_HLP_MIN_386();
8100
8101 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8102
8103 /** @todo Not entirely sure how the operand size prefix is handled here,
8104 * assuming that it will be ignored. Would be nice to have a few
8105 * test for this. */
8106 /*
8107 * If rm is denoting a register, no more instruction bytes.
8108 */
8109 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8110 {
8111 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8112 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
8113 {
8114 IEM_MC_BEGIN(0, 1);
8115 IEM_MC_LOCAL(uint32_t, u32Value);
8116 IEM_MC_FETCH_GREG_U16_SX_U32(u32Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8117 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
8118 IEM_MC_ADVANCE_RIP();
8119 IEM_MC_END();
8120 }
8121 else
8122 {
8123 IEM_MC_BEGIN(0, 1);
8124 IEM_MC_LOCAL(uint64_t, u64Value);
8125 IEM_MC_FETCH_GREG_U16_SX_U64(u64Value, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8126 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
8127 IEM_MC_ADVANCE_RIP();
8128 IEM_MC_END();
8129 }
8130 }
8131 else
8132 {
8133 /*
8134 * We're loading a register from memory.
8135 */
8136 if (pVCpu->iem.s.enmEffOpSize != IEMMODE_64BIT)
8137 {
8138 IEM_MC_BEGIN(0, 2);
8139 IEM_MC_LOCAL(uint32_t, u32Value);
8140 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8141 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8142 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8143 IEM_MC_FETCH_MEM_U16_SX_U32(u32Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
8144 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32Value);
8145 IEM_MC_ADVANCE_RIP();
8146 IEM_MC_END();
8147 }
8148 else
8149 {
8150 IEM_MC_BEGIN(0, 2);
8151 IEM_MC_LOCAL(uint64_t, u64Value);
8152 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8153 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8154 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8155 IEM_MC_FETCH_MEM_U16_SX_U64(u64Value, pVCpu->iem.s.iEffSeg, GCPtrEffDst);
8156 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64Value);
8157 IEM_MC_ADVANCE_RIP();
8158 IEM_MC_END();
8159 }
8160 }
8161 return VINF_SUCCESS;
8162}
8163
8164
8165/** Opcode 0x0f 0xc0. */
8166FNIEMOP_DEF(iemOp_xadd_Eb_Gb)
8167{
8168 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8169 IEMOP_HLP_MIN_486();
8170 IEMOP_MNEMONIC(xadd_Eb_Gb, "xadd Eb,Gb");
8171
8172 /*
8173 * If rm is denoting a register, no more instruction bytes.
8174 */
8175 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8176 {
8177 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8178
8179 IEM_MC_BEGIN(3, 0);
8180 IEM_MC_ARG(uint8_t *, pu8Dst, 0);
8181 IEM_MC_ARG(uint8_t *, pu8Reg, 1);
8182 IEM_MC_ARG(uint32_t *, pEFlags, 2);
8183
8184 IEM_MC_REF_GREG_U8(pu8Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8185 IEM_MC_REF_GREG_U8(pu8Reg, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8186 IEM_MC_REF_EFLAGS(pEFlags);
8187 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u8, pu8Dst, pu8Reg, pEFlags);
8188
8189 IEM_MC_ADVANCE_RIP();
8190 IEM_MC_END();
8191 }
8192 else
8193 {
8194 /*
8195 * We're accessing memory.
8196 */
8197 IEM_MC_BEGIN(3, 3);
8198 IEM_MC_ARG(uint8_t *, pu8Dst, 0);
8199 IEM_MC_ARG(uint8_t *, pu8Reg, 1);
8200 IEM_MC_ARG_LOCAL_EFLAGS(pEFlags, EFlags, 2);
8201 IEM_MC_LOCAL(uint8_t, u8RegCopy);
8202 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8203
8204 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8205 IEM_MC_MEM_MAP(pu8Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0 /*arg*/);
8206 IEM_MC_FETCH_GREG_U8(u8RegCopy, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8207 IEM_MC_REF_LOCAL(pu8Reg, u8RegCopy);
8208 IEM_MC_FETCH_EFLAGS(EFlags);
8209 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
8210 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u8, pu8Dst, pu8Reg, pEFlags);
8211 else
8212 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u8_locked, pu8Dst, pu8Reg, pEFlags);
8213
8214 IEM_MC_MEM_COMMIT_AND_UNMAP(pu8Dst, IEM_ACCESS_DATA_RW);
8215 IEM_MC_COMMIT_EFLAGS(EFlags);
8216 IEM_MC_STORE_GREG_U8(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u8RegCopy);
8217 IEM_MC_ADVANCE_RIP();
8218 IEM_MC_END();
8219 return VINF_SUCCESS;
8220 }
8221 return VINF_SUCCESS;
8222}
8223
8224
8225/** Opcode 0x0f 0xc1. */
8226FNIEMOP_DEF(iemOp_xadd_Ev_Gv)
8227{
8228 IEMOP_MNEMONIC(xadd_Ev_Gv, "xadd Ev,Gv");
8229 IEMOP_HLP_MIN_486();
8230 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8231
8232 /*
8233 * If rm is denoting a register, no more instruction bytes.
8234 */
8235 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8236 {
8237 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8238
8239 switch (pVCpu->iem.s.enmEffOpSize)
8240 {
8241 case IEMMODE_16BIT:
8242 IEM_MC_BEGIN(3, 0);
8243 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
8244 IEM_MC_ARG(uint16_t *, pu16Reg, 1);
8245 IEM_MC_ARG(uint32_t *, pEFlags, 2);
8246
8247 IEM_MC_REF_GREG_U16(pu16Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8248 IEM_MC_REF_GREG_U16(pu16Reg, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8249 IEM_MC_REF_EFLAGS(pEFlags);
8250 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u16, pu16Dst, pu16Reg, pEFlags);
8251
8252 IEM_MC_ADVANCE_RIP();
8253 IEM_MC_END();
8254 return VINF_SUCCESS;
8255
8256 case IEMMODE_32BIT:
8257 IEM_MC_BEGIN(3, 0);
8258 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
8259 IEM_MC_ARG(uint32_t *, pu32Reg, 1);
8260 IEM_MC_ARG(uint32_t *, pEFlags, 2);
8261
8262 IEM_MC_REF_GREG_U32(pu32Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8263 IEM_MC_REF_GREG_U32(pu32Reg, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8264 IEM_MC_REF_EFLAGS(pEFlags);
8265 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u32, pu32Dst, pu32Reg, pEFlags);
8266
8267 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
8268 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Reg);
8269 IEM_MC_ADVANCE_RIP();
8270 IEM_MC_END();
8271 return VINF_SUCCESS;
8272
8273 case IEMMODE_64BIT:
8274 IEM_MC_BEGIN(3, 0);
8275 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
8276 IEM_MC_ARG(uint64_t *, pu64Reg, 1);
8277 IEM_MC_ARG(uint32_t *, pEFlags, 2);
8278
8279 IEM_MC_REF_GREG_U64(pu64Dst, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
8280 IEM_MC_REF_GREG_U64(pu64Reg, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8281 IEM_MC_REF_EFLAGS(pEFlags);
8282 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u64, pu64Dst, pu64Reg, pEFlags);
8283
8284 IEM_MC_ADVANCE_RIP();
8285 IEM_MC_END();
8286 return VINF_SUCCESS;
8287
8288 IEM_NOT_REACHED_DEFAULT_CASE_RET();
8289 }
8290 }
8291 else
8292 {
8293 /*
8294 * We're accessing memory.
8295 */
8296 switch (pVCpu->iem.s.enmEffOpSize)
8297 {
8298 case IEMMODE_16BIT:
8299 IEM_MC_BEGIN(3, 3);
8300 IEM_MC_ARG(uint16_t *, pu16Dst, 0);
8301 IEM_MC_ARG(uint16_t *, pu16Reg, 1);
8302 IEM_MC_ARG_LOCAL_EFLAGS(pEFlags, EFlags, 2);
8303 IEM_MC_LOCAL(uint16_t, u16RegCopy);
8304 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8305
8306 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8307 IEM_MC_MEM_MAP(pu16Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0 /*arg*/);
8308 IEM_MC_FETCH_GREG_U16(u16RegCopy, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8309 IEM_MC_REF_LOCAL(pu16Reg, u16RegCopy);
8310 IEM_MC_FETCH_EFLAGS(EFlags);
8311 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
8312 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u16, pu16Dst, pu16Reg, pEFlags);
8313 else
8314 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u16_locked, pu16Dst, pu16Reg, pEFlags);
8315
8316 IEM_MC_MEM_COMMIT_AND_UNMAP(pu16Dst, IEM_ACCESS_DATA_RW);
8317 IEM_MC_COMMIT_EFLAGS(EFlags);
8318 IEM_MC_STORE_GREG_U16(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u16RegCopy);
8319 IEM_MC_ADVANCE_RIP();
8320 IEM_MC_END();
8321 return VINF_SUCCESS;
8322
8323 case IEMMODE_32BIT:
8324 IEM_MC_BEGIN(3, 3);
8325 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
8326 IEM_MC_ARG(uint32_t *, pu32Reg, 1);
8327 IEM_MC_ARG_LOCAL_EFLAGS(pEFlags, EFlags, 2);
8328 IEM_MC_LOCAL(uint32_t, u32RegCopy);
8329 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8330
8331 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8332 IEM_MC_MEM_MAP(pu32Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0 /*arg*/);
8333 IEM_MC_FETCH_GREG_U32(u32RegCopy, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8334 IEM_MC_REF_LOCAL(pu32Reg, u32RegCopy);
8335 IEM_MC_FETCH_EFLAGS(EFlags);
8336 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
8337 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u32, pu32Dst, pu32Reg, pEFlags);
8338 else
8339 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u32_locked, pu32Dst, pu32Reg, pEFlags);
8340
8341 IEM_MC_MEM_COMMIT_AND_UNMAP(pu32Dst, IEM_ACCESS_DATA_RW);
8342 IEM_MC_COMMIT_EFLAGS(EFlags);
8343 IEM_MC_STORE_GREG_U32(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u32RegCopy);
8344 IEM_MC_ADVANCE_RIP();
8345 IEM_MC_END();
8346 return VINF_SUCCESS;
8347
8348 case IEMMODE_64BIT:
8349 IEM_MC_BEGIN(3, 3);
8350 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
8351 IEM_MC_ARG(uint64_t *, pu64Reg, 1);
8352 IEM_MC_ARG_LOCAL_EFLAGS(pEFlags, EFlags, 2);
8353 IEM_MC_LOCAL(uint64_t, u64RegCopy);
8354 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8355
8356 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8357 IEM_MC_MEM_MAP(pu64Dst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0 /*arg*/);
8358 IEM_MC_FETCH_GREG_U64(u64RegCopy, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8359 IEM_MC_REF_LOCAL(pu64Reg, u64RegCopy);
8360 IEM_MC_FETCH_EFLAGS(EFlags);
8361 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
8362 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u64, pu64Dst, pu64Reg, pEFlags);
8363 else
8364 IEM_MC_CALL_VOID_AIMPL_3(iemAImpl_xadd_u64_locked, pu64Dst, pu64Reg, pEFlags);
8365
8366 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64Dst, IEM_ACCESS_DATA_RW);
8367 IEM_MC_COMMIT_EFLAGS(EFlags);
8368 IEM_MC_STORE_GREG_U64(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, u64RegCopy);
8369 IEM_MC_ADVANCE_RIP();
8370 IEM_MC_END();
8371 return VINF_SUCCESS;
8372
8373 IEM_NOT_REACHED_DEFAULT_CASE_RET();
8374 }
8375 }
8376}
8377
8378
8379/** Opcode 0x0f 0xc2 - cmpps Vps,Wps,Ib */
8380FNIEMOP_STUB(iemOp_cmpps_Vps_Wps_Ib);
8381/** Opcode 0x66 0x0f 0xc2 - cmppd Vpd,Wpd,Ib */
8382FNIEMOP_STUB(iemOp_cmppd_Vpd_Wpd_Ib);
8383/** Opcode 0xf3 0x0f 0xc2 - cmpss Vss,Wss,Ib */
8384FNIEMOP_STUB(iemOp_cmpss_Vss_Wss_Ib);
8385/** Opcode 0xf2 0x0f 0xc2 - cmpsd Vsd,Wsd,Ib */
8386FNIEMOP_STUB(iemOp_cmpsd_Vsd_Wsd_Ib);
8387
8388
8389/** Opcode 0x0f 0xc3. */
8390FNIEMOP_DEF(iemOp_movnti_My_Gy)
8391{
8392 IEMOP_MNEMONIC(movnti_My_Gy, "movnti My,Gy");
8393
8394 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8395
8396 /* Only the register -> memory form makes sense, assuming #UD for the other form. */
8397 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
8398 {
8399 switch (pVCpu->iem.s.enmEffOpSize)
8400 {
8401 case IEMMODE_32BIT:
8402 IEM_MC_BEGIN(0, 2);
8403 IEM_MC_LOCAL(uint32_t, u32Value);
8404 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8405
8406 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8407 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8408 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse2)
8409 return IEMOP_RAISE_INVALID_OPCODE();
8410
8411 IEM_MC_FETCH_GREG_U32(u32Value, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8412 IEM_MC_STORE_MEM_U32(pVCpu->iem.s.iEffSeg, GCPtrEffDst, u32Value);
8413 IEM_MC_ADVANCE_RIP();
8414 IEM_MC_END();
8415 break;
8416
8417 case IEMMODE_64BIT:
8418 IEM_MC_BEGIN(0, 2);
8419 IEM_MC_LOCAL(uint64_t, u64Value);
8420 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8421
8422 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8423 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8424 if (!IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fSse2)
8425 return IEMOP_RAISE_INVALID_OPCODE();
8426
8427 IEM_MC_FETCH_GREG_U64(u64Value, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8428 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffDst, u64Value);
8429 IEM_MC_ADVANCE_RIP();
8430 IEM_MC_END();
8431 break;
8432
8433 case IEMMODE_16BIT:
8434 /** @todo check this form. */
8435 return IEMOP_RAISE_INVALID_OPCODE();
8436 }
8437 }
8438 else
8439 return IEMOP_RAISE_INVALID_OPCODE();
8440 return VINF_SUCCESS;
8441}
8442/* Opcode 0x66 0x0f 0xc3 - invalid */
8443/* Opcode 0xf3 0x0f 0xc3 - invalid */
8444/* Opcode 0xf2 0x0f 0xc3 - invalid */
8445
8446/** Opcode 0x0f 0xc4 - pinsrw Pq, Ry/Mw,Ib */
8447FNIEMOP_STUB(iemOp_pinsrw_Pq_RyMw_Ib);
8448/** Opcode 0x66 0x0f 0xc4 - pinsrw Vdq, Ry/Mw,Ib */
8449FNIEMOP_STUB(iemOp_pinsrw_Vdq_RyMw_Ib);
8450/* Opcode 0xf3 0x0f 0xc4 - invalid */
8451/* Opcode 0xf2 0x0f 0xc4 - invalid */
8452
8453/** Opcode 0x0f 0xc5 - pextrw Gd, Nq, Ib */
8454FNIEMOP_STUB(iemOp_pextrw_Gd_Nq_Ib);
8455/** Opcode 0x66 0x0f 0xc5 - pextrw Gd, Udq, Ib */
8456FNIEMOP_STUB(iemOp_pextrw_Gd_Udq_Ib);
8457/* Opcode 0xf3 0x0f 0xc5 - invalid */
8458/* Opcode 0xf2 0x0f 0xc5 - invalid */
8459
8460/** Opcode 0x0f 0xc6 - shufps Vps, Wps, Ib */
8461FNIEMOP_STUB(iemOp_shufps_Vps_Wps_Ib);
8462/** Opcode 0x66 0x0f 0xc6 - shufpd Vpd, Wpd, Ib */
8463FNIEMOP_STUB(iemOp_shufpd_Vpd_Wpd_Ib);
8464/* Opcode 0xf3 0x0f 0xc6 - invalid */
8465/* Opcode 0xf2 0x0f 0xc6 - invalid */
8466
8467
8468/** Opcode 0x0f 0xc7 !11/1. */
8469FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg8b_Mq, uint8_t, bRm)
8470{
8471 IEMOP_MNEMONIC(cmpxchg8b, "cmpxchg8b Mq");
8472
8473 IEM_MC_BEGIN(4, 3);
8474 IEM_MC_ARG(uint64_t *, pu64MemDst, 0);
8475 IEM_MC_ARG(PRTUINT64U, pu64EaxEdx, 1);
8476 IEM_MC_ARG(PRTUINT64U, pu64EbxEcx, 2);
8477 IEM_MC_ARG_LOCAL_EFLAGS(pEFlags, EFlags, 3);
8478 IEM_MC_LOCAL(RTUINT64U, u64EaxEdx);
8479 IEM_MC_LOCAL(RTUINT64U, u64EbxEcx);
8480 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8481
8482 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8483 IEMOP_HLP_DONE_DECODING();
8484 IEM_MC_MEM_MAP(pu64MemDst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0 /*arg*/);
8485
8486 IEM_MC_FETCH_GREG_U32(u64EaxEdx.s.Lo, X86_GREG_xAX);
8487 IEM_MC_FETCH_GREG_U32(u64EaxEdx.s.Hi, X86_GREG_xDX);
8488 IEM_MC_REF_LOCAL(pu64EaxEdx, u64EaxEdx);
8489
8490 IEM_MC_FETCH_GREG_U32(u64EbxEcx.s.Lo, X86_GREG_xBX);
8491 IEM_MC_FETCH_GREG_U32(u64EbxEcx.s.Hi, X86_GREG_xCX);
8492 IEM_MC_REF_LOCAL(pu64EbxEcx, u64EbxEcx);
8493
8494 IEM_MC_FETCH_EFLAGS(EFlags);
8495 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
8496 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg8b, pu64MemDst, pu64EaxEdx, pu64EbxEcx, pEFlags);
8497 else
8498 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg8b_locked, pu64MemDst, pu64EaxEdx, pu64EbxEcx, pEFlags);
8499
8500 IEM_MC_MEM_COMMIT_AND_UNMAP(pu64MemDst, IEM_ACCESS_DATA_RW);
8501 IEM_MC_COMMIT_EFLAGS(EFlags);
8502 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF)
8503 /** @todo Testcase: Check effect of cmpxchg8b on bits 63:32 in rax and rdx. */
8504 IEM_MC_STORE_GREG_U32(X86_GREG_xAX, u64EaxEdx.s.Lo);
8505 IEM_MC_STORE_GREG_U32(X86_GREG_xDX, u64EaxEdx.s.Hi);
8506 IEM_MC_ENDIF();
8507 IEM_MC_ADVANCE_RIP();
8508
8509 IEM_MC_END();
8510 return VINF_SUCCESS;
8511}
8512
8513
8514/** Opcode REX.W 0x0f 0xc7 !11/1. */
8515FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg16b_Mdq, uint8_t, bRm)
8516{
8517 IEMOP_MNEMONIC(cmpxchg16b, "cmpxchg16b Mdq");
8518 if (IEM_GET_GUEST_CPU_FEATURES(pVCpu)->fMovCmpXchg16b)
8519 {
8520#if 0
8521 RT_NOREF(bRm);
8522 IEMOP_BITCH_ABOUT_STUB();
8523 return VERR_IEM_INSTR_NOT_IMPLEMENTED;
8524#else
8525 IEM_MC_BEGIN(4, 3);
8526 IEM_MC_ARG(PRTUINT128U, pu128MemDst, 0);
8527 IEM_MC_ARG(PRTUINT128U, pu128RaxRdx, 1);
8528 IEM_MC_ARG(PRTUINT128U, pu128RbxRcx, 2);
8529 IEM_MC_ARG_LOCAL_EFLAGS(pEFlags, EFlags, 3);
8530 IEM_MC_LOCAL(RTUINT128U, u128RaxRdx);
8531 IEM_MC_LOCAL(RTUINT128U, u128RbxRcx);
8532 IEM_MC_LOCAL(RTGCPTR, GCPtrEffDst);
8533
8534 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8535 IEMOP_HLP_DONE_DECODING();
8536 IEM_MC_RAISE_GP0_IF_EFF_ADDR_UNALIGNED(GCPtrEffDst, 16);
8537 IEM_MC_MEM_MAP(pu128MemDst, IEM_ACCESS_DATA_RW, pVCpu->iem.s.iEffSeg, GCPtrEffDst, 0 /*arg*/);
8538
8539 IEM_MC_FETCH_GREG_U64(u128RaxRdx.s.Lo, X86_GREG_xAX);
8540 IEM_MC_FETCH_GREG_U64(u128RaxRdx.s.Hi, X86_GREG_xDX);
8541 IEM_MC_REF_LOCAL(pu128RaxRdx, u128RaxRdx);
8542
8543 IEM_MC_FETCH_GREG_U64(u128RbxRcx.s.Lo, X86_GREG_xBX);
8544 IEM_MC_FETCH_GREG_U64(u128RbxRcx.s.Hi, X86_GREG_xCX);
8545 IEM_MC_REF_LOCAL(pu128RbxRcx, u128RbxRcx);
8546
8547 IEM_MC_FETCH_EFLAGS(EFlags);
8548# ifdef RT_ARCH_AMD64
8549 if (IEM_GET_HOST_CPU_FEATURES(pVCpu)->fMovCmpXchg16b)
8550 {
8551 if (!(pVCpu->iem.s.fPrefixes & IEM_OP_PRF_LOCK))
8552 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
8553 else
8554 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b_locked, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
8555 }
8556 else
8557# endif
8558 {
8559 /* Note! The fallback for 32-bit systems and systems without CX16 is multiple
8560 accesses and not all all atomic, which works fine on in UNI CPU guest
8561 configuration (ignoring DMA). If guest SMP is active we have no choice
8562 but to use a rendezvous callback here. Sigh. */
8563 if (pVCpu->CTX_SUFF(pVM)->cCpus == 1)
8564 IEM_MC_CALL_VOID_AIMPL_4(iemAImpl_cmpxchg16b_fallback, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
8565 else
8566 {
8567 IEM_MC_CALL_CIMPL_4(iemCImpl_cmpxchg16b_fallback_rendezvous, pu128MemDst, pu128RaxRdx, pu128RbxRcx, pEFlags);
8568 /* Does not get here, tail code is duplicated in iemCImpl_cmpxchg16b_fallback_rendezvous. */
8569 }
8570 }
8571
8572 IEM_MC_MEM_COMMIT_AND_UNMAP(pu128MemDst, IEM_ACCESS_DATA_RW);
8573 IEM_MC_COMMIT_EFLAGS(EFlags);
8574 IEM_MC_IF_EFL_BIT_NOT_SET(X86_EFL_ZF)
8575 IEM_MC_STORE_GREG_U64(X86_GREG_xAX, u128RaxRdx.s.Lo);
8576 IEM_MC_STORE_GREG_U64(X86_GREG_xDX, u128RaxRdx.s.Hi);
8577 IEM_MC_ENDIF();
8578 IEM_MC_ADVANCE_RIP();
8579
8580 IEM_MC_END();
8581 return VINF_SUCCESS;
8582#endif
8583 }
8584 Log(("cmpxchg16b -> #UD\n"));
8585 return IEMOP_RAISE_INVALID_OPCODE();
8586}
8587
8588FNIEMOP_DEF_1(iemOp_Grp9_cmpxchg8bOr16b, uint8_t, bRm)
8589{
8590 if (pVCpu->iem.s.fPrefixes & IEM_OP_PRF_SIZE_REX_W)
8591 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg16b_Mdq, bRm);
8592 return FNIEMOP_CALL_1(iemOp_Grp9_cmpxchg8b_Mq, bRm);
8593}
8594
8595/** Opcode 0x0f 0xc7 11/6. */
8596FNIEMOP_UD_STUB_1(iemOp_Grp9_rdrand_Rv, uint8_t, bRm);
8597
8598/** Opcode 0x0f 0xc7 !11/6. */
8599#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
8600FNIEMOP_DEF_1(iemOp_Grp9_vmptrld_Mq, uint8_t, bRm)
8601{
8602 IEMOP_MNEMONIC(vmptrld, "vmptrld");
8603 IEMOP_HLP_IN_VMX_OPERATION("vmptrld", kVmxVDiag_Vmptrld);
8604 IEMOP_HLP_VMX_INSTR("vmptrld", kVmxVDiag_Vmptrld);
8605 IEM_MC_BEGIN(2, 0);
8606 IEM_MC_ARG(uint8_t, iEffSeg, 0);
8607 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
8608 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
8609 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
8610 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
8611 IEM_MC_CALL_CIMPL_2(iemCImpl_vmptrld, iEffSeg, GCPtrEffSrc);
8612 IEM_MC_END();
8613 return VINF_SUCCESS;
8614}
8615#else
8616FNIEMOP_UD_STUB_1(iemOp_Grp9_vmptrld_Mq, uint8_t, bRm);
8617#endif
8618
8619/** Opcode 0x66 0x0f 0xc7 !11/6. */
8620#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
8621FNIEMOP_DEF_1(iemOp_Grp9_vmclear_Mq, uint8_t, bRm)
8622{
8623 IEMOP_MNEMONIC(vmclear, "vmclear");
8624 IEMOP_HLP_IN_VMX_OPERATION("vmclear", kVmxVDiag_Vmclear);
8625 IEMOP_HLP_VMX_INSTR("vmclear", kVmxVDiag_Vmclear);
8626 IEM_MC_BEGIN(2, 0);
8627 IEM_MC_ARG(uint8_t, iEffSeg, 0);
8628 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
8629 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8630 IEMOP_HLP_DONE_DECODING();
8631 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
8632 IEM_MC_CALL_CIMPL_2(iemCImpl_vmclear, iEffSeg, GCPtrEffDst);
8633 IEM_MC_END();
8634 return VINF_SUCCESS;
8635}
8636#else
8637FNIEMOP_UD_STUB_1(iemOp_Grp9_vmclear_Mq, uint8_t, bRm);
8638#endif
8639
8640/** Opcode 0xf3 0x0f 0xc7 !11/6. */
8641#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
8642FNIEMOP_DEF_1(iemOp_Grp9_vmxon_Mq, uint8_t, bRm)
8643{
8644 IEMOP_MNEMONIC(vmxon, "vmxon");
8645 IEMOP_HLP_VMX_INSTR("vmxon", kVmxVDiag_Vmxon);
8646 IEM_MC_BEGIN(2, 0);
8647 IEM_MC_ARG(uint8_t, iEffSeg, 0);
8648 IEM_MC_ARG(RTGCPTR, GCPtrEffSrc, 1);
8649 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
8650 IEMOP_HLP_DONE_DECODING();
8651 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
8652 IEM_MC_CALL_CIMPL_2(iemCImpl_vmxon, iEffSeg, GCPtrEffSrc);
8653 IEM_MC_END();
8654 return VINF_SUCCESS;
8655}
8656#else
8657FNIEMOP_UD_STUB_1(iemOp_Grp9_vmxon_Mq, uint8_t, bRm);
8658#endif
8659
8660/** Opcode [0xf3] 0x0f 0xc7 !11/7. */
8661#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
8662FNIEMOP_DEF_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm)
8663{
8664 IEMOP_MNEMONIC(vmptrst, "vmptrst");
8665 IEMOP_HLP_IN_VMX_OPERATION("vmptrst", kVmxVDiag_Vmptrst);
8666 IEMOP_HLP_VMX_INSTR("vmptrst", kVmxVDiag_Vmptrst);
8667 IEM_MC_BEGIN(2, 0);
8668 IEM_MC_ARG(uint8_t, iEffSeg, 0);
8669 IEM_MC_ARG(RTGCPTR, GCPtrEffDst, 1);
8670 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffDst, bRm, 0);
8671 IEMOP_HLP_DONE_DECODING_NO_SIZE_OP_REPZ_OR_REPNZ_PREFIXES();
8672 IEM_MC_ASSIGN(iEffSeg, pVCpu->iem.s.iEffSeg);
8673 IEM_MC_CALL_CIMPL_2(iemCImpl_vmptrst, iEffSeg, GCPtrEffDst);
8674 IEM_MC_END();
8675 return VINF_SUCCESS;
8676}
8677#else
8678FNIEMOP_UD_STUB_1(iemOp_Grp9_vmptrst_Mq, uint8_t, bRm);
8679#endif
8680
8681/** Opcode 0x0f 0xc7 11/7. */
8682FNIEMOP_UD_STUB_1(iemOp_Grp9_rdseed_Rv, uint8_t, bRm);
8683
8684
8685/**
8686 * Group 9 jump table for register variant.
8687 */
8688IEM_STATIC const PFNIEMOPRM g_apfnGroup9RegReg[] =
8689{ /* pfx: none, 066h, 0f3h, 0f2h */
8690 /* /0 */ IEMOP_X4(iemOp_InvalidWithRM),
8691 /* /1 */ IEMOP_X4(iemOp_InvalidWithRM),
8692 /* /2 */ IEMOP_X4(iemOp_InvalidWithRM),
8693 /* /3 */ IEMOP_X4(iemOp_InvalidWithRM),
8694 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM),
8695 /* /5 */ IEMOP_X4(iemOp_InvalidWithRM),
8696 /* /6 */ iemOp_Grp9_rdrand_Rv, iemOp_Grp9_rdrand_Rv, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
8697 /* /7 */ iemOp_Grp9_rdseed_Rv, iemOp_Grp9_rdseed_Rv, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
8698};
8699AssertCompile(RT_ELEMENTS(g_apfnGroup9RegReg) == 8*4);
8700
8701
8702/**
8703 * Group 9 jump table for memory variant.
8704 */
8705IEM_STATIC const PFNIEMOPRM g_apfnGroup9MemReg[] =
8706{ /* pfx: none, 066h, 0f3h, 0f2h */
8707 /* /0 */ IEMOP_X4(iemOp_InvalidWithRM),
8708 /* /1 */ iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, iemOp_Grp9_cmpxchg8bOr16b, /* see bs3-cpu-decoding-1 */
8709 /* /2 */ IEMOP_X4(iemOp_InvalidWithRM),
8710 /* /3 */ IEMOP_X4(iemOp_InvalidWithRM),
8711 /* /4 */ IEMOP_X4(iemOp_InvalidWithRM),
8712 /* /5 */ IEMOP_X4(iemOp_InvalidWithRM),
8713 /* /6 */ iemOp_Grp9_vmptrld_Mq, iemOp_Grp9_vmclear_Mq, iemOp_Grp9_vmxon_Mq, iemOp_InvalidWithRM,
8714 /* /7 */ iemOp_Grp9_vmptrst_Mq, iemOp_InvalidWithRM, iemOp_InvalidWithRM, iemOp_InvalidWithRM,
8715};
8716AssertCompile(RT_ELEMENTS(g_apfnGroup9MemReg) == 8*4);
8717
8718
8719/** Opcode 0x0f 0xc7. */
8720FNIEMOP_DEF(iemOp_Grp9)
8721{
8722 uint8_t bRm; IEM_OPCODE_GET_NEXT_RM(&bRm);
8723 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8724 /* register, register */
8725 return FNIEMOP_CALL_1(g_apfnGroup9RegReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
8726 + pVCpu->iem.s.idxPrefix], bRm);
8727 /* memory, register */
8728 return FNIEMOP_CALL_1(g_apfnGroup9MemReg[ ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) * 4
8729 + pVCpu->iem.s.idxPrefix], bRm);
8730}
8731
8732
8733/**
8734 * Common 'bswap register' helper.
8735 */
8736FNIEMOP_DEF_1(iemOpCommonBswapGReg, uint8_t, iReg)
8737{
8738 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8739 switch (pVCpu->iem.s.enmEffOpSize)
8740 {
8741 case IEMMODE_16BIT:
8742 IEM_MC_BEGIN(1, 0);
8743 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
8744 IEM_MC_REF_GREG_U32(pu32Dst, iReg); /* Don't clear the high dword! */
8745 IEM_MC_CALL_VOID_AIMPL_1(iemAImpl_bswap_u16, pu32Dst);
8746 IEM_MC_ADVANCE_RIP();
8747 IEM_MC_END();
8748 return VINF_SUCCESS;
8749
8750 case IEMMODE_32BIT:
8751 IEM_MC_BEGIN(1, 0);
8752 IEM_MC_ARG(uint32_t *, pu32Dst, 0);
8753 IEM_MC_REF_GREG_U32(pu32Dst, iReg);
8754 IEM_MC_CLEAR_HIGH_GREG_U64_BY_REF(pu32Dst);
8755 IEM_MC_CALL_VOID_AIMPL_1(iemAImpl_bswap_u32, pu32Dst);
8756 IEM_MC_ADVANCE_RIP();
8757 IEM_MC_END();
8758 return VINF_SUCCESS;
8759
8760 case IEMMODE_64BIT:
8761 IEM_MC_BEGIN(1, 0);
8762 IEM_MC_ARG(uint64_t *, pu64Dst, 0);
8763 IEM_MC_REF_GREG_U64(pu64Dst, iReg);
8764 IEM_MC_CALL_VOID_AIMPL_1(iemAImpl_bswap_u64, pu64Dst);
8765 IEM_MC_ADVANCE_RIP();
8766 IEM_MC_END();
8767 return VINF_SUCCESS;
8768
8769 IEM_NOT_REACHED_DEFAULT_CASE_RET();
8770 }
8771}
8772
8773
8774/** Opcode 0x0f 0xc8. */
8775FNIEMOP_DEF(iemOp_bswap_rAX_r8)
8776{
8777 IEMOP_MNEMONIC(bswap_rAX_r8, "bswap rAX/r8");
8778 /* Note! Intel manuals states that R8-R15 can be accessed by using a REX.X
8779 prefix. REX.B is the correct prefix it appears. For a parallel
8780 case, see iemOp_mov_AL_Ib and iemOp_mov_eAX_Iv. */
8781 IEMOP_HLP_MIN_486();
8782 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xAX | pVCpu->iem.s.uRexB);
8783}
8784
8785
8786/** Opcode 0x0f 0xc9. */
8787FNIEMOP_DEF(iemOp_bswap_rCX_r9)
8788{
8789 IEMOP_MNEMONIC(bswap_rCX_r9, "bswap rCX/r9");
8790 IEMOP_HLP_MIN_486();
8791 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xCX | pVCpu->iem.s.uRexB);
8792}
8793
8794
8795/** Opcode 0x0f 0xca. */
8796FNIEMOP_DEF(iemOp_bswap_rDX_r10)
8797{
8798 IEMOP_MNEMONIC(bswap_rDX_r9, "bswap rDX/r9");
8799 IEMOP_HLP_MIN_486();
8800 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xDX | pVCpu->iem.s.uRexB);
8801}
8802
8803
8804/** Opcode 0x0f 0xcb. */
8805FNIEMOP_DEF(iemOp_bswap_rBX_r11)
8806{
8807 IEMOP_MNEMONIC(bswap_rBX_r9, "bswap rBX/r9");
8808 IEMOP_HLP_MIN_486();
8809 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xBX | pVCpu->iem.s.uRexB);
8810}
8811
8812
8813/** Opcode 0x0f 0xcc. */
8814FNIEMOP_DEF(iemOp_bswap_rSP_r12)
8815{
8816 IEMOP_MNEMONIC(bswap_rSP_r12, "bswap rSP/r12");
8817 IEMOP_HLP_MIN_486();
8818 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xSP | pVCpu->iem.s.uRexB);
8819}
8820
8821
8822/** Opcode 0x0f 0xcd. */
8823FNIEMOP_DEF(iemOp_bswap_rBP_r13)
8824{
8825 IEMOP_MNEMONIC(bswap_rBP_r13, "bswap rBP/r13");
8826 IEMOP_HLP_MIN_486();
8827 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xBP | pVCpu->iem.s.uRexB);
8828}
8829
8830
8831/** Opcode 0x0f 0xce. */
8832FNIEMOP_DEF(iemOp_bswap_rSI_r14)
8833{
8834 IEMOP_MNEMONIC(bswap_rSI_r14, "bswap rSI/r14");
8835 IEMOP_HLP_MIN_486();
8836 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xSI | pVCpu->iem.s.uRexB);
8837}
8838
8839
8840/** Opcode 0x0f 0xcf. */
8841FNIEMOP_DEF(iemOp_bswap_rDI_r15)
8842{
8843 IEMOP_MNEMONIC(bswap_rDI_r15, "bswap rDI/r15");
8844 IEMOP_HLP_MIN_486();
8845 return FNIEMOP_CALL_1(iemOpCommonBswapGReg, X86_GREG_xDI | pVCpu->iem.s.uRexB);
8846}
8847
8848
8849/* Opcode 0x0f 0xd0 - invalid */
8850/** Opcode 0x66 0x0f 0xd0 - addsubpd Vpd, Wpd */
8851FNIEMOP_STUB(iemOp_addsubpd_Vpd_Wpd);
8852/* Opcode 0xf3 0x0f 0xd0 - invalid */
8853/** Opcode 0xf2 0x0f 0xd0 - addsubps Vps, Wps */
8854FNIEMOP_STUB(iemOp_addsubps_Vps_Wps);
8855
8856/** Opcode 0x0f 0xd1 - psrlw Pq, Qq */
8857FNIEMOP_STUB(iemOp_psrlw_Pq_Qq);
8858/** Opcode 0x66 0x0f 0xd1 - psrlw Vx, W */
8859FNIEMOP_STUB(iemOp_psrlw_Vx_W);
8860/* Opcode 0xf3 0x0f 0xd1 - invalid */
8861/* Opcode 0xf2 0x0f 0xd1 - invalid */
8862
8863/** Opcode 0x0f 0xd2 - psrld Pq, Qq */
8864FNIEMOP_STUB(iemOp_psrld_Pq_Qq);
8865/** Opcode 0x66 0x0f 0xd2 - psrld Vx, Wx */
8866FNIEMOP_STUB(iemOp_psrld_Vx_Wx);
8867/* Opcode 0xf3 0x0f 0xd2 - invalid */
8868/* Opcode 0xf2 0x0f 0xd2 - invalid */
8869
8870/** Opcode 0x0f 0xd3 - psrlq Pq, Qq */
8871FNIEMOP_STUB(iemOp_psrlq_Pq_Qq);
8872/** Opcode 0x66 0x0f 0xd3 - psrlq Vx, Wx */
8873FNIEMOP_STUB(iemOp_psrlq_Vx_Wx);
8874/* Opcode 0xf3 0x0f 0xd3 - invalid */
8875/* Opcode 0xf2 0x0f 0xd3 - invalid */
8876
8877/** Opcode 0x0f 0xd4 - paddq Pq, Qq */
8878FNIEMOP_STUB(iemOp_paddq_Pq_Qq);
8879/** Opcode 0x66 0x0f 0xd4 - paddq Vx, W */
8880FNIEMOP_STUB(iemOp_paddq_Vx_W);
8881/* Opcode 0xf3 0x0f 0xd4 - invalid */
8882/* Opcode 0xf2 0x0f 0xd4 - invalid */
8883
8884/** Opcode 0x0f 0xd5 - pmullw Pq, Qq */
8885FNIEMOP_STUB(iemOp_pmullw_Pq_Qq);
8886/** Opcode 0x66 0x0f 0xd5 - pmullw Vx, Wx */
8887FNIEMOP_STUB(iemOp_pmullw_Vx_Wx);
8888/* Opcode 0xf3 0x0f 0xd5 - invalid */
8889/* Opcode 0xf2 0x0f 0xd5 - invalid */
8890
8891/* Opcode 0x0f 0xd6 - invalid */
8892
8893/**
8894 * @opcode 0xd6
8895 * @oppfx 0x66
8896 * @opcpuid sse2
8897 * @opgroup og_sse2_pcksclr_datamove
8898 * @opxcpttype none
8899 * @optest op1=-1 op2=2 -> op1=2
8900 * @optest op1=0 op2=-42 -> op1=-42
8901 */
8902FNIEMOP_DEF(iemOp_movq_Wq_Vq)
8903{
8904 IEMOP_MNEMONIC2(MR, MOVQ, movq, WqZxReg_WO, Vq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
8905 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8906 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8907 {
8908 /*
8909 * Register, register.
8910 */
8911 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8912 IEM_MC_BEGIN(0, 2);
8913 IEM_MC_LOCAL(uint64_t, uSrc);
8914
8915 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
8916 IEM_MC_ACTUALIZE_SSE_STATE_FOR_CHANGE();
8917
8918 IEM_MC_FETCH_XREG_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8919 IEM_MC_STORE_XREG_U64_ZX_U128((bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB, uSrc);
8920
8921 IEM_MC_ADVANCE_RIP();
8922 IEM_MC_END();
8923 }
8924 else
8925 {
8926 /*
8927 * Memory, register.
8928 */
8929 IEM_MC_BEGIN(0, 2);
8930 IEM_MC_LOCAL(uint64_t, uSrc);
8931 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
8932
8933 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
8934 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8935 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
8936 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
8937
8938 IEM_MC_FETCH_XREG_U64(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
8939 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
8940
8941 IEM_MC_ADVANCE_RIP();
8942 IEM_MC_END();
8943 }
8944 return VINF_SUCCESS;
8945}
8946
8947
8948/**
8949 * @opcode 0xd6
8950 * @opcodesub 11 mr/reg
8951 * @oppfx f3
8952 * @opcpuid sse2
8953 * @opgroup og_sse2_simdint_datamove
8954 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
8955 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
8956 */
8957FNIEMOP_DEF(iemOp_movq2dq_Vdq_Nq)
8958{
8959 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
8960 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
8961 {
8962 /*
8963 * Register, register.
8964 */
8965 IEMOP_MNEMONIC2(RM_REG, MOVQ2DQ, movq2dq, VqZx_WO, Nq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
8966 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
8967 IEM_MC_BEGIN(0, 1);
8968 IEM_MC_LOCAL(uint64_t, uSrc);
8969
8970 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
8971 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
8972
8973 IEM_MC_FETCH_MREG_U64(uSrc, bRm & X86_MODRM_RM_MASK);
8974 IEM_MC_STORE_XREG_U64_ZX_U128(((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg, uSrc);
8975 IEM_MC_FPU_TO_MMX_MODE();
8976
8977 IEM_MC_ADVANCE_RIP();
8978 IEM_MC_END();
8979 return VINF_SUCCESS;
8980 }
8981
8982 /**
8983 * @opdone
8984 * @opmnemonic udf30fd6mem
8985 * @opcode 0xd6
8986 * @opcodesub !11 mr/reg
8987 * @oppfx f3
8988 * @opunused intel-modrm
8989 * @opcpuid sse
8990 * @optest ->
8991 */
8992 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedDecode, bRm);
8993}
8994
8995
8996/**
8997 * @opcode 0xd6
8998 * @opcodesub 11 mr/reg
8999 * @oppfx f2
9000 * @opcpuid sse2
9001 * @opgroup og_sse2_simdint_datamove
9002 * @optest op1=1 op2=2 -> op1=2 ftw=0xff
9003 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
9004 * @optest op1=0 op2=0x1123456789abcdef -> op1=0x1123456789abcdef ftw=0xff
9005 * @optest op1=0 op2=0xfedcba9876543210 -> op1=0xfedcba9876543210 ftw=0xff
9006 * @optest op1=-42 op2=0xfedcba9876543210
9007 * -> op1=0xfedcba9876543210 ftw=0xff
9008 */
9009FNIEMOP_DEF(iemOp_movdq2q_Pq_Uq)
9010{
9011 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9012 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT))
9013 {
9014 /*
9015 * Register, register.
9016 */
9017 IEMOP_MNEMONIC2(RM_REG, MOVDQ2Q, movdq2q, Pq_WO, Uq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9018 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9019 IEM_MC_BEGIN(0, 1);
9020 IEM_MC_LOCAL(uint64_t, uSrc);
9021
9022 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
9023 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
9024
9025 IEM_MC_FETCH_XREG_U64(uSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
9026 IEM_MC_STORE_MREG_U64((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK, uSrc);
9027 IEM_MC_FPU_TO_MMX_MODE();
9028
9029 IEM_MC_ADVANCE_RIP();
9030 IEM_MC_END();
9031 return VINF_SUCCESS;
9032 }
9033
9034 /**
9035 * @opdone
9036 * @opmnemonic udf20fd6mem
9037 * @opcode 0xd6
9038 * @opcodesub !11 mr/reg
9039 * @oppfx f2
9040 * @opunused intel-modrm
9041 * @opcpuid sse
9042 * @optest ->
9043 */
9044 return FNIEMOP_CALL_1(iemOp_InvalidWithRMNeedDecode, bRm);
9045}
9046
9047/** Opcode 0x0f 0xd7 - pmovmskb Gd, Nq */
9048FNIEMOP_DEF(iemOp_pmovmskb_Gd_Nq)
9049{
9050 /* Note! Taking the lazy approch here wrt the high 32-bits of the GREG. */
9051 /** @todo testcase: Check that the instruction implicitly clears the high
9052 * bits in 64-bit mode. The REX.W is first necessary when VLMAX > 256
9053 * and opcode modifications are made to work with the whole width (not
9054 * just 128). */
9055 IEMOP_MNEMONIC(pmovmskb_Gd_Udq, "pmovmskb Gd,Nq");
9056 /* Docs says register only. */
9057 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9058 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) /** @todo test that this is registers only. */
9059 {
9060 IEMOP_HLP_DECODED_NL_2(OP_PMOVMSKB, IEMOPFORM_RM_REG, OP_PARM_Gd, OP_PARM_Vdq, DISOPTYPE_MMX | DISOPTYPE_HARMLESS);
9061 IEM_MC_BEGIN(2, 0);
9062 IEM_MC_ARG(uint64_t *, pDst, 0);
9063 IEM_MC_ARG(uint64_t const *, pSrc, 1);
9064 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT_CHECK_SSE_OR_MMXEXT();
9065 IEM_MC_PREPARE_FPU_USAGE();
9066 IEM_MC_REF_GREG_U64(pDst, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
9067 IEM_MC_REF_MREG_U64_CONST(pSrc, bRm & X86_MODRM_RM_MASK);
9068 IEM_MC_CALL_MMX_AIMPL_2(iemAImpl_pmovmskb_u64, pDst, pSrc);
9069 IEM_MC_ADVANCE_RIP();
9070 IEM_MC_END();
9071 return VINF_SUCCESS;
9072 }
9073 return IEMOP_RAISE_INVALID_OPCODE();
9074}
9075
9076/** Opcode 0x66 0x0f 0xd7 - */
9077FNIEMOP_DEF(iemOp_pmovmskb_Gd_Ux)
9078{
9079 /* Note! Taking the lazy approch here wrt the high 32-bits of the GREG. */
9080 /** @todo testcase: Check that the instruction implicitly clears the high
9081 * bits in 64-bit mode. The REX.W is first necessary when VLMAX > 256
9082 * and opcode modifications are made to work with the whole width (not
9083 * just 128). */
9084 IEMOP_MNEMONIC(pmovmskb_Gd_Nq, "vpmovmskb Gd, Ux");
9085 /* Docs says register only. */
9086 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9087 if ((bRm & X86_MODRM_MOD_MASK) == (3 << X86_MODRM_MOD_SHIFT)) /** @todo test that this is registers only. */
9088 {
9089 IEMOP_HLP_DECODED_NL_2(OP_PMOVMSKB, IEMOPFORM_RM_REG, OP_PARM_Gd, OP_PARM_Vdq, DISOPTYPE_SSE | DISOPTYPE_HARMLESS);
9090 IEM_MC_BEGIN(2, 0);
9091 IEM_MC_ARG(uint64_t *, pDst, 0);
9092 IEM_MC_ARG(PCRTUINT128U, pSrc, 1);
9093 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
9094 IEM_MC_PREPARE_SSE_USAGE();
9095 IEM_MC_REF_GREG_U64(pDst, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
9096 IEM_MC_REF_XREG_U128_CONST(pSrc, (bRm & X86_MODRM_RM_MASK) | pVCpu->iem.s.uRexB);
9097 IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_pmovmskb_u128, pDst, pSrc);
9098 IEM_MC_ADVANCE_RIP();
9099 IEM_MC_END();
9100 return VINF_SUCCESS;
9101 }
9102 return IEMOP_RAISE_INVALID_OPCODE();
9103}
9104
9105/* Opcode 0xf3 0x0f 0xd7 - invalid */
9106/* Opcode 0xf2 0x0f 0xd7 - invalid */
9107
9108
9109/** Opcode 0x0f 0xd8 - psubusb Pq, Qq */
9110FNIEMOP_STUB(iemOp_psubusb_Pq_Qq);
9111/** Opcode 0x66 0x0f 0xd8 - psubusb Vx, W */
9112FNIEMOP_STUB(iemOp_psubusb_Vx_W);
9113/* Opcode 0xf3 0x0f 0xd8 - invalid */
9114/* Opcode 0xf2 0x0f 0xd8 - invalid */
9115
9116/** Opcode 0x0f 0xd9 - psubusw Pq, Qq */
9117FNIEMOP_STUB(iemOp_psubusw_Pq_Qq);
9118/** Opcode 0x66 0x0f 0xd9 - psubusw Vx, Wx */
9119FNIEMOP_STUB(iemOp_psubusw_Vx_Wx);
9120/* Opcode 0xf3 0x0f 0xd9 - invalid */
9121/* Opcode 0xf2 0x0f 0xd9 - invalid */
9122
9123/** Opcode 0x0f 0xda - pminub Pq, Qq */
9124FNIEMOP_STUB(iemOp_pminub_Pq_Qq);
9125/** Opcode 0x66 0x0f 0xda - pminub Vx, Wx */
9126FNIEMOP_STUB(iemOp_pminub_Vx_Wx);
9127/* Opcode 0xf3 0x0f 0xda - invalid */
9128/* Opcode 0xf2 0x0f 0xda - invalid */
9129
9130/** Opcode 0x0f 0xdb - pand Pq, Qq */
9131FNIEMOP_STUB(iemOp_pand_Pq_Qq);
9132/** Opcode 0x66 0x0f 0xdb - pand Vx, W */
9133FNIEMOP_STUB(iemOp_pand_Vx_W);
9134/* Opcode 0xf3 0x0f 0xdb - invalid */
9135/* Opcode 0xf2 0x0f 0xdb - invalid */
9136
9137/** Opcode 0x0f 0xdc - paddusb Pq, Qq */
9138FNIEMOP_STUB(iemOp_paddusb_Pq_Qq);
9139/** Opcode 0x66 0x0f 0xdc - paddusb Vx, Wx */
9140FNIEMOP_STUB(iemOp_paddusb_Vx_Wx);
9141/* Opcode 0xf3 0x0f 0xdc - invalid */
9142/* Opcode 0xf2 0x0f 0xdc - invalid */
9143
9144/** Opcode 0x0f 0xdd - paddusw Pq, Qq */
9145FNIEMOP_STUB(iemOp_paddusw_Pq_Qq);
9146/** Opcode 0x66 0x0f 0xdd - paddusw Vx, Wx */
9147FNIEMOP_STUB(iemOp_paddusw_Vx_Wx);
9148/* Opcode 0xf3 0x0f 0xdd - invalid */
9149/* Opcode 0xf2 0x0f 0xdd - invalid */
9150
9151/** Opcode 0x0f 0xde - pmaxub Pq, Qq */
9152FNIEMOP_STUB(iemOp_pmaxub_Pq_Qq);
9153/** Opcode 0x66 0x0f 0xde - pmaxub Vx, W */
9154FNIEMOP_STUB(iemOp_pmaxub_Vx_W);
9155/* Opcode 0xf3 0x0f 0xde - invalid */
9156/* Opcode 0xf2 0x0f 0xde - invalid */
9157
9158/** Opcode 0x0f 0xdf - pandn Pq, Qq */
9159FNIEMOP_STUB(iemOp_pandn_Pq_Qq);
9160/** Opcode 0x66 0x0f 0xdf - pandn Vx, Wx */
9161FNIEMOP_STUB(iemOp_pandn_Vx_Wx);
9162/* Opcode 0xf3 0x0f 0xdf - invalid */
9163/* Opcode 0xf2 0x0f 0xdf - invalid */
9164
9165/** Opcode 0x0f 0xe0 - pavgb Pq, Qq */
9166FNIEMOP_STUB(iemOp_pavgb_Pq_Qq);
9167/** Opcode 0x66 0x0f 0xe0 - pavgb Vx, Wx */
9168FNIEMOP_STUB(iemOp_pavgb_Vx_Wx);
9169/* Opcode 0xf3 0x0f 0xe0 - invalid */
9170/* Opcode 0xf2 0x0f 0xe0 - invalid */
9171
9172/** Opcode 0x0f 0xe1 - psraw Pq, Qq */
9173FNIEMOP_STUB(iemOp_psraw_Pq_Qq);
9174/** Opcode 0x66 0x0f 0xe1 - psraw Vx, W */
9175FNIEMOP_STUB(iemOp_psraw_Vx_W);
9176/* Opcode 0xf3 0x0f 0xe1 - invalid */
9177/* Opcode 0xf2 0x0f 0xe1 - invalid */
9178
9179/** Opcode 0x0f 0xe2 - psrad Pq, Qq */
9180FNIEMOP_STUB(iemOp_psrad_Pq_Qq);
9181/** Opcode 0x66 0x0f 0xe2 - psrad Vx, Wx */
9182FNIEMOP_STUB(iemOp_psrad_Vx_Wx);
9183/* Opcode 0xf3 0x0f 0xe2 - invalid */
9184/* Opcode 0xf2 0x0f 0xe2 - invalid */
9185
9186/** Opcode 0x0f 0xe3 - pavgw Pq, Qq */
9187FNIEMOP_STUB(iemOp_pavgw_Pq_Qq);
9188/** Opcode 0x66 0x0f 0xe3 - pavgw Vx, Wx */
9189FNIEMOP_STUB(iemOp_pavgw_Vx_Wx);
9190/* Opcode 0xf3 0x0f 0xe3 - invalid */
9191/* Opcode 0xf2 0x0f 0xe3 - invalid */
9192
9193/** Opcode 0x0f 0xe4 - pmulhuw Pq, Qq */
9194FNIEMOP_STUB(iemOp_pmulhuw_Pq_Qq);
9195/** Opcode 0x66 0x0f 0xe4 - pmulhuw Vx, W */
9196FNIEMOP_STUB(iemOp_pmulhuw_Vx_W);
9197/* Opcode 0xf3 0x0f 0xe4 - invalid */
9198/* Opcode 0xf2 0x0f 0xe4 - invalid */
9199
9200/** Opcode 0x0f 0xe5 - pmulhw Pq, Qq */
9201FNIEMOP_STUB(iemOp_pmulhw_Pq_Qq);
9202/** Opcode 0x66 0x0f 0xe5 - pmulhw Vx, Wx */
9203FNIEMOP_STUB(iemOp_pmulhw_Vx_Wx);
9204/* Opcode 0xf3 0x0f 0xe5 - invalid */
9205/* Opcode 0xf2 0x0f 0xe5 - invalid */
9206
9207/* Opcode 0x0f 0xe6 - invalid */
9208/** Opcode 0x66 0x0f 0xe6 - cvttpd2dq Vx, Wpd */
9209FNIEMOP_STUB(iemOp_cvttpd2dq_Vx_Wpd);
9210/** Opcode 0xf3 0x0f 0xe6 - cvtdq2pd Vx, Wpd */
9211FNIEMOP_STUB(iemOp_cvtdq2pd_Vx_Wpd);
9212/** Opcode 0xf2 0x0f 0xe6 - cvtpd2dq Vx, Wpd */
9213FNIEMOP_STUB(iemOp_cvtpd2dq_Vx_Wpd);
9214
9215
9216/**
9217 * @opcode 0xe7
9218 * @opcodesub !11 mr/reg
9219 * @oppfx none
9220 * @opcpuid sse
9221 * @opgroup og_sse1_cachect
9222 * @opxcpttype none
9223 * @optest op1=-1 op2=2 -> op1=2 ftw=0xff
9224 * @optest op1=0 op2=-42 -> op1=-42 ftw=0xff
9225 */
9226FNIEMOP_DEF(iemOp_movntq_Mq_Pq)
9227{
9228 IEMOP_MNEMONIC2(MR_MEM, MOVNTQ, movntq, Mq_WO, Pq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9229 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9230 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
9231 {
9232 /* Register, memory. */
9233 IEM_MC_BEGIN(0, 2);
9234 IEM_MC_LOCAL(uint64_t, uSrc);
9235 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
9236
9237 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
9238 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9239 IEM_MC_MAYBE_RAISE_MMX_RELATED_XCPT();
9240 IEM_MC_ACTUALIZE_FPU_STATE_FOR_CHANGE();
9241
9242 IEM_MC_FETCH_MREG_U64(uSrc, (bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK);
9243 IEM_MC_STORE_MEM_U64(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
9244 IEM_MC_FPU_TO_MMX_MODE();
9245
9246 IEM_MC_ADVANCE_RIP();
9247 IEM_MC_END();
9248 return VINF_SUCCESS;
9249 }
9250 /**
9251 * @opdone
9252 * @opmnemonic ud0fe7reg
9253 * @opcode 0xe7
9254 * @opcodesub 11 mr/reg
9255 * @oppfx none
9256 * @opunused immediate
9257 * @opcpuid sse
9258 * @optest ->
9259 */
9260 return IEMOP_RAISE_INVALID_OPCODE();
9261}
9262
9263/**
9264 * @opcode 0xe7
9265 * @opcodesub !11 mr/reg
9266 * @oppfx 0x66
9267 * @opcpuid sse2
9268 * @opgroup og_sse2_cachect
9269 * @opxcpttype 1
9270 * @optest op1=-1 op2=2 -> op1=2
9271 * @optest op1=0 op2=-42 -> op1=-42
9272 */
9273FNIEMOP_DEF(iemOp_movntdq_Mdq_Vdq)
9274{
9275 IEMOP_MNEMONIC2(MR_MEM, MOVNTDQ, movntdq, Mdq_WO, Vdq, DISOPTYPE_HARMLESS, IEMOPHINT_IGNORES_OP_SIZES);
9276 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
9277 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
9278 {
9279 /* Register, memory. */
9280 IEM_MC_BEGIN(0, 2);
9281 IEM_MC_LOCAL(RTUINT128U, uSrc);
9282 IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
9283
9284 IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
9285 IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX();
9286 IEM_MC_MAYBE_RAISE_SSE2_RELATED_XCPT();
9287 IEM_MC_ACTUALIZE_SSE_STATE_FOR_READ();
9288
9289 IEM_MC_FETCH_XREG_U128(uSrc, ((bRm >> X86_MODRM_REG_SHIFT) & X86_MODRM_REG_SMASK) | pVCpu->iem.s.uRexReg);
9290 IEM_MC_STORE_MEM_U128_ALIGN_SSE(pVCpu->iem.s.iEffSeg, GCPtrEffSrc, uSrc);
9291
9292 IEM_MC_ADVANCE_RIP();
9293 IEM_MC_END();
9294 return VINF_SUCCESS;
9295 }
9296
9297 /**
9298 * @opdone
9299 * @opmnemonic ud660fe7reg
9300 * @opcode 0xe7
9301 * @opcodesub 11 mr/reg
9302 * @oppfx 0x66
9303 * @opunused immediate
9304 * @opcpuid sse
9305 * @optest ->
9306 */
9307 return IEMOP_RAISE_INVALID_OPCODE();
9308}
9309
9310/* Opcode 0xf3 0x0f 0xe7 - invalid */
9311/* Opcode 0xf2 0x0f 0xe7 - invalid */
9312
9313
9314/** Opcode 0x0f 0xe8 - psubsb Pq, Qq */
9315FNIEMOP_STUB(iemOp_psubsb_Pq_Qq);
9316/** Opcode 0x66 0x0f 0xe8 - psubsb Vx, W */
9317FNIEMOP_STUB(iemOp_psubsb_Vx_W);
9318/* Opcode 0xf3 0x0f 0xe8 - invalid */
9319/* Opcode 0xf2 0x0f 0xe8 - invalid */
9320
9321/** Opcode 0x0f 0xe9 - psubsw Pq, Qq */
9322FNIEMOP_STUB(iemOp_psubsw_Pq_Qq);
9323/** Opcode 0x66 0x0f 0xe9 - psubsw Vx, Wx */
9324FNIEMOP_STUB(iemOp_psubsw_Vx_Wx);
9325/* Opcode 0xf3 0x0f 0xe9 - invalid */
9326/* Opcode 0xf2 0x0f 0xe9 - invalid */
9327
9328/** Opcode 0x0f 0xea - pminsw Pq, Qq */
9329FNIEMOP_STUB(iemOp_pminsw_Pq_Qq);
9330/** Opcode 0x66 0x0f 0xea - pminsw Vx, Wx */
9331FNIEMOP_STUB(iemOp_pminsw_Vx_Wx);
9332/* Opcode 0xf3 0x0f 0xea - invalid */
9333/* Opcode 0xf2 0x0f 0xea - invalid */
9334
9335/** Opcode 0x0f 0xeb - por Pq, Qq */
9336FNIEMOP_STUB(iemOp_por_Pq_Qq);
9337/** Opcode 0x66 0x0f 0xeb - por Vx, W */
9338FNIEMOP_STUB(iemOp_por_Vx_W);
9339/* Opcode 0xf3 0x0f 0xeb - invalid */
9340/* Opcode 0xf2 0x0f 0xeb - invalid */
9341
9342/** Opcode 0x0f 0xec - paddsb Pq, Qq */
9343FNIEMOP_STUB(iemOp_paddsb_Pq_Qq);
9344/** Opcode 0x66 0x0f 0xec - paddsb Vx, Wx */
9345FNIEMOP_STUB(iemOp_paddsb_Vx_Wx);
9346/* Opcode 0xf3 0x0f 0xec - invalid */
9347/* Opcode 0xf2 0x0f 0xec - invalid */
9348
9349/** Opcode 0x0f 0xed - paddsw Pq, Qq */
9350FNIEMOP_STUB(iemOp_paddsw_Pq_Qq);
9351/** Opcode 0x66 0x0f 0xed - paddsw Vx, Wx */
9352FNIEMOP_STUB(iemOp_paddsw_Vx_Wx);
9353/* Opcode 0xf3 0x0f 0xed - invalid */
9354/* Opcode 0xf2 0x0f 0xed - invalid */
9355
9356/** Opcode 0x0f 0xee - pmaxsw Pq, Qq */
9357FNIEMOP_STUB(iemOp_pmaxsw_Pq_Qq);
9358/** Opcode 0x66 0x0f 0xee - pmaxsw Vx, W */
9359FNIEMOP_STUB(iemOp_pmaxsw_Vx_W);
9360/* Opcode 0xf3 0x0f 0xee - invalid */
9361/* Opcode 0xf2 0x0f 0xee - invalid */
9362
9363
9364/** Opcode 0x0f 0xef - pxor Pq, Qq */
9365FNIEMOP_DEF(iemOp_pxor_Pq_Qq)
9366{
9367 IEMOP_MNEMONIC(pxor, "pxor");
9368 return FNIEMOP_CALL_1(iemOpCommonMmx_FullFull_To_Full, &g_iemAImpl_pxor);
9369}
9370
9371/** Opcode 0x66 0x0f 0xef - pxor Vx, Wx */
9372FNIEMOP_DEF(iemOp_pxor_Vx_Wx)
9373{
9374 IEMOP_MNEMONIC(pxor_Vx_Wx, "pxor");
9375 return FNIEMOP_CALL_1(iemOpCommonSse2_FullFull_To_Full, &g_iemAImpl_pxor);
9376}
9377
9378/* Opcode 0xf3 0x0f 0xef - invalid */
9379/* Opcode 0xf2 0x0f 0xef - invalid */
9380
9381/* Opcode 0x0f 0xf0 - invalid */
9382/* Opcode 0x66 0x0f 0xf0 - invalid */
9383/** Opcode 0xf2 0x0f 0xf0 - lddqu Vx, Mx */
9384FNIEMOP_STUB(iemOp_lddqu_Vx_Mx);
9385
9386/** Opcode 0x0f 0xf1 - psllw Pq, Qq */
9387FNIEMOP_STUB(iemOp_psllw_Pq_Qq);
9388/** Opcode 0x66 0x0f 0xf1 - psllw Vx, W */
9389FNIEMOP_STUB(iemOp_psllw_Vx_W);
9390/* Opcode 0xf2 0x0f 0xf1 - invalid */
9391
9392/** Opcode 0x0f 0xf2 - pslld Pq, Qq */
9393FNIEMOP_STUB(iemOp_pslld_Pq_Qq);
9394/** Opcode 0x66 0x0f 0xf2 - pslld Vx, Wx */
9395FNIEMOP_STUB(iemOp_pslld_Vx_Wx);
9396/* Opcode 0xf2 0x0f 0xf2 - invalid */
9397
9398/** Opcode 0x0f 0xf3 - psllq Pq, Qq */
9399FNIEMOP_STUB(iemOp_psllq_Pq_Qq);
9400/** Opcode 0x66 0x0f 0xf3 - psllq Vx, Wx */
9401FNIEMOP_STUB(iemOp_psllq_Vx_Wx);
9402/* Opcode 0xf2 0x0f 0xf3 - invalid */
9403
9404/** Opcode 0x0f 0xf4 - pmuludq Pq, Qq */
9405FNIEMOP_STUB(iemOp_pmuludq_Pq_Qq);
9406/** Opcode 0x66 0x0f 0xf4 - pmuludq Vx, W */
9407FNIEMOP_STUB(iemOp_pmuludq_Vx_W);
9408/* Opcode 0xf2 0x0f 0xf4 - invalid */
9409
9410/** Opcode 0x0f 0xf5 - pmaddwd Pq, Qq */
9411FNIEMOP_STUB(iemOp_pmaddwd_Pq_Qq);
9412/** Opcode 0x66 0x0f 0xf5 - pmaddwd Vx, Wx */
9413FNIEMOP_STUB(iemOp_pmaddwd_Vx_Wx);
9414/* Opcode 0xf2 0x0f 0xf5 - invalid */
9415
9416/** Opcode 0x0f 0xf6 - psadbw Pq, Qq */
9417FNIEMOP_STUB(iemOp_psadbw_Pq_Qq);
9418/** Opcode 0x66 0x0f 0xf6 - psadbw Vx, Wx */
9419FNIEMOP_STUB(iemOp_psadbw_Vx_Wx);
9420/* Opcode 0xf2 0x0f 0xf6 - invalid */
9421
9422/** Opcode 0x0f 0xf7 - maskmovq Pq, Nq */
9423FNIEMOP_STUB(iemOp_maskmovq_Pq_Nq);
9424/** Opcode 0x66 0x0f 0xf7 - maskmovdqu Vdq, Udq */
9425FNIEMOP_STUB(iemOp_maskmovdqu_Vdq_Udq);
9426/* Opcode 0xf2 0x0f 0xf7 - invalid */
9427
9428/** Opcode 0x0f 0xf8 - psubb Pq, Qq */
9429FNIEMOP_STUB(iemOp_psubb_Pq_Qq);
9430/** Opcode 0x66 0x0f 0xf8 - psubb Vx, W */
9431FNIEMOP_STUB(iemOp_psubb_Vx_W);
9432/* Opcode 0xf2 0x0f 0xf8 - invalid */
9433
9434/** Opcode 0x0f 0xf9 - psubw Pq, Qq */
9435FNIEMOP_STUB(iemOp_psubw_Pq_Qq);
9436/** Opcode 0x66 0x0f 0xf9 - psubw Vx, Wx */
9437FNIEMOP_STUB(iemOp_psubw_Vx_Wx);
9438/* Opcode 0xf2 0x0f 0xf9 - invalid */
9439
9440/** Opcode 0x0f 0xfa - psubd Pq, Qq */
9441FNIEMOP_STUB(iemOp_psubd_Pq_Qq);
9442/** Opcode 0x66 0x0f 0xfa - psubd Vx, Wx */
9443FNIEMOP_STUB(iemOp_psubd_Vx_Wx);
9444/* Opcode 0xf2 0x0f 0xfa - invalid */
9445
9446/** Opcode 0x0f 0xfb - psubq Pq, Qq */
9447FNIEMOP_STUB(iemOp_psubq_Pq_Qq);
9448/** Opcode 0x66 0x0f 0xfb - psubq Vx, W */
9449FNIEMOP_STUB(iemOp_psubq_Vx_W);
9450/* Opcode 0xf2 0x0f 0xfb - invalid */
9451
9452/** Opcode 0x0f 0xfc - paddb Pq, Qq */
9453FNIEMOP_STUB(iemOp_paddb_Pq_Qq);
9454/** Opcode 0x66 0x0f 0xfc - paddb Vx, Wx */
9455FNIEMOP_STUB(iemOp_paddb_Vx_Wx);
9456/* Opcode 0xf2 0x0f 0xfc - invalid */
9457
9458/** Opcode 0x0f 0xfd - paddw Pq, Qq */
9459FNIEMOP_STUB(iemOp_paddw_Pq_Qq);
9460/** Opcode 0x66 0x0f 0xfd - paddw Vx, Wx */
9461FNIEMOP_STUB(iemOp_paddw_Vx_Wx);
9462/* Opcode 0xf2 0x0f 0xfd - invalid */
9463
9464/** Opcode 0x0f 0xfe - paddd Pq, Qq */
9465FNIEMOP_STUB(iemOp_paddd_Pq_Qq);
9466/** Opcode 0x66 0x0f 0xfe - paddd Vx, W */
9467FNIEMOP_STUB(iemOp_paddd_Vx_W);
9468/* Opcode 0xf2 0x0f 0xfe - invalid */
9469
9470
9471/** Opcode **** 0x0f 0xff - UD0 */
9472FNIEMOP_DEF(iemOp_ud0)
9473{
9474 IEMOP_MNEMONIC(ud0, "ud0");
9475 if (pVCpu->iem.s.enmCpuVendor == CPUMCPUVENDOR_INTEL)
9476 {
9477 uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm); RT_NOREF(bRm);
9478#ifndef TST_IEM_CHECK_MC
9479 if ((bRm & X86_MODRM_MOD_MASK) != (3 << X86_MODRM_MOD_SHIFT))
9480 {
9481 RTGCPTR GCPtrEff;
9482 VBOXSTRICTRC rcStrict = iemOpHlpCalcRmEffAddr(pVCpu, bRm, 0, &GCPtrEff);
9483 if (rcStrict != VINF_SUCCESS)
9484 return rcStrict;
9485 }
9486#endif
9487 IEMOP_HLP_DONE_DECODING();
9488 }
9489 return IEMOP_RAISE_INVALID_OPCODE();
9490}
9491
9492
9493
9494/**
9495 * Two byte opcode map, first byte 0x0f.
9496 *
9497 * @remarks The g_apfnVexMap1 table is currently a subset of this one, so please
9498 * check if it needs updating as well when making changes.
9499 */
9500IEM_STATIC const PFNIEMOP g_apfnTwoByteMap[] =
9501{
9502 /* no prefix, 066h prefix f3h prefix, f2h prefix */
9503 /* 0x00 */ IEMOP_X4(iemOp_Grp6),
9504 /* 0x01 */ IEMOP_X4(iemOp_Grp7),
9505 /* 0x02 */ IEMOP_X4(iemOp_lar_Gv_Ew),
9506 /* 0x03 */ IEMOP_X4(iemOp_lsl_Gv_Ew),
9507 /* 0x04 */ IEMOP_X4(iemOp_Invalid),
9508 /* 0x05 */ IEMOP_X4(iemOp_syscall),
9509 /* 0x06 */ IEMOP_X4(iemOp_clts),
9510 /* 0x07 */ IEMOP_X4(iemOp_sysret),
9511 /* 0x08 */ IEMOP_X4(iemOp_invd),
9512 /* 0x09 */ IEMOP_X4(iemOp_wbinvd),
9513 /* 0x0a */ IEMOP_X4(iemOp_Invalid),
9514 /* 0x0b */ IEMOP_X4(iemOp_ud2),
9515 /* 0x0c */ IEMOP_X4(iemOp_Invalid),
9516 /* 0x0d */ IEMOP_X4(iemOp_nop_Ev_GrpP),
9517 /* 0x0e */ IEMOP_X4(iemOp_femms),
9518 /* 0x0f */ IEMOP_X4(iemOp_3Dnow),
9519
9520 /* 0x10 */ iemOp_movups_Vps_Wps, iemOp_movupd_Vpd_Wpd, iemOp_movss_Vss_Wss, iemOp_movsd_Vsd_Wsd,
9521 /* 0x11 */ iemOp_movups_Wps_Vps, iemOp_movupd_Wpd_Vpd, iemOp_movss_Wss_Vss, iemOp_movsd_Wsd_Vsd,
9522 /* 0x12 */ iemOp_movlps_Vq_Mq__movhlps, iemOp_movlpd_Vq_Mq, iemOp_movsldup_Vdq_Wdq, iemOp_movddup_Vdq_Wdq,
9523 /* 0x13 */ iemOp_movlps_Mq_Vq, iemOp_movlpd_Mq_Vq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9524 /* 0x14 */ iemOp_unpcklps_Vx_Wx, iemOp_unpcklpd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9525 /* 0x15 */ iemOp_unpckhps_Vx_Wx, iemOp_unpckhpd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9526 /* 0x16 */ iemOp_movhps_Vdq_Mq__movlhps_Vdq_Uq, iemOp_movhpd_Vdq_Mq, iemOp_movshdup_Vdq_Wdq, iemOp_InvalidNeedRM,
9527 /* 0x17 */ iemOp_movhps_Mq_Vq, iemOp_movhpd_Mq_Vq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9528 /* 0x18 */ IEMOP_X4(iemOp_prefetch_Grp16),
9529 /* 0x19 */ IEMOP_X4(iemOp_nop_Ev),
9530 /* 0x1a */ IEMOP_X4(iemOp_nop_Ev),
9531 /* 0x1b */ IEMOP_X4(iemOp_nop_Ev),
9532 /* 0x1c */ IEMOP_X4(iemOp_nop_Ev),
9533 /* 0x1d */ IEMOP_X4(iemOp_nop_Ev),
9534 /* 0x1e */ IEMOP_X4(iemOp_nop_Ev),
9535 /* 0x1f */ IEMOP_X4(iemOp_nop_Ev),
9536
9537 /* 0x20 */ iemOp_mov_Rd_Cd, iemOp_mov_Rd_Cd, iemOp_mov_Rd_Cd, iemOp_mov_Rd_Cd,
9538 /* 0x21 */ iemOp_mov_Rd_Dd, iemOp_mov_Rd_Dd, iemOp_mov_Rd_Dd, iemOp_mov_Rd_Dd,
9539 /* 0x22 */ iemOp_mov_Cd_Rd, iemOp_mov_Cd_Rd, iemOp_mov_Cd_Rd, iemOp_mov_Cd_Rd,
9540 /* 0x23 */ iemOp_mov_Dd_Rd, iemOp_mov_Dd_Rd, iemOp_mov_Dd_Rd, iemOp_mov_Dd_Rd,
9541 /* 0x24 */ iemOp_mov_Rd_Td, iemOp_mov_Rd_Td, iemOp_mov_Rd_Td, iemOp_mov_Rd_Td,
9542 /* 0x25 */ iemOp_Invalid, iemOp_Invalid, iemOp_Invalid, iemOp_Invalid,
9543 /* 0x26 */ iemOp_mov_Td_Rd, iemOp_mov_Td_Rd, iemOp_mov_Td_Rd, iemOp_mov_Td_Rd,
9544 /* 0x27 */ iemOp_Invalid, iemOp_Invalid, iemOp_Invalid, iemOp_Invalid,
9545 /* 0x28 */ iemOp_movaps_Vps_Wps, iemOp_movapd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9546 /* 0x29 */ iemOp_movaps_Wps_Vps, iemOp_movapd_Wpd_Vpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9547 /* 0x2a */ iemOp_cvtpi2ps_Vps_Qpi, iemOp_cvtpi2pd_Vpd_Qpi, iemOp_cvtsi2ss_Vss_Ey, iemOp_cvtsi2sd_Vsd_Ey,
9548 /* 0x2b */ iemOp_movntps_Mps_Vps, iemOp_movntpd_Mpd_Vpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9549 /* 0x2c */ iemOp_cvttps2pi_Ppi_Wps, iemOp_cvttpd2pi_Ppi_Wpd, iemOp_cvttss2si_Gy_Wss, iemOp_cvttsd2si_Gy_Wsd,
9550 /* 0x2d */ iemOp_cvtps2pi_Ppi_Wps, iemOp_cvtpd2pi_Qpi_Wpd, iemOp_cvtss2si_Gy_Wss, iemOp_cvtsd2si_Gy_Wsd,
9551 /* 0x2e */ iemOp_ucomiss_Vss_Wss, iemOp_ucomisd_Vsd_Wsd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9552 /* 0x2f */ iemOp_comiss_Vss_Wss, iemOp_comisd_Vsd_Wsd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9553
9554 /* 0x30 */ IEMOP_X4(iemOp_wrmsr),
9555 /* 0x31 */ IEMOP_X4(iemOp_rdtsc),
9556 /* 0x32 */ IEMOP_X4(iemOp_rdmsr),
9557 /* 0x33 */ IEMOP_X4(iemOp_rdpmc),
9558 /* 0x34 */ IEMOP_X4(iemOp_sysenter),
9559 /* 0x35 */ IEMOP_X4(iemOp_sysexit),
9560 /* 0x36 */ IEMOP_X4(iemOp_Invalid),
9561 /* 0x37 */ IEMOP_X4(iemOp_getsec),
9562 /* 0x38 */ IEMOP_X4(iemOp_3byte_Esc_0f_38),
9563 /* 0x39 */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRM),
9564 /* 0x3a */ IEMOP_X4(iemOp_3byte_Esc_0f_3a),
9565 /* 0x3b */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRMImm8),
9566 /* 0x3c */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRM),
9567 /* 0x3d */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRM),
9568 /* 0x3e */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRMImm8),
9569 /* 0x3f */ IEMOP_X4(iemOp_InvalidNeed3ByteEscRMImm8),
9570
9571 /* 0x40 */ IEMOP_X4(iemOp_cmovo_Gv_Ev),
9572 /* 0x41 */ IEMOP_X4(iemOp_cmovno_Gv_Ev),
9573 /* 0x42 */ IEMOP_X4(iemOp_cmovc_Gv_Ev),
9574 /* 0x43 */ IEMOP_X4(iemOp_cmovnc_Gv_Ev),
9575 /* 0x44 */ IEMOP_X4(iemOp_cmove_Gv_Ev),
9576 /* 0x45 */ IEMOP_X4(iemOp_cmovne_Gv_Ev),
9577 /* 0x46 */ IEMOP_X4(iemOp_cmovbe_Gv_Ev),
9578 /* 0x47 */ IEMOP_X4(iemOp_cmovnbe_Gv_Ev),
9579 /* 0x48 */ IEMOP_X4(iemOp_cmovs_Gv_Ev),
9580 /* 0x49 */ IEMOP_X4(iemOp_cmovns_Gv_Ev),
9581 /* 0x4a */ IEMOP_X4(iemOp_cmovp_Gv_Ev),
9582 /* 0x4b */ IEMOP_X4(iemOp_cmovnp_Gv_Ev),
9583 /* 0x4c */ IEMOP_X4(iemOp_cmovl_Gv_Ev),
9584 /* 0x4d */ IEMOP_X4(iemOp_cmovnl_Gv_Ev),
9585 /* 0x4e */ IEMOP_X4(iemOp_cmovle_Gv_Ev),
9586 /* 0x4f */ IEMOP_X4(iemOp_cmovnle_Gv_Ev),
9587
9588 /* 0x50 */ iemOp_movmskps_Gy_Ups, iemOp_movmskpd_Gy_Upd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9589 /* 0x51 */ iemOp_sqrtps_Vps_Wps, iemOp_sqrtpd_Vpd_Wpd, iemOp_sqrtss_Vss_Wss, iemOp_sqrtsd_Vsd_Wsd,
9590 /* 0x52 */ iemOp_rsqrtps_Vps_Wps, iemOp_InvalidNeedRM, iemOp_rsqrtss_Vss_Wss, iemOp_InvalidNeedRM,
9591 /* 0x53 */ iemOp_rcpps_Vps_Wps, iemOp_InvalidNeedRM, iemOp_rcpss_Vss_Wss, iemOp_InvalidNeedRM,
9592 /* 0x54 */ iemOp_andps_Vps_Wps, iemOp_andpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9593 /* 0x55 */ iemOp_andnps_Vps_Wps, iemOp_andnpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9594 /* 0x56 */ iemOp_orps_Vps_Wps, iemOp_orpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9595 /* 0x57 */ iemOp_xorps_Vps_Wps, iemOp_xorpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9596 /* 0x58 */ iemOp_addps_Vps_Wps, iemOp_addpd_Vpd_Wpd, iemOp_addss_Vss_Wss, iemOp_addsd_Vsd_Wsd,
9597 /* 0x59 */ iemOp_mulps_Vps_Wps, iemOp_mulpd_Vpd_Wpd, iemOp_mulss_Vss_Wss, iemOp_mulsd_Vsd_Wsd,
9598 /* 0x5a */ iemOp_cvtps2pd_Vpd_Wps, iemOp_cvtpd2ps_Vps_Wpd, iemOp_cvtss2sd_Vsd_Wss, iemOp_cvtsd2ss_Vss_Wsd,
9599 /* 0x5b */ iemOp_cvtdq2ps_Vps_Wdq, iemOp_cvtps2dq_Vdq_Wps, iemOp_cvttps2dq_Vdq_Wps, iemOp_InvalidNeedRM,
9600 /* 0x5c */ iemOp_subps_Vps_Wps, iemOp_subpd_Vpd_Wpd, iemOp_subss_Vss_Wss, iemOp_subsd_Vsd_Wsd,
9601 /* 0x5d */ iemOp_minps_Vps_Wps, iemOp_minpd_Vpd_Wpd, iemOp_minss_Vss_Wss, iemOp_minsd_Vsd_Wsd,
9602 /* 0x5e */ iemOp_divps_Vps_Wps, iemOp_divpd_Vpd_Wpd, iemOp_divss_Vss_Wss, iemOp_divsd_Vsd_Wsd,
9603 /* 0x5f */ iemOp_maxps_Vps_Wps, iemOp_maxpd_Vpd_Wpd, iemOp_maxss_Vss_Wss, iemOp_maxsd_Vsd_Wsd,
9604
9605 /* 0x60 */ iemOp_punpcklbw_Pq_Qd, iemOp_punpcklbw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9606 /* 0x61 */ iemOp_punpcklwd_Pq_Qd, iemOp_punpcklwd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9607 /* 0x62 */ iemOp_punpckldq_Pq_Qd, iemOp_punpckldq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9608 /* 0x63 */ iemOp_packsswb_Pq_Qq, iemOp_packsswb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9609 /* 0x64 */ iemOp_pcmpgtb_Pq_Qq, iemOp_pcmpgtb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9610 /* 0x65 */ iemOp_pcmpgtw_Pq_Qq, iemOp_pcmpgtw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9611 /* 0x66 */ iemOp_pcmpgtd_Pq_Qq, iemOp_pcmpgtd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9612 /* 0x67 */ iemOp_packuswb_Pq_Qq, iemOp_packuswb_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9613 /* 0x68 */ iemOp_punpckhbw_Pq_Qd, iemOp_punpckhbw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9614 /* 0x69 */ iemOp_punpckhwd_Pq_Qd, iemOp_punpckhwd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9615 /* 0x6a */ iemOp_punpckhdq_Pq_Qd, iemOp_punpckhdq_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9616 /* 0x6b */ iemOp_packssdw_Pq_Qd, iemOp_packssdw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9617 /* 0x6c */ iemOp_InvalidNeedRM, iemOp_punpcklqdq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9618 /* 0x6d */ iemOp_InvalidNeedRM, iemOp_punpckhqdq_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9619 /* 0x6e */ iemOp_movd_q_Pd_Ey, iemOp_movd_q_Vy_Ey, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9620 /* 0x6f */ iemOp_movq_Pq_Qq, iemOp_movdqa_Vdq_Wdq, iemOp_movdqu_Vdq_Wdq, iemOp_InvalidNeedRM,
9621
9622 /* 0x70 */ iemOp_pshufw_Pq_Qq_Ib, iemOp_pshufd_Vx_Wx_Ib, iemOp_pshufhw_Vx_Wx_Ib, iemOp_pshuflw_Vx_Wx_Ib,
9623 /* 0x71 */ IEMOP_X4(iemOp_Grp12),
9624 /* 0x72 */ IEMOP_X4(iemOp_Grp13),
9625 /* 0x73 */ IEMOP_X4(iemOp_Grp14),
9626 /* 0x74 */ iemOp_pcmpeqb_Pq_Qq, iemOp_pcmpeqb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9627 /* 0x75 */ iemOp_pcmpeqw_Pq_Qq, iemOp_pcmpeqw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9628 /* 0x76 */ iemOp_pcmpeqd_Pq_Qq, iemOp_pcmpeqd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9629 /* 0x77 */ iemOp_emms, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9630
9631 /* 0x78 */ iemOp_vmread_Ey_Gy, iemOp_AmdGrp17, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9632 /* 0x79 */ iemOp_vmwrite_Gy_Ey, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9633 /* 0x7a */ iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9634 /* 0x7b */ iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9635 /* 0x7c */ iemOp_InvalidNeedRM, iemOp_haddpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_haddps_Vps_Wps,
9636 /* 0x7d */ iemOp_InvalidNeedRM, iemOp_hsubpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_hsubps_Vps_Wps,
9637 /* 0x7e */ iemOp_movd_q_Ey_Pd, iemOp_movd_q_Ey_Vy, iemOp_movq_Vq_Wq, iemOp_InvalidNeedRM,
9638 /* 0x7f */ iemOp_movq_Qq_Pq, iemOp_movdqa_Wx_Vx, iemOp_movdqu_Wx_Vx, iemOp_InvalidNeedRM,
9639
9640 /* 0x80 */ IEMOP_X4(iemOp_jo_Jv),
9641 /* 0x81 */ IEMOP_X4(iemOp_jno_Jv),
9642 /* 0x82 */ IEMOP_X4(iemOp_jc_Jv),
9643 /* 0x83 */ IEMOP_X4(iemOp_jnc_Jv),
9644 /* 0x84 */ IEMOP_X4(iemOp_je_Jv),
9645 /* 0x85 */ IEMOP_X4(iemOp_jne_Jv),
9646 /* 0x86 */ IEMOP_X4(iemOp_jbe_Jv),
9647 /* 0x87 */ IEMOP_X4(iemOp_jnbe_Jv),
9648 /* 0x88 */ IEMOP_X4(iemOp_js_Jv),
9649 /* 0x89 */ IEMOP_X4(iemOp_jns_Jv),
9650 /* 0x8a */ IEMOP_X4(iemOp_jp_Jv),
9651 /* 0x8b */ IEMOP_X4(iemOp_jnp_Jv),
9652 /* 0x8c */ IEMOP_X4(iemOp_jl_Jv),
9653 /* 0x8d */ IEMOP_X4(iemOp_jnl_Jv),
9654 /* 0x8e */ IEMOP_X4(iemOp_jle_Jv),
9655 /* 0x8f */ IEMOP_X4(iemOp_jnle_Jv),
9656
9657 /* 0x90 */ IEMOP_X4(iemOp_seto_Eb),
9658 /* 0x91 */ IEMOP_X4(iemOp_setno_Eb),
9659 /* 0x92 */ IEMOP_X4(iemOp_setc_Eb),
9660 /* 0x93 */ IEMOP_X4(iemOp_setnc_Eb),
9661 /* 0x94 */ IEMOP_X4(iemOp_sete_Eb),
9662 /* 0x95 */ IEMOP_X4(iemOp_setne_Eb),
9663 /* 0x96 */ IEMOP_X4(iemOp_setbe_Eb),
9664 /* 0x97 */ IEMOP_X4(iemOp_setnbe_Eb),
9665 /* 0x98 */ IEMOP_X4(iemOp_sets_Eb),
9666 /* 0x99 */ IEMOP_X4(iemOp_setns_Eb),
9667 /* 0x9a */ IEMOP_X4(iemOp_setp_Eb),
9668 /* 0x9b */ IEMOP_X4(iemOp_setnp_Eb),
9669 /* 0x9c */ IEMOP_X4(iemOp_setl_Eb),
9670 /* 0x9d */ IEMOP_X4(iemOp_setnl_Eb),
9671 /* 0x9e */ IEMOP_X4(iemOp_setle_Eb),
9672 /* 0x9f */ IEMOP_X4(iemOp_setnle_Eb),
9673
9674 /* 0xa0 */ IEMOP_X4(iemOp_push_fs),
9675 /* 0xa1 */ IEMOP_X4(iemOp_pop_fs),
9676 /* 0xa2 */ IEMOP_X4(iemOp_cpuid),
9677 /* 0xa3 */ IEMOP_X4(iemOp_bt_Ev_Gv),
9678 /* 0xa4 */ IEMOP_X4(iemOp_shld_Ev_Gv_Ib),
9679 /* 0xa5 */ IEMOP_X4(iemOp_shld_Ev_Gv_CL),
9680 /* 0xa6 */ IEMOP_X4(iemOp_InvalidNeedRM),
9681 /* 0xa7 */ IEMOP_X4(iemOp_InvalidNeedRM),
9682 /* 0xa8 */ IEMOP_X4(iemOp_push_gs),
9683 /* 0xa9 */ IEMOP_X4(iemOp_pop_gs),
9684 /* 0xaa */ IEMOP_X4(iemOp_rsm),
9685 /* 0xab */ IEMOP_X4(iemOp_bts_Ev_Gv),
9686 /* 0xac */ IEMOP_X4(iemOp_shrd_Ev_Gv_Ib),
9687 /* 0xad */ IEMOP_X4(iemOp_shrd_Ev_Gv_CL),
9688 /* 0xae */ IEMOP_X4(iemOp_Grp15),
9689 /* 0xaf */ IEMOP_X4(iemOp_imul_Gv_Ev),
9690
9691 /* 0xb0 */ IEMOP_X4(iemOp_cmpxchg_Eb_Gb),
9692 /* 0xb1 */ IEMOP_X4(iemOp_cmpxchg_Ev_Gv),
9693 /* 0xb2 */ IEMOP_X4(iemOp_lss_Gv_Mp),
9694 /* 0xb3 */ IEMOP_X4(iemOp_btr_Ev_Gv),
9695 /* 0xb4 */ IEMOP_X4(iemOp_lfs_Gv_Mp),
9696 /* 0xb5 */ IEMOP_X4(iemOp_lgs_Gv_Mp),
9697 /* 0xb6 */ IEMOP_X4(iemOp_movzx_Gv_Eb),
9698 /* 0xb7 */ IEMOP_X4(iemOp_movzx_Gv_Ew),
9699 /* 0xb8 */ iemOp_jmpe, iemOp_InvalidNeedRM, iemOp_popcnt_Gv_Ev, iemOp_InvalidNeedRM,
9700 /* 0xb9 */ IEMOP_X4(iemOp_Grp10),
9701 /* 0xba */ IEMOP_X4(iemOp_Grp8),
9702 /* 0xbb */ IEMOP_X4(iemOp_btc_Ev_Gv), // 0xf3?
9703 /* 0xbc */ iemOp_bsf_Gv_Ev, iemOp_bsf_Gv_Ev, iemOp_tzcnt_Gv_Ev, iemOp_bsf_Gv_Ev,
9704 /* 0xbd */ iemOp_bsr_Gv_Ev, iemOp_bsr_Gv_Ev, iemOp_lzcnt_Gv_Ev, iemOp_bsr_Gv_Ev,
9705 /* 0xbe */ IEMOP_X4(iemOp_movsx_Gv_Eb),
9706 /* 0xbf */ IEMOP_X4(iemOp_movsx_Gv_Ew),
9707
9708 /* 0xc0 */ IEMOP_X4(iemOp_xadd_Eb_Gb),
9709 /* 0xc1 */ IEMOP_X4(iemOp_xadd_Ev_Gv),
9710 /* 0xc2 */ iemOp_cmpps_Vps_Wps_Ib, iemOp_cmppd_Vpd_Wpd_Ib, iemOp_cmpss_Vss_Wss_Ib, iemOp_cmpsd_Vsd_Wsd_Ib,
9711 /* 0xc3 */ iemOp_movnti_My_Gy, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9712 /* 0xc4 */ iemOp_pinsrw_Pq_RyMw_Ib, iemOp_pinsrw_Vdq_RyMw_Ib, iemOp_InvalidNeedRMImm8, iemOp_InvalidNeedRMImm8,
9713 /* 0xc5 */ iemOp_pextrw_Gd_Nq_Ib, iemOp_pextrw_Gd_Udq_Ib, iemOp_InvalidNeedRMImm8, iemOp_InvalidNeedRMImm8,
9714 /* 0xc6 */ iemOp_shufps_Vps_Wps_Ib, iemOp_shufpd_Vpd_Wpd_Ib, iemOp_InvalidNeedRMImm8, iemOp_InvalidNeedRMImm8,
9715 /* 0xc7 */ IEMOP_X4(iemOp_Grp9),
9716 /* 0xc8 */ IEMOP_X4(iemOp_bswap_rAX_r8),
9717 /* 0xc9 */ IEMOP_X4(iemOp_bswap_rCX_r9),
9718 /* 0xca */ IEMOP_X4(iemOp_bswap_rDX_r10),
9719 /* 0xcb */ IEMOP_X4(iemOp_bswap_rBX_r11),
9720 /* 0xcc */ IEMOP_X4(iemOp_bswap_rSP_r12),
9721 /* 0xcd */ IEMOP_X4(iemOp_bswap_rBP_r13),
9722 /* 0xce */ IEMOP_X4(iemOp_bswap_rSI_r14),
9723 /* 0xcf */ IEMOP_X4(iemOp_bswap_rDI_r15),
9724
9725 /* 0xd0 */ iemOp_InvalidNeedRM, iemOp_addsubpd_Vpd_Wpd, iemOp_InvalidNeedRM, iemOp_addsubps_Vps_Wps,
9726 /* 0xd1 */ iemOp_psrlw_Pq_Qq, iemOp_psrlw_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9727 /* 0xd2 */ iemOp_psrld_Pq_Qq, iemOp_psrld_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9728 /* 0xd3 */ iemOp_psrlq_Pq_Qq, iemOp_psrlq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9729 /* 0xd4 */ iemOp_paddq_Pq_Qq, iemOp_paddq_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9730 /* 0xd5 */ iemOp_pmullw_Pq_Qq, iemOp_pmullw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9731 /* 0xd6 */ iemOp_InvalidNeedRM, iemOp_movq_Wq_Vq, iemOp_movq2dq_Vdq_Nq, iemOp_movdq2q_Pq_Uq,
9732 /* 0xd7 */ iemOp_pmovmskb_Gd_Nq, iemOp_pmovmskb_Gd_Ux, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9733 /* 0xd8 */ iemOp_psubusb_Pq_Qq, iemOp_psubusb_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9734 /* 0xd9 */ iemOp_psubusw_Pq_Qq, iemOp_psubusw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9735 /* 0xda */ iemOp_pminub_Pq_Qq, iemOp_pminub_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9736 /* 0xdb */ iemOp_pand_Pq_Qq, iemOp_pand_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9737 /* 0xdc */ iemOp_paddusb_Pq_Qq, iemOp_paddusb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9738 /* 0xdd */ iemOp_paddusw_Pq_Qq, iemOp_paddusw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9739 /* 0xde */ iemOp_pmaxub_Pq_Qq, iemOp_pmaxub_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9740 /* 0xdf */ iemOp_pandn_Pq_Qq, iemOp_pandn_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9741
9742 /* 0xe0 */ iemOp_pavgb_Pq_Qq, iemOp_pavgb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9743 /* 0xe1 */ iemOp_psraw_Pq_Qq, iemOp_psraw_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9744 /* 0xe2 */ iemOp_psrad_Pq_Qq, iemOp_psrad_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9745 /* 0xe3 */ iemOp_pavgw_Pq_Qq, iemOp_pavgw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9746 /* 0xe4 */ iemOp_pmulhuw_Pq_Qq, iemOp_pmulhuw_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9747 /* 0xe5 */ iemOp_pmulhw_Pq_Qq, iemOp_pmulhw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9748 /* 0xe6 */ iemOp_InvalidNeedRM, iemOp_cvttpd2dq_Vx_Wpd, iemOp_cvtdq2pd_Vx_Wpd, iemOp_cvtpd2dq_Vx_Wpd,
9749 /* 0xe7 */ iemOp_movntq_Mq_Pq, iemOp_movntdq_Mdq_Vdq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9750 /* 0xe8 */ iemOp_psubsb_Pq_Qq, iemOp_psubsb_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9751 /* 0xe9 */ iemOp_psubsw_Pq_Qq, iemOp_psubsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9752 /* 0xea */ iemOp_pminsw_Pq_Qq, iemOp_pminsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9753 /* 0xeb */ iemOp_por_Pq_Qq, iemOp_por_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9754 /* 0xec */ iemOp_paddsb_Pq_Qq, iemOp_paddsb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9755 /* 0xed */ iemOp_paddsw_Pq_Qq, iemOp_paddsw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9756 /* 0xee */ iemOp_pmaxsw_Pq_Qq, iemOp_pmaxsw_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9757 /* 0xef */ iemOp_pxor_Pq_Qq, iemOp_pxor_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9758
9759 /* 0xf0 */ iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM, iemOp_lddqu_Vx_Mx,
9760 /* 0xf1 */ iemOp_psllw_Pq_Qq, iemOp_psllw_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9761 /* 0xf2 */ iemOp_pslld_Pq_Qq, iemOp_pslld_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9762 /* 0xf3 */ iemOp_psllq_Pq_Qq, iemOp_psllq_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9763 /* 0xf4 */ iemOp_pmuludq_Pq_Qq, iemOp_pmuludq_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9764 /* 0xf5 */ iemOp_pmaddwd_Pq_Qq, iemOp_pmaddwd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9765 /* 0xf6 */ iemOp_psadbw_Pq_Qq, iemOp_psadbw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9766 /* 0xf7 */ iemOp_maskmovq_Pq_Nq, iemOp_maskmovdqu_Vdq_Udq, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9767 /* 0xf8 */ iemOp_psubb_Pq_Qq, iemOp_psubb_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9768 /* 0xf9 */ iemOp_psubw_Pq_Qq, iemOp_psubw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9769 /* 0xfa */ iemOp_psubd_Pq_Qq, iemOp_psubd_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9770 /* 0xfb */ iemOp_psubq_Pq_Qq, iemOp_psubq_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9771 /* 0xfc */ iemOp_paddb_Pq_Qq, iemOp_paddb_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9772 /* 0xfd */ iemOp_paddw_Pq_Qq, iemOp_paddw_Vx_Wx, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9773 /* 0xfe */ iemOp_paddd_Pq_Qq, iemOp_paddd_Vx_W, iemOp_InvalidNeedRM, iemOp_InvalidNeedRM,
9774 /* 0xff */ IEMOP_X4(iemOp_ud0),
9775};
9776AssertCompile(RT_ELEMENTS(g_apfnTwoByteMap) == 1024);
9777
9778/** @} */
9779
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