Lines Matching refs:ctxt
859 x86_emul_hw_exception(e, mkec(e, ##ec, 0), ctxt); \
914 ctxt->regs->r(ip)) > MAX_INST_LEN, \
916 rc = ops->insn_fetch(x86_seg_cs, _ip, &_x, (_size), ctxt); \
931 # define mode_64bit() (ctxt->addr_size == 64)
968 _register_address_increment(_regs.r(sp), -(dec), ctxt->sp_size/8); \
969 truncate_word(_regs.r(sp), ctxt->sp_size/8); \
972 unsigned long sp = truncate_word(_regs.r(sp), ctxt->sp_size/8); \
973 _register_address_increment(_regs.r(sp), (inc), ctxt->sp_size/8); \
984 rc = ops->insn_fetch(x86_seg_cs, ip, NULL, 0, ctxt); \
992 ASSERT(!ctxt->lma); \
995 generate_exception_if(ctxt->lma && (cs)->l \
1004 ops->write_segment(x86_seg_cs, cs, ctxt); \
1024 struct x86_emulate_ctxt *ctxt, in _get_fpu() argument
1031 rc = ops->get_fpu(fpu_handle_exception, fic, type, ctxt); in _get_fpu()
1045 rc = ops->read_cr(4, &cr4, ctxt); in _get_fpu()
1053 rc = ops->read_cr(0, &cr0, ctxt); in _get_fpu()
1059 ASSERT((cr0 & X86_CR0_PE) && !(ctxt->regs->eflags & X86_EFLAGS_VM)); in _get_fpu()
1078 rc = _get_fpu(_type, _fic, ctxt, ops); \
1091 ops->read_cr(4, &cr4, ctxt) == X86EMUL_OKAY && \
1101 struct x86_emulate_ctxt *ctxt, in put_fpu() argument
1105 ops->put_fpu(ctxt, X86EMUL_FPU_fpu, NULL); in put_fpu()
1109 .ip = ctxt->regs->r(ip), in put_fpu()
1110 .cs = ctxt->regs->cs, in put_fpu()
1111 .op = ((ctxt->opcode & 7) << 8) | state->modrm, in put_fpu()
1116 ops->read_segment(x86_seg_cs, &sreg, ctxt) == X86EMUL_OKAY ) in put_fpu()
1123 ctxt) == X86EMUL_OKAY ) in put_fpu()
1128 case x86_seg_cs: aux.ds = ctxt->regs->cs; break; in put_fpu()
1129 case x86_seg_ds: aux.ds = ctxt->regs->ds; break; in put_fpu()
1130 case x86_seg_es: aux.ds = ctxt->regs->es; break; in put_fpu()
1131 case x86_seg_fs: aux.ds = ctxt->regs->fs; break; in put_fpu()
1132 case x86_seg_gs: aux.ds = ctxt->regs->gs; break; in put_fpu()
1133 case x86_seg_ss: aux.ds = ctxt->regs->ss; break; in put_fpu()
1138 ops->put_fpu(ctxt, X86EMUL_FPU_none, &aux); in put_fpu()
1141 ops->put_fpu(ctxt, X86EMUL_FPU_none, NULL); in put_fpu()
1239 !is_branch_step(ctxt, ops) ) \
1263 __put_rep_prefix(&_regs, ctxt->regs, ad_bytes, reps_completed); \
1291 struct x86_emulate_ctxt *ctxt, in read_ulong() argument
1295 return ops->read(seg, offset, val, bytes, ctxt); in read_ulong()
1424 struct x86_emulate_ctxt *ctxt, in get_cpl() argument
1429 if ( ctxt->regs->eflags & X86_EFLAGS_VM ) in get_cpl()
1433 ops->read_segment(x86_seg_ss, ®, ctxt) ) in get_cpl()
1441 struct x86_emulate_ctxt *ctxt, in _mode_iopl() argument
1444 int cpl = get_cpl(ctxt, ops); in _mode_iopl()
1447 return cpl <= MASK_EXTR(ctxt->regs->eflags, X86_EFLAGS_IOPL); in _mode_iopl()
1451 int _cpl = get_cpl(ctxt, ops); \
1456 int _iopl = _mode_iopl(ctxt, ops); \
1462 if ( ops->read_cr && get_cpl(ctxt, ops) == 3 ) \
1464 rc = ops->read_cr(4, &cr4, ctxt); \
1473 struct x86_emulate_ctxt *ctxt, in ioport_access_check() argument
1480 if ( !(ctxt->regs->eflags & X86_EFLAGS_VM) && mode_iopl() ) in ioport_access_check()
1488 if ( (rc = ops->read_segment(x86_seg_tr, &tr, ctxt)) != 0 ) in ioport_access_check()
1494 switch ( rc = read_ulong(x86_seg_tr, 0x66, &iobmp, 2, ctxt, ops) ) in ioport_access_check()
1500 generate_exception_if(!ctxt->event_pending, EXC_GP, 0); in ioport_access_check()
1509 &iobmp, 2, ctxt, ops) ) in ioport_access_check()
1515 generate_exception_if(!ctxt->event_pending, EXC_GP, 0); in ioport_access_check()
1531 struct x86_emulate_ctxt *ctxt, in in_realmode() argument
1540 rc = ops->read_cr(0, &cr0, ctxt); in in_realmode()
1546 struct x86_emulate_ctxt *ctxt, in in_protmode() argument
1549 return !(in_realmode(ctxt, ops) || (ctxt->regs->eflags & X86_EFLAGS_VM)); in in_protmode()
1561 struct x86_emulate_ctxt *ctxt, in vcpu_has() argument
1568 rc = ops->cpuid(eax, 0, &res, ctxt); in vcpu_has()
1587 #define vcpu_has_fpu() vcpu_has( 1, EDX, 0, ctxt, ops)
1588 #define vcpu_has_sep() vcpu_has( 1, EDX, 11, ctxt, ops)
1589 #define vcpu_has_cx8() vcpu_has( 1, EDX, 8, ctxt, ops)
1590 #define vcpu_has_cmov() vcpu_has( 1, EDX, 15, ctxt, ops)
1591 #define vcpu_has_clflush() vcpu_has( 1, EDX, 19, ctxt, ops)
1592 #define vcpu_has_mmx() vcpu_has( 1, EDX, 23, ctxt, ops)
1593 #define vcpu_has_sse() vcpu_has( 1, EDX, 25, ctxt, ops)
1594 #define vcpu_has_sse2() vcpu_has( 1, EDX, 26, ctxt, ops)
1595 #define vcpu_has_sse3() vcpu_has( 1, ECX, 0, ctxt, ops)
1596 #define vcpu_has_pclmulqdq() vcpu_has( 1, ECX, 1, ctxt, ops)
1597 #define vcpu_has_ssse3() vcpu_has( 1, ECX, 9, ctxt, ops)
1598 #define vcpu_has_cx16() vcpu_has( 1, ECX, 13, ctxt, ops)
1599 #define vcpu_has_sse4_1() vcpu_has( 1, ECX, 19, ctxt, ops)
1600 #define vcpu_has_sse4_2() vcpu_has( 1, ECX, 20, ctxt, ops)
1601 #define vcpu_has_movbe() vcpu_has( 1, ECX, 22, ctxt, ops)
1602 #define vcpu_has_popcnt() vcpu_has( 1, ECX, 23, ctxt, ops)
1603 #define vcpu_has_aesni() vcpu_has( 1, ECX, 25, ctxt, ops)
1604 #define vcpu_has_avx() vcpu_has( 1, ECX, 28, ctxt, ops)
1605 #define vcpu_has_rdrand() vcpu_has( 1, ECX, 30, ctxt, ops)
1606 #define vcpu_has_mmxext() (vcpu_has(0x80000001, EDX, 22, ctxt, ops) || \
1608 #define vcpu_has_lahf_lm() vcpu_has(0x80000001, ECX, 0, ctxt, ops)
1609 #define vcpu_has_cr8_legacy() vcpu_has(0x80000001, ECX, 4, ctxt, ops)
1610 #define vcpu_has_lzcnt() vcpu_has(0x80000001, ECX, 5, ctxt, ops)
1611 #define vcpu_has_sse4a() vcpu_has(0x80000001, ECX, 6, ctxt, ops)
1612 #define vcpu_has_misalignsse() vcpu_has(0x80000001, ECX, 7, ctxt, ops)
1613 #define vcpu_has_tbm() vcpu_has(0x80000001, ECX, 21, ctxt, ops)
1614 #define vcpu_has_bmi1() vcpu_has( 7, EBX, 3, ctxt, ops)
1615 #define vcpu_has_hle() vcpu_has( 7, EBX, 4, ctxt, ops)
1616 #define vcpu_has_avx2() vcpu_has( 7, EBX, 5, ctxt, ops)
1617 #define vcpu_has_bmi2() vcpu_has( 7, EBX, 8, ctxt, ops)
1618 #define vcpu_has_rtm() vcpu_has( 7, EBX, 11, ctxt, ops)
1619 #define vcpu_has_mpx() vcpu_has( 7, EBX, 14, ctxt, ops)
1620 #define vcpu_has_rdseed() vcpu_has( 7, EBX, 18, ctxt, ops)
1621 #define vcpu_has_adx() vcpu_has( 7, EBX, 19, ctxt, ops)
1622 #define vcpu_has_smap() vcpu_has( 7, EBX, 20, ctxt, ops)
1623 #define vcpu_has_clflushopt() vcpu_has( 7, EBX, 23, ctxt, ops)
1624 #define vcpu_has_clwb() vcpu_has( 7, EBX, 24, ctxt, ops)
1625 #define vcpu_has_sha() vcpu_has( 7, EBX, 29, ctxt, ops)
1626 #define vcpu_has_rdpid() vcpu_has( 7, ECX, 22, ctxt, ops)
1627 #define vcpu_has_clzero() vcpu_has(0x80000008, EBX, 0, ctxt, ops)
1657 struct x86_emulate_ctxt *ctxt, in realmode_load_seg() argument
1665 if ( (rc = ops->read_segment(seg, sreg, ctxt)) == X86EMUL_OKAY ) in realmode_load_seg()
1684 struct x86_emulate_ctxt *ctxt, in protmode_load_seg() argument
1690 int cpl = get_cpl(ctxt, ops); in protmode_load_seg()
1711 if ( ctxt->vendor != X86_VENDOR_AMD || !ops->read_segment || in protmode_load_seg()
1712 ops->read_segment(seg, sreg, ctxt) != X86EMUL_OKAY ) in protmode_load_seg()
1729 switch ( rc = ops->read(sel_seg, sel & 0xfff8, &desc, sizeof(desc), ctxt) ) in protmode_load_seg()
1735 if ( !ctxt->event_pending ) in protmode_load_seg()
1776 if ( ctxt->lma && (desc.b & (1 << 21)) && (desc.b & (1 << 22)) ) in protmode_load_seg()
1838 ctxt->vendor != X86_VENDOR_AMD in protmode_load_seg()
1839 ? mode_64bit() : ctxt->lma; in protmode_load_seg()
1844 &desc_hi, sizeof(desc_hi), ctxt) ) in protmode_load_seg()
1850 if ( !ctxt->event_pending ) in protmode_load_seg()
1856 if ( !mode_64bit() && ctxt->vendor == X86_VENDOR_AMD && in protmode_load_seg()
1873 &new_desc_b, sizeof(desc.b), ctxt)) ) in protmode_load_seg()
1879 if ( !ctxt->event_pending ) in protmode_load_seg()
1915 struct x86_emulate_ctxt *ctxt, in load_seg() argument
1927 if ( in_protmode(ctxt, ops) ) in load_seg()
1928 rc = protmode_load_seg(seg, sel, is_ret, sreg, ctxt, ops); in load_seg()
1930 rc = realmode_load_seg(seg, sel, sreg, ctxt, ops); in load_seg()
1933 rc = ops->write_segment(seg, sreg, ctxt); in load_seg()
1971 const struct x86_emulate_ctxt *ctxt) in decode_vex_gpr() argument
1977 unsigned int size, struct x86_emulate_ctxt *ctxt, in is_aligned() argument
1993 if ( ops->read_segment(seg, ®, ctxt) != X86EMUL_OKAY ) in is_aligned()
2000 static bool is_branch_step(struct x86_emulate_ctxt *ctxt, in is_branch_step() argument
2006 ops->read_msr(MSR_IA32_DEBUGCTLMSR, &debugctl, ctxt) == X86EMUL_OKAY && in is_branch_step()
2010 static bool umip_active(struct x86_emulate_ctxt *ctxt, in umip_active() argument
2016 return get_cpl(ctxt, ops) > 0 && in umip_active()
2017 ops->read_cr && ops->read_cr(4, &cr4, ctxt) == X86EMUL_OKAY && in umip_active()
2021 static void adjust_bnd(struct x86_emulate_ctxt *ctxt, in adjust_bnd() argument
2033 ops->read_msr(MSR_IA32_BNDCFGS, &bndcfg, ctxt) != X86EMUL_OKAY ) in adjust_bnd()
2054 struct x86_emulate_ctxt *ctxt) in x86emul_unhandleable_rw() argument
2076 struct x86_emulate_ctxt *ctxt, in x86_decode_onebyte() argument
2081 switch ( ctxt->opcode ) in x86_decode_onebyte()
2109 ctxt->opcode |= X86EMUL_OPC_F3(0, 0); in x86_decode_onebyte()
2161 struct x86_emulate_ctxt *ctxt, in x86_decode_twobyte() argument
2166 switch ( ctxt->opcode & X86EMUL_OPC_MASK ) in x86_decode_twobyte()
2199 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_twobyte()
2216 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_twobyte()
2228 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_twobyte()
2247 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_twobyte()
2257 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_twobyte()
2264 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_twobyte()
2293 struct x86_emulate_ctxt *ctxt, in x86_decode_0f38() argument
2296 switch ( ctxt->opcode & X86EMUL_OPC_MASK ) in x86_decode_0f38()
2304 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_0f38()
2310 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_0f38()
2317 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_0f38()
2343 struct x86_emulate_ctxt *ctxt, in x86_decode_0f3a() argument
2347 ctxt->opcode |= MASK_INSR(vex.pfx, X86EMUL_OPC_PFX_MASK); in x86_decode_0f3a()
2349 switch ( ctxt->opcode & X86EMUL_OPC_MASK ) in x86_decode_0f3a()
2381 struct x86_emulate_ctxt *ctxt, in x86_decode() argument
2396 state->regs = ctxt->regs; in x86_decode()
2397 state->ip = ctxt->regs->r(ip); in x86_decode()
2400 ctxt->retire.raw = 0; in x86_decode()
2401 x86_emul_reset_event(ctxt); in x86_decode()
2403 op_bytes = def_op_bytes = ad_bytes = def_ad_bytes = ctxt->addr_size/8; in x86_decode()
2515 if ( modrm_mod != 3 || in_realmode(ctxt, ops) ) in x86_decode()
2866 ctxt->opcode = opcode; in x86_decode()
2872 rc = x86_decode_onebyte(state, ctxt, ops); in x86_decode()
2876 rc = x86_decode_twobyte(state, ctxt, ops); in x86_decode()
2880 rc = x86_decode_0f38(state, ctxt, ops); in x86_decode()
2891 rc = x86_decode_0f3a(state, ctxt, ops); in x86_decode()
2924 (ctxt->opcode & X86EMUL_OPC_PFX_MASK) == X86EMUL_OPC_66(0, 0) ) in x86_decode()
2960 op_bytes = 4 << (ctxt->opcode & 1); in x86_decode()
2985 struct x86_emulate_ctxt *ctxt, in x86_emulate() argument
2989 struct cpu_user_regs _regs = *ctxt->regs; in x86_emulate()
2995 !is_branch_step(ctxt, ops); in x86_emulate()
3006 rc = x86_decode(&state, ctxt, ops); in x86_emulate()
3018 rc = ops->validate(&state, ctxt); in x86_emulate()
3028 b = ctxt->opcode; in x86_emulate()
3085 &src.val, src.bytes, ctxt, ops)) ) in x86_emulate()
3196 &dst.val, dst.bytes, ctxt, ops)) ) in x86_emulate()
3209 switch ( ctxt->opcode ) in x86_emulate()
3260 ctxt)) != X86EMUL_OKAY ) in x86_emulate()
3276 op_bytes, ctxt, ops)) != X86EMUL_OKAY || in x86_emulate()
3277 (rc = load_seg(seg, dst.val, 0, NULL, ctxt, ops)) != X86EMUL_OKAY ) in x86_emulate()
3280 ctxt->retire.mov_ss = true; in x86_emulate()
3344 &dst.val, dst.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3357 op_bytes, ctxt)) != 0 ) in x86_emulate()
3368 &dst.val, op_bytes, ctxt, ops)) != 0 ) in x86_emulate()
3384 &ea.val, op_bytes, ctxt, ops)) ) in x86_emulate()
3401 &src.val, 4, ctxt, ops)) ) in x86_emulate()
3415 &dst.val, 2, ctxt, ops)) ) in x86_emulate()
3427 generate_exception_if(!in_protmode(ctxt, ops), EXC_UD); in x86_emulate()
3447 &dst.val, op_bytes, ctxt, ops)) ) in x86_emulate()
3458 if ( (rc = ioport_access_check(port, dst.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3466 rc = ops->read_io(port, dst.bytes, &dst.val, ctxt); in x86_emulate()
3472 &nr_reps, ctxt); in x86_emulate()
3476 if ( (rc = ops->read_io(port, dst.bytes, &dst.val, ctxt)) != 0 ) in x86_emulate()
3498 if ( (rc = ioport_access_check(port, dst.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3507 ctxt, ops); in x86_emulate()
3513 &nr_reps, ctxt); in x86_emulate()
3517 dst.bytes, ctxt, ops)) != X86EMUL_OKAY ) in x86_emulate()
3524 if ( (rc = ops->write_io(port, dst.bytes, dst.val, ctxt)) != 0 ) in x86_emulate()
3538 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
3603 if ( (rc = ops->read_segment(seg, &sreg, ctxt)) != 0 ) in x86_emulate()
3619 if ( (rc = load_seg(seg, src.val, 0, NULL, ctxt, ops)) != 0 ) in x86_emulate()
3622 ctxt->retire.mov_ss = true; in x86_emulate()
3632 &dst.val, dst.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3675 if ( (rc = ops->read_segment(x86_seg_cs, &sreg, ctxt)) || in x86_emulate()
3676 (rc = load_seg(x86_seg_cs, imm2, 0, &cs, ctxt, ops)) || in x86_emulate()
3680 &src.val, op_bytes, ctxt)) || in x86_emulate()
3682 &_regs.r(ip), op_bytes, ctxt)) || in x86_emulate()
3683 (rc = ops->write_segment(x86_seg_cs, &cs, ctxt)) ) in x86_emulate()
3705 rc = ops->read_cr(4, &cr4, ctxt); in x86_emulate()
3728 rc = ops->read_cr(4, &cr4, ctxt); in x86_emulate()
3744 &dst.val, op_bytes, ctxt, ops)) != 0 ) in x86_emulate()
3790 &nr_reps, ctxt)) == X86EMUL_UNHANDLEABLE) ) in x86_emulate()
3793 &dst.val, dst.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3812 &dst.val, dst.bytes, ctxt, ops)) || in x86_emulate()
3814 &src.val, src.bytes, ctxt, ops)) ) in x86_emulate()
3836 &nr_reps, ctxt)) == X86EMUL_UNHANDLEABLE) ) in x86_emulate()
3853 &dst.val, dst.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3864 &dst.val, src.bytes, ctxt, ops)) != 0 ) in x86_emulate()
3922 &dst.val, op_bytes, ctxt, ops)) != 0 || in x86_emulate()
3923 (rc = ops->insn_fetch(x86_seg_cs, dst.val, NULL, 0, ctxt)) ) in x86_emulate()
3926 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
3935 &dst.val, 2, ctxt, ops)) != X86EMUL_OKAY ) in x86_emulate()
3938 if ( (rc = load_seg(seg, dst.val, 0, NULL, ctxt, ops)) != X86EMUL_OKAY ) in x86_emulate()
3949 &_regs.r(bp), dst.bytes, ctxt)) ) in x86_emulate()
3959 ebp = truncate_word(_regs.r(bp) - i*dst.bytes, ctxt->sp_size/8); in x86_emulate()
3961 &temp_data, dst.bytes, ctxt, ops)) || in x86_emulate()
3963 &temp_data, dst.bytes, ctxt)) ) in x86_emulate()
3967 &dst.val, dst.bytes, ctxt)) ) in x86_emulate()
3986 &dst.val, dst.bytes, ctxt, ops)) ) in x86_emulate()
3993 &dst.val, op_bytes, ctxt, ops)) || in x86_emulate()
3995 &src.val, op_bytes, ctxt, ops)) || in x86_emulate()
3996 (rc = load_seg(x86_seg_cs, src.val, 1, &cs, ctxt, ops)) || in x86_emulate()
4008 ASSERT(!ctxt->event_pending); in x86_emulate()
4009 switch ( ctxt->opcode ) in x86_emulate()
4012 ctxt->event.vector = EXC_BP; in x86_emulate()
4013 ctxt->event.type = X86_EVENTTYPE_SW_EXCEPTION; in x86_emulate()
4016 ctxt->event.vector = imm1; in x86_emulate()
4017 ctxt->event.type = X86_EVENTTYPE_SW_INTERRUPT; in x86_emulate()
4020 ctxt->event.vector = EXC_OF; in x86_emulate()
4021 ctxt->event.type = X86_EVENTTYPE_SW_EXCEPTION; in x86_emulate()
4024 ctxt->event.vector = EXC_DB; in x86_emulate()
4025 ctxt->event.type = X86_EVENTTYPE_PRI_SW_EXCEPTION; in x86_emulate()
4028 ctxt->event.error_code = X86_EVENT_NO_EC; in x86_emulate()
4029 ctxt->event.insn_len = _regs.r(ip) - ctxt->regs->r(ip); in x86_emulate()
4030 ctxt->event_pending = true; in x86_emulate()
4038 fail_if(!in_realmode(ctxt, ops)); in x86_emulate()
4039 ctxt->retire.unblock_nmi = true; in x86_emulate()
4041 &eip, op_bytes, ctxt, ops)) || in x86_emulate()
4043 &sel, op_bytes, ctxt, ops)) || in x86_emulate()
4045 &eflags, op_bytes, ctxt, ops)) ) in x86_emulate()
4052 if ( (rc = load_seg(x86_seg_cs, sel, 1, &cs, ctxt, ops)) || in x86_emulate()
4091 &al, 1, ctxt, ops)) != 0 ) in x86_emulate()
4115 4, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4195 4, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4214 2, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4259 4, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4322 4, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4342 10, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4352 10, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4383 8, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4436 8, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4556 2, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4576 10, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4583 8, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4593 10, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
4638 if ( (rc = ioport_access_check(port, op_bytes, ctxt, ops)) != 0 ) in x86_emulate()
4644 rc = ops->write_io(port, op_bytes, _regs.eax, ctxt); in x86_emulate()
4651 rc = ops->read_io(port, dst.bytes, &dst.val, ctxt); in x86_emulate()
4668 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
4676 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
4682 if ( (rc = load_seg(x86_seg_cs, imm2, 0, &cs, ctxt, ops)) || in x86_emulate()
4689 ctxt->retire.hlt = true; in x86_emulate()
4905 ctxt->retire.sti = true; in x86_emulate()
4914 ctxt->retire.sti = true; in x86_emulate()
4941 if ( (rc = ops->insn_fetch(x86_seg_cs, src.val, NULL, 0, ctxt)) ) in x86_emulate()
4945 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
4948 if ( (rc = ops->insn_fetch(x86_seg_cs, src.val, NULL, 0, ctxt)) ) in x86_emulate()
4952 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
4960 &imm2, 2, ctxt, ops)) ) in x86_emulate()
4975 generate_exception_if(!in_protmode(ctxt, ops), EXC_UD); in x86_emulate()
4979 generate_exception_if(umip_active(ctxt, ops), EXC_GP, 0); in x86_emulate()
4983 if ( (rc = load_seg(seg, src.val, 0, NULL, ctxt, ops)) != 0 ) in x86_emulate()
4989 &sreg, ctxt, ops) ) in x86_emulate()
4998 if ( ctxt->event_pending ) in x86_emulate()
5000 ASSERT(ctxt->event.vector == EXC_PF); in x86_emulate()
5036 if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) != X86EMUL_OKAY ) in x86_emulate()
5049 if ( (rc = ops->vmfunc(ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5068 generate_exception_if(!in_protmode(ctxt, ops), EXC_UD); in x86_emulate()
5072 ctxt)) ) in x86_emulate()
5079 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5094 ops->cpuid(1, 0, &cpuid_leaf, ctxt) == X86EMUL_OKAY ) in x86_emulate()
5104 &nr_reps, ctxt); in x86_emulate()
5116 rc = ops->write(ea.mem.seg, base, &zero, sizeof(zero), ctxt); in x86_emulate()
5133 generate_exception_if(umip_active(ctxt, ops), EXC_GP, 0); in x86_emulate()
5135 if ( (rc = ops->read_segment(seg, &sreg, ctxt)) ) in x86_emulate()
5145 2, ctxt)) != X86EMUL_OKAY || in x86_emulate()
5147 &sreg.base, op_bytes, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5158 &limit, 2, ctxt, ops)) || in x86_emulate()
5160 &base, mode_64bit() ? 8 : 4, ctxt, ops)) ) in x86_emulate()
5167 if ( (rc = ops->write_segment(seg, &sreg, ctxt)) ) in x86_emulate()
5172 generate_exception_if(umip_active(ctxt, ops), EXC_GP, 0); in x86_emulate()
5183 if ( (rc = ops->read_cr(0, &dst.val, ctxt)) ) in x86_emulate()
5191 if ( (rc = ops->read_cr(0, &cr0, ctxt)) ) in x86_emulate()
5196 &cr0w, 2, ctxt, ops)) ) in x86_emulate()
5200 if ( (rc = ops->write_cr(0, cr0, ctxt)) ) in x86_emulate()
5208 if ( (rc = ops->invlpg(ea.mem.seg, ea.mem.off, ctxt)) ) in x86_emulate()
5223 generate_exception_if(!in_protmode(ctxt, ops), EXC_UD); in x86_emulate()
5226 ctxt, ops) ) in x86_emulate()
5237 if ( ctxt->lma ) in x86_emulate()
5252 if ( ctxt->event_pending ) in x86_emulate()
5254 ASSERT(ctxt->event.vector == EXC_PF); in x86_emulate()
5271 generate_exception_if(!in_protmode(ctxt, ops), EXC_UD); in x86_emulate()
5274 ctxt, ops) ) in x86_emulate()
5283 if ( ctxt->lma ) in x86_emulate()
5297 if ( ctxt->event_pending ) in x86_emulate()
5299 ASSERT(ctxt->event.vector == EXC_PF); in x86_emulate()
5314 generate_exception_if(!in_protmode(ctxt, ops), EXC_UD); in x86_emulate()
5318 if ( (rc = ops->read_msr(MSR_EFER, &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5322 if ( (rc = ops->read_msr(MSR_STAR, &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5333 if ( ctxt->lma ) in x86_emulate()
5341 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5346 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5361 if ( (rc = ops->write_segment(x86_seg_cs, &cs, ctxt)) || in x86_emulate()
5362 (rc = ops->write_segment(x86_seg_ss, &sreg, ctxt)) ) in x86_emulate()
5386 if ( (rc = ops->read_cr(0, &dst.val, ctxt)) != X86EMUL_OKAY || in x86_emulate()
5387 (rc = ops->write_cr(0, dst.val & ~X86_CR0_TS, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5395 if ( (rc = ops->wbinvd(ctxt)) != 0 ) in x86_emulate()
5569 rc = write(modrm_reg, src.val, ctxt); in x86_emulate()
5577 rc = read(modrm_reg, &dst.val, ctxt); in x86_emulate()
5613 rex_prefix & REX_W ? 8 : 4, ctxt, ops); in x86_emulate()
5655 vex.pfx & VEX_PREFIX_DOUBLE_MASK ? 8 : 4, ctxt); in x86_emulate()
5702 ctxt); in x86_emulate()
5733 ctxt)) != 0 ) in x86_emulate()
5741 if ( (rc = ops->read_cr(4, &cr4, ctxt)) ) in x86_emulate()
5747 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5756 if ( (rc = ops->read_msr(_regs.ecx, &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5765 generate_exception_if(!in_protmode(ctxt, ops), EXC_GP, 0); in x86_emulate()
5769 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5779 cs.attr = ctxt->lma ? 0xa9b /* G+L+P+S+Code */ in x86_emulate()
5788 if ( (rc = ops->write_segment(x86_seg_cs, &cs, ctxt)) != 0 || in x86_emulate()
5789 (rc = ops->write_segment(x86_seg_ss, &sreg, ctxt)) != 0 ) in x86_emulate()
5793 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5795 _regs.r(ip) = ctxt->lma ? msr_val : (uint32_t)msr_val; in x86_emulate()
5798 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5800 _regs.r(sp) = ctxt->lma ? msr_val : (uint32_t)msr_val; in x86_emulate()
5808 generate_exception_if(!in_protmode(ctxt, ops), EXC_GP, 0); in x86_emulate()
5812 &msr_val, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
5834 if ( (rc = ops->write_segment(x86_seg_cs, &cs, ctxt)) != 0 || in x86_emulate()
5835 (rc = ops->write_segment(x86_seg_ss, &sreg, ctxt)) != 0 ) in x86_emulate()
6391 adjust_bnd(ctxt, ops, vex.pfx); in x86_emulate()
6405 &msr_val, ctxt)) == X86EMUL_EXCEPTION ) in x86_emulate()
6408 x86_emul_reset_event(ctxt); in x86_emulate()
6417 rc = ops->cpuid(_regs.eax, _regs.ecx, &cpuid_leaf, ctxt); in x86_emulate()
6513 if ( (rc = ops->wbinvd(ctxt)) != X86EMUL_OKAY ) in x86_emulate()
6530 if ( (rc = ops->wbinvd(ctxt)) != 0 ) in x86_emulate()
6556 if ( (rc = ops->read_cr(4, &cr4, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
6561 if ( (rc = ops->read_segment(seg, &sreg, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
6583 if ( (rc = ops->write_segment(seg, &sreg, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
6832 ctxt)) != X86EMUL_OKAY ) in x86_emulate()
6876 ctxt, ops), in x86_emulate()
6891 ctxt)) != X86EMUL_OKAY ) in x86_emulate()
6931 op_bytes, ctxt)) != X86EMUL_OKAY ) in x86_emulate()
7172 rc = ops->read(ea.mem.seg, ea.mem.off, mmvalp, 16 << vex.l, ctxt); in x86_emulate()
7438 src.reg = decode_vex_gpr(vex.reg, &_regs, ctxt); in x86_emulate()
7472 dst.reg = decode_vex_gpr(vex.reg, &_regs, ctxt); in x86_emulate()
7515 ea.reg = decode_vex_gpr(vex.reg, &_regs, ctxt); in x86_emulate()
7709 rc = ops->read(ea.mem.seg, ea.mem.off, mmvalp, 16, ctxt); in x86_emulate()
7758 ctxt, ops)) != X86EMUL_OKAY ) in x86_emulate()
7798 dst.reg = decode_vex_gpr(vex.reg, &_regs, ctxt); in x86_emulate()
7826 ctxt, ops)) != X86EMUL_OKAY ) in x86_emulate()
7885 ctxt, ops), in x86_emulate()
7892 ctxt); in x86_emulate()
7914 switch ( ctxt->opcode ) in x86_emulate()
7935 if ( likely((ctxt->opcode & ~(X86EMUL_OPC_PFX_MASK | in x86_emulate()
7961 !ctxt->force_writeback ) in x86_emulate()
7968 &dst.val, dst.bytes, ctxt); in x86_emulate()
7976 dst.bytes, ctxt); in x86_emulate()
7987 put_fpu(&fic, false, state, ctxt, ops); in x86_emulate()
7994 if ( rc == X86EMUL_OKAY && singlestep && !ctxt->retire.mov_ss ) in x86_emulate()
7996 ctxt->retire.singlestep = true; in x86_emulate()
7997 ctxt->retire.sti = false; in x86_emulate()
8001 *ctxt->regs = _regs; in x86_emulate()
8004 ctxt->regs->r(ip) = _regs.r(ip); in x86_emulate()
8008 ctxt->regs->eflags &= ~X86_EFLAGS_RF; in x86_emulate()
8011 put_fpu(&fic, fic.insn_bytes > 0 && dst.type == OP_MEM, state, ctxt, ops); in x86_emulate()
8057 struct x86_emulate_ctxt *ctxt, in x86_emulate_wrapper() argument
8060 unsigned long orig_ip = ctxt->regs->r(ip); in x86_emulate_wrapper()
8064 ASSERT(ctxt->lma); in x86_emulate_wrapper()
8066 rc = x86_emulate(ctxt, ops); in x86_emulate_wrapper()
8074 typeof(ctxt->retire) retire = ctxt->retire; in x86_emulate_wrapper()
8082 ASSERT(ctxt->regs->r(ip) == orig_ip); in x86_emulate_wrapper()
8090 ASSERT(ctxt->event_pending == (rc == X86EMUL_EXCEPTION)); in x86_emulate_wrapper()
8102 struct x86_emulate_ctxt *ctxt, in x86_decode_insn() argument
8106 struct x86_emulate_ctxt *ctxt)) in x86_decode_insn()
8114 int rc = x86_decode(state, ctxt, &ops); in x86_decode_insn()
8196 const struct x86_emulate_ctxt *ctxt) in x86_insn_is_mem_access() argument
8199 return ctxt->opcode != 0x8d /* LEA */ && in x86_insn_is_mem_access()
8200 (ctxt->opcode != X86EMUL_OPC(0x0f, 0x01) || in x86_insn_is_mem_access()
8203 switch ( ctxt->opcode ) in x86_insn_is_mem_access()
8223 const struct x86_emulate_ctxt *ctxt) in x86_insn_is_mem_write() argument
8241 return ctxt->opcode == X86EMUL_OPC(0x0f, 0x01) && in x86_insn_is_mem_write()
8244 switch ( ctxt->opcode ) in x86_insn_is_mem_write()
8315 const struct x86_emulate_ctxt *ctxt) in x86_insn_is_portio() argument
8317 switch ( ctxt->opcode ) in x86_insn_is_portio()
8330 const struct x86_emulate_ctxt *ctxt) in x86_insn_is_cr_access() argument
8332 switch ( ctxt->opcode ) in x86_insn_is_cr_access()
8369 const struct x86_emulate_ctxt *ctxt) in x86_insn_length() argument
8373 return state->ip - ctxt->regs->r(ip); in x86_insn_length()