From patchwork Sun Feb 4 21:06:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Xu X-Patchwork-Id: 13544793 X-Patchwork-Delegate: bpf@iogearbox.net Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7370A286A2; Sun, 4 Feb 2024 21:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707080816; cv=none; b=cP/r783w02q4SkaoMKG/GIVwqmV1jtilYbA8IgTKw5J7ZPLZLJ8RZ6ZSJuFZ1oDVdfkmZlx2UJTl6cu+l7p6LqRYdtYhSSoXPgpxTY1zJ9zKoLDfmV2TZbAyw/Go61u5MnhbVZH0cFzikV7PS8l2dgDszpkpiVOVP4MVxmbcFmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707080816; c=relaxed/simple; bh=gFwS6vxiBgvT11yXjGHqr4yJHWdE/1x2NVikNGRS9H0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ncqxbJQycGfGTRwa2VMe4vApUg8FD0S1OBaNfPtcBfh+V3WZUaWfsvCLhJco8EujcG3EohcMfCnd2kNMQqOk7rQBEvgKPItp2GpqOnSHNCF5/jzD0ve0i3aZDfrdDOvaYU83xBK2BF0iZ4R96XurWfjkBeB7+Kzf5DSPpYNqLk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dxuuu.xyz; spf=pass smtp.mailfrom=dxuuu.xyz; dkim=pass (2048-bit key) header.d=dxuuu.xyz header.i=@dxuuu.xyz header.b=GKTUL29a; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=bkLT99Zl; arc=none smtp.client-ip=64.147.123.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dxuuu.xyz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dxuuu.xyz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dxuuu.xyz header.i=@dxuuu.xyz header.b="GKTUL29a"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="bkLT99Zl" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 3C6103200A20; Sun, 4 Feb 2024 16:06:52 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 04 Feb 2024 16:06:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1707080811; x= 1707167211; bh=7eOp9MN6MrBcOuvpFREhe6SLoBsf9aJYXjA+m/qLJE4=; b=G KTUL29apt61ZrpFR70Qf+Uuf9FuqZ9k4Buify7qqK8AlcXRltsYDO/mlmaliCwYM IWNrlFqcXlvzC+7J4PUOnqEzEdQSqs9TSl9mwtELv7VvtOnwrmOCaNcLl3KqqwL4 V1fD6sYzKjUi888XV+qWdgI/cF4BHeg9GsI6VSPP7b7eYJvU/07qxwg0QWKLOach sBlUOM68DyoEpB9sp6fBhIlX1diBetShqJn57puxapBtyRiSRX4rpoOL9/lxHxfQ VndPwaYTyEZedqb3/bJJKPD62OLqBrYA3FYr42ezkEZud7hCG0igGiEn9c3FMdV5 2D1KwSp9RNFoo8RZFzdTw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707080811; x= 1707167211; bh=7eOp9MN6MrBcOuvpFREhe6SLoBsf9aJYXjA+m/qLJE4=; b=b kLT99Zlfu9ovowCv4Uw7ncLKddYd5DLh2nMuZ4KunauBexyD+DNR5jE/31Oc9djL 9QD/UbpbEC6hDPHpenPXTYFkZ2xheSeFWFpregRd1wODOcY03IEPlv3VRH7HucI/ PgzPWTFqv42nHcIjjp29MWHjDw8kLiey/STVka6qD0KT+5o9y77nHvSUxVHw0/Rh VqUnxTwp5CXgjW1sDq6PL19Vl9lb5dINbryy/d5UPLWXKkgH+MA/S2MCur7YLqip vLA47Q7/uwi1C3DUGPOUSJOe3U5IQdwDXWn6Gn19eLvbbmr4aCxMhoFC2Glt5fJ0 S8f9Kad9oZQDxP8Toch2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedukedgudeggecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepffgrnhhivghlucgiuhcu oegugihusegugihuuhhurdighiiiqeenucggtffrrghtthgvrhhnpefgfefggeejhfduie ekvdeuteffleeifeeuvdfhheejleejjeekgfffgefhtddtteenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegugihusegugihuuhhurdighiii X-ME-Proxy: Feedback-ID: i6a694271:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 4 Feb 2024 16:06:50 -0500 (EST) From: Daniel Xu To: andrii@kernel.org, daniel@iogearbox.net, ast@kernel.org, olsajiri@gmail.com, quentin@isovalent.com, alan.maguire@oracle.com Cc: martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2 1/2] bpf: Have bpf_rdonly_cast() take a const pointer Date: Sun, 4 Feb 2024 14:06:34 -0700 Message-ID: X-Mailer: git-send-email 2.42.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Since 20d59ee55172 ("libbpf: add bpf_core_cast() macro"), libbpf is now exporting a const arg version of bpf_rdonly_cast(). This causes the following conflicting type error when generating kfunc prototypes from BTF: In file included from skeleton/pid_iter.bpf.c:5: /home/dxu/dev/linux/tools/bpf/bpftool/bootstrap/libbpf/include/bpf/bpf_core_read.h:297:14: error: conflicting types for 'bpf_rdonly_cast' extern void *bpf_rdonly_cast(const void *obj__ign, __u32 btf_id__k) __ksym __weak; ^ ./vmlinux.h:135625:14: note: previous declaration is here extern void *bpf_rdonly_cast(void *obj__ign, u32 btf_id__k) __weak __ksym; This is b/c the kernel defines bpf_rdonly_cast() with non-const arg. Since const arg is more permissive and thus backwards compatible, we change the kernel definition as well to avoid conflicting type errors. Signed-off-by: Daniel Xu Acked-by: Yonghong Song --- kernel/bpf/helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 4db1c658254c..3503949b4c1b 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2484,9 +2484,9 @@ __bpf_kfunc void *bpf_cast_to_kern_ctx(void *obj) return obj; } -__bpf_kfunc void *bpf_rdonly_cast(void *obj__ign, u32 btf_id__k) +__bpf_kfunc void *bpf_rdonly_cast(const void *obj__ign, u32 btf_id__k) { - return obj__ign; + return (void *)obj__ign; } __bpf_kfunc void bpf_rcu_read_lock(void)