public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nadav Amit <nadav.amit@gmail.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tosatti <mtosatti@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] KVM: fix mov immediate emulation for 64-bit operands
Date: Sat, 7 Jan 2012 22:21:35 +0200	[thread overview]
Message-ID: <E0EE2EE9-96C1-4354-BDCE-19E3AF2C0F30@gmail.com> (raw)
In-Reply-To: 1325967346-12539-1-git-send-email-namit@cs.technion.ac.il

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 <nadav.amit@gmail.com>
---
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



       reply	other threads:[~2012-01-07 20:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1325967346-12539-1-git-send-email-namit@cs.technion.ac.il>
2012-01-07 20:21 ` Nadav Amit [this message]
2012-01-07 20:25   ` [PATCH] KVM: fix mov immediate emulation for 64-bit operands H. Peter Anvin
2012-01-08  0:30     ` Nadav Amit
2012-01-08  1:26       ` Takuya Yoshikawa
2012-01-08  8:47         ` Nadav Amit
2012-01-08 14:05           ` Avi Kivity
2012-01-08 14:08             ` Avi Kivity
2012-01-08 14:44               ` Nadav Amit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E0EE2EE9-96C1-4354-BDCE-19E3AF2C0F30@gmail.com \
    --to=nadav.amit@gmail.com \
    --cc=avi@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox