[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871qfprjeg.fsf@all.your.base.are.belong.to.us>
Date: Sat, 26 Aug 2023 16:02:47 +0200
From: Björn Töpel <bjorn@...nel.org>
To: Puranjay Mohan <puranjay12@...il.com>, paul.walmsley@...ive.com,
palmer@...belt.com, aou@...s.berkeley.edu, pulehui@...wei.com,
conor.dooley@...rochip.com, ast@...nel.org, daniel@...earbox.net,
andrii@...nel.org, martin.lau@...ux.dev, song@...nel.org,
yhs@...com, kpsingh@...nel.org, bpf@...r.kernel.org,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: puranjay12@...il.com
Subject: Re: [PATCH bpf-next v2 2/3] riscv: implement a memset like function
for text
Puranjay Mohan <puranjay12@...il.com> writes:
> The BPF JIT needs to write invalid instructions to RX regions of memory
> to invalidate removed BPF programs. This needs a function like memset()
> that can work with RX memory.
>
> Implement patch_text_set_nosync() which is similar to text_poke_set() of
> x86.
Some additional nits, in addition to the other comments (Song, kernel
test bot, Lehui).
> Signed-off-by: Puranjay Mohan <puranjay12@...il.com>
> ---
> arch/riscv/include/asm/patch.h | 1 +
> arch/riscv/kernel/patch.c | 74 ++++++++++++++++++++++++++++++++++
> 2 files changed, 75 insertions(+)
>
> diff --git a/arch/riscv/include/asm/patch.h b/arch/riscv/include/asm/patch.h
> index 63c98833d510..aa5c1830ea43 100644
> --- a/arch/riscv/include/asm/patch.h
> +++ b/arch/riscv/include/asm/patch.h
> @@ -7,6 +7,7 @@
> #define _ASM_RISCV_PATCH_H
>
> int patch_text_nosync(void *addr, const void *insns, size_t len);
> +int patch_text_set_nosync(void *addr, const int c, size_t len);
> int patch_text(void *addr, u32 *insns, int ninsns);
>
> extern int riscv_patch_in_stop_machine;
> diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
> index 465b2eebbc37..24d49999ac1a 100644
> --- a/arch/riscv/kernel/patch.c
> +++ b/arch/riscv/kernel/patch.c
> @@ -13,6 +13,7 @@
> #include <asm/fixmap.h>
> #include <asm/ftrace.h>
> #include <asm/patch.h>
> +#include <asm/string.h>
>
> struct patch_insn {
> void *addr;
> @@ -53,6 +54,34 @@ static void patch_unmap(int fixmap)
> }
> NOKPROBE_SYMBOL(patch_unmap);
>
> +static int __patch_insn_set(void *addr, const int c, size_t len)
Drop the "const" from "const int c" everywhere in this patch, and let's
just use u8 instead of int. We don't need to carry the old memset()
legacy argumentts! We're more modern than that! ;-)
Björn
Powered by blists - more mailing lists