Skip to content

Commit 887cd30

Browse files
tititiou36jgunthorpe
authored andcommitted
IB/hfi1: Constify struct flag_table
'struct flag_table' are not modified in this driver. Constifying this structure moves some data to a read-only section, so increase overall security. On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 302932 40271 112 343315 53d13 drivers/infiniband/hw/hfi1/chip.o After: ===== text data bss dec hex filename 311636 31567 112 343315 53d13 drivers/infiniband/hw/hfi1/chip.o Link: https://lore.kernel.org/r/782b6a648bfbbf2bb83f81a73c0460b5bb7642a1.1720959310.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 1df03a4 commit 887cd30

File tree

1 file changed

+15
-15
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+15
-15
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ struct flag_table {
251251
/*
252252
* CCE Error flags.
253253
*/
254-
static struct flag_table cce_err_status_flags[] = {
254+
static const struct flag_table cce_err_status_flags[] = {
255255
/* 0*/ FLAG_ENTRY0("CceCsrParityErr",
256256
CCE_ERR_STATUS_CCE_CSR_PARITY_ERR_SMASK),
257257
/* 1*/ FLAG_ENTRY0("CceCsrReadBadAddrErr",
@@ -341,7 +341,7 @@ static struct flag_table cce_err_status_flags[] = {
341341
* Misc Error flags
342342
*/
343343
#define MES(text) MISC_ERR_STATUS_MISC_##text##_ERR_SMASK
344-
static struct flag_table misc_err_status_flags[] = {
344+
static const struct flag_table misc_err_status_flags[] = {
345345
/* 0*/ FLAG_ENTRY0("CSR_PARITY", MES(CSR_PARITY)),
346346
/* 1*/ FLAG_ENTRY0("CSR_READ_BAD_ADDR", MES(CSR_READ_BAD_ADDR)),
347347
/* 2*/ FLAG_ENTRY0("CSR_WRITE_BAD_ADDR", MES(CSR_WRITE_BAD_ADDR)),
@@ -360,7 +360,7 @@ static struct flag_table misc_err_status_flags[] = {
360360
/*
361361
* TXE PIO Error flags and consequences
362362
*/
363-
static struct flag_table pio_err_status_flags[] = {
363+
static const struct flag_table pio_err_status_flags[] = {
364364
/* 0*/ FLAG_ENTRY("PioWriteBadCtxt",
365365
SEC_WRITE_DROPPED,
366366
SEND_PIO_ERR_STATUS_PIO_WRITE_BAD_CTXT_ERR_SMASK),
@@ -502,7 +502,7 @@ static struct flag_table pio_err_status_flags[] = {
502502
/*
503503
* TXE SDMA Error flags
504504
*/
505-
static struct flag_table sdma_err_status_flags[] = {
505+
static const struct flag_table sdma_err_status_flags[] = {
506506
/* 0*/ FLAG_ENTRY0("SDmaRpyTagErr",
507507
SEND_DMA_ERR_STATUS_SDMA_RPY_TAG_ERR_SMASK),
508508
/* 1*/ FLAG_ENTRY0("SDmaCsrParityErr",
@@ -530,7 +530,7 @@ static struct flag_table sdma_err_status_flags[] = {
530530
* TXE Egress Error flags
531531
*/
532532
#define SEES(text) SEND_EGRESS_ERR_STATUS_##text##_ERR_SMASK
533-
static struct flag_table egress_err_status_flags[] = {
533+
static const struct flag_table egress_err_status_flags[] = {
534534
/* 0*/ FLAG_ENTRY0("TxPktIntegrityMemCorErr", SEES(TX_PKT_INTEGRITY_MEM_COR)),
535535
/* 1*/ FLAG_ENTRY0("TxPktIntegrityMemUncErr", SEES(TX_PKT_INTEGRITY_MEM_UNC)),
536536
/* 2 reserved */
@@ -631,7 +631,7 @@ static struct flag_table egress_err_status_flags[] = {
631631
* TXE Egress Error Info flags
632632
*/
633633
#define SEEI(text) SEND_EGRESS_ERR_INFO_##text##_ERR_SMASK
634-
static struct flag_table egress_err_info_flags[] = {
634+
static const struct flag_table egress_err_info_flags[] = {
635635
/* 0*/ FLAG_ENTRY0("Reserved", 0ull),
636636
/* 1*/ FLAG_ENTRY0("VLErr", SEEI(VL)),
637637
/* 2*/ FLAG_ENTRY0("JobKeyErr", SEEI(JOB_KEY)),
@@ -680,7 +680,7 @@ static struct flag_table egress_err_info_flags[] = {
680680
* TXE Send error flags
681681
*/
682682
#define SES(name) SEND_ERR_STATUS_SEND_##name##_ERR_SMASK
683-
static struct flag_table send_err_status_flags[] = {
683+
static const struct flag_table send_err_status_flags[] = {
684684
/* 0*/ FLAG_ENTRY0("SendCsrParityErr", SES(CSR_PARITY)),
685685
/* 1*/ FLAG_ENTRY0("SendCsrReadBadAddrErr", SES(CSR_READ_BAD_ADDR)),
686686
/* 2*/ FLAG_ENTRY0("SendCsrWriteBadAddrErr", SES(CSR_WRITE_BAD_ADDR))
@@ -689,7 +689,7 @@ static struct flag_table send_err_status_flags[] = {
689689
/*
690690
* TXE Send Context Error flags and consequences
691691
*/
692-
static struct flag_table sc_err_status_flags[] = {
692+
static const struct flag_table sc_err_status_flags[] = {
693693
/* 0*/ FLAG_ENTRY("InconsistentSop",
694694
SEC_PACKET_DROPPED | SEC_SC_HALTED,
695695
SEND_CTXT_ERR_STATUS_PIO_INCONSISTENT_SOP_ERR_SMASK),
@@ -712,7 +712,7 @@ static struct flag_table sc_err_status_flags[] = {
712712
* RXE Receive Error flags
713713
*/
714714
#define RXES(name) RCV_ERR_STATUS_RX_##name##_ERR_SMASK
715-
static struct flag_table rxe_err_status_flags[] = {
715+
static const struct flag_table rxe_err_status_flags[] = {
716716
/* 0*/ FLAG_ENTRY0("RxDmaCsrCorErr", RXES(DMA_CSR_COR)),
717717
/* 1*/ FLAG_ENTRY0("RxDcIntfParityErr", RXES(DC_INTF_PARITY)),
718718
/* 2*/ FLAG_ENTRY0("RxRcvHdrUncErr", RXES(RCV_HDR_UNC)),
@@ -847,7 +847,7 @@ static struct flag_table rxe_err_status_flags[] = {
847847
* DCC Error Flags
848848
*/
849849
#define DCCE(name) DCC_ERR_FLG_##name##_SMASK
850-
static struct flag_table dcc_err_flags[] = {
850+
static const struct flag_table dcc_err_flags[] = {
851851
FLAG_ENTRY0("bad_l2_err", DCCE(BAD_L2_ERR)),
852852
FLAG_ENTRY0("bad_sc_err", DCCE(BAD_SC_ERR)),
853853
FLAG_ENTRY0("bad_mid_tail_err", DCCE(BAD_MID_TAIL_ERR)),
@@ -900,7 +900,7 @@ static struct flag_table dcc_err_flags[] = {
900900
* LCB error flags
901901
*/
902902
#define LCBE(name) DC_LCB_ERR_FLG_##name##_SMASK
903-
static struct flag_table lcb_err_flags[] = {
903+
static const struct flag_table lcb_err_flags[] = {
904904
/* 0*/ FLAG_ENTRY0("CSR_PARITY_ERR", LCBE(CSR_PARITY_ERR)),
905905
/* 1*/ FLAG_ENTRY0("INVALID_CSR_ADDR", LCBE(INVALID_CSR_ADDR)),
906906
/* 2*/ FLAG_ENTRY0("RST_FOR_FAILED_DESKEW", LCBE(RST_FOR_FAILED_DESKEW)),
@@ -943,7 +943,7 @@ static struct flag_table lcb_err_flags[] = {
943943
* DC8051 Error Flags
944944
*/
945945
#define D8E(name) DC_DC8051_ERR_FLG_##name##_SMASK
946-
static struct flag_table dc8051_err_flags[] = {
946+
static const struct flag_table dc8051_err_flags[] = {
947947
FLAG_ENTRY0("SET_BY_8051", D8E(SET_BY_8051)),
948948
FLAG_ENTRY0("LOST_8051_HEART_BEAT", D8E(LOST_8051_HEART_BEAT)),
949949
FLAG_ENTRY0("CRAM_MBE", D8E(CRAM_MBE)),
@@ -962,7 +962,7 @@ static struct flag_table dc8051_err_flags[] = {
962962
*
963963
* Flags in DC8051_DBG_ERR_INFO_SET_BY_8051.ERROR field.
964964
*/
965-
static struct flag_table dc8051_info_err_flags[] = {
965+
static const struct flag_table dc8051_info_err_flags[] = {
966966
FLAG_ENTRY0("Spico ROM check failed", SPICO_ROM_FAILED),
967967
FLAG_ENTRY0("Unknown frame received", UNKNOWN_FRAME),
968968
FLAG_ENTRY0("Target BER not met", TARGET_BER_NOT_MET),
@@ -986,7 +986,7 @@ static struct flag_table dc8051_info_err_flags[] = {
986986
*
987987
* Flags in DC8051_DBG_ERR_INFO_SET_BY_8051.HOST_MSG field.
988988
*/
989-
static struct flag_table dc8051_info_host_msg_flags[] = {
989+
static const struct flag_table dc8051_info_host_msg_flags[] = {
990990
FLAG_ENTRY0("Host request done", 0x0001),
991991
FLAG_ENTRY0("BC PWR_MGM message", 0x0002),
992992
FLAG_ENTRY0("BC SMA message", 0x0004),
@@ -5275,7 +5275,7 @@ static int append_str(char *buf, char **curp, int *lenp, const char *s)
52755275
* the buffer. End in '*' if the buffer is too short.
52765276
*/
52775277
static char *flag_string(char *buf, int buf_len, u64 flags,
5278-
struct flag_table *table, int table_size)
5278+
const struct flag_table *table, int table_size)
52795279
{
52805280
char extra[32];
52815281
char *p = buf;

0 commit comments

Comments
 (0)