All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bandan Das <bsd@redhat.com>
To: kvm@vger.kernel.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Gleb Natapov <gleb@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 3/6] KVM: emulate: cleanup decode_rm
Date: Thu, 10 Apr 2014 20:03:29 -0400	[thread overview]
Message-ID: <1397174612-17373-4-git-send-email-bsd@redhat.com> (raw)
In-Reply-To: <1397174612-17373-1-git-send-email-bsd@redhat.com>

Remove the if conditional - that will help us avoid
an "else initialize to 0" Also, rearrange operators
for slightly better code.

Signed-off-by: Bandan Das <bsd@redhat.com>
---
 arch/x86/kvm/emulate.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index a6d9892..9cbaba2 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1064,19 +1064,17 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
 			struct operand *op)
 {
 	u8 sib;
-	int index_reg = 0, base_reg = 0, scale;
+	int index_reg, base_reg, scale;
 	int rc = X86EMUL_CONTINUE;
 	ulong modrm_ea = 0;
 
-	if (ctxt->rex_prefix) {
-		ctxt->modrm_reg = (ctxt->rex_prefix & 4) << 1;	/* REX.R */
-		index_reg = (ctxt->rex_prefix & 2) << 2; /* REX.X */
-		ctxt->modrm_rm = base_reg = (ctxt->rex_prefix & 1) << 3; /* REG.B */
-	}
+	index_reg = (ctxt->rex_prefix << 2) & 8; /* REX.X */
+	base_reg = (ctxt->rex_prefix << 3) & 8; /* REG.B */
 
-	ctxt->modrm_mod |= (ctxt->modrm & 0xc0) >> 6;
-	ctxt->modrm_reg |= (ctxt->modrm & 0x38) >> 3;
-	ctxt->modrm_rm |= (ctxt->modrm & 0x07);
+	ctxt->modrm_mod = (ctxt->modrm & 0xc0) >> 6;
+	ctxt->modrm_reg = ((ctxt->rex_prefix << 1) & 8) | /* REX.R */
+		((ctxt->modrm & 0x38) >> 3);
+	ctxt->modrm_rm = base_reg | (ctxt->modrm & 0x07);
 	ctxt->modrm_seg = VCPU_SREG_DS;
 
 	if (ctxt->modrm_mod == 3) {
-- 
1.8.3.1


  parent reply	other threads:[~2014-04-11  0:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-11  0:03 [RFC PATCH v2 0/6] Emulator speedups - avoid initializations where possible Bandan Das
2014-04-11  0:03 ` [RFC PATCH v2 1/6] KVM: emulate: move init_decode_cache to emulate.c Bandan Das
2014-04-11  0:03 ` [RFC PATCH v2 2/6] KVM: emulate: Remove ctxt->intercept and ctxt->check_perm checks Bandan Das
2014-04-11  0:03 ` Bandan Das [this message]
2014-04-13 12:51   ` [RFC PATCH v2 3/6] KVM: emulate: cleanup decode_rm Paolo Bonzini
2014-04-11  0:03 ` [RFC PATCH v2 4/6] KVM: emulate: clean up initializations in init_decode_cache Bandan Das
2014-04-11  0:03 ` [RFC PATCH v2 5/6] KVM: emulate: rework seg_override Bandan Das
2014-04-11  0:03 ` [RFC PATCH v2 6/6] KVM: emulate: remove memopp and rip_relative Bandan Das
2014-04-13 12:48   ` Paolo Bonzini
2014-04-14 14:01     ` Bandan Das

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=1397174612-17373-4-git-send-email-bsd@redhat.com \
    --to=bsd@redhat.com \
    --cc=gleb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.