mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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 <bjorn@kernel.org> Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU/RVA23 Signed-off-by: Peilin Ye <yepeilin@google.com> Reviewed-by: Pu Lehui <pulehui@huawei.com> Link: https://lore.kernel.org/r/09cb2aec979aaed9d16db41f0f5b364de39377c0.1746588351.git.yepeilin@google.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
		
							parent
							
								
									b69d4413aa
								
							
						
					
					
						commit
						fce7bd8e38
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		| 
						 | 
					@ -3649,16 +3649,16 @@ static int insn_def_regno(const struct bpf_insn *insn)
 | 
				
			||||||
	case BPF_ST:
 | 
						case BPF_ST:
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	case BPF_STX:
 | 
						case BPF_STX:
 | 
				
			||||||
		if ((BPF_MODE(insn->code) == BPF_ATOMIC ||
 | 
							if (BPF_MODE(insn->code) == BPF_ATOMIC ||
 | 
				
			||||||
		     BPF_MODE(insn->code) == BPF_PROBE_ATOMIC) &&
 | 
							    BPF_MODE(insn->code) == BPF_PROBE_ATOMIC) {
 | 
				
			||||||
		    (insn->imm & BPF_FETCH)) {
 | 
					 | 
				
			||||||
			if (insn->imm == BPF_CMPXCHG)
 | 
								if (insn->imm == BPF_CMPXCHG)
 | 
				
			||||||
				return BPF_REG_0;
 | 
									return BPF_REG_0;
 | 
				
			||||||
			else
 | 
								else if (insn->imm == BPF_LOAD_ACQ)
 | 
				
			||||||
 | 
									return insn->dst_reg;
 | 
				
			||||||
 | 
								else if (insn->imm & BPF_FETCH)
 | 
				
			||||||
				return insn->src_reg;
 | 
									return insn->src_reg;
 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return -1;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							return -1;
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		return insn->dst_reg;
 | 
							return insn->dst_reg;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue