From patchwork Sun Jun 16 07:57:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13699463 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 825ECC27C77 for ; Sun, 16 Jun 2024 07:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=9PkIY/+JvPRQH3lG8FJNGa1VEAbWJvoCrfAn8QG8UOQ=; b=n/R4fNG5vAs1X3RKgUA+83Dent zzZgLwxkRmbgsTxERqItBiiilri3hCR9cM8mN1xI6I8JiSka5DnRPJzTH/ehAMQxnAKJGFoF9qaVy CLFiA8pYIbBmMO4NIJC/7ujl8/VYgOBRoERHLHcEWX4vOq3Mk+t+rRlSoFEm3ZdhpKfthFvO/ad+Y QXM507QK+xi8hwtic5Cu3DK4ywI8gpB3mk6h49Ahz1K5qCT8HAr+nDx3LHXS7KwADgqTL/Tg/7Fmr 1ybcX/MdRSMvives6EfLOBfKb6PD1rE/aIH8eLirtccK61fYyizHQMfI7JEPr1VZNjruzy2alDfaD 2n9ecwIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIkmH-000000074r7-001v; Sun, 16 Jun 2024 07:58:17 +0000 Received: from out-67.smtpout.orange.fr ([193.252.22.67] helo=msa.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIkmC-000000074qX-0sso for linux-arm-kernel@lists.infradead.org; Sun, 16 Jun 2024 07:58:14 +0000 Received: from fedora.home ([86.243.222.230]) by smtp.orange.fr with ESMTPA id Ikm4sPtRXuRA3Ikm4selgw; Sun, 16 Jun 2024 09:58:09 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1718524689; bh=9PkIY/+JvPRQH3lG8FJNGa1VEAbWJvoCrfAn8QG8UOQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Q/A1m8nE15VUD/F2KcFqQih3WKQqzCifDKGM/2EAxMQuLgsA1LyLfRtrEmPYV+Vqd STY3RwYuI1z7WiPj9tuxMFpl1eBPybkYBaaz8Zu01+YPVXzoGpB9izrLaVD5wplg2i t8WoLktVjxlysIhGPNCEga6dOPNTE8k87gzCBdYwa/WCLrLca25kv8Gu5lggYiUf1O /3zzT/U2k55aKMYfPki78VajtGkxfrH2HqfYG+T65uxF1naq/n6Kt+LgZTfc1UQmkG egZmBWxCTSR193wV1xn33tEcGTLRucGFwUXesx9ySaEK9jR1sAYo487TUP4FusDu8V pnurseGbfG92w== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 16 Jun 2024 09:58:09 +0200 X-ME-IP: 86.243.222.230 From: Christophe JAILLET To: Horatiu Vultur , UNGLinuxDriver@microchip.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lars Povlsen , Steen Hegelund , Daniel Machon Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next] net: microchip: Constify struct vcap_operations Date: Sun, 16 Jun 2024 09:57:56 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240616_005812_826350_7D71C8BE X-CRM114-Status: GOOD ( 14.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org "struct vcap_operations" are not modified in these drivers. Constifying this structure moves some data to a read-only section, so increase overall security. In order to do it, "struct vcap_control" also needs to be adjusted to this new const qualifier. As an example, on a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 15176 1094 16 16286 3f9e drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.o After: ===== text data bss dec hex filename 15268 998 16 16282 3f9a drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.o Signed-off-by: Christophe JAILLET Reviewed-by: Daniel Machon --- I hope this can be applied as a single patch. I think it can be split between lan966x, sparx5 and vcap if really needed. --- drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c | 2 +- drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c | 2 +- drivers/net/ethernet/microchip/vcap/vcap_api.h | 2 +- drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c | 2 +- drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c b/drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c index a4414f63c9b1..a1471e38d118 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_vcap_impl.c @@ -581,7 +581,7 @@ static void lan966x_vcap_move(struct net_device *dev, lan966x_vcap_wait_update(lan966x, admin->tgt_inst); } -static struct vcap_operations lan966x_vcap_ops = { +static const struct vcap_operations lan966x_vcap_ops = { .validate_keyset = lan966x_vcap_validate_keyset, .add_default_fields = lan966x_vcap_add_default_fields, .cache_erase = lan966x_vcap_cache_erase, diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c b/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c index 187efa1fc904..967c8621c250 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_vcap_impl.c @@ -1507,7 +1507,7 @@ static void sparx5_vcap_move(struct net_device *ndev, struct vcap_admin *admin, } } -static struct vcap_operations sparx5_vcap_ops = { +static const struct vcap_operations sparx5_vcap_ops = { .validate_keyset = sparx5_vcap_validate_keyset, .add_default_fields = sparx5_vcap_add_default_fields, .cache_erase = sparx5_vcap_cache_erase, diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.h b/drivers/net/ethernet/microchip/vcap/vcap_api.h index 9eccfa633c1a..6069ad95c27e 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api.h +++ b/drivers/net/ethernet/microchip/vcap/vcap_api.h @@ -271,7 +271,7 @@ struct vcap_operations { /* VCAP API Client control interface */ struct vcap_control { - struct vcap_operations *ops; /* client supplied operations */ + const struct vcap_operations *ops; /* client supplied operations */ const struct vcap_info *vcaps; /* client supplied vcap models */ const struct vcap_statistics *stats; /* client supplied vcap stats */ struct list_head list; /* list of vcap instances */ diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c index b23c11b0647c..9c9d38042125 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs_kunit.c @@ -221,7 +221,7 @@ static int vcap_test_port_info(struct net_device *ndev, return 0; } -static struct vcap_operations test_callbacks = { +static const struct vcap_operations test_callbacks = { .validate_keyset = test_val_keyset, .add_default_fields = test_add_def_fields, .cache_erase = test_cache_erase, diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c index fe4e166de8a0..51d9423b08a6 100644 --- a/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c +++ b/drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c @@ -211,7 +211,7 @@ static int vcap_test_port_info(struct net_device *ndev, return 0; } -static struct vcap_operations test_callbacks = { +static const struct vcap_operations test_callbacks = { .validate_keyset = test_val_keyset, .add_default_fields = test_add_def_fields, .cache_erase = test_cache_erase,