x86 emulator: fix parity calculation for AAD instruction
authorGleb Natapov <gleb@redhat.com>
Wed, 13 Feb 2013 15:50:39 +0000 (17:50 +0200)
committerGleb Natapov <gleb@redhat.com>
Wed, 13 Feb 2013 16:01:00 +0000 (18:01 +0200)
Reported-by: Paolo Bonzini <pbonzini@redhat.com>
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
arch/x86/kvm/emulate.c

index 2b11318151a468d5ec296674e71d4d7346f7af80..a335cc6cde72aa099cbd718bfc02a71c3d70feb2 100644 (file)
@@ -2995,14 +2995,11 @@ static int em_aad(struct x86_emulate_ctxt *ctxt)
 
        ctxt->dst.val = (ctxt->dst.val & 0xffff0000) | al;
 
-       ctxt->eflags &= ~(X86_EFLAGS_PF | X86_EFLAGS_SF | X86_EFLAGS_ZF);
-
-       if (!al)
-               ctxt->eflags |= X86_EFLAGS_ZF;
-       if (!(al & 1))
-               ctxt->eflags |= X86_EFLAGS_PF;
-       if (al & 0x80)
-               ctxt->eflags |= X86_EFLAGS_SF;
+       /* Set PF, ZF, SF */
+       ctxt->src.type = OP_IMM;
+       ctxt->src.val = 0;
+       ctxt->src.bytes = 1;
+       fastop(ctxt, em_or);
 
        return X86EMUL_CONTINUE;
 }