NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.23k stars 5.84k forks source link

PowerPC VLE e_rlwinm and e_rlwimi bit mask generation incorrect #1021

Closed revofrank closed 5 years ago

revofrank commented 5 years ago

These two instructions generate a bit mask using operands NB and ME. The operands are defined in the ppc_common.sinc file as "ME=(1,5)" and "NB= (11,15)". ME looks correct but NB is incorrectly set to the same location as the bit bit shift field "SHL=(11,15)".

I think the definition of NB in ppc_common.since should read "NB=(6,10)" instead.

As an example "74 63 37 7F" decodes using as "e_rlwinm A,S,SHL,NB,ME" with fields:

Which gives the incorrect current behavior: 08fd4168 74 63 37 7f e_rlwinm r3,r3,0x6,0x6,0x1f

Whereas the expected correct behavior taking NB=(6,10) would be: 08fd4168 74 63 37 7f e_rlwinm r3,r3,0x6,0x1d,0x1f

For reference the VLE reference manual e_rlwinm instruction is shown below. Note that Ghidra uses NB in place of MB and that the manual's bit ordering needs to be reversed. So operand MB at bits 21..25 would correspond to NB(6,10).

PowerPC VLE e_rlwinm instruction

GhidorahRex commented 5 years ago

Duplicate of #752