diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2014-03-27 07:00:57 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-07-11 03:13:57 -0400 |
commit | e24186e097b80c5995ff75e1bbcd541d09c9e42b (patch) | |
tree | e6593ced13487cad8f8cd92c453f1a44b5186631 /arch/x86/kvm | |
parent | 6addfc42992be4b073c39137ecfdf4b2aa2d487f (diff) |
KVM: emulate: move around some checks
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>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/emulate.c | 17 |
1 files 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: | |||
4388 | ctxt->d |= opcode.flags; | 4388 | ctxt->d |= opcode.flags; |
4389 | } | 4389 | } |
4390 | 4390 | ||
4391 | /* Unrecognised? */ | ||
4392 | if (ctxt->d == 0) | ||
4393 | return EMULATION_FAILED; | ||
4394 | |||
4391 | ctxt->execute = opcode.u.execute; | 4395 | ctxt->execute = opcode.u.execute; |
4392 | ctxt->check_perm = opcode.check_perm; | 4396 | ctxt->check_perm = opcode.check_perm; |
4393 | ctxt->intercept = opcode.intercept; | 4397 | ctxt->intercept = opcode.intercept; |
4394 | 4398 | ||
4395 | /* Unrecognised? */ | 4399 | if (ctxt->d & NotImpl) |
4396 | if (ctxt->d == 0 || (ctxt->d & NotImpl)) | ||
4397 | return EMULATION_FAILED; | 4400 | return EMULATION_FAILED; |
4398 | 4401 | ||
4399 | if (!(ctxt->d & EmulateOnUD) && ctxt->ud) | 4402 | if (!(ctxt->d & EmulateOnUD) && ctxt->ud) |
@@ -4535,19 +4538,19 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) | |||
4535 | 4538 | ||
4536 | ctxt->mem_read.pos = 0; | 4539 | ctxt->mem_read.pos = 0; |
4537 | 4540 | ||
4538 | if ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) || | 4541 | /* LOCK prefix is allowed only with some instructions */ |
4539 | (ctxt->d & Undefined)) { | 4542 | if (ctxt->lock_prefix && (!(ctxt->d & Lock) || ctxt->dst.type != OP_MEM)) { |
4540 | rc = emulate_ud(ctxt); | 4543 | rc = emulate_ud(ctxt); |
4541 | goto done; | 4544 | goto done; |
4542 | } | 4545 | } |
4543 | 4546 | ||
4544 | /* LOCK prefix is allowed only with some instructions */ | 4547 | if ((ctxt->d & SrcMask) == SrcMemFAddr && ctxt->src.type != OP_MEM) { |
4545 | if (ctxt->lock_prefix && (!(ctxt->d & Lock) || ctxt->dst.type != OP_MEM)) { | ||
4546 | rc = emulate_ud(ctxt); | 4548 | rc = emulate_ud(ctxt); |
4547 | goto done; | 4549 | goto done; |
4548 | } | 4550 | } |
4549 | 4551 | ||
4550 | if ((ctxt->d & SrcMask) == SrcMemFAddr && ctxt->src.type != OP_MEM) { | 4552 | if ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) || |
4553 | (ctxt->d & Undefined)) { | ||
4551 | rc = emulate_ud(ctxt); | 4554 | rc = emulate_ud(ctxt); |
4552 | goto done; | 4555 | goto done; |
4553 | } | 4556 | } |