From: Nadav Amit Date: Mon, 2 Jun 2014 15:34:11 +0000 (+0300) Subject: KVM: x86: smsw emulation is incorrect in 64-bit mode X-Git-Tag: v3.17-rc1~141^2~84 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=32e94d0696c26c6ba4f3ff53e70f6e0e825979bc;p=uclinux-h8%2Flinux.git KVM: x86: smsw emulation is incorrect in 64-bit mode In 64-bit mode, when the destination is a register, the assignment is done according to the operand size. Otherwise (memory operand or no 64-bit mode), a 16-bit assignment is performed. Currently, 16-bit assignment is always done to the destination. Signed-off-by: Nadav Amit Signed-off-by: Paolo Bonzini --- diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index a151f8d24a1d..9b5d97db7631 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3235,7 +3235,8 @@ static int em_lidt(struct x86_emulate_ctxt *ctxt) static int em_smsw(struct x86_emulate_ctxt *ctxt) { - ctxt->dst.bytes = 2; + if (ctxt->dst.type == OP_MEM) + ctxt->dst.bytes = 2; ctxt->dst.val = ctxt->ops->get_cr(ctxt, 0); return X86EMUL_CONTINUE; }