Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf, arm64: Factor out emit_a64_add_i()

As suggested by Xu, factor out emit_a64_add_i() for later use. No
functional change.

Suggested-by: Xu Kuohai <xukuohai@huaweicloud.com>
Signed-off-by: Peilin Ye <yepeilin@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/bpf/fedbaca80e6d8bd5bcba1ac5320dfbbdab14472e.1735868489.git.yepeilin@google.com

authored by

Peilin Ye and committed by
Daniel Borkmann
66bb58ac 0a580721

+14 -8
+14 -8
arch/arm64/net/bpf_jit_comp.c
··· 267 267 return !(imm & ~0xfff) || !(imm & ~0xfff000); 268 268 } 269 269 270 + static inline void emit_a64_add_i(const bool is64, const int dst, const int src, 271 + const int tmp, const s32 imm, struct jit_ctx *ctx) 272 + { 273 + if (is_addsub_imm(imm)) { 274 + emit(A64_ADD_I(is64, dst, src, imm), ctx); 275 + } else if (is_addsub_imm(-imm)) { 276 + emit(A64_SUB_I(is64, dst, src, -imm), ctx); 277 + } else { 278 + emit_a64_mov_i(is64, tmp, imm, ctx); 279 + emit(A64_ADD(is64, dst, src, tmp), ctx); 280 + } 281 + } 282 + 270 283 /* 271 284 * There are 3 types of AArch64 LDR/STR (immediate) instruction: 272 285 * Post-index, Pre-index, Unsigned offset. ··· 1157 1144 /* dst = dst OP imm */ 1158 1145 case BPF_ALU | BPF_ADD | BPF_K: 1159 1146 case BPF_ALU64 | BPF_ADD | BPF_K: 1160 - if (is_addsub_imm(imm)) { 1161 - emit(A64_ADD_I(is64, dst, dst, imm), ctx); 1162 - } else if (is_addsub_imm(-imm)) { 1163 - emit(A64_SUB_I(is64, dst, dst, -imm), ctx); 1164 - } else { 1165 - emit_a64_mov_i(is64, tmp, imm, ctx); 1166 - emit(A64_ADD(is64, dst, dst, tmp), ctx); 1167 - } 1147 + emit_a64_add_i(is64, dst, dst, tmp, imm, ctx); 1168 1148 break; 1169 1149 case BPF_ALU | BPF_SUB | BPF_K: 1170 1150 case BPF_ALU64 | BPF_SUB | BPF_K: