Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp177204rdb; Sun, 21 Jan 2024 23:57:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsxDq5+Phap+csCEArXRXrH8I9PhkU81FyNtIt6fXGlsj8VMQSDMxhWRg+2iBHQmNjDwcS X-Received: by 2002:a05:6122:2a03:b0:4b6:dfda:525c with SMTP id fw3-20020a0561222a0300b004b6dfda525cmr1335063vkb.5.1705910258248; Sun, 21 Jan 2024 23:57:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705910258; cv=pass; d=google.com; s=arc-20160816; b=dFHZSfGynkmQmfNbicTXMbqdos5Fv/JJze5q9W9j83/Im0MqPe1Ve++lLnfORXrT8K HAWDLt/uT7vI5SGlltO9yuOKCKw6VL4XELU93Afg2CY3V7lr06L39wggAzbVXhKOHOdM OEStY/d1lGGXCgqagLv2/EZTT/Mr4vTTWEySr4aDuYEupvpsQqo7huhzbARPRzfhD/Gd aiqippjn3WnRTfLFdkDHKhTZPOstGBtMJ3vKmlqaM/7XmNcDcKBwgAQ94EA7DmSaHxrC YxWxy+F0+Hi1Ibge1MIjCvde7IvetCqLDJIBNkFByNg8GPJOXeZT6f1EUb8HxhXpZ775 wCBQ== ARC-Message-Signature: i=2; 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; bh=Kl0NyZPl+R2rhZNOSP8jglujEuP8qYixmEKXV/LzFSs=; fh=EvR41b01nAjTv94pCV1QdzfpeHL6jIcxejUnN6KALZM=; b=FHxQ8pl1Dn6q3qV51BnxAl35w7CtOyK3Vv5ubkKjjnA9vu8kSa654HZOhF+sfAn+uw rttHP5pl2PfUiOsiBDoe+yDhAj4mBzq3bSzr4qA4nU1dgSCmIDOPIiiLfFUjz6Lm4jBV 3Zb4Ud0OW3znJ0ACklzCFZkafgIhABqN2LSre6CuFWpPqzc0aSe9RE8uwnT9kNO3GtPL Gw/XgkdwNAMHljsakNoa4sG7+C4mKli6f7CYAYQVCuUaQiPXGHrs/ELsMOiP6z3vwW/w hlpdIAOyIJ+aeplVA6j/gnh0RbKtNvV1DtI7IqABpxojdJTRwbHjyMLZ7gC+1h3TR2NM EWNQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-32476-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32476-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u2-20020a0cdd02000000b006850d73205fsi4944987qvk.290.2024.01.21.23.57.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 23:57:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32476-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; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-32476-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32476-linux.lists.archive=gmail.com@vger.kernel.org" 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 0684D1C22298 for ; Mon, 22 Jan 2024 07:57:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1F5820DE7; Mon, 22 Jan 2024 07:57:14 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2386A18C2A; Mon, 22 Jan 2024 07:57:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705910234; cv=none; b=TEGCY9zNccH79PgosIum7FJVk0SAbvL/aVJjlYUd0qI1518bCKeImTNqX+dgHZy3pdH033rLIAWHa9Ybdfw/GgNdulftnbmza1/E0i63/4/xzdh+4Nm85iB8k6VPe2tbgFqrWeUwQxdCJ1RT+uxAxOAU4f4VfR/y7gVBE42fTLs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705910234; c=relaxed/simple; bh=5xOUQzMI3cF3quGn7LLDIkCU6YeMNa9MKn1b5kJuOQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JYnd7PajzCKkF27btJD3v07I9i/HQdOGQtLOD6ym+RaXBqN/LFP2fTzadtlMHTrDoQF5G4C2sfvXyyc+zCYLkTISyBVq/FUicWitu4j1HK5zzf2cm6TJykB611jVWI6gTN4wLWLpWYtXR6eE6D85GRcZ8avwqFM2rcD9G/CHOAc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxTOnQH65lkW0DAA--.3984S3; Mon, 22 Jan 2024 15:57:04 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxf8_NH65lKSIRAA--.13989S4; Mon, 22 Jan 2024 15:57:03 +0800 (CST) From: Tiezhu Yang To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Eduard Zingerman , John Fastabend , Jiri Olsa , Hou Tao , Song Liu , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v6 2/3] selftests/bpf: Copy insn_is_pseudo_func() into testing_helpers Date: Mon, 22 Jan 2024 15:56:59 +0800 Message-ID: <20240122075700.7120-3-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240122075700.7120-1-yangtiezhu@loongson.cn> References: <20240122075700.7120-1-yangtiezhu@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:AQAAf8Cxf8_NH65lKSIRAA--.13989S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7ZF4kGF1kuryfCF45Gr1rAFc_yoW8Xr4DpF WrGw40kr1jqFyxX3WUJa1qgFsagFWkZFW8Gryjq34UZr4DGF93XrWxKF40gasI939YvF1f Za1Iya4Y9F1xtacCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2 xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ Jw0_WrylYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwCFI7km07C267AKxVWUXVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07j2MKZUUUUU= insn_is_pseudo_func() will be used in test_verifier, the original idea is to move it from libbpf.c to libbpf_internal.h and then include the header to reuse this function, this just adds more internal code of libbpf used by selftests. While we have allowed it in some cases to avoid duplication of more complex logic, it is not justified in this case. Since insn_is_pseudo_func() and its helper is_ldimm64_insn() are trivial enough, just copy into testing_helpers. Suggested-by: Andrii Nakryiko Signed-off-by: Tiezhu Yang --- tools/testing/selftests/bpf/testing_helpers.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/bpf/testing_helpers.h b/tools/testing/selftests/bpf/testing_helpers.h index d14de81727e6..cd77dce1b1da 100644 --- a/tools/testing/selftests/bpf/testing_helpers.h +++ b/tools/testing/selftests/bpf/testing_helpers.h @@ -54,4 +54,14 @@ int get_xlated_program(int fd_prog, struct bpf_insn **buf, __u32 *cnt); int testing_prog_flags(void); bool is_jit_enabled(void); +static inline bool is_ldimm64_insn(struct bpf_insn *insn) +{ + return insn->code == (BPF_LD | BPF_IMM | BPF_DW); +} + +static inline bool insn_is_pseudo_func(struct bpf_insn *insn) +{ + return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC; +} + #endif /* __TESTING_HELPERS_H */ -- 2.42.0