diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-05-09 05:32:49 -0400 |
---|---|---|
committer | Gleb Natapov <gleb@redhat.com> | 2013-05-09 06:12:58 -0400 |
commit | a035d5c64d08a8ac12d81b596e7fa6d95a73c347 (patch) | |
tree | d294150c9d50c711d48e9d2e1827b4dde7c316ec /arch/x86/kvm | |
parent | 8d76c49e9ffeee839bc0b7a3278a23f99101263e (diff) |
KVM: emulator: emulate AAM
This is used by SGABIOS, KVM breaks with emulate_invalid_guest_state=1.
AAM needs the source operand to be unsigned; do the same in AAD as well
for consistency, even though it does not affect the result.
Reported-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: stable@vger.kernel.org # 3.9
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/emulate.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 8e517bba6a7c..55322a7c113d 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -2996,6 +2996,28 @@ static int em_das(struct x86_emulate_ctxt *ctxt) | |||
2996 | return X86EMUL_CONTINUE; | 2996 | return X86EMUL_CONTINUE; |
2997 | } | 2997 | } |
2998 | 2998 | ||
2999 | static int em_aam(struct x86_emulate_ctxt *ctxt) | ||
3000 | { | ||
3001 | u8 al, ah; | ||
3002 | |||
3003 | if (ctxt->src.val == 0) | ||
3004 | return emulate_de(ctxt); | ||
3005 | |||
3006 | al = ctxt->dst.val & 0xff; | ||
3007 | ah = al / ctxt->src.val; | ||
3008 | al %= ctxt->src.val; | ||
3009 | |||
3010 | ctxt->dst.val = (ctxt->dst.val & 0xffff0000) | al | (ah << 8); | ||
3011 | |||
3012 | /* Set PF, ZF, SF */ | ||
3013 | ctxt->src.type = OP_IMM; | ||
3014 | ctxt->src.val = 0; | ||
3015 | ctxt->src.bytes = 1; | ||
3016 | fastop(ctxt, em_or); | ||
3017 | |||
3018 | return X86EMUL_CONTINUE; | ||
3019 | } | ||
3020 | |||
2999 | static int em_aad(struct x86_emulate_ctxt *ctxt) | 3021 | static int em_aad(struct x86_emulate_ctxt *ctxt) |
3000 | { | 3022 | { |
3001 | u8 al = ctxt->dst.val & 0xff; | 3023 | u8 al = ctxt->dst.val & 0xff; |
@@ -3936,7 +3958,8 @@ static const struct opcode opcode_table[256] = { | |||
3936 | /* 0xD0 - 0xD7 */ | 3958 | /* 0xD0 - 0xD7 */ |
3937 | G(Src2One | ByteOp, group2), G(Src2One, group2), | 3959 | G(Src2One | ByteOp, group2), G(Src2One, group2), |
3938 | G(Src2CL | ByteOp, group2), G(Src2CL, group2), | 3960 | G(Src2CL | ByteOp, group2), G(Src2CL, group2), |
3939 | N, I(DstAcc | SrcImmByte | No64, em_aad), N, N, | 3961 | I(DstAcc | SrcImmUByte | No64, em_aam), |
3962 | I(DstAcc | SrcImmUByte | No64, em_aad), N, N, | ||
3940 | /* 0xD8 - 0xDF */ | 3963 | /* 0xD8 - 0xDF */ |
3941 | N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N, | 3964 | N, E(0, &escape_d9), N, E(0, &escape_db), N, E(0, &escape_dd), N, N, |
3942 | /* 0xE0 - 0xE7 */ | 3965 | /* 0xE0 - 0xE7 */ |