From: Dylan Hatch <dylanbhatch@google.com>
To: "Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Yonghong Song" <yonghong.song@linux.dev>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Hao Luo" <haoluo@google.com>, "Jiri Olsa" <jolsa@kernel.org>,
"Puranjay Mohan" <puranjay@kernel.org>,
"Xu Kuohai" <xukuohai@huaweicloud.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Song Liu" <song@kernel.org>, "Ard Biesheuvel" <ardb@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Dylan Hatch <dylanbhatch@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>
Subject: [PATCH v2 1/2] arm64: patching: Rename aarch64_insn_copy to text_poke.
Date: Sat, 12 Apr 2025 01:09:38 +0000 [thread overview]
Message-ID: <20250412010940.1686376-2-dylanbhatch@google.com> (raw)
In-Reply-To: <20250412010940.1686376-1-dylanbhatch@google.com>
Match the name and signature of the equivalent in the x86 text-poke API.
Making the src pointer const also allows this function to be
interchangeable with memcpy().
Signed-off-by: Dylan Hatch <dylanbhatch@google.com>
---
arch/arm64/include/asm/text-patching.h | 2 +-
arch/arm64/kernel/patching.c | 12 ++++++------
arch/arm64/net/bpf_jit_comp.c | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/arm64/include/asm/text-patching.h b/arch/arm64/include/asm/text-patching.h
index 587bdb91ab7a6..450d806d11109 100644
--- a/arch/arm64/include/asm/text-patching.h
+++ b/arch/arm64/include/asm/text-patching.h
@@ -9,7 +9,7 @@ int aarch64_insn_write(void *addr, u32 insn);
int aarch64_insn_write_literal_u64(void *addr, u64 val);
void *aarch64_insn_set(void *dst, u32 insn, size_t len);
-void *aarch64_insn_copy(void *dst, void *src, size_t len);
+void *text_poke(void *dst, const void *src, size_t len);
int aarch64_insn_patch_text_nosync(void *addr, u32 insn);
int aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt);
diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c
index 1041bc67a3eee..e07dc32620053 100644
--- a/arch/arm64/kernel/patching.c
+++ b/arch/arm64/kernel/patching.c
@@ -102,9 +102,9 @@ noinstr int aarch64_insn_write_literal_u64(void *addr, u64 val)
return ret;
}
-typedef void text_poke_f(void *dst, void *src, size_t patched, size_t len);
+typedef void text_poke_f(void *dst, const void *src, size_t patched, size_t len);
-static void *__text_poke(text_poke_f func, void *addr, void *src, size_t len)
+static void *__text_poke(text_poke_f func, void *addr, const void *src, size_t len)
{
unsigned long flags;
size_t patched = 0;
@@ -132,12 +132,12 @@ static void *__text_poke(text_poke_f func, void *addr, void *src, size_t len)
return addr;
}
-static void text_poke_memcpy(void *dst, void *src, size_t patched, size_t len)
+static void text_poke_memcpy(void *dst, const void *src, size_t patched, size_t len)
{
copy_to_kernel_nofault(dst, src + patched, len);
}
-static void text_poke_memset(void *dst, void *src, size_t patched, size_t len)
+static void text_poke_memset(void *dst, const void *src, size_t patched, size_t len)
{
u32 c = *(u32 *)src;
@@ -145,14 +145,14 @@ static void text_poke_memset(void *dst, void *src, size_t patched, size_t len)
}
/**
- * aarch64_insn_copy - Copy instructions into (an unused part of) RX memory
+ * text_poke - Copy instructions into (an unused part of) RX memory
* @dst: address to modify
* @src: source of the copy
* @len: length to copy
*
* Useful for JITs to dump new code blocks into unused regions of RX memory.
*/
-noinstr void *aarch64_insn_copy(void *dst, void *src, size_t len)
+noinstr void *text_poke(void *dst, const void *src, size_t len)
{
/* A64 instructions must be word aligned */
if ((uintptr_t)dst & 0x3)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 70d7c89d3ac90..b5be90edff410 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -2047,7 +2047,7 @@ bool bpf_jit_supports_kfunc_call(void)
void *bpf_arch_text_copy(void *dst, void *src, size_t len)
{
- if (!aarch64_insn_copy(dst, src, len))
+ if (!text_poke(dst, src, len))
return ERR_PTR(-EINVAL);
return dst;
}
--
2.49.0.604.gff1f9ca942-goog
next prev parent reply other threads:[~2025-04-12 1:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-12 1:09 [PATCH v2 0/2] arm64/module: Enable late module relocations Dylan Hatch
2025-04-12 1:09 ` Dylan Hatch [this message]
2025-04-21 22:14 ` [PATCH v2 1/2] arm64: patching: Rename aarch64_insn_copy to text_poke Dylan Hatch
2025-04-22 0:32 ` Song Liu
2025-04-12 1:09 ` [PATCH v2 2/2] arm64/module: Use text-poke API for late relocations Dylan Hatch
2025-04-22 0:35 ` Song Liu
2025-04-22 6:25 ` Song Liu
2025-04-23 0:27 ` Dylan Hatch
2025-04-23 4:42 ` Song Liu
2025-04-23 6:04 ` Toshiyuki Sato (Fujitsu)
2025-04-23 22:59 ` Dylan Hatch
2025-04-29 18:26 ` Dylan Hatch
2025-05-09 16:15 ` Will Deacon
2025-05-09 16:39 ` Song Liu
2025-05-22 23:35 ` Dylan Hatch
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=20250412010940.1686376-2-dylanbhatch@google.com \
--to=dylanbhatch@google.com \
--cc=akpm@linux-foundation.org \
--cc=andrii@kernel.org \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=geert@linux-m68k.org \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=mcgrof@kernel.org \
--cc=philmd@linaro.org \
--cc=puranjay@kernel.org \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=will@kernel.org \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
/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.