Message ID | 20230523194930.2116181-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2390444vqo; Tue, 23 May 2023 13:09:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58zWxfPTTTOwIYaBo4sIBscH08TORfnNvp87hIHTonoLINwEuOutl80cniyt2Lq9+CZAJn X-Received: by 2002:a17:902:d504:b0:1af:d19a:a67b with SMTP id b4-20020a170902d50400b001afd19aa67bmr2225508plg.33.1684872550066; Tue, 23 May 2023 13:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684872550; cv=none; d=google.com; s=arc-20160816; b=WeeJMKORojbEroCCwthDTPdkx8NFo3RjrvCu8HTZidOKzmvGTkFLr7rp26M8WCHj09 QvRXoIC+91wN0aA5YBtgA5u+HMELPZomJb3fChhG0sfWSr4Nq4wjcJQh2/3czh5YWPPT zpR1hLifWgvRSJqypaCfZ4EsyR4+BmSc3Fsabbvb/mHzSdYGrZ+4NfZN11s9E2J/6A5r S6GbS2mplel6RZGvHzf8E9EBligaZGVnT8tICLMYTE/uNR+A/rft0Jf3AUiEve7Ztjyn x7AiSXwodD4hEydXnbWLxyAsO4rIfBW4aNbpTWMUqqgMx+/Eo5zDESKfz7aQfW2RHM1J jOOA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=Bl6pRDDZOVD4/aU6DjrpsuXdhJzQ2AzCYc1yewqByow=; b=tpDRVITeGCOHPAGMir+v7AZET1Xw4GAUd+j678iR0xbICmxbZy8Y5pPequGm+arnuk HKB+URQNy1XGWaHO1UxAIDjPdaw1iJ5TNxlivtJ5+i2BGhCpS08zJBwOq9WduESs6chf fRKGB7EARwIDJ606H89sPYqw/Gf6I+nk5dEKTd+gH7MXbMSC/6tRdsk70LRPDtkT5h+F GmJj6yo5wc1Z4NdmUHHrMN0mcA+nV+kg8a1nf/iLHPbbWVwRkUIG1XQl0Q5zIUp9tcA+ qmZ3I40kG5e0GeDrFteAPDyaWHkTsMl5L8a5MhBJzypDpNWU5sAhYwGeecCj9Ovxxjng OZ/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oMQbKI0N; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x1-20020a170902ec8100b001afb96f4b8fsi325241plg.519.2023.05.23.13.08.55; Tue, 23 May 2023 13:09:10 -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=@kernel.org header.s=k20201202 header.b=oMQbKI0N; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238488AbjEWTtl (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 15:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjEWTtj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 15:49:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E26E2119 for <linux-kernel@vger.kernel.org>; Tue, 23 May 2023 12:49:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C81162701 for <linux-kernel@vger.kernel.org>; Tue, 23 May 2023 19:49:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3827C433D2; Tue, 23 May 2023 19:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684871377; bh=wGtFDXPE8CltQmJ9Fbh/aecZq2T4bSX/gGoZYsF+49Q=; h=From:To:Cc:Subject:Date:From; b=oMQbKI0Nj0UwqawJ3TbFjDbSkvvztGzzZjp2YrN7OJvYD+vJFcZCyydU6kdAJQjhu NAlf2lrJzRw5flZWTMAMVarPR/j+i1+s333STkNgcKC2cmhqD+TV/lxHwaAyeRWBqH PRfd5PM1IShFAHDWpWoSLNJVVA0y3J/bpB5eLiyu4bdEVMMrA65OVDUwgFr05NZUFT u8C+RcCuK4Knv0x+eE6T3SxhPx50u5Mncc97c4i2rY4v9dMbN2QRaj4dFiP8oDHsC9 kaDktqxoy/vLFovbKxqjj00KfGQLlupsY3cYfXtMJNNNst74ncHlF+ag5Vyt0i3npL cASbX5JTIUp/Q== From: Arnd Bergmann <arnd@kernel.org> To: Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de>, John Fastabend <john.fastabend@gmail.com>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, "Jason A. Donenfeld" <Jason@zx2c4.com>, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] [v2] bpf: hide unused bpf_patch_call_args Date: Tue, 23 May 2023 21:43:06 +0200 Message-Id: <20230523194930.2116181-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766716919281016793?= X-GMAIL-MSGID: =?utf-8?q?1766716919281016793?= |
Series |
[1/2,v2] bpf: hide unused bpf_patch_call_args
|
|
Commit Message
Arnd Bergmann
May 23, 2023, 7:43 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> This function has no callers and no declaration when CONFIG_BPF_JIT_ALWAYS_ON is enabled: kernel/bpf/core.c:2075:6: error: no previous prototype for 'bpf_patch_call_args' [-Werror=missing-prototypes] Hide the definition as well. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- v2: change indentation to align arguments better. Still not great as the line is just too long --- kernel/bpf/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On 5/23/23 12:43 PM, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > This function has no callers and no declaration when CONFIG_BPF_JIT_ALWAYS_ON > is enabled: > > kernel/bpf/core.c:2075:6: error: no previous prototype for 'bpf_patch_call_args' [-Werror=missing-prototypes] If CONFIG_BPF_JIT_ALWAYS_ON is enabled, the definition of bpf_patch_call_args should be invisible. Maybe I missed something. Could you list *ALL& bpf related config options in your setup so people can reproduce you above error messages? > > Hide the definition as well. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > v2: change indentation to align arguments better. Still not great > as the line is just too long > --- > kernel/bpf/core.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c > index 7421487422d4..0926714641eb 100644 > --- a/kernel/bpf/core.c > +++ b/kernel/bpf/core.c > @@ -2064,14 +2064,16 @@ EVAL4(PROG_NAME_LIST, 416, 448, 480, 512) > }; > #undef PROG_NAME_LIST > #define PROG_NAME_LIST(stack_size) PROG_NAME_ARGS(stack_size), > -static u64 (*interpreters_args[])(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5, > - const struct bpf_insn *insn) = { > +static __maybe_unused > +u64 (*interpreters_args[])(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5, > + const struct bpf_insn *insn) = { > EVAL6(PROG_NAME_LIST, 32, 64, 96, 128, 160, 192) > EVAL6(PROG_NAME_LIST, 224, 256, 288, 320, 352, 384) > EVAL4(PROG_NAME_LIST, 416, 448, 480, 512) > }; > #undef PROG_NAME_LIST > > +#ifdef CONFIG_BPF_SYSCALL > void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth) > { > stack_depth = max_t(u32, stack_depth, 1); > @@ -2080,6 +2082,7 @@ void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth) > __bpf_call_base_args; > insn->code = BPF_JMP | BPF_CALL_ARGS; > } > +#endif > > #else > static unsigned int __bpf_prog_ret0_warn(const void *ctx,
On Wed, May 24, 2023, at 05:05, Yonghong Song wrote: > On 5/23/23 12:43 PM, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> This function has no callers and no declaration when CONFIG_BPF_JIT_ALWAYS_ON >> is enabled: >> >> kernel/bpf/core.c:2075:6: error: no previous prototype for 'bpf_patch_call_args' [-Werror=missing-prototypes] > > If CONFIG_BPF_JIT_ALWAYS_ON is enabled, the definition of > bpf_patch_call_args should be invisible. Maybe I missed something. > Could you list *ALL& bpf related config options in your setup > so people can reproduce you above error messages? Sorry, my mistake. I've reworded the changelog now to fix this: | This function is only used when CONFIG_BPF_JIT_ALWAYS_ON is disabled, | but CONFIG_BPF_SYSCALL is enabled. When both are turned off, the | prototype is missing but the unused function is still compiled, | as seen from this W=1 warning: | | kernel/bpf/core.c:2075:6: error: no previous prototype for 'bpf_patch_call_args' [-Werror=missing-prototypes] | | Add a matching #ifdef for the definition to leave it out. If this makes sense now, I'll send out a v3. Arnd
On 5/24/23 6:23 AM, Arnd Bergmann wrote: > On Wed, May 24, 2023, at 05:05, Yonghong Song wrote: >> On 5/23/23 12:43 PM, Arnd Bergmann wrote: >>> From: Arnd Bergmann <arnd@arndb.de> >>> >>> This function has no callers and no declaration when CONFIG_BPF_JIT_ALWAYS_ON >>> is enabled: >>> >>> kernel/bpf/core.c:2075:6: error: no previous prototype for 'bpf_patch_call_args' [-Werror=missing-prototypes] >> >> If CONFIG_BPF_JIT_ALWAYS_ON is enabled, the definition of >> bpf_patch_call_args should be invisible. Maybe I missed something. >> Could you list *ALL& bpf related config options in your setup >> so people can reproduce you above error messages? > > Sorry, my mistake. I've reworded the changelog now to fix this: > > | This function is only used when CONFIG_BPF_JIT_ALWAYS_ON is disabled, > | but CONFIG_BPF_SYSCALL is enabled. When both are turned off, the > | prototype is missing but the unused function is still compiled, > | as seen from this W=1 warning: > | > | kernel/bpf/core.c:2075:6: error: no previous prototype for 'bpf_patch_call_args' [-Werror=missing-prototypes] > | > | Add a matching #ifdef for the definition to leave it out. > > If this makes sense now, I'll send out a v3. Yes, the above new commit message sounds good to me. Thanks. > > Arnd
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 7421487422d4..0926714641eb 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2064,14 +2064,16 @@ EVAL4(PROG_NAME_LIST, 416, 448, 480, 512) }; #undef PROG_NAME_LIST #define PROG_NAME_LIST(stack_size) PROG_NAME_ARGS(stack_size), -static u64 (*interpreters_args[])(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5, - const struct bpf_insn *insn) = { +static __maybe_unused +u64 (*interpreters_args[])(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5, + const struct bpf_insn *insn) = { EVAL6(PROG_NAME_LIST, 32, 64, 96, 128, 160, 192) EVAL6(PROG_NAME_LIST, 224, 256, 288, 320, 352, 384) EVAL4(PROG_NAME_LIST, 416, 448, 480, 512) }; #undef PROG_NAME_LIST +#ifdef CONFIG_BPF_SYSCALL void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth) { stack_depth = max_t(u32, stack_depth, 1); @@ -2080,6 +2082,7 @@ void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth) __bpf_call_base_args; insn->code = BPF_JMP | BPF_CALL_ARGS; } +#endif #else static unsigned int __bpf_prog_ret0_warn(const void *ctx,