From: Takuya Yoshikawa Subject: [PATCH 1/4] KVM: x86 emulator: Introduce ctxt->op_prefix for 0x66 prefix Date: Tue, 24 Apr 2012 00:33:31 +0900 Message-ID: <20120424003331.ac19627290a7689c24923071@gmail.com> References: <20120424003159.4fd245ec18b0b3eeddbea553@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp To: avi@redhat.com, mtosatti@redhat.com Return-path: Received: from mail-pz0-f51.google.com ([209.85.210.51]:34051 "EHLO mail-pz0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414Ab2DWPdg (ORCPT ); Mon, 23 Apr 2012 11:33:36 -0400 Received: by dadz8 with SMTP id z8so15711515dad.10 for ; Mon, 23 Apr 2012 08:33:35 -0700 (PDT) In-Reply-To: <20120424003159.4fd245ec18b0b3eeddbea553@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Takuya Yoshikawa This is needed to make prefix decoding a separate function. Signed-off-by: Takuya Yoshikawa Cc: Takuya Yoshikawa --- arch/x86/include/asm/kvm_emulate.h | 1 + arch/x86/kvm/emulate.c | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 1ac46c22..75783a7 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h @@ -261,6 +261,7 @@ struct x86_emulate_ctxt { u8 intercept; u8 lock_prefix; u8 rep_prefix; + u8 op_prefix; u8 op_bytes; u8 ad_bytes; u8 rex_prefix; diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index d5729a9..5a49290 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3879,7 +3879,6 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) int rc = X86EMUL_CONTINUE; int mode = ctxt->mode; int def_op_bytes, def_ad_bytes, goffset, simd_prefix; - bool op_prefix = false; struct opcode opcode; ctxt->memop.type = OP_NONE; @@ -3916,7 +3915,7 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) for (;;) { switch (ctxt->b = insn_fetch(u8, ctxt)) { case 0x66: /* operand-size override */ - op_prefix = true; + ctxt->op_prefix = ctxt->b; /* switch between 2/4 bytes */ ctxt->op_bytes = def_op_bytes ^ 6; break; @@ -3997,9 +3996,9 @@ done_prefixes: opcode = opcode.u.group[goffset]; break; case Prefix: - if (ctxt->rep_prefix && op_prefix) + if (ctxt->rep_prefix && ctxt->op_prefix) return EMULATION_FAILED; - simd_prefix = op_prefix ? 0x66 : ctxt->rep_prefix; + simd_prefix = ctxt->rep_prefix | ctxt->op_prefix; switch (simd_prefix) { case 0x00: opcode = opcode.u.gprefix->pfx_no; break; case 0x66: opcode = opcode.u.gprefix->pfx_66; break; -- 1.7.5.4