From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nadav Amit Subject: [PATCH] KVM: fix mov immediate emulation for 64-bit operands Date: Sat, 7 Jan 2012 22:21:35 +0200 Message-ID: References: <1325967346-12539-1-git-send-email-namit@cs.technion.ac.il> Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Avi Kivity , Marcelo Tosatti Return-path: Received: from mail-ee0-f46.google.com ([74.125.83.46]:54688 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751321Ab2AGUXP convert rfc822-to-8bit (ORCPT ); Sat, 7 Jan 2012 15:23:15 -0500 Sender: kvm-owner@vger.kernel.org List-ID: MOV immediate instruction (opcodes 0xB8-0xBF) may take 64-bit operand. The previous emulation implementation assumes the operand is no longer than 32. Signed-off-by: Nadav Amit --- arch/x86/kvm/emulate.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 05a562b..65d1d31 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3502,7 +3502,8 @@ static unsigned imm_size(struct x86_emulate_ctxt *ctxt) unsigned size; size = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes; - if (size == 8) + /* Immediates are usually no longer than 4 bytes */ + if (size == 8 && ((ctxt->b & 0xF8) != 0xB8 || ctxt->twobyte)) size = 4; return size; } @@ -3526,6 +3527,9 @@ static int decode_imm(struct x86_emulate_ctxt *ctxt, struct operand *op, case 4: op->val = insn_fetch(s32, ctxt); break; + case 8: + op->val = insn_fetch(s64, ctxt); + break; } if (!sign_extension) { switch (op->bytes) { -- 1.7.4.1