-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix PowerPC:BE:64 LQ instruction to support signed offsets #6827
base: master
Are you sure you want to change the base?
Conversation
Based on the Power ISA manual sign extended DQ<<4 is added to RA to get source EA.
This looks like a good fix. I would drop BITS_0_3 entirely. I'm not sure why your example binary has it set to something other than 0, but the Power ISA manual specifically says that the reserved bits are ignored. I had to double-check this since I was sure this was a bug. I would also change the line setting I also think if we're making this fix, we should fix the |
Thanks for looking into this! BITS_0_3 includes an AS/400 (IBM i) specific mask used by (at least) the ILE C compiler for safety checks: I developed the Processor module to get insight about such vendor-specific details, so I'd prefer this information to be included upstream as well. Please let me know if/how this can work for you! In the meantime I'll test your proposed changes and will add the code for STQ in this PR as well. |
I think it might be worth creating a separate AS variant for memory tagging instruction support that sets/unsets XER[43], since that behavior in LQ and STQ is specific to this processor. and also supports the other instructions - SETTAG, TXER, SEL*, LTPTR, SCV. |
I pushed the requested changes. I created some very basic test files that are disassembled as expected: lq_test.bin:
stq_test.bin:
|
Based on the Power ISA manual sign extended DQ<<4 is added to RA to get source EA.
I'm working on adding support for AS/400 programs to Ghidra. While my code is available in a dedicated repository, I'd like to see at least the Processor module improvements upstreamed. This PR is my first attempt to contribute code to Ghidra, so this is just a minimal change, and I'd appreciate any further feedback on how to improve the rest of the Processor module and maybe even getting the Loader/Analyzer exts to the project!
This PR can be tested with the following instruction (also present in the DEREF2.pgm shared here):
e1 1f ff b1 lq r8,-50(r31),0x01
This instruction doesn't decompile with the existing
PowerPC:BE:64:A2-32addr
language variant (which includesppc_isa.sinc
that definesLQ
), but it correctly decompiles with this fix.