Skip to content

Commit ed1a1fe

Browse files
Chenghao Duanchenhuacai
authored andcommitted
LoongArch: BPF: Rename and refactor validate_code()
1. Rename the existing validate_code() to validate_ctx() 2. Factor out the code validation handling into a new helper validate_code() Then: * validate_code() is used to check the validity of code. * validate_ctx() is used to check both code validity and table entry correctness. The new validate_code() will be used in subsequent changes. Reviewed-by: Hengqi Chen <hengqi.chen@gmail.com> 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>
1 parent 6ab55e0 commit ed1a1fe

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/loongarch/net/bpf_jit.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,14 @@ static int validate_code(struct jit_ctx *ctx)
11801180
return -1;
11811181
}
11821182

1183+
return 0;
1184+
}
1185+
1186+
static int validate_ctx(struct jit_ctx *ctx)
1187+
{
1188+
if (validate_code(ctx))
1189+
return -1;
1190+
11831191
if (WARN_ON_ONCE(ctx->num_exentries != ctx->prog->aux->num_exentries))
11841192
return -1;
11851193

@@ -1288,7 +1296,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
12881296
build_epilogue(&ctx);
12891297

12901298
/* 3. Extra pass to validate JITed code */
1291-
if (validate_code(&ctx)) {
1299+
if (validate_ctx(&ctx)) {
12921300
bpf_jit_binary_free(header);
12931301
prog = orig_prog;
12941302
goto out_offset;

0 commit comments

Comments
 (0)