Thread (23 messages) flat view 23 messages, 4 authors, 2015-07-22

Re: [RFC 5/8] powerpc/slb: Add documentation to runtime patching of SLB encoding

From: Segher Boessenkool <hidden>
Date: 2015-07-22 12:17:29

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help