diff options
author | Chenghao Duan <duanchenghao@kylinos.cn> | 2025-08-05 19:00:18 +0800 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2025-08-05 19:00:18 +0800 |
commit | 9fbd18cf4c69f512f7de3ab73235078f3e32ecec (patch) | |
tree | cb9f968dafa0a2544a74c262fff54806226217c9 /scripts | |
parent | ed1a1fe6ec5e73b23b310b434ace07d1e5060657 (diff) |
LoongArch: BPF: Add dynamic code modification support
This commit adds support for BPF dynamic code modification on the
LoongArch architecture:
1. Add bpf_arch_text_copy() for instruction block copying.
2. Add bpf_arch_text_poke() for runtime instruction patching.
3. Add bpf_arch_text_invalidate() for code invalidation.
On LoongArch, since symbol addresses in the direct mapping region can't
be reached via relative jump instructions from the paged mapping region,
we use the move_imm+jirl instruction pair as absolute jump instructions.
These require 2-5 instructions, so we reserve 5 NOP instructions in the
program as placeholders for function jumps.
The larch_insn_text_copy() function is solely used for BPF. And the use
of larch_insn_text_copy() requires PAGE_SIZE alignment. Currently, only
the size of the BPF trampoline is page-aligned.
Co-developed-by: George Guo <guodongtai@kylinos.cn>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
Signed-off-by: Chenghao Duan <duanchenghao@kylinos.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions