From: Gleb Natapov <gleb@redhat.com>
To: Denys Vlasenko <dvlasenk@redhat.com>
Cc: linux-kernel@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Avi Kivity <avi.kivity@gmail.com>
Subject: Re: [PATCH] x86/kvm/emulate.c: simplify NOP (opcode 0x90) check
Date: Thu, 4 Jul 2013 14:07:47 +0300 [thread overview]
Message-ID: <20130704110747.GH5113@redhat.com> (raw)
In-Reply-To: <51D55728.4060909@redhat.com>
On Thu, Jul 04, 2013 at 01:06:16PM +0200, Denys Vlasenko wrote:
> On 07/04/2013 11:13 AM, Gleb Natapov wrote:
> > On Thu, Jul 04, 2013 at 10:58:29AM +0200, Denys Vlasenko wrote:
> >> The check sits in switch() statement which itself can check
> >> for opcode 0x90 far more efficiently.
> >>
> >> On assembler level, this change simply eliminates the following
> >> bit of code:
> >>
> >> 4c 8b a3 d8 00 00 00 mov 0xd8(%rbx),%r12
> >> 31 f6 xor %esi,%esi
> >> 48 89 df mov %rbx,%rdi
> >> e8 32 8c ff ff callq 490 <reg_read>
> >> 48 8d 83 78 01 00 00 lea 0x178(%rbx),%rax
> >> 83 8b 70 01 00 00 01 orl $0x1,0x170(%rbx)
> >> 83 8b 74 01 00 00 01 orl $0x1,0x174(%rbx)
> >> 49 39 c4 cmp %rax,%r12
> >> 0f 84 88 fa ff ff je 7304 <x86_emulate_insn+0x204>
> >>
> >> Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
> >> CC: Paolo Bonzini <pbonzini@redhat.com>
> >> CC: Avi Kivity <avi.kivity@gmail.com>
> >> ---
> >> arch/x86/kvm/emulate.c | 6 +++---
> >> 1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> >> index 2bc1e81..7e6e74a 100644
> >> --- a/arch/x86/kvm/emulate.c
> >> +++ b/arch/x86/kvm/emulate.c
> >> @@ -4544,9 +4544,9 @@ special_insn:
> >> case 0x8d: /* lea r16/r32, m */
> >> ctxt->dst.val = ctxt->src.addr.mem.ea;
> >> break;
> >> - case 0x90 ... 0x97: /* nop / xchg reg, rax */
> >> - if (ctxt->dst.addr.reg == reg_rmw(ctxt, VCPU_REGS_RAX))
> >> - break;
> >> + case 0x90: /* nop */
> >> + break;
> > This does not work on 64bit and REX prefix.
>
> Can you elaborate?
>
> 0x90 is special-cased in CPU to be a NOP regardless of bit width.
> IOW, xchg %eax,%eax ordinarily would clear upper 32 bits of %rax,
> but 0x90 doesn't do that.
>
> Do you mean that with REX.R==1, 0x90 will refer to R8?
Yes.
--
Gleb.
next prev parent reply other threads:[~2013-07-04 11:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-04 8:58 [PATCH] x86/kvm/emulate.c: simplify NOP (opcode 0x90) check Denys Vlasenko
2013-07-04 9:13 ` Gleb Natapov
2013-07-04 11:06 ` Denys Vlasenko
2013-07-04 11:07 ` Gleb Natapov [this message]
2013-07-04 11:08 ` 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=20130704110747.GH5113@redhat.com \
--to=gleb@redhat.com \
--cc=avi.kivity@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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.