Skip to content

Commit

Permalink
KVM: emulate: move around some checks
Browse files Browse the repository at this point in the history
The only purpose of this patch is to make the next patch simpler
to review.  No semantic change.

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed Jul 11, 2014
1 parent 6addfc4 commit e24186e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions arch/x86/kvm/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -4388,12 +4388,15 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
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)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e24186e

Please sign in to comment.