Re: arch_prepare_bpf_trampoline() for arm ?
From: KP Singh <kpsingh@kernel.org>
Date: 2021-02-24 21:31:35
I checked with Will about it and learnt that ARM64 does support patching certain instructions (e.g. branch, brk, nops) using aarch64_insn_patch_text_nosync, it's used in ftrace: https://elixir.bootlin.com/linux/latest/source/arch/arm64/kernel/ftrace.c#L24 But one has to tolerate that not all CPUs will execute these instructions until a context synchronization happens due to an exception or an ISB instruction. But I think we can start with the same thing that FTrace does? - KP On Wed, Feb 24, 2021 at 10:01 PM Daniel Borkmann [off-list ref] wrote:
On 2/24/21 8:54 PM, Luigi Rizzo wrote:quoted
I prepared a BPF version of kstats[1] https://github.com/luigirizzo/lr-cstats that uses fentry/fexit hooks to monitor the execution time of a kernel function. I hoped to have it working on ARM64 too, but it looks like arch_prepare_bpf_trampoline() only exists for x86. Is there any outstanding patch for this function on ARM64, or any similar function I could look at to implement it myself ?Not that I'm currently aware of, arm64 support would definitely be great to have. From x86 side, the underlying arch dependency was basically on text_poke_bp() to patch instructions on a live kernel. Haven't checked recently whether an equivalent exists on arm64 yet, but perhaps Will might know.quoted
[1] kstats is an in-kernel also in the above repo and previously discussed at https://lwn.net/Articles/813303/