On Fri, 9 Feb 2024 at 05:07, Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > From: Alexei Starovoitov <ast@xxxxxxxxxx> > > Introduce helper macro bpf_arena_cast() that emits: > rX = rX > instruction with off = BPF_ARENA_CAST_KERN or off = BPF_ARENA_CAST_USER > and encodes address_space into imm32. > > It's useful with older LLVM that doesn't emit this insn automatically. > > Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> > --- Acked-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> But could this simply be added to libbpf along with bpf_cast_user and bpf_cast_kern? I believe since LLVM and the verifier support the new cast instructions, they are unlikely to disappear any time soon. It would probably also make it easier to use elsewhere (e.g. sched-ext) without having to copy them. I plan on doing the same eventually with assert macros too.