From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 419812AE7C for ; Wed, 29 Jan 2025 02:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738116477; cv=none; b=NOBOxm14KRUD2zhc7Cu/rjCHgBl7pMuLc/v+GbnCFPleKLea78QIdddHnxLOUt2DerB7BDlrcEVRNAJ6/J0h0LEiNPw4XG27FvcCVQDZOquZVmLag4O4Q3r+OeYwnZHf9/bFL5CJkRSPaWBid1C+aVS1Tm787I8WUJrBDvPuFro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738116477; c=relaxed/simple; bh=TnoiYQPHEkMogIv/c06URwtZAs4Gs+dd5/MwQl3rCHo=; h=MIME-Version:Date:Content-Type:From:Message-ID:Subject:To:Cc: In-Reply-To:References; b=q5zItBxgGliLqG9FwJosNpZPW0FOXgSLP9Lw62HClc9ksVYHAirKJ4sPH1uGmq+w0r4kC+kyAxicN62ZUgn79ysn36TkpuabC3lLieLxvbEutzAWQVBrv6hgUFCE04/8AyLBoKBNekmuNvzfe4QtieGyUGZZz3rwazbo6VRUGIw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=AnTFkeq3; arc=none smtp.client-ip=91.218.175.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="AnTFkeq3" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1738116467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vxFwu5R7sxps9teXeOqSJ8ZpqQ5AyDlKfsho2IFEN1o=; b=AnTFkeq3b6TXFV6Ogt+Be6Mxklk3mFNdKxoBTZMKGjv6z+kBP4niiHFyeIBStgFb7sVpbT oOwaxOX7a5wNxuuCCkE6tjzYZd1dMMsCcTK6c3H9dcSb7ufLnFXhrKmmT5fk/ewLKEaj5v 1cVaY9C0o3MvHlI9WMsie9posK2fu+M= Date: Wed, 29 Jan 2025 02:07:45 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Ihor Solodrai" Message-ID: TLS-Required: No Subject: Re: [PATCH bpf-next v1 7/8] selftests/bpf: Add selftests for load-acquire and store-release instructions To: "Eduard Zingerman" , "Peilin Ye" , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: bpf@ietf.org, "Xu Kuohai" , "David Vernet" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "John Fastabend" , "KP Singh" , "Stanislav Fomichev" , "Hao Luo" , "Jiri Olsa" , "Jonathan Corbet" , "Paul E. McKenney" , "Puranjay Mohan" , "Catalin Marinas" , "Will Deacon" , "Quentin Monnet" , "Mykola Lysenko" , "Shuah Khan" , "Josh Don" , "Barret Rhoden" , "Neel Natu" , "Benjamin Segall" , linux-kernel@vger.kernel.org In-Reply-To: <131a817f7f2749e78e527a251ca7971588cf62f8.camel@gmail.com> References: <3f2de7c6e5d2def7bdfb091347c1dacea0915974.1737763916.git.yepeilin@google.com> <131a817f7f2749e78e527a251ca7971588cf62f8.camel@gmail.com> X-Migadu-Flow: FLOW_OUT January 28, 2025 at 5:06 PM, "Eduard Zingerman" wrote= : >=20 >=20On Sat, 2025-01-25 at 02:19 +0000, Peilin Ye wrote: >=20 >=20>=20 >=20> Add several ./test_progs tests: > >=20 >=20>=20=20 >=20>=20 >=20> - atomics/load_acquire > >=20 >=20> - atomics/store_release > >=20 >=20> - arena_atomics/load_acquire > >=20 >=20> - arena_atomics/store_release > >=20 >=20> - verifier_load_acquire/* > >=20 >=20> - verifier_store_release/* > >=20 >=20> - verifier_precision/bpf_load_acquire > >=20 >=20> - verifier_precision/bpf_store_release > >=20 >=20>=20=20 >=20>=20 >=20> The last two tests are added to check if backtrack_insn() handles = the > >=20 >=20> new instructions correctly. > >=20 >=20>=20=20 >=20>=20 >=20> Additionally, the last test also makes sure that the verifier > >=20 >=20> "remembers" the value (in src_reg) we store-release into e.g. a st= ack > >=20 >=20> slot. For example, if we take a look at the test program: > >=20 >=20>=20=20 >=20>=20 >=20> #0: "r1 =3D 8;" > >=20 >=20> #1: "store_release((u64 *)(r10 - 8), r1);" > >=20 >=20> #2: "r1 =3D *(u64 *)(r10 - 8);" > >=20 >=20> #3: "r2 =3D r10;" > >=20 >=20> #4: "r2 +=3D r1;" /* mark_precise */ > >=20 >=20> #5: "r0 =3D 0;" > >=20 >=20> #6: "exit;" > >=20 >=20>=20=20 >=20>=20 >=20> At #1, if the verifier doesn't remember that we wrote 8 to the sta= ck, > >=20 >=20> then later at #4 we would be adding an unbounded scalar value to t= he > >=20 >=20> stack pointer, which would cause the program to be rejected: > >=20 >=20>=20=20 >=20>=20 >=20> VERIFIER LOG: > >=20 >=20> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >=20 >=20> ... > >=20 >=20> math between fp pointer and register with unbounded min value is n= ot allowed > >=20 >=20>=20=20 >=20>=20 >=20> All new tests depend on the pre-defined __BPF_FEATURE_LOAD_ACQ_STO= RE_REL > >=20 >=20> feature macro, which implies -mcpu>=3Dv4. > >=20 >=20 > This restriction would mean that tests are skipped on BPF CI, as it >=20 >=20currently runs using llvm 17 and 18. Instead, I suggest using some Eduard, if this feature requires a particular version of LLVM, it's not difficult to add a configuration for it to BPF CI. Whether we want to do it is an open question though. Issues may come up with other tests when newer LLVM is used. >=20 >=20macro hiding an inline assembly as below: >=20 >=20 asm volatile (".8byte %[insn];" >=20 >=20 : >=20 >=20 : [insn]"i"(*(long *)&(BPF_RAW_INSN(...))) >=20 >=20 : /* correct clobbers here */); >=20 >=20See the usage of the __imm_insn() macro in the test suite. >=20 >=20Also, "BPF_ATOMIC loads from R%d %s is not allowed\n" and >=20 >=20 "BPF_ATOMIC stores into R%d %s is not allowed\n" >=20 >=20situations are not tested. >=20 >=20[...] >=20 >=20>=20 >=20 > [...] >