Skip to content

Commit fce7bd8

Browse files
peilin-yeAlexei Starovoitov
authored andcommitted
bpf/verifier: Handle BPF_LOAD_ACQ instructions in insn_def_regno()
In preparation for supporting BPF load-acquire and store-release instructions for architectures where bpf_jit_needs_zext() returns true (e.g. riscv64), make insn_def_regno() handle load-acquires properly. Acked-by: Björn Töpel <[email protected]> Tested-by: Björn Töpel <[email protected]> # QEMU/RVA23 Signed-off-by: Peilin Ye <[email protected]> Reviewed-by: Pu Lehui <[email protected]> Link: https://lore.kernel.org/r/09cb2aec979aaed9d16db41f0f5b364de39377c0.1746588351.git.yepeilin@google.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent b69d441 commit fce7bd8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

kernel/bpf/verifier.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,16 +3649,16 @@ static int insn_def_regno(const struct bpf_insn *insn)
36493649
case BPF_ST:
36503650
return -1;
36513651
case BPF_STX:
3652-
if ((BPF_MODE(insn->code) == BPF_ATOMIC ||
3653-
BPF_MODE(insn->code) == BPF_PROBE_ATOMIC) &&
3654-
(insn->imm & BPF_FETCH)) {
3652+
if (BPF_MODE(insn->code) == BPF_ATOMIC ||
3653+
BPF_MODE(insn->code) == BPF_PROBE_ATOMIC) {
36553654
if (insn->imm == BPF_CMPXCHG)
36563655
return BPF_REG_0;
3657-
else
3656+
else if (insn->imm == BPF_LOAD_ACQ)
3657+
return insn->dst_reg;
3658+
else if (insn->imm & BPF_FETCH)
36583659
return insn->src_reg;
3659-
} else {
3660-
return -1;
36613660
}
3661+
return -1;
36623662
default:
36633663
return insn->dst_reg;
36643664
}

0 commit comments

Comments
 (0)