This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: x86 instruction classification
- From: Denys Vlasenko <dvlasenk at redhat dot com>
- To: Jim Keniston <jkenisto at us dot ibm dot com>
- Cc: utrace-devel <utrace-devel at redhat dot com>, systemtap <systemtap at sources dot redhat dot com>
- Date: Wed, 08 Apr 2009 14:33:41 +0200
- Subject: Re: x86 instruction classification
- References: <1238801021.3568.61.camel@dyn9047018139.beaverton.ibm.com>
On Fri, 2009-04-03 at 16:23 -0700, Jim Keniston wrote:
> As promised on yesterday's SystemTap call, here's inat.c. It consists
> of a couple of tables that capture more information about the x86
> instruction sets. For example, you could use this code to determine
> whether an opcode/instruction is invalid, privileged, a floating-point
> op, or in some other way of possible interest to uprobes and/or kprobes.
>
> Also included is cmp.c, a user program that provides an example of the
> tables' use and also serves as a check against the tables currently in
> use by x86 ubp/uprobes. (There are a few differences, which reflect
> either corrections in inat.c or differences in how the tables are used.)
>
> The intention is eventually provide this as an enhancement to our x86
> instruction-analysis code.
>
> inat.c uses the x86 kvm approach of one bitmap for each opcode.
>
> Comments welcome.
Nitpick:
static inline int test_bit(int nr, const volatile unsigned long *addr)
{
return ((1UL << (nr % BITS_PER_LONG)) &
(((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
}
Since nr is *signed* int, the nr / BITS_PER_LONG will be computed
like this:
leal 31(%rdi), %eax
testl %edi, %edi
cmovs %eax, %edi
sarl $5, %edi
With unsigned, it will be:
shrl $5, %edi
--
vda