diff options
author | Tiezhu Yang <yangtiezhu@loongson.cn> | 2022-08-29 11:05:09 +0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-08-29 15:38:14 +0200 |
commit | bbcf0f55e57841e532ab395596db9197e8d53e8d (patch) | |
tree | 064f8ae5f1073140956797ba0d93b8a0ed9843ed /arch/mips/net/bpf_jit_comp64.c | |
parent | bpf: Fix a few typos in BPF helpers documentation (diff) | |
download | linux-dev-bbcf0f55e57841e532ab395596db9197e8d53e8d.tar.xz linux-dev-bbcf0f55e57841e532ab395596db9197e8d53e8d.zip |
bpf, mips: No need to use min() to get MAX_TAIL_CALL_CNT
MAX_TAIL_CALL_CNT is 33, so min(MAX_TAIL_CALL_CNT, 0xffff) is always
MAX_TAIL_CALL_CNT, it is better to use MAX_TAIL_CALL_CNT directly.
At the same time, add BUILD_BUG_ON(MAX_TAIL_CALL_CNT > 0xffff) with a
comment on why the assertion is there.
Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Suggested-by: Johan Almbladh <johan.almbladh@anyfinetworks.com>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/1661742309-2320-1-git-send-email-yangtiezhu@loongson.cn
Diffstat (limited to '')
-rw-r--r-- | arch/mips/net/bpf_jit_comp64.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/mips/net/bpf_jit_comp64.c b/arch/mips/net/bpf_jit_comp64.c index 6475828ffb36..0e7c1bdcf914 100644 --- a/arch/mips/net/bpf_jit_comp64.c +++ b/arch/mips/net/bpf_jit_comp64.c @@ -548,11 +548,19 @@ void build_prologue(struct jit_context *ctx) int stack, saved, locals, reserved; /* + * In the unlikely event that the TCC limit is raised to more + * than 16 bits, it is clamped to the maximum value allowed for + * the generated code (0xffff). It is better fail to compile + * instead of degrading gracefully. + */ + BUILD_BUG_ON(MAX_TAIL_CALL_CNT > 0xffff); + + /* * The first instruction initializes the tail call count register. * On a tail call, the calling function jumps into the prologue * after this instruction. */ - emit(ctx, ori, tc, MIPS_R_ZERO, min(MAX_TAIL_CALL_CNT, 0xffff)); + emit(ctx, ori, tc, MIPS_R_ZERO, MAX_TAIL_CALL_CNT); /* === Entry-point for tail calls === */ |