From patchwork Sun Dec 17 13:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 180006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp700065dyi; Sun, 17 Dec 2023 05:19:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWPZ39jvl/6IkUEShI5Rfq82Bw79vKh/xtK/EvQBexylQZ4DvqHl87zFt7CAfDD/GmMEsC X-Received: by 2002:a50:cd83:0:b0:551:49af:b363 with SMTP id p3-20020a50cd83000000b0055149afb363mr2216572edi.62.1702819167924; Sun, 17 Dec 2023 05:19:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702819167; cv=none; d=google.com; s=arc-20160816; b=e4GsuBpA2RZbyYtS2aejJEivA7EkcVY1Qwr7UDD5mXRegJXeQjTHYDy1WXjOux5rij DF6e/Fjrg+sGdtP2Gt4tWDUcrbe0CTHS94NcWxbKp4qeGPHnkv+7o6kLL+8zV6jLkgP2 mflO8l0NwJZxT9s0PcyiAlcA8Ito31P00gFHg8XH+aG1u3DrlWgmEHS9q9lui/rBbesd qsHH2+sLkE6P4SpdzgzxXz4aKBhUgnUx1qBMk/bWllKO0D/H2A76En1tYQdKA6eyU/TW xD4G1pNhQWRXaHKRb0ZRyxa8J53kWApEJlJa5tD+9gN3GZ6E85UY/6UON1EXesJavJte 4syw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/5PxWUcu/ifiy+mTxB+eS5k2/O2oeySj89/JuoUzQzw=; fh=3dzUsPYTl3D+ZKzqLZpqv8iP7qE8k4oK6Kaq6YzhUUQ=; b=d8bYScQ8hWKL0QBrBSTlinVCNX8herB+EpaMM4dUCmevUEYWhqRIIN00wMuUP7e4dt gIRg+yz0GjhbQ4sPuG+jw4V+tREUJsCw6GbMTw3V00Y4aKOU/OTM5H0SflURby8UbgXT NtlQlrPFRMGJEbsKk4xfGBGX+FV2+OkviizOApYbREYYYI/RCP0c+RcJmP4iPNSJt/9x NdQ9BVzl7GPIoeM8fA5B+GBnkClmJdVdH1JdwGPH+N9ZTi27M2nuCfb2eOxSUE+vpxhv rtAGKkC3Uwa83QlfPaGSvyxzumM9BBH4dFcCd27Xtd85YcTTLzl0pwUUfw0Hgh82eg/X dKrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RzKLY7MN; spf=pass (google.com: domain of linux-kernel+bounces-2598-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2598-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w17-20020a056402269100b0054c90700948si9345882edd.321.2023.12.17.05.19.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:19:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2598-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RzKLY7MN; spf=pass (google.com: domain of linux-kernel+bounces-2598-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2598-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 882CC1F21F16 for ; Sun, 17 Dec 2023 13:19:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB58844C80; Sun, 17 Dec 2023 13:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RzKLY7MN" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E11DB446D3; Sun, 17 Dec 2023 13:18:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-6d3165ac96bso226580b3a.0; Sun, 17 Dec 2023 05:18:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702819119; x=1703423919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/5PxWUcu/ifiy+mTxB+eS5k2/O2oeySj89/JuoUzQzw=; b=RzKLY7MNyryEyzhFh/RudabzSklYQPMtFF3J1EMz3YQgnADBRtufbCETHLfhHrv1FW /38nQsqt9I3k1ul9seIQtBVJH0LXt5gyywKTRgrPv4fzrnDKfw5iBt8ZWyimeCNpiRFj NwuCHrk2jnOXz2tquCqOwK2fU36R+hHOJG45UvEQPW6Q6a/tpnXgRzJsU3ASIPKs7VPi SlK1876oVUJlwt5Q/W+x707FZ4YET0BpZa+5YZxY6zccpX8FkQicJkcFkl0Y2ddbmoEB yuxws+3eXq/NoxFr4aaIYZk1NRbi8kXdDZm/F7dcqPiYdCemI0ffFdcsFCpYZ7aO67AY W9Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702819119; x=1703423919; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/5PxWUcu/ifiy+mTxB+eS5k2/O2oeySj89/JuoUzQzw=; b=t7Orx+RSEFW4M2FOXNNVUqcEACVW3ealtviMH6KbFXJ6fsRXfLdWaY5sSjKhsNCxfi z93ckoWIbUrv4KUR2UWjUHBAXYnGn/2Y9VI4E01PYmmFrJhSqLetaaQYkr7u9C//CmDT 5wtkzlpk/b9sAW3rBrAiCssxQVZb+YAhx3IHz4P0hu+GswuxGffCuLd1zL6Ej+mOUb6N To8gOEZ9CkU9ixYlQZ2ho/V7u+sAejgvjR4mETA0foqhlLj5eXqffVywqi6bC1TO8Y19 1wppkszcFqDTTuke7gcyDZ8Eg7dJoCW5gqVgwNUaDv0NDEQwxpKZoA7PzpJztZW+H5sT DSfA== X-Gm-Message-State: AOJu0Yw+plCUc5xijHbqwk+Nty3Q7Bt8D1INbvv9jNnsZ5kf4X4kYeHd 6AkFrYi2h3NUaT+QWCz0U+Q= X-Received: by 2002:a05:6a20:7d93:b0:18f:97c:8244 with SMTP id v19-20020a056a207d9300b0018f097c8244mr9127608pzj.78.1702819119160; Sun, 17 Dec 2023 05:18:39 -0800 (PST) Received: from localhost.localdomain ([43.129.244.20]) by smtp.gmail.com with ESMTPSA id h10-20020a170902f7ca00b001d395d3df30sm1099425plw.130.2023.12.17.05.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 05:18:38 -0800 (PST) From: Menglong Dong To: andrii@kernel.org, eddyz87@gmail.com, yonghong.song@linux.dev, alexei.starovoitov@gmail.com Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, martin.lau@linux.dev, song@kernel.org, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: [PATCH bpf-next v4 2/3] selftests/bpf: activate the OP_NE login in range_cond() Date: Sun, 17 Dec 2023 21:17:15 +0800 Message-Id: <20231217131716.830290-3-menglong8.dong@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231217131716.830290-1-menglong8.dong@gmail.com> References: <20231217131716.830290-1-menglong8.dong@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785535311883956677 X-GMAIL-MSGID: 1785535311883956677 The edge range checking for the registers is supported by the verifier now, so we can activate the extended login in tools/testing/selftests/bpf/prog_tests/reg_bounds.c/range_cond() to test such logic. Besides, I added some cases to the "crafted_cases" array for this logic. These cases are mainly used to test the edge of the src reg and dst reg. All reg bounds testings has passed in the SLOW_TESTS mode: $ export SLOW_TESTS=1 && ./test_progs -t reg_bounds -j Summary: 65/18959832 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Menglong Dong --- v3: - do some adjustment to the crafted cases that we added v2: - add some cases to the "crafted_cases" --- .../selftests/bpf/prog_tests/reg_bounds.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/reg_bounds.c b/tools/testing/selftests/bpf/prog_tests/reg_bounds.c index 0c9abd279e18..c9dc9fe73211 100644 --- a/tools/testing/selftests/bpf/prog_tests/reg_bounds.c +++ b/tools/testing/selftests/bpf/prog_tests/reg_bounds.c @@ -590,12 +590,7 @@ static void range_cond(enum num_t t, struct range x, struct range y, *newy = range(t, max_t(t, x.a, y.a), min_t(t, x.b, y.b)); break; case OP_NE: - /* generic case, can't derive more information */ - *newx = range(t, x.a, x.b); - *newy = range(t, y.a, y.b); - break; - - /* below extended logic is not supported by verifier just yet */ + /* below logic is supported by the verifier now */ if (x.a == x.b && x.a == y.a) { /* X is a constant matching left side of Y */ *newx = range(t, x.a, x.b); @@ -2101,6 +2096,19 @@ static struct subtest_case crafted_cases[] = { {S32, S64, {(u32)(s32)S32_MIN, (u32)(s32)-255}, {(u32)(s32)-2, 0}}, {S32, S64, {0, 1}, {(u32)(s32)S32_MIN, (u32)(s32)S32_MIN}}, {S32, U32, {(u32)(s32)S32_MIN, (u32)(s32)S32_MIN}, {(u32)(s32)S32_MIN, (u32)(s32)S32_MIN}}, + + /* edge overlap testings for BPF_NE, skipped some cases that already + * exist above. + */ + {U64, U64, {0, U64_MAX}, {U64_MAX, U64_MAX}}, + {U64, U64, {0, U64_MAX}, {0, 0}}, + {S64, U64, {S64_MIN, 0}, {S64_MIN, S64_MIN}}, + {S64, U64, {S64_MIN, 0}, {0, 0}}, + {S64, U64, {S64_MIN, S64_MAX}, {S64_MAX, S64_MAX}}, + {U32, U32, {0, U32_MAX}, {0, 0}}, + {S32, U32, {(u32)(s32)S32_MIN, 0}, {0, 0}}, + {S32, U32, {(u32)(s32)S32_MIN, 0}, {(u32)(s32)S32_MIN, (u32)(s32)S32_MIN}}, + {S32, U32, {(u32)(s32)S32_MIN, S32_MAX}, {S32_MAX, S32_MAX}}, }; /* Go over crafted hard-coded cases. This is fast, so we do it as part of