Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6328968rdb; Thu, 14 Dec 2023 15:24:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3EHxCrh+/itg+Vzr6mGlhtfEyazGkXupvEaxIdCuiR06s5d38898/LuLMCPxwuhCQD4OO X-Received: by 2002:a05:6808:3306:b0:3ba:1380:20c7 with SMTP id ca6-20020a056808330600b003ba138020c7mr7561273oib.96.1702596283494; Thu, 14 Dec 2023 15:24:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702596283; cv=none; d=google.com; s=arc-20160816; b=FLN8BZ+Yv2Y9VwlwU2DFRZOeorJFf7JTrKezY6/YS/H/B9Dqf0vXxloTAN6LY7K6/c EwgAhR8BgvFZdxPFhR3qLNzn4sGsO4kX6P/hwGGnEM7H7SSHN6ZeNMYI246I8Ml0f2kW SF9l9qgi9BcWT7WYO4/3DU95eQIcTiFSA/1t9uWpImkEC5SeX8/LaQL7m4NbMSdd/yg3 VltqCcktaVBCZKfTbhXqRCGHNaYVmgms/Vmo3ZnqT++TEbtL3X+vyD4a2MWARkc1lYUG jyNLyIvmOEKEvBy1nRDiIyAoNwjPicILQ3xaFysoy6fX4BaOrMoP0BYgMYNluDNchy8j V7qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=pH7KARAejqAmd4NZA5cpMQIeqpV2b6Ne0T86GLGIoxM=; fh=CDb/2HM/RruQ8Rr32aeDN6Wvt2kfLe10J5w+RHIEnFk=; b=MiVyNPZpyz/tFAKQXrX+HixbSSDrG1F8PLWcJlcP9UHYAhz7n+GzVw9wCFUDz0Q1lB A0x+Ob7yOCaxixXJVSbqSbHle7kBJrIWgHSmsviF741c997xdinvPV0m1KcA4QDnrHUB 4BQbDbKRaAvLx4cgSzV3Dw9IK6QUX8Xgkkylm9zdKda2shQUhdKqz4DfWUDxGi7x7ANO FEeqbmjlsrDWFo2XK98yLTrTs45eldH/l9Vj9VtnArC7Rzo2HxUMJH7p9BIEUUmZmbBI ffZmOs3iB9dpo4YblEEqw408Y4f8IKlpQBBOtjNVVxW64o3Y5aAkd3dh9BRhwGNM0Rhu Kg8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eIsT7k7x; spf=pass (google.com: domain of linux-kernel+bounces-246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b4-20020a0ce884000000b0067a084c38f3si3788099qvo.205.2023.12.14.15.24.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 15:24:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eIsT7k7x; spf=pass (google.com: domain of linux-kernel+bounces-246-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-246-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 33ADA1C20D1C for ; Thu, 14 Dec 2023 23:24:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F04A224DF; Thu, 14 Dec 2023 23:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIsT7k7x" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 B1E4A6C6DC; Thu, 14 Dec 2023 23:24:31 +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-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-55225ed7ef9so64992a12.3; Thu, 14 Dec 2023 15:24:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702596270; x=1703201070; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=pH7KARAejqAmd4NZA5cpMQIeqpV2b6Ne0T86GLGIoxM=; b=eIsT7k7xGRINeUlbrrc8PwfZOM0QCTrxDlsp+3+GYgkt4Qgj421gTDu6J1/WKBb4fa X0r40dNS0fi7WGx53VWQQYzsL0squo0X69M8oY0BaLHBJ/FttX7UKBeXGgGDgmogbSbZ qW1LXGBsySw/naY7w7WIYP4TUn31A+FbT4I1w+Hllht9ftzlEpJyECFmTPC2VrP7tJwe PH/rnGW4izhkVgu74eyllIb9bx7bYkz6RxbSQysd6OpfZ2dV7kDNMWK1coRCrviyR/ga c5JQzD6SwIpwiilO3Vd9qhuz4s0eW8CSHiGjWEtpBQeO3Ppnm7Ngc14gPwyc/IRcn4Lc bOBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702596270; x=1703201070; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pH7KARAejqAmd4NZA5cpMQIeqpV2b6Ne0T86GLGIoxM=; b=IVgEuH2IY7wF4o7yz+hZViGFxrS/mbU0sUrm+NI96sPAgpt34OdBtJdMmeDZIbkQd9 bL7LIKlO++l0CTMP5Ja4la+eR38z6QqnmAWSEJTBdYkKhP82cgbbn3ggE3ZNpfJ5uZqg BT38YC8bX+PyT/fRWDWXUhVdoGPfiUDJBgIFmw3KcVNDijOM3dvAFUqWBO4csMSEjooj FB0+K/nVPEbONpu0uzyl/POuZ1Ha+4gfxTChNNvlzO7h5YN+ZYyItNjVRlPew6rEbCxo /ABCipBTZvjsHTSiG88udYzjC0qcMcVTVjeode7b/RsRLQ/y+Zg35M4HuDP3AFbQFIZO I3iA== X-Gm-Message-State: AOJu0Yy4NoiGi+IHVn2yXi6rXG26vK2d/uKHUJ/+ATyLBsDp8c4Tv0Nt hp5jdBflVkszggPRL9p9tOWAv1cn47oeBT52idk= X-Received: by 2002:a50:d61b:0:b0:552:17c8:fa4f with SMTP id x27-20020a50d61b000000b0055217c8fa4fmr1492622edi.72.1702596269898; Thu, 14 Dec 2023 15:24:29 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231214062434.3565630-1-menglong8.dong@gmail.com> <20231214062434.3565630-3-menglong8.dong@gmail.com> In-Reply-To: <20231214062434.3565630-3-menglong8.dong@gmail.com> From: Andrii Nakryiko Date: Thu, 14 Dec 2023 15:24:17 -0800 Message-ID: Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: activate the OP_NE login in range_cond() To: Menglong Dong Cc: andrii@kernel.org, eddyz87@gmail.com, yonghong.song@linux.dev, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 13, 2023 at 10:28=E2=80=AFPM Menglong Dong wrote: > > 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. > > Signed-off-by: Menglong Dong > --- > v2: > - add some cases to the "crafted_cases" > --- > .../selftests/bpf/prog_tests/reg_bounds.c | 25 ++++++++++++++----- > 1 file changed, 19 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..53b8711cfd2d 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 =3D 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 =3D range(t, x.a, x.b); > - *newy =3D 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 =3D=3D x.b && x.a =3D=3D y.a) { > /* X is a constant matching left side of Y */ > *newx =3D range(t, x.a, x.b); > @@ -2101,6 +2096,24 @@ static struct subtest_case crafted_cases[] =3D { > {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 */ > + {U64, U64, {1, 1}, {1, 0x80000000}}, > + {U64, S64, {1, 1}, {1, 0x80000000}}, > + {U64, U32, {1, 1}, {1, 0x80000000}}, > + {U64, S32, {1, 1}, {1, 0x80000000}}, > + {U64, U64, {0x80000000, 0x80000000}, {1, 0x80000000}}, > + {U64, S64, {0x80000000, 0x80000000}, {1, 0x80000000}}, > + {U64, U32, {0x80000000, 0x80000000}, {1, 0x80000000}}, > + {U64, S32, {0x80000000, 0x80000000}, {1, 0x80000000}}, > + {U64, U64, {1, 0x80000000}, {1, 1}}, > + {U64, S64, {1, 0x80000000}, {1, 1}}, > + {U64, U32, {1, 0x80000000}, {1, 1}}, > + {U64, S32, {1, 0x80000000}, {1, 1}}, > + {U64, U64, {1, 0x80000000}, {0x80000000, 0x80000000}}, > + {U64, S64, {1, 0x80000000}, {0x80000000, 0x80000000}}, > + {U64, U32, {1, 0x80000000}, {0x80000000, 0x80000000}}, > + {U64, S32, {1, 0x80000000}, {0x80000000, 0x80000000}}, JNE and JEQ are sign-agnostic, so there is no need to use both U64 and S64 variants for comparison. As for the choice of values. Wouldn't it make sense to use really a boundary conditions: 0, 0xffffffffffffffff, and 0x80000000000000 for 64-bit and 0, 0xffffffff, and 0x80000000 for 32-bit? For this one use U32 as the init = type? BTW, all these cases should be tested with auto-generated tests, so please make sure to run sudo SLOW_TESTS=3D1 ./test_progs -t reg_bounds_gen -j locally. It will take a bit of time, but should help to get confidence in that everything is working and nothing regressed. > }; > > /* Go over crafted hard-coded cases. This is fast, so we do it as part o= f > -- > 2.39.2 >