lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <62ac505b660f433745f98de5ee468671e5c63a0b.1721680761.git.christophe.jaillet@wanadoo.fr>
Date: Mon, 22 Jul 2024 22:39:48 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Ofir Bitton <obitton@...ana.ai>,
	Oded Gabbay <ogabbay@...nel.org>
Cc: linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org,
	Christophe JAILLET <christophe.jaillet@...adoo.fr>,
	dri-devel@...ts.freedesktop.org
Subject: [PATCH] accel/habanalabs/gaudi2: Constify several structures

These structures are not modified in this driver.

Constifying this structure moves about 8 ko of data to a read-only section,
so increase overall security.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
 191214	 134180	    456	 325850	  4f8da	drivers/accel/habanalabs/gaudi2/gaudi2.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
 198862	 126532	    456	 325850	  4f8da	drivers/accel/habanalabs/gaudi2/gaudi2.o


Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Compile tested-only.

A much bigger step, would be to constify gaudi2_irq_map_table.
But drivers/accel/habanalabs/include/gaudi2/gaudi2_async_ids_map_extended.h
states that this is a generated file. So I just report it here, could
someone modify the software that generates this file.

This would constify an additional 110 ko of data. Not too bad, for just 5
more letters!

   text	   data	    bss	    dec	    hex	filename
 310314	  14884	    456	 325654	  4f816	drivers/accel/habanalabs/gaudi2/gaudi2.o
---
 drivers/accel/habanalabs/gaudi2/gaudi2.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/accel/habanalabs/gaudi2/gaudi2.c b/drivers/accel/habanalabs/gaudi2/gaudi2.c
index a38b88baadf2..40aebae29ab1 100644
--- a/drivers/accel/habanalabs/gaudi2/gaudi2.c
+++ b/drivers/accel/habanalabs/gaudi2/gaudi2.c
@@ -173,7 +173,7 @@ struct gaudi2_razwi_info {
 	char *eng_name;
 };
 
-static struct gaudi2_razwi_info common_razwi_info[] = {
+static const struct gaudi2_razwi_info common_razwi_info[] = {
 		{RAZWI_INITIATOR_ID_X_Y(2, 4, 0), mmDCORE0_RTR0_CTRL_BASE,
 				GAUDI2_DCORE0_ENGINE_ID_DEC_0, "DEC0"},
 		{RAZWI_INITIATOR_ID_X_Y(2, 4, 4), mmDCORE0_RTR0_CTRL_BASE,
@@ -338,7 +338,7 @@ static struct gaudi2_razwi_info common_razwi_info[] = {
 				GAUDI2_ENGINE_ID_PSOC, "PSOC"}
 };
 
-static struct gaudi2_razwi_info mme_razwi_info[] = {
+static const struct gaudi2_razwi_info mme_razwi_info[] = {
 		/* MME X high coordinate is N/A, hence using only low coordinates */
 		{RAZWI_INITIATOR_ID_X_Y_LOW(7, 4), mmDCORE0_RTR5_CTRL_BASE,
 				GAUDI2_DCORE0_ENGINE_ID_MME, "MME0_WAP0"},
@@ -2108,7 +2108,7 @@ struct hbm_mc_error_causes {
 	char cause[50];
 };
 
-static struct hl_special_block_info gaudi2_special_blocks[] = GAUDI2_SPECIAL_BLOCKS;
+static const struct hl_special_block_info gaudi2_special_blocks[] = GAUDI2_SPECIAL_BLOCKS;
 
 /* Special blocks iterator is currently used to configure security protection bits,
  * and read global errors. Most HW blocks are addressable and those who aren't (N/A)-
@@ -2116,14 +2116,14 @@ static struct hl_special_block_info gaudi2_special_blocks[] = GAUDI2_SPECIAL_BLO
  * and global error reading, since currently they both share the same settings.
  * Once it changes, we must remember to use separate configurations for either one.
  */
-static int gaudi2_iterator_skip_block_types[] = {
+static const int gaudi2_iterator_skip_block_types[] = {
 		GAUDI2_BLOCK_TYPE_PLL,
 		GAUDI2_BLOCK_TYPE_EU_BIST,
 		GAUDI2_BLOCK_TYPE_HBM,
 		GAUDI2_BLOCK_TYPE_XFT
 };
 
-static struct range gaudi2_iterator_skip_block_ranges[] = {
+static const struct range gaudi2_iterator_skip_block_ranges[] = {
 		/* Skip all PSOC blocks except for PSOC_GLOBAL_CONF */
 		{mmPSOC_I2C_M0_BASE, mmPSOC_EFUSE_BASE},
 		{mmPSOC_BTL_BASE, mmPSOC_MSTR_IF_RR_SHRD_HBW_BASE},
@@ -2132,7 +2132,7 @@ static struct range gaudi2_iterator_skip_block_ranges[] = {
 		{mmCPU_TIMESTAMP_BASE, mmCPU_MSTR_IF_RR_SHRD_HBW_BASE}
 };
 
-static struct hbm_mc_error_causes hbm_mc_spi[GAUDI2_NUM_OF_HBM_MC_SPI_CAUSE] = {
+static const struct hbm_mc_error_causes hbm_mc_spi[GAUDI2_NUM_OF_HBM_MC_SPI_CAUSE] = {
 	{HBM_MC_SPI_TEMP_PIN_CHG_MASK, "temperature pins changed"},
 	{HBM_MC_SPI_THR_ENG_MASK, "temperature-based throttling engaged"},
 	{HBM_MC_SPI_THR_DIS_ENG_MASK, "temperature-based throttling disengaged"},
@@ -8300,9 +8300,9 @@ static void gaudi2_check_if_razwi_happened(struct hl_device *hdev)
 		gaudi2_ack_module_razwi_event_handler(hdev, RAZWI_ROT, mod_idx, 0, NULL);
 }
 
-static int gaudi2_psoc_razwi_get_engines(struct gaudi2_razwi_info *razwi_info, u32 array_size,
-						u32 axuser_xy, u32 *base, u16 *eng_id,
-						char *eng_name)
+static int gaudi2_psoc_razwi_get_engines(const struct gaudi2_razwi_info *razwi_info,
+					 u32 array_size, u32 axuser_xy,
+					 u32 *base, u16 *eng_id, char *eng_name)
 {
 
 	int i, num_of_eng = 0;
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ