This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: x86 instruction classification


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]