aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-10-31 06:19:42 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2013-10-31 17:14:10 -0400
commit98f73630f96f1a6d8c845b8b3e5f9ae532cf82d1 (patch)
tree5dd9af4bef9d355f563a8586bc337256ce3322d2 /arch/x86
parenta94b40a630f7bb90636c375103457c053f51418e (diff)
KVM: x86: emulate SAHF instruction
Yet another instruction that we fail to emulate, this time found in Windows 2008R2 32-bit. Reviewed-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/emulate.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 8e2a07bd8eac..16c037e7db7d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -3296,6 +3296,18 @@ static int em_cpuid(struct x86_emulate_ctxt *ctxt)
3296 return X86EMUL_CONTINUE; 3296 return X86EMUL_CONTINUE;
3297} 3297}
3298 3298
3299static int em_sahf(struct x86_emulate_ctxt *ctxt)
3300{
3301 u32 flags;
3302
3303 flags = EFLG_CF | EFLG_PF | EFLG_AF | EFLG_ZF | EFLG_SF;
3304 flags &= *reg_rmw(ctxt, VCPU_REGS_RAX) >> 8;
3305
3306 ctxt->eflags &= ~0xffUL;
3307 ctxt->eflags |= flags | X86_EFLAGS_FIXED;
3308 return X86EMUL_CONTINUE;
3309}
3310
3299static int em_lahf(struct x86_emulate_ctxt *ctxt) 3311static int em_lahf(struct x86_emulate_ctxt *ctxt)
3300{ 3312{
3301 *reg_rmw(ctxt, VCPU_REGS_RAX) &= ~0xff00UL; 3313 *reg_rmw(ctxt, VCPU_REGS_RAX) &= ~0xff00UL;
@@ -3790,7 +3802,8 @@ static const struct opcode opcode_table[256] = {
3790 D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd), 3802 D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd),
3791 I(SrcImmFAddr | No64, em_call_far), N, 3803 I(SrcImmFAddr | No64, em_call_far), N,
3792 II(ImplicitOps | Stack, em_pushf, pushf), 3804 II(ImplicitOps | Stack, em_pushf, pushf),
3793 II(ImplicitOps | Stack, em_popf, popf), N, I(ImplicitOps, em_lahf), 3805 II(ImplicitOps | Stack, em_popf, popf),
3806 I(ImplicitOps, em_sahf), I(ImplicitOps, em_lahf),
3794 /* 0xA0 - 0xA7 */ 3807 /* 0xA0 - 0xA7 */
3795 I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov), 3808 I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
3796 I2bv(DstMem | SrcAcc | Mov | MemAbs | PageTable, em_mov), 3809 I2bv(DstMem | SrcAcc | Mov | MemAbs | PageTable, em_mov),