From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 088AEC001DF for ; Tue, 1 Aug 2023 14:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233969AbjHAOli (ORCPT ); Tue, 1 Aug 2023 10:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbjHAOlh (ORCPT ); Tue, 1 Aug 2023 10:41:37 -0400 Received: from out-76.mta0.migadu.com (out-76.mta0.migadu.com [91.218.175.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9207DE9 for ; Tue, 1 Aug 2023 07:41:36 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1690900894; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=V4lu9rl80wnpynbxYMmCvM9Rbb29PtC/a1L2v3oqVO0=; b=qVaXNcLloEZwQ2po8bFkXfXrg349uHQUgN8d/XBrekpVlt+0SSC30kHjxtrIdeMT1gDnTR CkVGzp5+BONOjUUfdt7ukfJMwMQ35o+ByfUy8Mhv0SsUFyiBPNK7tP+0UdeW2t38BnZefB 8Gck6qbJnSiJKaq139e4ecgImIX7OUo= Date: Tue, 1 Aug 2023 07:41:26 -0700 MIME-Version: 1.0 Reply-To: yonghong.song@linux.dev Subject: Re: [PATCH] [v5] bpf: fix bpf_probe_read_kernel prototype mismatch Content-Language: en-US To: Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Song Liu , Steven Rostedt , Masami Hiramatsu Cc: Arnd Bergmann , stable@vger.kernel.org, John Fastabend , Martin KaFai Lau , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Kumar Kartikeya Dwivedi , Dave Marchevsky , David Vernet , Peter Zijlstra , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org References: <20230801111449.185301-1-arnd@kernel.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20230801111449.185301-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org On 8/1/23 4:13 AM, Arnd Bergmann wrote: > From: Arnd Bergmann > > bpf_probe_read_kernel() has a __weak definition in core.c and another > definition with an incompatible prototype in kernel/trace/bpf_trace.c, > when CONFIG_BPF_EVENTS is enabled. > > Since the two are incompatible, there cannot be a shared declaration in > a header file, but the lack of a prototype causes a W=1 warning: > > kernel/bpf/core.c:1638:12: error: no previous prototype for 'bpf_probe_read_kernel' [-Werror=missing-prototypes] > > On 32-bit architectures, the local prototype > > u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr) > > passes arguments in other registers as the one in bpf_trace.c > > BPF_CALL_3(bpf_probe_read_kernel, void *, dst, u32, size, > const void *, unsafe_ptr) > > which uses 64-bit arguments in pairs of registers. > > As both versions of the function are fairly simple and only really > differ in one line, just move them into a header file as an inline > function that does not add any overhead for the bpf_trace.c callers > and actually avoids a function call for the other one. > > Cc: stable@vger.kernel.org > Link: https://lore.kernel.org/all/ac25cb0f-b804-1649-3afb-1dc6138c2716@iogearbox.net/ > Signed-off-by: Arnd Bergmann Acked-by: Yonghong Song