From: Michael Ellerman <mpe@ellerman.id.au>
To: Anshuman Khandual <khandual@linux.vnet.ibm.com>, linuxppc-dev@ozlabs.org
Cc: mikey@neuling.org, Segher Boessenkool <segher@kernel.crashing.org>
Subject: Re: [5/8] powerpc/slb: Add documentation to runtime patching of SLB encoding
Date: Wed, 12 Aug 2015 15:12:53 +1000 (AEST) [thread overview]
Message-ID: <20150812051253.7DEB91401DA@ozlabs.org> (raw)
In-Reply-To: <1438153805-31828-5-git-send-email-khandual@linux.vnet.ibm.com>
On Wed, 2015-29-07 at 07:10:02 UTC, Anshuman Khandual wrote:
> This patch adds some documentation to 'patch_slb_encoding' function
> explaining about how it clears the existing immediate value in the
> given instruction and inserts a new one there.
>
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> ---
> arch/powerpc/mm/slb.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
> index c87d5de..1962357 100644
> --- a/arch/powerpc/mm/slb.c
> +++ b/arch/powerpc/mm/slb.c
> @@ -279,7 +279,18 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
> static inline void patch_slb_encoding(unsigned int *insn_addr,
> unsigned int immed)
> {
> - int insn = (*insn_addr & 0xffff0000) | immed;
> +
> + /*
> + * 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 addi) and cmpldi both take a 16-bit immediate
> + * value, and it is situated in the same location in the instruction,
> + * ie. bits 16-31 (Big endian bit order) or the lower 16 bits.
> + * To patch the value we read the existing instruction, clear the
> + * immediate value, and or in our new value, then write the instruction
> + * back.
> + */
> + unsigned int insn = (*insn_addr & 0xffff0000) | immed;
> patch_instruction(insn_addr, insn);
> }
As Segher pointed out the signedness of the immediate value differs between the
instructions, I added:
+ * The signedness of the immediate operand differs between the two
+ * instructions however this code is only ever patching a small value,
+ * much less than 1 << 15, so we can get away with it.
cheers
next prev parent reply other threads:[~2015-08-12 5:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-29 7:09 [PATCH 1/8] powerpc/slb: Remove a duplicate extern variable Anshuman Khandual
2015-07-29 7:09 ` [PATCH 2/8] powerpc/slb: Rename all the 'slot' occurrences to 'entry' Anshuman Khandual
2015-08-13 1:44 ` [2/8] " Michael Ellerman
2015-07-29 7:10 ` [PATCH 3/8] powerpc/slb: Define macros for the bolted slots Anshuman Khandual
2015-07-29 7:10 ` [PATCH 4/8] powerpc/slb: Add some helper functions to improve modularization Anshuman Khandual
2015-08-12 4:11 ` [4/8] " Michael Ellerman
2015-08-12 6:36 ` Anshuman Khandual
2015-07-29 7:10 ` [PATCH 5/8] powerpc/slb: Add documentation to runtime patching of SLB encoding Anshuman Khandual
2015-08-12 5:12 ` Michael Ellerman [this message]
2015-08-13 1:44 ` [5/8] " Michael Ellerman
2015-07-29 7:10 ` [PATCH 6/8] powerpc/prom: Simplify the logic while fetching SLB size Anshuman Khandual
2015-08-13 1:44 ` [6/8] " Michael Ellerman
2015-07-29 7:10 ` [PATCH 7/8] powerpc/xmon: Drop the 'valid' variable completely in 'dump_segments' Anshuman Khandual
2015-08-13 1:44 ` [7/8] " Michael Ellerman
2015-07-29 7:10 ` [PATCH 8/8] powerpc/xmon: Add some more elements to the existing PACA dump list Anshuman Khandual
2015-08-12 6:05 ` Michael Ellerman
2015-08-12 6:27 ` Anshuman Khandual
2015-08-13 1:44 ` [1/8] powerpc/slb: Remove a duplicate extern variable Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150812051253.7DEB91401DA@ozlabs.org \
--to=mpe@ellerman.id.au \
--cc=khandual@linux.vnet.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mikey@neuling.org \
--cc=segher@kernel.crashing.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).