public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>, Jim Keniston <jkenisto@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>,
	        Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	        Andi Kleen <andi@firstfloor.org>,
	kvm@vger.kernel.org,         Steven Rostedt <rostedt@goodmis.org>,
	        Frederic Weisbecker <fweisbec@gmail.com>,
	        Andrew Morton <akpm@linux-foundation.org>,
	        Arnaldo Carvalho de Melo <acme@redhat.com>,
	        systemtap-ml <systemtap@sources.redhat.com>,
	        LKML <linux-kernel@vger.kernel.org>,
	        Vegard Nossum <vegard.nossum@gmail.com>,
	Avi Kivity <avi@redhat.com>,
	        Roland McGrath <roland@redhat.com>
Subject: Re: [PATCH -tip 3/6 V4.1] x86: instruction decorder API
Date: Sat, 04 Apr 2009 00:36:00 -0000	[thread overview]
Message-ID: <49D6ABD1.7040704@redhat.com> (raw)
In-Reply-To: <49D69F39.4010101@zytor.com>

Hi Peter,

H. Peter Anvin wrote:
> Masami Hiramatsu wrote:
>> Add x86 instruction decoder to arch-specific libraries. This decoder
>> can decode all x86 instructions into prefix, opcode, modrm, sib,
>> displacement and immediates. This can also show the length of
>> instructions.
>>
>> changes from v4:
>>  - make bitmap tables static.
> 
> Hi Masami,
> 
> On the surface the overall structure looks fine, but I have a couple of 
> concerns:
> 
> 1. is this meant to be able to decode userspace code or just kernel 
> code?  If it is supposed to be able to decode userspace code, is there a 
> reason you're not dealing with 16-bit or V86 mode code at all?  If not, 
> why are you including the 32-bit decoder in a 64-bit kernel (as well as 
> instructions which we're pretty much guaranteed to never use in the 
> kernel, such as ENTER.)

Actually, this aims to decode both of user space and kernel code.
At this point, it just needs to cover kernel code, because kprobes
just want to decode kernel binary.
However, this is just a starting point, uprobe developers want to
use it to decode user-space code. In that case, it needs to be
enhanced.


> 2. you're already not dealing with all existing three-byte opcode 
> spaces, nor with DREX or VEX encodings for upcoming processors.  This 
> doesn't matter so much for the kernel, but it does matter if this is 
> supposed to be used for user-space code.
> 
> 3. is there any need to deal with instruction set differences among 
> processors?  (Again, this depends on the usage model.)

Agreed. When it support decoding user-space code, it should
support all kind of instructions.

> 
> 4. you have a bunch of magic opcode constants all over the place.  This 
> means that as new instructions come in -- and they're going to be coming 
> in -- this is going to be hard to update.  It would be cleaner if we 
> could have an intermediate format that preprocesses down to all the 
> relevant tables and perhaps even some of the code rather than 
> open-coding everything in C.
> 
> This matters... for example you have:
> 
> +		} else if (opcode == 0xea /* jmp far seg:offs */) {
> +			__get_immptr(insn);
> 
> ... but nothing similar for opcode 0x9a.  This is extremely hard to spot 
> with this kind of structure.

Oops, that should be a bug. Hmm, I think we'd better bit-flags tables
for classifying opcodes.
Jim, can your INAT idea help this situation?

http://sources.redhat.com/ml/systemtap/2009-q2/msg00109.html

> 
> The more data-driven we can make it (without bloating the code too much) 
> the better off we are, I believe.
> 
> 	-hpa

Thank you for good advice!

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com

  reply	other threads:[~2009-04-04  0:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-02 17:23 [PATCH -tip 3/6 V4] " Masami Hiramatsu
2009-04-03 23:28 ` [PATCH -tip 3/6 V4.1] " Masami Hiramatsu
2009-04-03 23:45   ` H. Peter Anvin
2009-04-04  0:36     ` Masami Hiramatsu [this message]
2009-04-06 22:48       ` Jim Keniston
2009-04-06 22:57         ` H. Peter Anvin
2009-04-16 23:30           ` Masami Hiramatsu
2009-04-16 23:41             ` H. Peter Anvin
2009-04-17 13:31               ` Masami Hiramatsu
2009-04-17 18:10                 ` H. Peter Anvin
2009-04-17  0:06             ` Jim Keniston
2009-04-17  0:10               ` H. Peter Anvin
2009-04-22  0:16                 ` Masami Hiramatsu
2009-04-23  0:47                   ` Jim Keniston
2009-04-23 17:27                     ` Masami Hiramatsu
2009-04-23 22:23                       ` Jim Keniston
2009-04-24  3:53                         ` Masami Hiramatsu

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=49D6ABD1.7040704@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jkenisto@us.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=systemtap@sources.redhat.com \
    --cc=vegard.nossum@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).