[RFC] a little disassembly infrastructure
sonny
sonny at burdell.org
Sat Oct 25 09:13:53 EST 2008
Hollis Blanchard wrote:
> Hi, I wrote this patch for KVM [1], but now that I look closer it seems
> like there might be some overlapping functionality.
>
> First there's emulate_instruction(), but since that only handles a few
> instructions it's just an ordered list of if ((instruction & MASK_A) ==
> INST_A) tests, so it doesn't actually parse out opcodes or anything.
>
> I've also found xmon's ppc-opc.c. That parses the opcode and operands,
> so could use some shared macros. Of course, the actual lookup isn't
> time-sensitive, so that doesn't make sense to share. On the other hand,
> if we do come up with something fast *and* robust for KVM, maybe xmon
> could use that.
>
> Of course, these macros alone is pretty small, so maybe it's not a big
> deal to make a kvm-specific copy of them, leaving the other uses alone.
>
> Comments?
>
> [1] KVM on PowerPC traps when privileged instructions are executed in
> the guest context. We must then (quickly!) disassemble them and emulate
> their behavior. Right now we do this with a giant switch statement or
> two, but are considering more sophisticated techniques in the future.
>
Yeah, personally I like this change. I was looking at emulating some
PPC instructions in a driver and based on inspection I was going to use
the code you had in for KVM. Having these macros in a generic header is
a "Good Thing" IMHO. I think we should have a generic disassembly
infrastructure and use that everywhere.
More information about the Linuxppc-dev
mailing list