Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1965472rwi; Tue, 1 Nov 2022 02:02:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5juk/Wkr0hBwHSvvgGshVB/ItxtR6dYhGyytzE7hF1BtC4LOSBv3ktlBwqfIHWnwb9uGGR X-Received: by 2002:a05:6402:7c4:b0:462:9bc2:d0d0 with SMTP id u4-20020a05640207c400b004629bc2d0d0mr18362258edy.122.1667293365993; Tue, 01 Nov 2022 02:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667293365; cv=none; d=google.com; s=arc-20160816; b=PF4DD2HnC+87n2Q/0BQePC09bft/RgFe91JkfNL0zGJqRJL7apMtJqU3k9E7mxkDP5 J6IMq6z9Mi3SbfFub+7GCsXphwZEDO1TCt1vx8+RGnkWDHlPnWzD4fKsXwfsB65NczZq OPTtJSYNRzV5MwuGB2byagopod+/rF64X/QVhzWb4Ao/N8z98MefWC0OlJEe7Ap40WT2 JstX5lf/iIm4YIJxS/NAOOcpfBhkMM+yd+1MCfVI/BR47FPtVENkP1idJIAMM5o3K/lC //g9mgywqZgq+wXvdZOGky1W+Z1iZiLUc8QWOYIeyCvbukLGlUwcstwjVjKJYWPHzVYM y1ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=S7YqvcW7uJgnvwYFXgxeJbVFHcM8MqyxOmFtKk4o1e8=; b=UEL5e0BCdeM/UBSGvdOsFJiJgzzWfEf3huXKxsHAcR4JF3HmoWqU8XQ6tghPW3oqBf w+d4VdSi0r0EVaWxVlegjX6UGfwkDny+TRX5wM77F4FLCVAftPHW5oajln2zmTTYFZgu PnU2nxxNcnQvxl37zBntUO3pTiW7tfS/LkoIJT7HyeNB/p+JTmezWGf4c5NFAxs33NP1 Ud2CDHmXF8eRx6jE/C0aHpHcl0Uu0tTkxf/C4ysJar6K8ipugp74jP2MpWCBuN8QzyQk vplOgoDD0+n1nedJxdi2XzDFdX7WD05SR/vyJf+iqw38wcchIVv/RyiSFlTal91GxsE5 uIqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Axuh0GyB; 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 nc31-20020a1709071c1f00b0078d3a35e181si11842240ejc.871.2022.11.01.02.02.14; Tue, 01 Nov 2022 02:02:45 -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=20210112 header.b=Axuh0GyB; 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 S229720AbiKAH5U (ORCPT + 97 others); Tue, 1 Nov 2022 03:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbiKAH5S (ORCPT ); Tue, 1 Nov 2022 03:57:18 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE3018362; Tue, 1 Nov 2022 00:57:16 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id kt23so35082371ejc.7; Tue, 01 Nov 2022 00:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=S7YqvcW7uJgnvwYFXgxeJbVFHcM8MqyxOmFtKk4o1e8=; b=Axuh0GyB1m/5zx5ujC1ZRQ4nA4yP8lbxoJxh2ikRk1bImT3tAn0Nfc1R+2N0W4CwDI 0ga1iUmOM+E/a6Z6sIIvR/usEy/w2grMFecHrNCgbAySFhBCTt2o4WKwVWJvvQoa5y+A /TLMYlvP0zcb5CtfVLCqlfrafVi/eXzekKxl9RCiQ6fSJ8234zLHsMA+A1JskX5PNeID kGqE+xU/9xhSNBVOtIX0olQpAcgipeFLWSoq3EC5UZ40SiiveQsuDCls2BedKmaWu/A8 69NauQoJTskQwEuik/8OYa4xodSCjjE+bR6WWEk+NamTPh6YvxKoaIibUnkuZQu0AoXO Bm+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=S7YqvcW7uJgnvwYFXgxeJbVFHcM8MqyxOmFtKk4o1e8=; b=LzM/7eruQH9D0t68AHv0C538pBOVL/wrKpfxSU8V8IXCtmwksTUcmhJMT1+Ks0qNHn oc+Lup9D3/VTz4POn0Nc8FIKLPud1aXTlDPWijTFBfqprzfoTFJ1alV1/eN/6ZrQu+4C lwrMHQYZkjRimptVbpsRyAfM9/gU0f5nQR+NGkq9f3RUmFjqb9vrmYn7iHkhAysmCsGH /DCD5EpPVdhONNeDqj8syX1lpJJE4uFgM9qRh98V4bsATiqxLS1rArkbUy19TlqyK1B0 v1j6FZTFfS+jljjQMQiwx44ry+Y8lTljdnAT020v/BrG1zNzXs6KMMTkM0fjWuST8LMn fi9g== X-Gm-Message-State: ACrzQf0rxRylmN1UUCaGB0q0leZGovvvlxCDFJoAbeyBUIgaqHQpF5Hu rxrNm1YZStE7OBQYUeGCfQo= X-Received: by 2002:a17:907:80a:b0:783:2585:5d73 with SMTP id wv10-20020a170907080a00b0078325855d73mr16851516ejb.642.1667289434901; Tue, 01 Nov 2022 00:57:14 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id d25-20020aa7c1d9000000b00456c6b4b777sm4124898edp.69.2022.11.01.00.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 00:57:14 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Tue, 1 Nov 2022 08:57:11 +0100 To: Nathan Chancellor Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Nick Desaulniers , Tom Rix , x86@kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev Subject: Re: [PATCH bpf] bpf: Mark bpf_arch_init_dispatcher_early() as __init_or_module Message-ID: References: <20221031173819.2344270-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221031173819.2344270-1-nathan@kernel.org> 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 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 On Mon, Oct 31, 2022 at 10:38:19AM -0700, Nathan Chancellor wrote: > After commit dbe69b299884 ("bpf: Fix dispatcher patchable function entry > to 5 bytes nop"), building kernel/bpf/dispatcher.c in certain > configurations with LLVM's integrated assembler results in a known > recordmcount bug: > > Cannot find symbol for section 4: .init.text. > kernel/bpf/dispatcher.o: failed > > This occurs when there are only weak symbols in a particular section in > the translation unit; in this case, bpf_arch_init_dispatcher_early() is > marked '__weak __init' and it is the only symbol in the .init.text > section. recordmcount expects there to be a symbol for a particular > section but LLVM's integrated assembler (and GNU as after 2.37) do not > generated section symbols. This has been worked around in the kernel > before in commit 55d5b7dd6451 ("initramfs: fix clang build failure") > and commit 6e7b64b9dd6d ("elfcore: fix building with clang"). > > Fixing recordmcount has been brought up before but there is no clear > solution that does not break ftrace outright. > > Unfortunately, working around this issue by removing the '__init' from > bpf_arch_init_dispatcher_early() is not an option, as the x86 version of > bpf_arch_init_dispatcher_early() calls text_poke_early(), which is > marked '__init_or_module', meaning that when CONFIG_MODULES is disabled, > bpf_arch_init_dispatcher_early() has to be marked '__init' as well to > avoid a section mismatch warning from modpost. > > However, bpf_arch_init_dispatcher_early() can be marked > '__init_or_module' as well, which would resolve the recordmcount warning > for configurations that support modules (i.e., the vast majority of > them) while not introducing any new warnings for all configurations. Do > so to clear up the build failure for CONFIG_MODULES=y configurations. > > Link: https://github.com/ClangBuiltLinux/linux/issues/981 > Signed-off-by: Nathan Chancellor LGTM but the whole thing might be actually going away: https://lore.kernel.org/bpf/Y2BD6xZ108lv3j7J@krava/T/#u because it won't compile on gcc 7 jirka > --- > arch/x86/net/bpf_jit_comp.c | 2 +- > include/linux/bpf.h | 2 +- > kernel/bpf/dispatcher.c | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c > index 00127abd89ee..4145939bbb6a 100644 > --- a/arch/x86/net/bpf_jit_comp.c > +++ b/arch/x86/net/bpf_jit_comp.c > @@ -389,7 +389,7 @@ static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t, > return ret; > } > > -int __init bpf_arch_init_dispatcher_early(void *ip) > +int __init_or_module bpf_arch_init_dispatcher_early(void *ip) > { > const u8 *nop_insn = x86_nops[5]; > > diff --git a/include/linux/bpf.h b/include/linux/bpf.h > index 0566705c1d4e..4aa7bde406f5 100644 > --- a/include/linux/bpf.h > +++ b/include/linux/bpf.h > @@ -971,7 +971,7 @@ struct bpf_trampoline *bpf_trampoline_get(u64 key, > struct bpf_attach_target_info *tgt_info); > void bpf_trampoline_put(struct bpf_trampoline *tr); > int arch_prepare_bpf_dispatcher(void *image, void *buf, s64 *funcs, int num_funcs); > -int __init bpf_arch_init_dispatcher_early(void *ip); > +int __init_or_module bpf_arch_init_dispatcher_early(void *ip); > > #define BPF_DISPATCHER_INIT(_name) { \ > .mutex = __MUTEX_INITIALIZER(_name.mutex), \ > diff --git a/kernel/bpf/dispatcher.c b/kernel/bpf/dispatcher.c > index 04f0a045dcaa..e14a68e9a74f 100644 > --- a/kernel/bpf/dispatcher.c > +++ b/kernel/bpf/dispatcher.c > @@ -91,7 +91,7 @@ int __weak arch_prepare_bpf_dispatcher(void *image, void *buf, s64 *funcs, int n > return -ENOTSUPP; > } > > -int __weak __init bpf_arch_init_dispatcher_early(void *ip) > +int __weak __init_or_module bpf_arch_init_dispatcher_early(void *ip) > { > return -ENOTSUPP; > } > > base-commit: 8bdc2acd420c6f3dd1f1c78750ec989f02a1e2b9 > -- > 2.38.1 >