linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 04/19] KVM: emulate: move around some checks
Date: Mon, 14 Jul 2014 13:38:28 +0200	[thread overview]
Message-ID: <1405337923-4776-5-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1405337923-4776-1-git-send-email-pbonzini@redhat.com>

The only purpose of this patch is to make the next patch simpler
to review.  No semantic change.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 arch/x86/kvm/emulate.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 15453e569f3d..d79677c6056d 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -4388,12 +4388,15 @@ done_prefixes:
 		ctxt->d |= opcode.flags;
 	}
 
+	/* Unrecognised? */
+	if (ctxt->d == 0)
+		return EMULATION_FAILED;
+
 	ctxt->execute = opcode.u.execute;
 	ctxt->check_perm = opcode.check_perm;
 	ctxt->intercept = opcode.intercept;
 
-	/* Unrecognised? */
-	if (ctxt->d == 0 || (ctxt->d & NotImpl))
+	if (ctxt->d & NotImpl)
 		return EMULATION_FAILED;
 
 	if (!(ctxt->d & EmulateOnUD) && ctxt->ud)
@@ -4535,19 +4538,19 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
 
 	ctxt->mem_read.pos = 0;
 
-	if ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) ||
-			(ctxt->d & Undefined)) {
+	/* LOCK prefix is allowed only with some instructions */
+	if (ctxt->lock_prefix && (!(ctxt->d & Lock) || ctxt->dst.type != OP_MEM)) {
 		rc = emulate_ud(ctxt);
 		goto done;
 	}
 
-	/* LOCK prefix is allowed only with some instructions */
-	if (ctxt->lock_prefix && (!(ctxt->d & Lock) || ctxt->dst.type != OP_MEM)) {
+	if ((ctxt->d & SrcMask) == SrcMemFAddr && ctxt->src.type != OP_MEM) {
 		rc = emulate_ud(ctxt);
 		goto done;
 	}
 
-	if ((ctxt->d & SrcMask) == SrcMemFAddr && ctxt->src.type != OP_MEM) {
+	if ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) ||
+			(ctxt->d & Undefined)) {
 		rc = emulate_ud(ctxt);
 		goto done;
 	}
-- 
1.8.3.1



  parent reply	other threads:[~2014-07-14 11:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-14 11:38 [PATCH resend 00/19] Emulator speedups for 3.17 Paolo Bonzini
2014-07-14 11:38 ` [PATCH 01/19] KVM: vmx: speed up emulation of invalid guest state Paolo Bonzini
2014-07-14 11:38 ` [PATCH 02/19] KVM: x86: return all bits from get_interrupt_shadow Paolo Bonzini
2014-07-14 11:38 ` [PATCH 03/19] KVM: x86: avoid useless set of KVM_REQ_EVENT after emulation Paolo Bonzini
2014-07-14 11:38 ` Paolo Bonzini [this message]
2014-07-14 11:38 ` [PATCH 05/19] KVM: emulate: protect checks on ctxt->d by a common "if (unlikely())" Paolo Bonzini
2014-07-14 11:38 ` [PATCH 06/19] KVM: emulate: speed up emulated moves Paolo Bonzini
2014-07-14 11:38 ` [PATCH 07/19] KVM: emulate: simplify writeback Paolo Bonzini
2014-07-14 11:38 ` [PATCH 08/19] KVM: emulate: move init_decode_cache to emulate.c Paolo Bonzini
2014-07-14 11:38 ` [PATCH 09/19] KVM: emulate: Remove ctxt->intercept and ctxt->check_perm checks Paolo Bonzini
2014-07-14 11:38 ` [PATCH 10/19] KVM: emulate: cleanup decode_modrm Paolo Bonzini
2014-07-14 11:38 ` [PATCH 11/19] KVM: emulate: clean up initializations in init_decode_cache Paolo Bonzini
2014-07-14 11:38 ` [PATCH 12/19] KVM: emulate: rework seg_override Paolo Bonzini
2014-07-14 11:38 ` [PATCH 13/19] KVM: emulate: do not initialize memopp Paolo Bonzini
2014-07-14 11:38 ` [PATCH 14/19] KVM: emulate: speed up do_insn_fetch Paolo Bonzini
2014-07-14 11:38 ` [PATCH 15/19] KVM: emulate: avoid repeated calls to do_insn_fetch_bytes Paolo Bonzini
2014-07-14 11:38 ` [PATCH 16/19] KVM: emulate: avoid per-byte copying in instruction fetches Paolo Bonzini
2014-07-14 11:38 ` [PATCH 17/19] KVM: emulate: put pointers in the fetch_cache Paolo Bonzini
2014-07-14 11:38 ` [PATCH 18/19] KVM: x86: ensure emulator fetches do not span multiple pages Paolo Bonzini
2014-07-14 11:38 ` [PATCH 19/19] KVM: x86: use kvm_read_guest_page for emulator accesses Paolo Bonzini

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=1405337923-4776-5-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.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;
as well as URLs for NNTP newsgroup(s).