From patchwork Wed Nov 27 19:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887318 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 DAADE83A17; Wed, 27 Nov 2024 19:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; cv=none; b=vCNEG5j1ZCkpZVSJI2U4C3hYTlDf0vo9SZ5LrmybKyQdl1ZrJcDOs9oiJzNneYVu7kBf0k84jFEtiqSQK04/v8yyCWv8FPF41x1YsE1bJnz2clAgBlw28OgyOVonzBLHOq9Tl943vGj9ZwZyE21B6fbmNRivvq68Y0TZzJQH3WY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; c=relaxed/simple; bh=SPP5A1FLuqjp7YWIjzGFzkMuvaLaozdDJfexWQfvdfA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iK42B7hDoBhSwD/4dVu9zDsXUUZcrA+Eu7N64Kusto1bvBfYpVoZEgrQMListnNJAtG8+fNQOm220EDfqV4pHGn7VK88oNBckHIJe5inGA2CpWXkjn7EP9flzJIaleeP2xsdD9+DJP+k+V2XNA2MZKWfDmfUXXhQf0is0ZqSyTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=ffDLLbXM; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ffDLLbXM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735245; bh=SPP5A1FLuqjp7YWIjzGFzkMuvaLaozdDJfexWQfvdfA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ffDLLbXMINI3aaTSl45JsazDmUpbn4W+EfqQTkrzumTBybsKHHwAYup9HVu8d6SX0 3icCN2XAHfFFuw//q6SzsoiyxOrocRnMORBXvb09SarMlo+qK2kJ1FS5DxSp3MCsHP vzVJI4FwQY/6wQTXt2w6ldnRHEweHPd3IrxUuA58= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:20 +0100 Subject: [PATCH bpf-next 1/9] bpf: tcp: Remove inaccurate comment about extern Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-1-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=782; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=SPP5A1FLuqjp7YWIjzGFzkMuvaLaozdDJfexWQfvdfA=; b=KN/aWxe/VChXuEDXwVRvceUnWWLhuyTogCfxgTBGVFF0Y/k72S+3+6FI1HX5L6DeNfT3TvlK5 Zx+f01lMb9QBRVgzGOkguEDk+x7e0ZuqvNuEpWW66CBHCe0oOJBWMwH X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The "extern" qualifier which the comment refers to was removed. Also remove the comment. Fixes: f6be98d19985 ("bpf, net: switch to dynamic registration") Signed-off-by: Thomas Weißschuh --- net/ipv4/bpf_tcp_ca.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c index 554804774628e4b3d03bc3b19b96d717a581439e..ce5012f6821d543541b13275aff87bef0abf4677 100644 --- a/net/ipv4/bpf_tcp_ca.c +++ b/net/ipv4/bpf_tcp_ca.c @@ -11,7 +11,6 @@ #include #include -/* "extern" is to avoid sparse warning. It is only used in bpf_struct_ops.c. */ static struct bpf_struct_ops bpf_tcp_congestion_ops; static const struct btf_type *tcp_sock_type; From patchwork Wed Nov 27 19:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887320 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 682791FF7AA; Wed, 27 Nov 2024 19:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; cv=none; b=cj+K0zZmbZ//hzLz7QeRET3kEoVzY3C62V2zvWSUDH4Af7d6Ce2G8CXOG8PoH/Xno27rnJIptRYpZn5h/0XvWIQCjyqsqSr834wQGLbHG4hTQqVZdJI9KkI0XdU6AnUgJm3kOCbbecr4FHrud5t77zuCagvB1jR64fsT2pLfB7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; c=relaxed/simple; bh=j+Y13MSIpYC9IMfunH7OOKMb4F7xuB+1KU8yNntWscA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VE5DANU24Td1vMToxK3cwNsNcJBor5r6uBA/LwlZ8/8HrerBbKAT26BX/kCMhwz/04C2uBZ8i6rYJM+HBQrQMbl4XJ5fGL06SK4ylqmcbhxabxLzdWbA0zWi3wA/z1/ZW+sYvcJMi1s3y5eELrbG2OmJlqpjVInzz45tT4JSPwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=mXXNK4Bp; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="mXXNK4Bp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735245; bh=j+Y13MSIpYC9IMfunH7OOKMb4F7xuB+1KU8yNntWscA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mXXNK4BpTRDyul0Yyyh+2TgWb4YZnsqvI4bGeVRlCnmUAJWZOJzL0kB2MV7Ci7N+W WSPiB4tzpKZySb+VCjTXh6L4ty3V99gzGECWZvrqEl1V4JRsQR7ntFYGcgPw0iDC0G 1MGQF58Isit24zn0O4WkBqsnQ/G6Qt5MHtYuUArQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:21 +0100 Subject: [PATCH bpf-next 2/9] bpf: Move func_models from bpf_struct_ops to bpf_struct_ops_desc Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-2-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=3668; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=j+Y13MSIpYC9IMfunH7OOKMb4F7xuB+1KU8yNntWscA=; b=qf3rhqnd/jR5IPIOWFkhYUOSIKFWy2kJxY+Qsb9QXA8GibI1+LPwRaJaQxEPBo2c297pFfmw/ sxd7IMK0WK/A4U7ARq4JdXzG/LGlLeLLiboLL7G2qtyT3UgMNP61EY/ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The func_models are the only member of struct bpf_struct_ops which are modified by the BPF core. Moving it into bpf_struct_ops_desc allows the static definitions of bpf_struct_ops throughout the tree being moved into read-only memory. The dummy ops don't have access to a bpf_struct_ops_desc. For them declare a dedicated static variable for the func_members. Signed-off-by: Thomas Weißschuh --- include/linux/bpf.h | 4 ++-- kernel/bpf/bpf_struct_ops.c | 4 ++-- net/bpf/bpf_dummy_struct_ops.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 3ace0d6227e3cb70dd75bdc6afa52870dee250f1..b734543b7a2b48e717d4f1be765e0198114b4f0a 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1779,7 +1779,6 @@ struct btf_member; * @type: BTF type. * @value_type: Value type. * @name: The name of the struct bpf_struct_ops object. - * @func_models: Func models * @type_id: BTF type id. * @value_id: BTF value id. */ @@ -1799,7 +1798,6 @@ struct bpf_struct_ops { void *cfi_stubs; struct module *owner; const char *name; - struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS]; }; /* Every member of a struct_ops type has an instance even a member is not @@ -1825,6 +1823,8 @@ struct bpf_struct_ops_desc { /* Collection of argument information for each member */ struct bpf_struct_ops_arg_info *arg_info; + + struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS]; }; enum bpf_struct_ops_state { diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c index 606efe32485a985b854aa7e96e1a7f7cfd5057d3..7ee7c25d21d480d46b40b23ff8aec9d12ea81f68 100644 --- a/kernel/bpf/bpf_struct_ops.c +++ b/kernel/bpf/bpf_struct_ops.c @@ -397,7 +397,7 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc, if (btf_distill_func_proto(log, btf, func_proto, mname, - &st_ops->func_models[i])) { + &st_ops_desc->func_models[i])) { pr_warn("Error in parsing func ptr %s in struct %s\n", mname, st_ops->name); err = -EINVAL; @@ -777,7 +777,7 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, trampoline_start = image_off; err = bpf_struct_ops_prepare_trampoline(tlinks, link, - &st_ops->func_models[i], + &st_ops_desc->func_models[i], *(void **)(st_ops->cfi_stubs + moff), &image, &image_off, st_map->image_pages_cnt < MAX_TRAMP_IMAGE_PAGES); diff --git a/net/bpf/bpf_dummy_struct_ops.c b/net/bpf/bpf_dummy_struct_ops.c index f71f67c6896b3de862a556d6f1e959a378cbda96..3a675227074e546e6a02e80db3841ed72d5bbff8 100644 --- a/net/bpf/bpf_dummy_struct_ops.c +++ b/net/bpf/bpf_dummy_struct_ops.c @@ -129,7 +129,7 @@ extern const struct bpf_link_ops bpf_struct_ops_link_lops; int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr, union bpf_attr __user *uattr) { - const struct bpf_struct_ops *st_ops = &bpf_bpf_dummy_ops; + static typeof_member(struct bpf_struct_ops_desc, func_models) func_models; const struct btf_type *func_proto; struct bpf_dummy_ops_test_args *args; struct bpf_tramp_links *tlinks = NULL; @@ -175,7 +175,7 @@ int bpf_struct_ops_test_run(struct bpf_prog *prog, const union bpf_attr *kattr, op_idx = prog->expected_attach_type; err = bpf_struct_ops_prepare_trampoline(tlinks, link, - &st_ops->func_models[op_idx], + &func_models[op_idx], &dummy_ops_test_ret_function, &image, &image_off, true); From patchwork Wed Nov 27 19:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887321 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 AB1016A8D2; Wed, 27 Nov 2024 19:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; cv=none; b=Wg7yWmwtQ0QaZEE8vRYmKMcgsnJh0C7V+zsaDu0bKg/nVLkrKlmyaxHgm4QtbY2WrAzEI2KtP8YOalBVvfSITZJo4KaURFZ6VhF50kvRlQ4TCpF0YNOzhT4WaJupHyRqh1mfCZV+E55XAafvbx+R4ITIMyazvLkxfUUsKxDnSWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; c=relaxed/simple; bh=FSIdOPI7G71E81SlPJ31/CYJakCYciP1NuGPqiBf6ns=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u+f94P8mnIkTxT1mw1WA0cnF2gjZEBR15rshp21LkSKVJUgWsOu4/ERKqary3A1L8xp1anFOUWcALo2qkFo4Clve/swdYlMcakPSU8zDEakMlgol6q8C91RGOsO8OM+7fnQv+ZxNeADAwQYZfCzS0YyDrBA8PrVHOoBb3FVuJgo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=I6pQFHuR; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="I6pQFHuR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735245; bh=FSIdOPI7G71E81SlPJ31/CYJakCYciP1NuGPqiBf6ns=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=I6pQFHuRsMWz+nzxgY5drDkP68HgKXd+aWd9/pBgEYyRyX/ErDpqsU8wUnzr6cq/r YDisRnXWXx7Le2sDwQJeAJDFVde/P5a5CwLLnZ18+j9M9rzkrLKR4Tct84bcYsHw9y /is+W8VI3svs8i089MDIHSVyE8ACTL2U9XvyFru8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:22 +0100 Subject: [PATCH bpf-next 3/9] bpf: Allow registration of const struct bpf_struct_ops Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-3-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=3024; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FSIdOPI7G71E81SlPJ31/CYJakCYciP1NuGPqiBf6ns=; b=BJolLI/HSp5zIdyovEjzP9haUQNeQtMfAuKZzuqRexsJKhlQLDcJESuCetrloLZ+5ElnmmXOI tGmg7p3EYXDBjnLfzFE4MviBreoiQuz8G6K9/esh2CoF3PeFLkRrbXu X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The BPF core does not need to modify instances of struct bpf_struct_ops anymore. Reflect this in the API so users can move their instances into read-only memory. Signed-off-by: Thomas Weißschuh --- include/linux/bpf.h | 2 +- include/linux/btf.h | 2 +- kernel/bpf/bpf_struct_ops.c | 2 +- kernel/bpf/btf.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index b734543b7a2b48e717d4f1be765e0198114b4f0a..a9267af9671b2bc8961cde24d2f79f473ab227d7 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1814,7 +1814,7 @@ struct bpf_struct_ops_arg_info { }; struct bpf_struct_ops_desc { - struct bpf_struct_ops *st_ops; + const struct bpf_struct_ops *st_ops; const struct btf_type *type; const struct btf_type *value_type; diff --git a/include/linux/btf.h b/include/linux/btf.h index 4214e76c916861462e45e98690fcf461c05ca737..87a5ddef9fdc4b7f09d375ec5959abd6d07533a9 100644 --- a/include/linux/btf.h +++ b/include/linux/btf.h @@ -519,7 +519,7 @@ struct bpf_verifier_log; #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) struct bpf_struct_ops; -int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops); +int __register_bpf_struct_ops(const struct bpf_struct_ops *st_ops); const struct bpf_struct_ops_desc *bpf_struct_ops_find_value(struct btf *btf, u32 value_id); const struct bpf_struct_ops_desc *bpf_struct_ops_find(struct btf *btf, u32 type_id); #else diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c index 7ee7c25d21d480d46b40b23ff8aec9d12ea81f68..967f0914d473fcde4a6ce3bb6ac976345daf8e88 100644 --- a/kernel/bpf/bpf_struct_ops.c +++ b/kernel/bpf/bpf_struct_ops.c @@ -314,7 +314,7 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc, struct btf *btf, struct bpf_verifier_log *log) { - struct bpf_struct_ops *st_ops = st_ops_desc->st_ops; + const struct bpf_struct_ops *st_ops = st_ops_desc->st_ops; struct bpf_struct_ops_arg_info *arg_info; const struct btf_member *member; const struct btf_type *t; diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index e7a59e6462a9331d0acb17a88a4ebf641509c050..e3be8b7d6cbb268cf389bac9d3f889dbfd664a2e 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -9155,7 +9155,7 @@ bool btf_type_ids_nocast_alias(struct bpf_verifier_log *log, #ifdef CONFIG_BPF_JIT static int -btf_add_struct_ops(struct btf *btf, struct bpf_struct_ops *st_ops, +btf_add_struct_ops(struct btf *btf, const struct bpf_struct_ops *st_ops, struct bpf_verifier_log *log) { struct btf_struct_ops_tab *tab, *new_tab; @@ -9242,7 +9242,7 @@ bpf_struct_ops_find(struct btf *btf, u32 type_id) return NULL; } -int __register_bpf_struct_ops(struct bpf_struct_ops *st_ops) +int __register_bpf_struct_ops(const struct bpf_struct_ops *st_ops) { struct bpf_verifier_log *log; struct btf *btf; From patchwork Wed Nov 27 19:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887323 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 AE3C6204082; Wed, 27 Nov 2024 19:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; cv=none; b=ebill7ScvJRTT2hyqByKXWH2J7FAwYiE+p/FXS1dIQwNd4IeWcAnIKQ9JFCvczmTdSo87hTc834GQM8r5e1STeHcsxi6GL47ADCSA6Vv0xWYtwN4r2pVi58xFxLb2R7n5OuaNnSl7ONwpvlXz5xiqVLRUf+ovYlyD2vffgQyngQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; c=relaxed/simple; bh=3rctmezwlCnJHJyzeUdMtikNSq141Sldc2+hgFUUhjk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=APvQga+mIfjT7N3xpIrwCjRGeS/tnEPgelc+FLf71QDRQKcT/S5htuq1NIc4or8pa+DS9ZR77j8GYoYAtNcHoh9R6aDv/rasGIpj6oUbDvFiW16v+pIgGrRsFGB+UGk39qFXZcrdUFHwm68lb0I5SIHpN9KP+MBHby781LL7/I4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Z+GeIXER; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Z+GeIXER" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735245; bh=3rctmezwlCnJHJyzeUdMtikNSq141Sldc2+hgFUUhjk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z+GeIXER2Zg36gl3BBXVGtEmEZkKCPvmohtmST9bxks1ArkuiByBrVDJlrZOdjlpX fTWxTuOaFqPbqU4cuUEjutTbhoVqXA/0Zl1ErZ1p0C2F5oMFziRn7C4TYsFVAoX0T6 eDKCdGlfs3fTIYb5ZsieT64VpejLP/Q7+T1lXuZg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:23 +0100 Subject: [PATCH bpf-next 4/9] const_structs.checkpatch: add bpf_struct_ops Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-4-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=693; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=3rctmezwlCnJHJyzeUdMtikNSq141Sldc2+hgFUUhjk=; b=6DzHI/fSbgD40QFAxB1P9wL4KCIvbaHi7tT1rqbM+fUIdlNUTGiKf0h4sanbM4UgP37azYPde swQX9s30MU8BhqRRlfEXT2pt5zWs1J/92u8Ku+uBD5cXZCZ9ysB+XTp X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Now that the BPF core can handle "const struct bpf_struct_ops", make sure that new usages of the struct already enter the tree as const. Signed-off-by: Thomas Weißschuh --- scripts/const_structs.checkpatch | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/const_structs.checkpatch b/scripts/const_structs.checkpatch index 014b3bfe32374880a5f0cbdcc2763c24ba47b5c7..1457067dbc18e2586f5ef0c8c44367cb3011731d 100644 --- a/scripts/const_structs.checkpatch +++ b/scripts/const_structs.checkpatch @@ -1,6 +1,7 @@ acpi_dock_ops address_space_operations backlight_ops +bpf_struct_ops block_device_operations bus_type clk_ops From patchwork Wed Nov 27 19:15:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887322 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 8EC58200B95; Wed, 27 Nov 2024 19:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; cv=none; b=kIvABfJdRYRHd2w9ZyJcXnkWumpfSyKwcJ59QJfBFH33cm8+UZK0rwzxi+mYblUxWjpepK8rA3g12xiZU7tBy4ut6I7jANs4HwndBvT5dckloBUZyyP0EZ2t57LE1ynSQpWheWchqQsGd8ZbsyLQdMY3i1urHJv136u9nhjvZDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735251; c=relaxed/simple; bh=KtwbEqFpnwCczek16OOedUheaLXyXVIfozidQrI0uUw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FzuCGfN2S2Ow3ukQmvuNYe/gEJrYG49WdqLS7wfs/3LjPLaWqANCw78IBbHEXO6zJdkoSU8buVFP5kfgERwK/nuPw+CHQx6AI27eYm92yLcGCWNucRIMWhBy9Ai3US1qGX4bS1ajUxddkeN5SePrfZrqIzJUvWfq19IB26q+ZxA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=jFMJYZsw; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="jFMJYZsw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735246; bh=KtwbEqFpnwCczek16OOedUheaLXyXVIfozidQrI0uUw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jFMJYZswpV72PsYnBLk9fA0ivlsvcxSLmKiej9qOQ9tbfsnNAmgryDG60B9Ed42Qp H6jkH4PnoIBpYN6VlX9h1KzmmX6ktBYiCrxjmE9N9Rxs0ZDlS5U46uujAUnqhGY8Y5 qT6Hb4SRVe+kP/PvifyXuUC3r7kB41qOeXD/9YwM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:24 +0100 Subject: [PATCH bpf-next 5/9] bpf: Allow registration of const cfi_stubs Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-5-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=1514; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=KtwbEqFpnwCczek16OOedUheaLXyXVIfozidQrI0uUw=; b=KpuXC0mLiHk4BoFEt+TSl42FiwTEq/ap2yVY3heLEigxFb2I0wUKPZJZkINMI1AopeGtO6wnI 2Oev6Ufy0VwDveY03Cs721MrPZ83t+7IyUUQv9ly1zWAYM/J1rBehAB X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The BPF core does not need to modify the cfi_stubs. Reflect this in the API so users can move their structures into read-only memory. Signed-off-by: Thomas Weißschuh --- include/linux/bpf.h | 2 +- kernel/bpf/bpf_struct_ops.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index a9267af9671b2bc8961cde24d2f79f473ab227d7..fbe5ae7c2b380fdb624ea1f04fdf56e4f6710f14 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1795,7 +1795,7 @@ struct bpf_struct_ops { void (*unreg)(void *kdata, struct bpf_link *link); int (*update)(void *kdata, void *old_kdata, struct bpf_link *link); int (*validate)(void *kdata); - void *cfi_stubs; + const void *cfi_stubs; struct module *owner; const char *name; }; diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c index 967f0914d473fcde4a6ce3bb6ac976345daf8e88..2a9b9c39f1e7c2c22dc83ad68766b522117f3979 100644 --- a/kernel/bpf/bpf_struct_ops.c +++ b/kernel/bpf/bpf_struct_ops.c @@ -778,7 +778,7 @@ static long bpf_struct_ops_map_update_elem(struct bpf_map *map, void *key, trampoline_start = image_off; err = bpf_struct_ops_prepare_trampoline(tlinks, link, &st_ops_desc->func_models[i], - *(void **)(st_ops->cfi_stubs + moff), + *(void *const *)(st_ops->cfi_stubs + moff), &image, &image_off, st_map->image_pages_cnt < MAX_TRAMP_IMAGE_PAGES); if (err) From patchwork Wed Nov 27 19:15:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887326 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 2D47A2040A1; Wed, 27 Nov 2024 19:20:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; cv=none; b=T1kEIFkwgeVK7l4WG+Qs5PINvlRDQh9fiJ2z7PBOup5OmhN1eUOW+Ld47TBuuYwNPUP4DpysDm+c3rlPsQSxQ1fiTgVlJm8hYWqXxlUiZ72mm/+h5mrlzMmO+ss52LdxzdiZac2OnuM78Gtk0LYbqWghBVS7PESCZb3sGAh35vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; c=relaxed/simple; bh=uaijE66Fe3UNqo6KTVPXSOBtcXZnHjGLU0ltOFEPyPU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uVPRAt55BHrwfd3zzqzWrQOuuDsPoRl3SmaWI8lhGvEnQp/2NBDPQ0XYvGgVZH+qvc3ZCyGnDNrPIDwTX0WU0h0n4Zu+X3GTyWY1gmbuynyx1NCMuWmT0TT5RduCJozqwaojVnl7N6k2zHgZdfqS/9JYFEqePDyX348S3UBqRSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=dsM2BpMX; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="dsM2BpMX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735251; bh=uaijE66Fe3UNqo6KTVPXSOBtcXZnHjGLU0ltOFEPyPU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dsM2BpMXK7P/gLpFmVIYx3PjQnMbU4m44KahAfDMYgAlvHaboZro7Z+60G9Wr3hYH ptbSe27SjJoZUOTFIN9Uj1Ynh2UlWLK6wdOyjFI+91ZencR7WsCGGAZYRvKr+NlqlB tnC6pgRo7T20UfFmuu0IwfZoF8k/Fac9hOhVXx78= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:25 +0100 Subject: [PATCH bpf-next 6/9] bpf, net: tcp: Constify BPF ops Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-6-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=1437; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=uaijE66Fe3UNqo6KTVPXSOBtcXZnHjGLU0ltOFEPyPU=; b=Qm2cJwW4/GkO4d4SaspvVMAln4+ovMuChvelp6LJdqe9MvTLEA1jzkm+NlAMwWK692WfQ1eDo FJ2te6sasfOBEiqOwNjIChtBhQmG+k+whvC6lJ12zAW1b49RglDM8jA X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The BPF core now allows the registration of read-only ops tables, make use of it. Signed-off-by: Thomas Weißschuh --- net/ipv4/bpf_tcp_ca.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c index ce5012f6821d543541b13275aff87bef0abf4677..9b95dcacf3467de69e366e9196c36c4c92f78d75 100644 --- a/net/ipv4/bpf_tcp_ca.c +++ b/net/ipv4/bpf_tcp_ca.c @@ -11,7 +11,7 @@ #include #include -static struct bpf_struct_ops bpf_tcp_congestion_ops; +static const struct bpf_struct_ops bpf_tcp_congestion_ops; static const struct btf_type *tcp_sock_type; static u32 tcp_sock_id, sock_id; @@ -307,7 +307,7 @@ static void __bpf_tcp_ca_release(struct sock *sk) { } -static struct tcp_congestion_ops __bpf_ops_tcp_congestion_ops = { +static const struct tcp_congestion_ops __bpf_ops_tcp_congestion_ops = { .ssthresh = bpf_tcp_ca_ssthresh, .cong_avoid = bpf_tcp_ca_cong_avoid, .set_state = bpf_tcp_ca_set_state, @@ -323,7 +323,7 @@ static struct tcp_congestion_ops __bpf_ops_tcp_congestion_ops = { .release = __bpf_tcp_ca_release, }; -static struct bpf_struct_ops bpf_tcp_congestion_ops = { +static const struct bpf_struct_ops bpf_tcp_congestion_ops = { .verifier_ops = &bpf_tcp_ca_verifier_ops, .reg = bpf_tcp_ca_reg, .unreg = bpf_tcp_ca_unreg, From patchwork Wed Nov 27 19:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887327 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 D3C9B204090; Wed, 27 Nov 2024 19:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735255; cv=none; b=UeSTfTn0rGt3tPJ9P+VUAknn2kZ2M3w45z0uDI70E0Aazo3OSJp5iUFWC8kuZI56/xE2AD3bQQg8Oej+bmOqzfmSDb6BGZLofXBPzDPFe1XnGNSJxBYr6xYn8DdWTxbcqAeYyNeUhv8+z0c/oz5pojsUGN+Xn4mXUrN/I5qeyY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735255; c=relaxed/simple; bh=JU12z5rzuDuGYgEeHlT+HyoAu3E4JCuKXMHid87TuTc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JJrK+5qoGcZq/ScqXmtFN53bJWWpg5ztGNbgsnMrWb1qWQJ9q39Zhy+ocs6PyzWHP5OA8r3jEXzS76sqQTZ11mAZujIm3ckJLGBfbR522LHbLvA8Z8kSZzYv4aeqZi0kILWLhVLhgzFKrhaqbqUEr3Sgtd2O3zNLa+vp8tZh0cM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Dq2Z1Bc0; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Dq2Z1Bc0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735246; bh=JU12z5rzuDuGYgEeHlT+HyoAu3E4JCuKXMHid87TuTc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Dq2Z1Bc0N+mMBm+xuOWCk+4pqOO71TH3uul5yo2vJAWu+4lq62GkvOe0/iEB+57oq GS0d4cd0LsXI85+bW+I3B4Ymv/NLaKSi/8A4mmF8K8xTAviH0DUxX/Lc0Q7M+iTYaT iDmMKKXKt9BJvTZna2fYE5h68wYTy2xP671fup1U= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:26 +0100 Subject: [PATCH bpf-next 7/9] bpf, net: dummy_ops: Constify BPF ops Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-7-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=1414; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=JU12z5rzuDuGYgEeHlT+HyoAu3E4JCuKXMHid87TuTc=; b=X7Jn4w2by4ezsk3zFqrGQVObmVC43mtETN0abDpQwXFZr7P4ri9iVD/phbu2o7dKGkYVBFmzF luLnFIbfcs8D8fAns2NOKxhI9ALI8pOA3NpMiHoanSAQE7nizqnHfhr X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The BPF core now allows the registration of read-only ops tables, make use of it. Signed-off-by: Thomas Weißschuh --- net/bpf/bpf_dummy_struct_ops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/bpf/bpf_dummy_struct_ops.c b/net/bpf/bpf_dummy_struct_ops.c index 3a675227074e546e6a02e80db3841ed72d5bbff8..b0f3d90f153b34d46fbf37964cc3caf4bec9a4af 100644 --- a/net/bpf/bpf_dummy_struct_ops.c +++ b/net/bpf/bpf_dummy_struct_ops.c @@ -7,7 +7,7 @@ #include #include -static struct bpf_struct_ops bpf_bpf_dummy_ops; +static const struct bpf_struct_ops bpf_bpf_dummy_ops; /* A common type for test_N with return value in bpf_dummy_ops */ typedef int (*dummy_ops_test_ret_fn)(struct bpf_dummy_ops_state *state, ...); @@ -297,13 +297,13 @@ static int bpf_dummy_test_sleepable(struct bpf_dummy_ops_state *cb) return 0; } -static struct bpf_dummy_ops __bpf_bpf_dummy_ops = { +static const struct bpf_dummy_ops __bpf_bpf_dummy_ops = { .test_1 = bpf_dummy_ops__test_1, .test_2 = bpf_dummy_test_2, .test_sleepable = bpf_dummy_test_sleepable, }; -static struct bpf_struct_ops bpf_bpf_dummy_ops = { +static const struct bpf_struct_ops bpf_bpf_dummy_ops = { .verifier_ops = &bpf_dummy_verifier_ops, .init = bpf_dummy_init, .check_member = bpf_dummy_ops_check_member, From patchwork Wed Nov 27 19:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887325 X-Patchwork-Delegate: jikos@jikos.cz Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 DC64A204094; Wed, 27 Nov 2024 19:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; cv=none; b=lgBNprP+ELXsH+PR/wuekJahzbnKZhHyT/f1l2FmmCI4cImDbapv1rkcqqVGt/fXwOHQmLRlXGbSUzXo5GskN2YLNHz1dUErrKOVvsY6yepBplUwG/aMPbMx1pc1lwypSDcQIFXNenJ2CuuYw1BR/QD/3IgRP4GO38OiPso9dgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; c=relaxed/simple; bh=wNs3Wb11muL3asSVvBpcSkxAu1290QussnP8tf9Yvjg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pMqr9aGQyXknYEgfLWFViVI2oq//soik+LMawxLntbIOq8gEQ0Q3hRVUCU0VJxmzBJd7VEfuQ7b1m8RhcRTOIkKk1uIcpF6T/VXP2p2GVIKRxxFuAPlYLGNybk3AG/5PUv/AplMx2uEum1VJu++HY2BLRdP1Me0A5mFM4HLXh9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=T2MvmcqV; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="T2MvmcqV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735246; bh=wNs3Wb11muL3asSVvBpcSkxAu1290QussnP8tf9Yvjg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=T2MvmcqVSqI12EKlTC5q2ll1kYXVttIO6XSzFXkGUBGoqh2/2BeDztPVP5mWvvamt z37jBkjW5BBYXd3CtAfv7A72h/6i+GMOxhrv44aC6rjh+3JJDX+K4FSXhE+X0iFv3K JotN5C214FRrmfD1xEAVk51ex92YnFCPH9frsfl0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:27 +0100 Subject: [PATCH bpf-next 8/9] HID: bpf: constify BPF ops Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-8-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=1184; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=wNs3Wb11muL3asSVvBpcSkxAu1290QussnP8tf9Yvjg=; b=8LGTCLhU0HxX6GwS9jdWYvJajU7R38vOLd7IfmazH1xj2Oo1MF9Y18jR7dDggU3YdzdLFG4am fh84tTfDvhkAcYO1QRer7xtXMctCEAXmMJLq7RTffVXUgPcgsuTJu8T X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The BPF core now allows the registration of read-only ops tables, make use of it. Signed-off-by: Thomas Weißschuh --- drivers/hid/bpf/hid_bpf_struct_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/bpf/hid_bpf_struct_ops.c b/drivers/hid/bpf/hid_bpf_struct_ops.c index 0e611a9d79d753213abbdf81f7ac0557e50c2ede..2baefb351a01fcb351fd6da8ca72f42d27779df5 100644 --- a/drivers/hid/bpf/hid_bpf_struct_ops.c +++ b/drivers/hid/bpf/hid_bpf_struct_ops.c @@ -289,14 +289,14 @@ static int __hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, u64 source) return 0; } -static struct hid_bpf_ops __bpf_hid_bpf_ops = { +static const struct hid_bpf_ops __bpf_hid_bpf_ops = { .hid_device_event = __hid_bpf_device_event, .hid_rdesc_fixup = __hid_bpf_rdesc_fixup, .hid_hw_request = __hid_bpf_hw_request, .hid_hw_output_report = __hid_bpf_hw_output_report, }; -static struct bpf_struct_ops bpf_hid_bpf_ops = { +static const struct bpf_struct_ops bpf_hid_bpf_ops = { .verifier_ops = &hid_bpf_verifier_ops, .init = hid_bpf_ops_init, .check_member = hid_bpf_ops_check_member, From patchwork Wed Nov 27 19:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13887324 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 B0364204084; Wed, 27 Nov 2024 19:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; cv=none; b=I8Lpma6sES8xhVaGodOWaEVMpa/V425gMaV3ieZ7qM+OJrStVKHXZ64YwepygeuOOEQ+I8bkEckXhCMxwygbK6eLP/E6KHBV5ee3V4yzb59BkSl9P7rAET8Au8EHByfH5E6ZaYr/S9WEkcYCg4SiyRtNEVD4IDMI3cIu2ZXJ8L4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732735254; c=relaxed/simple; bh=nbtK+ExfnhyZ5gIuDVa+ktGgkDaweYMcUS0HqG+YpRw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RNsmI0FNTCSTyceNkRHtJN2LTQrnnXvNIJMV9HLb17rvGsWC2vFtDMsc3TV9ycANtODNj/vQpZrVVkhgAi2z3UjvzDGJPVb7tLHA3SCMg4y9xSmcj0dkZusXSywn5t+kfBd/rAfGgMpO77QaS5XZTRCwas0G0hP9cQXE/XPP5kQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=tLcqbmWn; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="tLcqbmWn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1732735246; bh=nbtK+ExfnhyZ5gIuDVa+ktGgkDaweYMcUS0HqG+YpRw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tLcqbmWncVQtNYbVmUS4nz2f9F8Sx7+sQ72Vs2nHeofqor4aTS3Il377VCKRGDT7Q dKW3SknUt3I14pxhEcaF/reEIcmCbarycyi41v4gBcbJ2FACOmrnB4Gf0+y+eNVCDM 88W4vgzgoW0v+q70nDmi49oCKF5tVMYU1tx/pbMI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 27 Nov 2024 20:15:28 +0100 Subject: [PATCH bpf-next 9/9] sched_ext: Constify BPF ops Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241127-bpf-const-ops-v1-9-a698b8d58680@weissschuh.net> References: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> In-Reply-To: <20241127-bpf-const-ops-v1-0-a698b8d58680@weissschuh.net> To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Martin KaFai Lau , Kui-Feng Lee , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jiri Kosina , Benjamin Tissoires , Tejun Heo , David Vernet , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732735245; l=1292; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=nbtK+ExfnhyZ5gIuDVa+ktGgkDaweYMcUS0HqG+YpRw=; b=5zWiiR7OeqVtKBCAJqaHUdaXLiAsRczQ+k3xFIAeIbrkbMHLGvOzyXVhTwQ3uzOF+d0gwO38M 3MftYCnHb5cDCybqRyCLbxCaiQaluJkIYv+kFJkBeG3IpjA8QsuHTkB X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The BPF core now allows the registration of read-only ops tables, make use of it. Signed-off-by: Thomas Weißschuh --- kernel/sched/ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c index 7fff1d0454770f5fab3e13708816d56653637ee9..6d3cced2951f61b73e6779edfb62b63c1ab62093 100644 --- a/kernel/sched/ext.c +++ b/kernel/sched/ext.c @@ -5914,7 +5914,7 @@ static void sched_ext_ops__dump(struct scx_dump_ctx *ctx) {} static void sched_ext_ops__dump_cpu(struct scx_dump_ctx *ctx, s32 cpu, bool idle) {} static void sched_ext_ops__dump_task(struct scx_dump_ctx *ctx, struct task_struct *p) {} -static struct sched_ext_ops __bpf_ops_sched_ext_ops = { +static const struct sched_ext_ops __bpf_ops_sched_ext_ops = { .select_cpu = sched_ext_ops__select_cpu, .enqueue = sched_ext_ops__enqueue, .dequeue = sched_ext_ops__dequeue, @@ -5952,7 +5952,7 @@ static struct sched_ext_ops __bpf_ops_sched_ext_ops = { .dump_task = sched_ext_ops__dump_task, }; -static struct bpf_struct_ops bpf_sched_ext_ops = { +static const struct bpf_struct_ops bpf_sched_ext_ops = { .verifier_ops = &bpf_scx_verifier_ops, .reg = bpf_scx_reg, .unreg = bpf_scx_unreg,