From: Benjamin Gray <bgray@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Cc: Benjamin Gray <bgray@linux.ibm.com>
Subject: [PATCH v1 3/3] powerpc/code-patching: Optimise patch_memcpy() to 4 byte chunks
Date: Fri, 15 Mar 2024 13:57:36 +1100 [thread overview]
Message-ID: <20240315025736.404867-3-bgray@linux.ibm.com> (raw)
In-Reply-To: <20240315025736.404867-1-bgray@linux.ibm.com>
As we are patching instructions, we can assume the length is a multiple
of 4 and the destination address is aligned.
Atomicity of patching a prefixed instruction is not a concern, as the
original implementation doesn't provide it anyway.
Signed-off-by: Benjamin Gray <bgray@linux.ibm.com>
---
arch/powerpc/lib/code-patching.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
index c6633759b509..ed450a32918c 100644
--- a/arch/powerpc/lib/code-patching.c
+++ b/arch/powerpc/lib/code-patching.c
@@ -394,10 +394,10 @@ static int patch_memset32(u32 *addr, u32 val, size_t count)
return -EPERM;
}
-static int patch_memcpy(void *dst, void *src, size_t len)
+static int patch_memcpy32(u32 *dst, u32 *src, size_t count)
{
- for (void *end = src + len; src < end; dst++, src++)
- __put_kernel_nofault(dst, src, u8, failed);
+ for (u32 *end = src + count; src < end; dst++, src++)
+ __put_kernel_nofault(dst, src, u32, failed);
return 0;
@@ -424,7 +424,7 @@ static int __patch_instructions(u32 *patch_addr, u32 *code, size_t len, bool rep
err = patch_memset32(patch_addr, val, len / 4);
}
} else {
- err = patch_memcpy(patch_addr, code, len);
+ err = patch_memcpy32(patch_addr, code, len / 4);
}
smp_wmb(); /* smp write barrier */
--
2.44.0
next prev parent reply other threads:[~2024-03-15 3:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 2:57 [PATCH v1 1/3] powerpc/code-patching: Test patch_instructions() during boot Benjamin Gray
2024-03-15 2:57 ` [PATCH v1 2/3] powerpc/code-patching: Use dedicated memory routines for patching Benjamin Gray
2024-03-15 3:17 ` Benjamin Gray
2024-03-15 6:36 ` Christophe Leroy
2024-03-17 21:42 ` Benjamin Gray
2024-03-15 2:57 ` Benjamin Gray [this message]
2024-03-15 6:39 ` [PATCH v1 3/3] powerpc/code-patching: Optimise patch_memcpy() to 4 byte chunks Christophe Leroy
2024-03-17 21:44 ` Benjamin Gray
2024-03-15 7:14 ` [PATCH v1 1/3] powerpc/code-patching: Test patch_instructions() during boot Christophe Leroy
2024-03-17 21:38 ` Benjamin Gray
2024-03-17 22:23 ` Benjamin Gray
2024-03-18 2:25 ` Michael Ellerman
2024-03-17 22:24 ` Benjamin Gray
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=20240315025736.404867-3-bgray@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.