KVM: x86 emulator: emulate LAHF
authorAvi Kivity <avi@redhat.com>
Mon, 11 Jun 2012 10:09:07 +0000 (13:09 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jul 2012 11:19:03 +0000 (14:19 +0300)
Opcode 9F.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/emulate.c

index 5053e9efb14029b14fa5a37c7a5d0fd69fcbd769..90b549ed89970742995bdf51761a2650433316cb 100644 (file)
@@ -3227,6 +3227,13 @@ static int em_cpuid(struct x86_emulate_ctxt *ctxt)
        return X86EMUL_CONTINUE;
 }
 
+static int em_lahf(struct x86_emulate_ctxt *ctxt)
+{
+       ctxt->regs[VCPU_REGS_RAX] &= ~0xff00UL;
+       ctxt->regs[VCPU_REGS_RAX] |= (ctxt->eflags & 0xff) << 8;
+       return X86EMUL_CONTINUE;
+}
+
 static bool valid_cr(int nr)
 {
        switch (nr) {
@@ -3622,7 +3629,7 @@ static struct opcode opcode_table[256] = {
        D(DstAcc | SrcNone), I(ImplicitOps | SrcAcc, em_cwd),
        I(SrcImmFAddr | No64, em_call_far), N,
        II(ImplicitOps | Stack, em_pushf, pushf),
-       II(ImplicitOps | Stack, em_popf, popf), N, N,
+       II(ImplicitOps | Stack, em_popf, popf), N, I(ImplicitOps, em_lahf),
        /* 0xA0 - 0xA7 */
        I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
        I2bv(DstMem | SrcAcc | Mov | MemAbs | PageTable, em_mov),