x86 instruction classification
Denys Vlasenko
dvlasenk@redhat.com
Wed Apr 8 12:34:00 GMT 2009
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
More information about the Systemtap
mailing list