On Wed, Jul 22, 2015 at 03:51:03PM +1000, Michael Ellerman wrote:
> How about:
> 
>       /*
>        * This function patches either an li or a cmpldi instruction with
>        * a new immediate value. This relies on the fact that both li
>        * (which is actually ori) and cmpldi both take a 16-bit immediate
>        * value, and it is situated in the same location in the instruction,
>        * ie. bits 0-15.
>        * To patch the value we read the existing instruction, clear the
>        * immediate value, and or in our new value, then write the instruction
>        * back.
>        */

As Gabriel says, li is addi.  It takes a 16-bit sign-extended immediate,
while cmpldi takes a 16-bit zero-extended immediate.  This function
doesn't deal with that difference, it probably should (I didn't check if
the callers take care; there should be an assertion somewhere).


Segher
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to