mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-23 06:25:12 +00:00
target-i386: Fix SMSW and LMSW from/to register
SMSW and LMSW accept register operands, but commit 1906b2a ("target-i386: Rearrange processing of 0F 01", 2016-02-13) did not account for that. Backports commit 880f8486503b32a29b653a3c0b3cfc5432012f38 from qemu
This commit is contained in:
parent
bdf1189046
commit
a233d7b13e
|
@ -55,11 +55,17 @@
|
|||
#endif
|
||||
|
||||
/* For a switch indexed by MODRM, match all memory operands for a given OP. */
|
||||
#define CASE_MEM_OP(OP) \
|
||||
#define CASE_MODRM_MEM_OP(OP) \
|
||||
case (0 << 6) | (OP << 3) | 0 ... (0 << 6) | (OP << 3) | 7: \
|
||||
case (1 << 6) | (OP << 3) | 0 ... (1 << 6) | (OP << 3) | 7: \
|
||||
case (2 << 6) | (OP << 3) | 0 ... (2 << 6) | (OP << 3) | 7
|
||||
|
||||
#define CASE_MODRM_OP(OP) \
|
||||
case (0 << 6) | (OP << 3) | 0 ... (0 << 6) | (OP << 3) | 7: \
|
||||
case (1 << 6) | (OP << 3) | 0 ... (1 << 6) | (OP << 3) | 7: \
|
||||
case (2 << 6) | (OP << 3) | 0 ... (2 << 6) | (OP << 3) | 7: \
|
||||
case (3 << 6) | (OP << 3) | 0 ... (3 << 6) | (OP << 3) | 7
|
||||
|
||||
#include "exec/gen-icount.h"
|
||||
|
||||
typedef struct DisasContext {
|
||||
|
@ -7710,7 +7716,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
|
|||
case 0x101:
|
||||
modrm = cpu_ldub_code(env, s->pc++);
|
||||
switch (modrm) {
|
||||
CASE_MEM_OP(0): /* sgdt */
|
||||
CASE_MODRM_MEM_OP(0): /* sgdt */
|
||||
gen_svm_check_intercept(s, pc_start, SVM_EXIT_GDTR_READ);
|
||||
gen_lea_modrm(env, s, modrm);
|
||||
tcg_gen_ld32u_tl(tcg_ctx, cpu_T0,
|
||||
|
@ -7767,7 +7773,7 @@ case 0x101:
|
|||
gen_eob(s);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(1): /* sidt */
|
||||
CASE_MODRM_MEM_OP(1): /* sidt */
|
||||
gen_svm_check_intercept(s, pc_start, SVM_EXIT_IDTR_READ);
|
||||
gen_lea_modrm(env, s, modrm);
|
||||
tcg_gen_ld32u_tl(tcg_ctx, cpu_T0, cpu_env, offsetof(CPUX86State, idt.limit));
|
||||
|
@ -7917,7 +7923,7 @@ case 0x101:
|
|||
tcg_const_i32(tcg_ctx, s->aflag - 1));
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(2): /* lgdt */
|
||||
CASE_MODRM_MEM_OP(2): /* lgdt */
|
||||
if (s->cpl != 0) {
|
||||
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
|
||||
break;
|
||||
|
@ -7934,7 +7940,7 @@ case 0x101:
|
|||
tcg_gen_st32_tl(tcg_ctx, cpu_T1, cpu_env, offsetof(CPUX86State, gdt.limit));
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(3): /* lidt */
|
||||
CASE_MODRM_MEM_OP(3): /* lidt */
|
||||
if (s->cpl != 0) {
|
||||
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
|
||||
break;
|
||||
|
@ -7951,7 +7957,7 @@ case 0x101:
|
|||
tcg_gen_st32_tl(tcg_ctx, cpu_T1, cpu_env, offsetof(CPUX86State, idt.limit));
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(4): /* smsw */
|
||||
CASE_MODRM_OP(4): /* smsw */
|
||||
gen_svm_check_intercept(s, pc_start, SVM_EXIT_READ_CR0);
|
||||
#if defined TARGET_X86_64 && defined HOST_WORDS_BIGENDIAN
|
||||
tcg_gen_ld32u_tl(tcg_ctx, cpu_T0, cpu_env, offsetof(CPUX86State, cr[0]) + 4);
|
||||
|
@ -7961,7 +7967,7 @@ case 0x101:
|
|||
gen_ldst_modrm(env, s, modrm, MO_16, OR_TMP0, 1);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(6): /* lmsw */
|
||||
CASE_MODRM_OP(6): /* lmsw */
|
||||
if (s->cpl != 0) {
|
||||
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
|
||||
break;
|
||||
|
@ -7973,7 +7979,7 @@ case 0x101:
|
|||
gen_eob(s);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(7): /* invlpg */
|
||||
CASE_MODRM_MEM_OP(7): /* invlpg */
|
||||
if (s->cpl != 0) {
|
||||
gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
|
||||
break;
|
||||
|
@ -8457,7 +8463,7 @@ case 0x101:
|
|||
case 0x1ae:
|
||||
modrm = cpu_ldub_code(env, s->pc++);
|
||||
switch (modrm) {
|
||||
CASE_MEM_OP(0): /* fxsave */
|
||||
CASE_MODRM_MEM_OP(0): /* fxsave */
|
||||
if (!(s->cpuid_features & CPUID_FXSR)
|
||||
|| (prefixes & PREFIX_LOCK)) {
|
||||
goto illegal_op;
|
||||
|
@ -8470,7 +8476,7 @@ case 0x101:
|
|||
gen_helper_fxsave(tcg_ctx, cpu_env, cpu_A0);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(1): /* fxrstor */
|
||||
CASE_MODRM_MEM_OP(1): /* fxrstor */
|
||||
if (!(s->cpuid_features & CPUID_FXSR)
|
||||
|| (prefixes & PREFIX_LOCK)) {
|
||||
goto illegal_op;
|
||||
|
@ -8483,7 +8489,7 @@ case 0x101:
|
|||
gen_helper_fxrstor(tcg_ctx, cpu_env, cpu_A0);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(2): /* ldmxcsr */
|
||||
CASE_MODRM_MEM_OP(2): /* ldmxcsr */
|
||||
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK)) {
|
||||
goto illegal_op;
|
||||
}
|
||||
|
@ -8496,7 +8502,7 @@ case 0x101:
|
|||
gen_helper_ldmxcsr(tcg_ctx, cpu_env, cpu_tmp2_i32);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(3): /* stmxcsr */
|
||||
CASE_MODRM_MEM_OP(3): /* stmxcsr */
|
||||
if ((s->flags & HF_EM_MASK) || !(s->flags & HF_OSFXSR_MASK)) {
|
||||
goto illegal_op;
|
||||
}
|
||||
|
@ -8509,7 +8515,7 @@ case 0x101:
|
|||
gen_op_st_v(s, MO_32, cpu_T0, cpu_A0);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(4): /* xsave */
|
||||
CASE_MODRM_MEM_OP(4): /* xsave */
|
||||
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|
||||
|| (prefixes & (PREFIX_LOCK | PREFIX_DATA
|
||||
| PREFIX_REPZ | PREFIX_REPNZ))) {
|
||||
|
@ -8521,7 +8527,7 @@ case 0x101:
|
|||
gen_helper_xsave(tcg_ctx, cpu_env, cpu_A0, cpu_tmp1_i64);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(5): /* xrstor */
|
||||
CASE_MODRM_MEM_OP(5): /* xrstor */
|
||||
if ((s->cpuid_ext_features & CPUID_EXT_XSAVE) == 0
|
||||
|| (prefixes & (PREFIX_LOCK | PREFIX_DATA
|
||||
| PREFIX_REPZ | PREFIX_REPNZ))) {
|
||||
|
@ -8538,7 +8544,7 @@ case 0x101:
|
|||
gen_eob(s);
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(6): /* xsaveopt / clwb */
|
||||
CASE_MODRM_MEM_OP(6): /* xsaveopt / clwb */
|
||||
if (prefixes & PREFIX_LOCK) {
|
||||
goto illegal_op;
|
||||
}
|
||||
|
@ -8562,7 +8568,7 @@ case 0x101:
|
|||
}
|
||||
break;
|
||||
|
||||
CASE_MEM_OP(7): /* clflush / clflushopt */
|
||||
CASE_MODRM_MEM_OP(7): /* clflush / clflushopt */
|
||||
if (prefixes & PREFIX_LOCK) {
|
||||
goto illegal_op;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue