Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1821967rwd; Fri, 2 Jun 2023 00:06:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/PXPHFT+4ULqr0s8hMHnFljoJBnFdSvnqLqDgCoLiLCiJzEywsJVWHWhUKELxuV3WtgCi X-Received: by 2002:a9d:6246:0:b0:6ab:1338:fed5 with SMTP id i6-20020a9d6246000000b006ab1338fed5mr1740265otk.11.1685689563306; Fri, 02 Jun 2023 00:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685689563; cv=none; d=google.com; s=arc-20160816; b=lIzXEBA07q8qJ5WcyB3TkSZ7Xd+HAtll/vN1BBRY/Q3pLofZAfZ9D5mh29a1yQm42S 2ww7ACE8351x+tAf2sb9erMPs3ReBcQW6QNdWoGIKzKVhOy0xG7WJMbsCHnKrUfQlTpI g/vPtiMZKObz73EG07EkovsPPl00/hRK4INdyBVABacBRDvd1y5lmuleYYBM0a60yNsR z4faR3KNP5YKNXZCDWUiIm0XXGX6p/CshOevslKVWr6WcNCXoOfv7b1e7efkUTUgVJsF X4U/PN0H6Pv0Aq1KsFG5wTTzOzNn7wkoxaMU+Tco6xzX/faYRv6IQ50ZUReGcCTpvv4F 8VsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YMePapRvx579minlQSYMxdALrJ1DqOKehZl4zrZxhok=; b=VJgiSugZvzt2zHpZ070NfbAkAjr02Cz2a3VdwFpLa4Uf+PIp19hCc7EhSYw/DGa0Q6 NHon9Rw4xe3ErgEGvIR/nTXxbWFDMcXAYqhkl1l1OgIkjY9kwgoPCLj0ZHLU1bQp0JQE i8pV6HZYozHLYcZG+AkA4WZymB0blbnybTMgYuPugs83hg/IOqqPeojWO2bIiEcLvPNX 2PZN7qmSOqmDH/Vfn4Fy4Ihn1MTPH7Pr31pjBmLmFaxQGpbLSXh0M3LqBah9iBqYKeox DfhfoImOKt72gIj8KyN3Jwh2rwWpHPXxsZ9h0rKVQpEo9hVUQNDsFDP2JucfJaVaHgKy 18Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BxLYbhTW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w62-20020a627b41000000b0064d6a4089e1si285131pfc.182.2023.06.02.00.05.51; Fri, 02 Jun 2023 00:06:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BxLYbhTW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234206AbjFBHDT (ORCPT + 99 others); Fri, 2 Jun 2023 03:03:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234123AbjFBHCw (ORCPT ); Fri, 2 Jun 2023 03:02:52 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C610518C; Fri, 2 Jun 2023 00:02:24 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id 98e67ed59e1d1-25632c99eecso812975a91.2; Fri, 02 Jun 2023 00:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685689344; x=1688281344; 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=YMePapRvx579minlQSYMxdALrJ1DqOKehZl4zrZxhok=; b=BxLYbhTWK8mJwbyPR/LlyVGVuQAcXwfCxqSsMg2YPA03+bbXxEdgOFXnqXRBM69X2q zmyFvjlMhIJ8vCnJt2rNASjwWqysYKceTpfaLCPhhSn9n38Z0xsqaU3ChoLXS7CXmOt+ N8Yub2RgyYxgM5iRVj7tcFwCKCjgha77xlAgdyUWN7b0y5rwy8geyPSo3ViN8tb9XS2G 8dorEvu+d7B9p0/tz0cp1BnFeOYYoSrJkpN46AaBm+D46ErKloGm9Zfw6LhIG/ns094b kvBM0UePowXsDo6wpLojXTbdMXcflBblDyIAdQYSYlKVGsVb1E2x7qYM4ABpwq58XIpY i59A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685689344; x=1688281344; 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=YMePapRvx579minlQSYMxdALrJ1DqOKehZl4zrZxhok=; b=aYgiIhQrhAFaqoy+5Ja2n2I4Og2tYKMpbOnbiNzpgMTUR9+0MibP590GJn0mNgeqzx vJF+jwfG1K9Cjmw0zU6BS4Sqbv6svQLB2t4q2apeh7BJJButC5PJ3Zs5DpBgfUgFQ7aw sxvS7IqvX9r4IzZHcsl4Mic3YbUA9FJI7A74R5kB1O5BxUntm8Ry1JJLWyARoaBSG6HA HxB/mgzLQ5hvlHbJj/zdjVH4+QKO4cwCSFLC/dugB8VdtC+ke+rvLAM4w7y+p+YeDsSq BX7qXTm104zq1P9TfCcmRpr7pKj3qPyrx73z1Y8kCDAv6oHJQcs84Med1c8epHmJmRNE +kDA== X-Gm-Message-State: AC+VfDzSzN1nVN7MOon7ohw/yHjVetktKiqmuFd5tu0yzjz6p8xi7hZb mNu+arsn6SQwT1odLjSd4+M= X-Received: by 2002:a17:902:ef85:b0:1b1:9272:55f3 with SMTP id iz5-20020a170902ef8500b001b1927255f3mr776489plb.66.1685689344095; Fri, 02 Jun 2023 00:02:24 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.24]) by smtp.gmail.com with ESMTPSA id jk11-20020a170903330b00b001ac7c725c1asm572716plb.6.2023.06.02.00.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jun 2023 00:02:23 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: olsajiri@gmail.com Cc: davem@davemloft.net, dsahern@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mykolal@fb.com, shuah@kernel.org, benbjiang@tencent.com, iii@linux.ibm.com, imagedong@tencent.com, xukuohai@huawei.com, chantr4@gmail.com, zwisler@google.com, eddyz87@gmail.com, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf-next v2 3/5] libbpf: make BPF_PROG support 15 function arguments Date: Fri, 2 Jun 2023 14:59:56 +0800 Message-Id: <20230602065958.2869555-4-imagedong@tencent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230602065958.2869555-1-imagedong@tencent.com> References: <20230602065958.2869555-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Menglong Dong Now that we changed MAX_BPF_FUNC_ARGS from 12 to 14, we should update BPF_PROG() too. Extend BPF_PROG() to make it support 15 arguments, 14 for kernel function arguments and 1 for return value of FEXIT. Reviewed-by: Jiang Biao Signed-off-by: Menglong Dong --- tools/lib/bpf/bpf_helpers.h | 9 ++++++--- tools/lib/bpf/bpf_tracing.h | 10 ++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/lib/bpf/bpf_helpers.h b/tools/lib/bpf/bpf_helpers.h index bbab9ad9dc5a..d1574491cf16 100644 --- a/tools/lib/bpf/bpf_helpers.h +++ b/tools/lib/bpf/bpf_helpers.h @@ -194,11 +194,13 @@ enum libbpf_tristate { #define ___bpf_apply(fn, n) ___bpf_concat(fn, n) #endif #ifndef ___bpf_nth -#define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, N, ...) N +#define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, \ + _d, _e, _f, N, ...) N #endif #ifndef ___bpf_narg #define ___bpf_narg(...) \ - ___bpf_nth(_, ##__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + ___bpf_nth(_, ##__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, \ + 6, 5, 4, 3, 2, 1, 0) #endif #define ___bpf_fill0(arr, p, x) do {} while (0) @@ -290,7 +292,8 @@ enum libbpf_tristate { #define ___bpf_pick_printk(...) \ ___bpf_nth(_, ##__VA_ARGS__, __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, \ __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, \ - __bpf_vprintk, __bpf_vprintk, __bpf_printk /*3*/, __bpf_printk /*2*/,\ + __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, __bpf_vprintk, \ + __bpf_vprintk, __bpf_printk /*3*/, __bpf_printk /*2*/, \ __bpf_printk /*1*/, __bpf_printk /*0*/) /* Helper macro to print out debug messages */ diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index be076a4041ab..4e940239f1c1 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -628,10 +628,13 @@ struct pt_regs; #define ___bpf_apply(fn, n) ___bpf_concat(fn, n) #endif #ifndef ___bpf_nth -#define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, N, ...) N +#define ___bpf_nth(_, _1, _2, _3, _4, _5, _6, _7, _8, _9, _a, _b, _c, \ + _d, _e, _f, N, ...) N #endif #ifndef ___bpf_narg -#define ___bpf_narg(...) ___bpf_nth(_, ##__VA_ARGS__, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#define ___bpf_narg(...) \ + ___bpf_nth(_, ##__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, \ + 6, 5, 4, 3, 2, 1, 0) #endif #define ___bpf_ctx_cast0() ctx @@ -647,6 +650,9 @@ struct pt_regs; #define ___bpf_ctx_cast10(x, args...) ___bpf_ctx_cast9(args), (void *)ctx[9] #define ___bpf_ctx_cast11(x, args...) ___bpf_ctx_cast10(args), (void *)ctx[10] #define ___bpf_ctx_cast12(x, args...) ___bpf_ctx_cast11(args), (void *)ctx[11] +#define ___bpf_ctx_cast13(x, args...) ___bpf_ctx_cast12(args), (void *)ctx[12] +#define ___bpf_ctx_cast14(x, args...) ___bpf_ctx_cast13(args), (void *)ctx[13] +#define ___bpf_ctx_cast15(x, args...) ___bpf_ctx_cast14(args), (void *)ctx[14] #define ___bpf_ctx_cast(args...) ___bpf_apply(___bpf_ctx_cast, ___bpf_narg(args))(args) /* -- 2.40.1