implement minimum security revision
Subsystems (5)
cover implement minimum security revision
The ice device has security revision fields associated with the ``fw.undi`` and ``fw.mgmt`` sections of the flash. Additionally each of these security revisions has a minimum security revision device parameter.
The minimum security revision indicates the lowest security revision that will be loaded by the device. If the associated flash section has a lower security revision, the device will not load it.
Implement support for displaying and updating the minimum security revision fields for the device as driver-specific devlink parameters.
Jacob Keller (4):
ice: create flash_info structure and separate NVM version
ice: cache NVM module bank information
ice: read security revision to ice_nvm_info and ice_orom_info
ice: add devlink parameters to read and write minimum security
revision
Documentation/networking/devlink/ice.rst | 43 ++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 17 + drivers/net/ethernet/intel/ice/ice_devlink.c | 254 ++++++++- drivers/net/ethernet/intel/ice/ice_devlink.h | 2 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 8 +- drivers/net/ethernet/intel/ice/ice_main.c | 3 + drivers/net/ethernet/intel/ice/ice_nvm.c | 532 ++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_nvm.h | 4 + drivers/net/ethernet/intel/ice/ice_type.h | 91 ++- 9 files changed, 888 insertions(+), 66 deletions(-)
base-commit: f2e834694b0d92187d889172da842e27829df371
Signature · 1 line
2.28.0.497.g54e85e7af1ac
PATCH 1/4 ice: create flash_info structure and separate NVM version
The ice_nvm_info structure has become somewhat of a dumping ground for all of the fields related to flash version. It holds the NVM version and EETRACK id, the OptionROM info structure, the flash size, the ShadowRAM size, and more.
A future change is going to add the ability to read the NVM version and EETRACK ID from the inactive NVM bank. To make this simpler, it is useful to have these NVM version info fields extracted to their own structure.
Rename ice_nvm_info into ice_flash_info, and create a separate ice_nvm_info structure that will contain the eetrack and NVM map version. Move the netlist_ver structure into ice_flash_info and rename it ice_netlist_info for consistency.
Modify the static ice_get_orom_ver_info to take the option rom structure as a pointer. This makes it more obvious what portion of the hw struct is being modified. Do the same for ice_get_netlist_ver_info.
Introduce a new ice_get_nvm_ver_info function, which will be similar to ice_get_orom_ver_info and ice_get_netlist_ver_info, used to keep the NVM version extraction code co-located.
--- drivers/net/ethernet/intel/ice/ice_devlink.c | 16 ++-- drivers/net/ethernet/intel/ice/ice_ethtool.c | 8 +- drivers/net/ethernet/intel/ice/ice_nvm.c | 97 ++++++++++++-------- drivers/net/ethernet/intel/ice/ice_type.h | 37 ++++---- 4 files changed, 93 insertions(+), 65 deletions(-)
drivers/net/ethernet/intel/ice/ice_devlink.c +8 -8
@@ -62,7 +62,7 @@ static int ice_info_fw_build(struct ice_pf *pf, char *buf, size_t len)static int ice_info_orom_ver (struct ice_pf *pf,char *buf,size_t len) { -struct ice_orom_info *orom = &pf->hw.nvm.orom; +struct ice_orom_info *orom = &pf->hw.flash.orom;snprintf (buf, len,"%u.%u.%u" , orom->major, orom->build, orom->patch);
@@ -71,16 +71,16 @@ static int ice_info_orom_ver(struct ice_pf *pf, char *buf, size_t len)static int ice_info_nvm_ver (struct ice_pf *pf,char *buf,size_t len) { -struct ice_nvm_info *nvm = &pf->hw.nvm; +struct ice_nvm_info *nvm = &pf->hw.flash.nvm; -snprintf (buf, len,"%x.%02x" , nvm->major_ver, nvm->minor_ver); +snprintf (buf, len,"%x.%02x" , nvm->major, nvm->minor);return 0 ; }static int ice_info_eetrack (struct ice_pf *pf,char *buf,size_t len) { -struct ice_nvm_info *nvm = &pf->hw.nvm; +struct ice_nvm_info *nvm = &pf->hw.flash.nvm;snprintf (buf, len,"0x%08x" , nvm->eetrack);
@@ -108,7 +108,7 @@ static int ice_info_ddp_pkg_version(struct ice_pf *pf, char *buf, size_t len)static int ice_info_netlist_ver (struct ice_pf *pf,char *buf,size_t len) { -struct ice_netlist_ver_info *netlist = &pf->hw.netlist_ver; +struct ice_netlist_info *netlist = &pf->hw.flash.netlist;/* The netlist version fields are BCD formatted */ snprintf(buf, len, "%x.%x.%x-%x.%x.%x", netlist->major, netlist->minor,
@@ -120,7 +120,7 @@ static int ice_info_netlist_ver(struct ice_pf *pf, char *buf, size_t len)static int ice_info_netlist_build (struct ice_pf *pf,char *buf,size_t len) { -struct ice_netlist_ver_info *netlist = &pf->hw.netlist_ver; +struct ice_netlist_info *netlist = &pf->hw.flash.netlist;snprintf (buf, len,"0x%08x" , netlist->hash);
@@ -436,7 +436,7 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,void *nvm_data;u32 nvm_size; - nvm_size = hw->nvm.flash_size; + nvm_size = hw->flash.flash_size; nvm_data =vzalloc (nvm_size);if (!nvm_data)return -ENOMEM ;
@@ -536,7 +536,7 @@ void ice_devlink_init_regions(struct ice_pf *pf)struct device *dev =ice_pf_to_dev (pf);u64 nvm_size; - nvm_size = pf->hw.nvm.flash_size; + nvm_size = pf->hw.flash.flash_size; pf->nvm_region =devlink_region_create (devlink, &ice_nvm_region_ops,1 , nvm_size);if (IS_ERR (pf->nvm_region)) {
drivers/net/ethernet/intel/ice/ice_ethtool.c +4 -4
@@ -179,8 +179,8 @@ ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)struct ice_orom_info *orom;struct ice_nvm_info *nvm; - nvm = &hw->nvm; - orom = &nvm->orom; + nvm = &hw->flash.nvm; + orom = &hw->flash.orom;strscpy (drvinfo->driver,KBUILD_MODNAME ,sizeof (drvinfo->driver));
@@ -188,7 +188,7 @@ ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)* determined) which contains more pertinent information. */ snprintf (drvinfo->fw_version,sizeof (drvinfo->fw_version), -"%x.%02x 0x%x %d.%d.%d" , nvm->major_ver, nvm->minor_ver, +"%x.%02x 0x%x %d.%d.%d" , nvm->major, nvm->minor, nvm->eetrack, orom->major, orom->build, orom->patch); strscpy(drvinfo->bus_info, pci_name(pf->pdev),
@@ -250,7 +250,7 @@ static int ice_get_eeprom_len(struct net_device *netdev)struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_pf *pf = np->vsi->back; -return (int )pf->hw.nvm.flash_size; +return (int )pf->hw.flash.flash_size; } static int
drivers/net/ethernet/intel/ice/ice_nvm.c +60 -37
187 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_type.h +21 -16
@@ -313,14 +313,30 @@ struct ice_orom_info {u16 build;/* Build version of OROM */ }; -/* NVM Information */ +/* NVM version information */ struct ice_nvm_info { +u32 eetrack; +u8 major; +u8 minor; +}; + +/* netlist version information */ +struct ice_netlist_info { +u32 major;/* major high/low */ +u32 minor;/* minor high/low */ +u32 type;/* type high/low */ +u32 rev;/* revision high/low */ +u32 hash;/* SHA-1 hash word */ +u16 cust_ver;/* customer version */ +}; + +/* Flash Chip Information */ +struct ice_flash_info {struct ice_orom_info orom;/* Option ROM version info */ -u32 eetrack;/* NVM data version */ +struct ice_nvm_info nvm;/* NVM version information */ +struct ice_netlist_info netlist;/* Netlist version info */ u16 sr_words;/* Shadow RAM size in words */ u32 flash_size;/* Size of available flash in bytes */ -u8 major_ver;/* major version of NVM package */ -u8 minor_ver;/* minor version of dev starter */ u8 blank_nvm_mode;/* is NVM empty (no FW present) */ };
@@ -348,16 +364,6 @@ struct ice_link_default_override_tlv {#define ICE_NVM_VER_LEN 32 -/* netlist version information */ -struct ice_netlist_ver_info { -u32 major;/* major high/low */ -u32 minor;/* minor high/low */ -u32 type;/* type high/low */ -u32 rev;/* revision high/low */ -u32 hash;/* SHA-1 hash word */ -u16 cust_ver;/* customer version */ -}; -/* Max number of port to queue branches w.r.t topology */ #define ICE_MAX_TRAFFIC_CLASS 8#define ICE_TXSCHED_MAX_BRANCHES ICE_MAX_TRAFFIC_CLASS
@@ -605,10 +611,9 @@ struct ice_hw {u8 evb_veb;/* true for VEB, false for VEPA */ u8 reset_ongoing;/* true if HW is in reset, false otherwise */ struct ice_bus_info bus; -struct ice_nvm_info nvm; +struct ice_flash_info flash;struct ice_hw_dev_caps dev_caps;/* device capabilities */ struct ice_hw_func_caps func_caps;/* function capabilities */ -struct ice_netlist_ver_info netlist_ver;/* netlist version info */ struct ice_switch_info *switch_info;/* switch filter lists */
Signature · 1 line
2.28.0.497.g54e85e7af1ac
PATCH 2/4 ice: cache NVM module bank information
In reply to Jacob KellerThe ice flash contains two copies of each of the NVM, Option ROM, and Netlist modules. Each bank has a pointer word and a size word. In order to correctly read from the active flash bank, the driver must calculate the offset manually.
During NVM initialization, read the Shadow RAM control word and determine which bank is active for each NVM module. Additionally, cache the size and pointer values for use in calculating the correct offset.
--- drivers/net/ethernet/intel/ice/ice_nvm.c | 151 ++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_type.h | 37 ++++++ 2 files changed, 188 insertions(+)
drivers/net/ethernet/intel/ice/ice_nvm.c +151 -0
@@ -609,6 +609,151 @@ static enum ice_status ice_discover_flash_size(struct ice_hw *hw)return status; } +/** +* ice_read_sr_pointer - Read the value of a Shadow RAM pointer word +* @hw: pointer to the HW structure +* @offset: the word offset of the Shadow RAM word to read +* @pointer: pointer value read from Shadow RAM +* +* Read the given Shadow RAM word, and convert it to a pointer value specified +* in bytes. This function assumes the specified offset is a valid pointer +* word. +* +* Each pointer word specifies whether it is stored in word size or 4KB +* sector size by using the highest bit. The reported pointer value will be in +* bytes, intended for flat NVM reads. +*/ +static enum ice_status +ice_read_sr_pointer (struct ice_hw *hw,u16 offset,u32 *pointer) +{ +enum ice_status status; +u16 value; + + status =ice_read_sr_word (hw, offset, &value); +if (status) +return status; + +/* Determine if the pointer is in 4KB or word units */ +if (value &ICE_SR_NVM_PTR_4KB_UNITS ) + *pointer = (value & ~ICE_SR_NVM_PTR_4KB_UNITS ) *4 *1024 ; +else + *pointer = value *2 ; + +return 0 ; +} + +/** +* ice_read_sr_area_size - Read an area size from a Shadow RAM word +* @hw: pointer to the HW structure +* @offset: the word offset of the Shadow RAM to read +* @size: size value read from the Shadow RAM +* +* Read the given Shadow RAM word, and convert it to an area size value +* specified in bytes. This function assumes the specified offset is a valid +* area size word. +* +* Each area size word is specified in 4KB sector units. This function reports +* the size in bytes, intended for flat NVM reads. +*/ +static enum ice_status +ice_read_sr_area_size (struct ice_hw *hw,u16 offset,u32 *size) +{ +enum ice_status status; +u16 value; + + status =ice_read_sr_word (hw, offset, &value); +if (status) +return status; + +/* Area sizes are always specified in 4KB units */ + *size = value *4 *1024 ; + +return 0 ; +} + +/** +* ice_determine_active_flash_banks - Discover active bank for each module +* @hw: pointer to the HW struct +* +* Read the Shadow RAM control word and determine which banks are active for +* the NVM, OROM, and Netlist modules. Also read and calculate the associated +* pointer and size. These values are then cached into the ice_flash_info +* structure for later use in order to calculate the correct offset to read +* from the active module. +*/ +static enum ice_status +ice_determine_active_flash_banks (struct ice_hw *hw) +{ +struct ice_bank_info *banks = &hw->flash.banks; +enum ice_status status; +u16 ctrl_word; + + status =ice_read_sr_word (hw,ICE_SR_NVM_CTRL_WORD , &ctrl_word); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read the Shadow RAM control word\n" ); +return status; + } + +/* Check that the control word indicates validity */ +if ((ctrl_word &ICE_SR_CTRL_WORD_1_M ) >>ICE_SR_CTRL_WORD_1_S !=ICE_SR_CTRL_WORD_VALID ) { +ice_debug (hw,ICE_DBG_NVM ,"Shadow RAM control word is invalid\n" ); +return ICE_ERR_CFG ; + } + +if (!(ctrl_word &ICE_SR_CTRL_WORD_NVM_BANK )) + banks->nvm_bank =ICE_1ST_FLASH_BANK ; +else + banks->nvm_bank =ICE_2ND_FLASH_BANK ; + +if (!(ctrl_word &ICE_SR_CTRL_WORD_OROM_BANK )) + banks->orom_bank =ICE_1ST_FLASH_BANK ; +else + banks->orom_bank =ICE_2ND_FLASH_BANK ; + +if (!(ctrl_word &ICE_SR_CTRL_WORD_NETLIST_BANK )) + banks->netlist_bank =ICE_1ST_FLASH_BANK ; +else + banks->netlist_bank =ICE_2ND_FLASH_BANK ; + + status =ice_read_sr_pointer (hw,ICE_SR_1ST_NVM_BANK_PTR , &banks->nvm_ptr); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read NVM bank pointer\n" ); +return status; + } + + status =ice_read_sr_area_size (hw,ICE_SR_NVM_BANK_SIZE , &banks->nvm_size); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read NVM bank area size\n" ); +return status; + } + + status =ice_read_sr_pointer (hw,ICE_SR_1ST_OROM_BANK_PTR , &banks->orom_ptr); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read OROM bank pointer\n" ); +return status; + } + + status =ice_read_sr_area_size (hw,ICE_SR_OROM_BANK_SIZE , &banks->orom_size); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read OROM bank area size\n" ); +return status; + } + + status =ice_read_sr_pointer (hw,ICE_SR_NETLIST_BANK_PTR , &banks->netlist_ptr); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read Netlist bank pointer\n" ); +return status; + } + + status =ice_read_sr_area_size (hw,ICE_SR_NETLIST_BANK_SIZE , &banks->netlist_size); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to read Netlist bank area size\n" ); +return status; + } + +return 0 ; +} +/** * ice_init_nvm - initializes NVM setting * @hw: pointer to the HW struct
@@ -651,6 +796,12 @@ enum ice_status ice_init_nvm(struct ice_hw *hw)return status; } + status =ice_determine_active_flash_banks (hw); +if (status) { +ice_debug (hw,ICE_DBG_NVM ,"Failed to determine active flash banks.\n" ); +return status; + } + status =ice_get_nvm_ver_info (hw, &flash->nvm);if (status) {ice_debug (hw,ICE_DBG_INIT ,"Failed to read NVM info.\n" );
drivers/net/ethernet/intel/ice/ice_type.h +37 -0
@@ -330,11 +330,34 @@ struct ice_netlist_info {u16 cust_ver;/* customer version */ }; +/* Enumeration of possible flash banks for the NVM, OROM, and Netlist modules +* of the flash image. +*/ +enum ice_flash_bank { +ICE_INVALID_FLASH_BANK , +ICE_1ST_FLASH_BANK , +ICE_2ND_FLASH_BANK , +}; + +/* information for accessing NVM, OROM, and Netlist flash banks */ +struct ice_bank_info { +u32 nvm_ptr;/* Pointer to 1st NVM bank */ +u32 nvm_size;/* Size of NVM bank */ +u32 orom_ptr;/* Pointer to 1st OROM bank */ +u32 orom_size;/* Size of OROM bank */ +u32 netlist_ptr;/* Pointer to 1st Netlist bank */ +u32 netlist_size;/* Size of Netlist bank */ +enum ice_flash_bank nvm_bank;/* Active NVM bank */ +enum ice_flash_bank orom_bank;/* Active OROM bank */ +enum ice_flash_bank netlist_bank;/* Active Netlist bank */ +}; +/* Flash Chip Information */ struct ice_flash_info {struct ice_orom_info orom;/* Option ROM version info */ struct ice_nvm_info nvm;/* NVM version information */ struct ice_netlist_info netlist;/* Netlist version info */ +struct ice_bank_info banks;/* Flash Bank information */ u16 sr_words;/* Shadow RAM size in words */ u32 flash_size;/* Size of available flash in bytes */ u8 blank_nvm_mode;/* is NVM empty (no FW present) */
@@ -770,6 +793,7 @@ struct ice_hw_port_stats { };/* Checksum and Shadow RAM pointers */ +#define ICE_SR_NVM_CTRL_WORD 0x00#define ICE_SR_BOOT_CFG_PTR 0x132#define ICE_SR_NVM_WOL_CFG 0x19#define ICE_NVM_OROM_VER_OFF 0x02
@@ -789,10 +813,23 @@ struct ice_hw_port_stats {#define ICE_OROM_VER_MASK (0xff << ICE_OROM_VER_SHIFT)#define ICE_SR_PFA_PTR 0x40#define ICE_SR_1ST_NVM_BANK_PTR 0x42 +#define ICE_SR_NVM_BANK_SIZE 0x43#define ICE_SR_1ST_OROM_BANK_PTR 0x44 +#define ICE_SR_OROM_BANK_SIZE 0x45#define ICE_SR_NETLIST_BANK_PTR 0x46 +#define ICE_SR_NETLIST_BANK_SIZE 0x47#define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800 +/* Auxiliary field, mask, and shift definition for Shadow RAM and NVM Flash */ +#define ICE_SR_CTRL_WORD_1_S 0x06 +#define ICE_SR_CTRL_WORD_1_M (0x03 << ICE_SR_CTRL_WORD_1_S) +#define ICE_SR_CTRL_WORD_VALID 0x1 +#define ICE_SR_CTRL_WORD_OROM_BANK BIT(3) +#define ICE_SR_CTRL_WORD_NETLIST_BANK BIT(4) +#define ICE_SR_CTRL_WORD_NVM_BANK BIT(5) + +#define ICE_SR_NVM_PTR_4KB_UNITS BIT(15) +/* Link override related */ #define ICE_SR_PFA_LINK_OVERRIDE_WORDS 10#define ICE_SR_PFA_LINK_OVERRIDE_PHY_WORDS 4
Signature · 1 line
2.28.0.497.g54e85e7af1ac
PATCH 3/4 ice: read security revision to ice_nvm_info and ice_orom_info
In reply to Jacob KellerThe main NVM module and the Option ROM module contain a security revision in their CSS header. This security revision is used to determine whether or not the signed module should be loaded at bootup. If the module security revision is lower than the associated minimum security revision, it will not be loaded.
The CSS header does not have a module id associated with it, and thus requires flat NVM reads in order to access it. To do this, take advantage of the cached bank information. Introduce a new "ice_read_flash_module" function that takes the module and bank to read. Implement both ice_read_active_nvm_module and ice_read_active_orom_module. These functions will use the cached values to determine the active bank and calculate the appropriate offset.
Using these new access functions, extract the security revision for both the main NVM bank and the Option ROM into the associated info structure.
Add the security revisions to the devlink info output. Report the main NVM bank security revision as "fw.mgmt.srev". Report the Option ROM security revision as "fw.undi.srev".
A future patch will add the associated minimum security revisions as devlink flash parameters.
--- Documentation/networking/devlink/ice.rst | 9 + drivers/net/ethernet/intel/ice/ice_devlink.c | 20 +++ drivers/net/ethernet/intel/ice/ice_nvm.c | 172 +++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_type.h | 9 + 4 files changed, 210 insertions(+)
Documentation/networking/devlink/ice.rst +9 -0
@@ -38,6 +38,11 @@ The ``ice`` driver reports the following versions - running - 0x305d955f - Unique identifier of the source for the management firmware. + * - ``fw.mgmt.srev`` + - running + - 2 + - Security revision of the management firmware and associated NVM + contents. * - ``fw.undi`` - running - 1.2581.0
@@ -48,6 +53,10 @@ The ``ice`` driver reports the following versions non-breaking changes and reset to 1 when the major version is incremented. The patch version is normally 0 but is incremented when a fix is delivered as a patch against an older base Option ROM. + * - ``fw.undi.srev`` + - running + - 2 + - Security revision of the Option ROM containing the UEFI driver. * - ``fw.psid.api`` - running - 0.80
drivers/net/ethernet/intel/ice/ice_devlink.c +20 -0
@@ -60,6 +60,15 @@ static int ice_info_fw_build(struct ice_pf *pf, char *buf, size_t len)return 0 ; } +static int ice_info_fw_srev (struct ice_pf *pf,char *buf,size_t len) +{ +struct ice_nvm_info *nvm = &pf->hw.flash.nvm; + +snprintf (buf, len,"%u" , nvm->srev); + +return 0 ; +} +static int ice_info_orom_ver (struct ice_pf *pf,char *buf,size_t len) {struct ice_orom_info *orom = &pf->hw.flash.orom;
@@ -69,6 +78,15 @@ static int ice_info_orom_ver(struct ice_pf *pf, char *buf, size_t len)return 0 ; } +static int ice_info_orom_srev (struct ice_pf *pf,char *buf,size_t len) +{ +struct ice_orom_info *orom = &pf->hw.flash.orom; + +snprintf (buf, len,"%u" , orom->srev); + +return 0 ; +} +static int ice_info_nvm_ver (struct ice_pf *pf,char *buf,size_t len) {struct ice_nvm_info *nvm = &pf->hw.flash.nvm;
@@ -145,7 +163,9 @@ static const struct ice_devlink_version {running (DEVLINK_INFO_VERSION_GENERIC_FW_MGMT , ice_info_fw_mgmt),running ("fw.mgmt.api" , ice_info_fw_api),running ("fw.mgmt.build" , ice_info_fw_build), +running ("fw.mgmt.srev" , ice_info_fw_srev),running (DEVLINK_INFO_VERSION_GENERIC_FW_UNDI , ice_info_orom_ver), +running ("fw.undi.srev" , ice_info_orom_srev),running ("fw.psid.api" , ice_info_nvm_ver),running (DEVLINK_INFO_VERSION_GENERIC_FW_BUNDLE_ID , ice_info_eetrack), running("fw.app.name", ice_info_ddp_pkg_name),
drivers/net/ethernet/intel/ice/ice_nvm.c +172 -0
196 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_type.h +9 -0
@@ -311,11 +311,13 @@ struct ice_orom_info {u8 major;/* Major version of OROM */ u8 patch;/* Patch version of OROM */ u16 build;/* Build version of OROM */ +u32 srev;/* Security revision */ };/* NVM version information */ struct ice_nvm_info {u32 eetrack; +u32 srev;u8 major;u8 minor; };
@@ -820,6 +822,13 @@ struct ice_hw_port_stats {#define ICE_SR_NETLIST_BANK_SIZE 0x47#define ICE_SR_SECTOR_SIZE_IN_WORDS 0x800 +/* CSS Header words */ +#define ICE_NVM_CSS_SREV_L 0x14 +#define ICE_NVM_CSS_SREV_H 0x15 + +/* Size in bytes of Option ROM trailer */ +#define ICE_NVM_OROM_TRAILER_LENGTH 660 +/* Auxiliary field, mask, and shift definition for Shadow RAM and NVM Flash */ #define ICE_SR_CTRL_WORD_1_S 0x06#define ICE_SR_CTRL_WORD_1_M (0x03 << ICE_SR_CTRL_WORD_1_S)
Signature · 1 line
2.28.0.497.g54e85e7af1ac
PATCH 4/4 ice: add devlink parameters to read and write minimum security revision
In reply to Jacob KellerThe ice NVM flash has a security revision field for the main NVM bank and the Option ROM bank. In addition to the revision within the module, the device also has a minimum security revision TLV area. This minimum security revision field indicates the minimum value that will be accepted for the associated security revision when loading the NVM bank.
Add functions to read and update the minimum security revisions. Use these functions to implement devlink parameters, "fw.undi.minsrev" and "fw.mgmt.minsrev".
These parameters are permanent (i.e. stored in flash), and are used to indicate the minimum security revision of the associated NVM bank. If the image in the bank has a lower security revision, then the flash loader will not continue loading that flash bank.
The new parameters allow for opting in to update the minimum security revision to ensure that a flash image with a known security flaw cannot be loaded.
Note that the minimum security revision cannot be reduced, only increased. The driver also refuses to allow an update if the currently active image revision is lower than the requested value. This is done to avoid potentially updating the value such that the device can no longer start.
--- Documentation/networking/devlink/ice.rst | 34 +++ .../net/ethernet/intel/ice/ice_adminq_cmd.h | 17 ++ drivers/net/ethernet/intel/ice/ice_devlink.c | 218 +++++++++++++++++- drivers/net/ethernet/intel/ice/ice_devlink.h | 2 + drivers/net/ethernet/intel/ice/ice_main.c | 3 + drivers/net/ethernet/intel/ice/ice_nvm.c | 112 +++++++++ drivers/net/ethernet/intel/ice/ice_nvm.h | 4 + drivers/net/ethernet/intel/ice/ice_type.h | 8 + 8 files changed, 397 insertions(+), 1 deletion(-)
Documentation/networking/devlink/ice.rst +34 -0
@@ -90,6 +90,40 @@ The ``ice`` driver reports the following versions - 0xee16ced7 - The first 4 bytes of the hash of the netlist module contents. +Parameters +========== + +The minimum security revision fields of the ice device control whether the +associated flash section can be loaded. If the security revision field of +the section -- ``fw.mgmt.srev`` for the main firmware section and +``fw.undi.srev`` for the Option ROM -- is lower than the associated minimum +security revision, then the device will not load that section of firmware. + +The ``ice`` driver implements driver-specific parameters for updating the +minimum security revision fields associated those two sections of the device +flash. Note that the device will not allow lowering a minimum security +revision, nor will it allow increasing the security revision higher than the +associated security revision of the active flash image. + +.. list-table:: Minimum security revision parameters + :widths: 5 5 5 85 + + * - Name + - Type + - Mode + - Description + * - ``fw.undi.minsrev`` + - u32 + - permanent + - The device's minimum security revision for the ``fw.undi`` section of + the flash. + * - ``fw.mgmt.minsrev`` + - u32 + - permanent + - The device's minimum security revision for the ``fw.mgmt`` section of + the flash. + + Flash Update ============
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +17 -0
@@ -1334,6 +1334,8 @@ struct ice_aqc_nvm_checksum {u8 rsvd2[12 ]; }; +#define ICE_AQC_NVM_MINSREV_MOD_ID 0x130 +/* The result of netlist NVM read comes in a TLV format. The actual data * (netlist header) starts from word offset 1 (byte 2). The FW strips * out the type field from the TLV header so all the netlist fields
@@ -1361,6 +1363,21 @@ struct ice_aqc_nvm_checksum {#define ICE_AQC_NVM_NETLIST_ID_BLK_SHA_HASH 0xA#define ICE_AQC_NVM_NETLIST_ID_BLK_CUST_VER 0x2F +/* Used for reading and writing MinSRev using 0x0701 and 0x0703. Note that the +* type field is excluded from the section when reading and writing from +* a module using the module_typeid field with these AQ commands. +*/ +struct ice_aqc_nvm_minsrev { +__le16 length; +__le16 validity; +#define ICE_AQC_NVM_MINSREV_NVM_VALID BIT(0) +#define ICE_AQC_NVM_MINSREV_OROM_VALID BIT(1) +__le16 nvm_minsrev_l; +__le16 nvm_minsrev_h; +__le16 orom_minsrev_l; +__le16 orom_minsrev_h; +}; +/* Used for NVM Set Package Data command - 0x070A */ struct ice_aqc_nvm_pkg_data {u8 reserved[3 ];
drivers/net/ethernet/intel/ice/ice_devlink.c +217 -1
236 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_devlink.h +2 -0
@@ -8,6 +8,8 @@ struct ice_pf *ice_allocate_pf(struct device *dev);int ice_devlink_register (struct ice_pf *pf);void ice_devlink_unregister (struct ice_pf *pf); +void ice_devlink_params_publish (struct ice_pf *pf); +void ice_devlink_params_unpublish (struct ice_pf *pf);int ice_devlink_create_port (struct ice_pf *pf);void ice_devlink_destroy_port (struct ice_pf *pf);
drivers/net/ethernet/intel/ice/ice_main.c +3 -0
@@ -4072,6 +4072,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) }ice_devlink_init_regions (pf); +ice_devlink_params_publish (pf); pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port;
@@ -4261,6 +4262,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)devm_kfree (dev, pf->vsi); err_init_pf_unroll:ice_deinit_pf (pf); +ice_devlink_params_unpublish (pf);ice_devlink_destroy_regions (pf);ice_deinit_hw (hw); err_exit_unroll:
@@ -4374,6 +4376,7 @@ static void ice_remove(struct pci_dev *pdev)ice_vsi_free_q_vectors (pf->vsi[i]); }ice_deinit_pf (pf); +ice_devlink_params_unpublish (pf);ice_devlink_destroy_regions (pf);ice_deinit_hw (&pf->hw);ice_devlink_unregister (pf);
drivers/net/ethernet/intel/ice/ice_nvm.c +112 -0
118 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_nvm.h +4 -0
@@ -14,6 +14,10 @@ enum ice_status ice_get_pfa_module_tlv(struct ice_hw *hw, u16 *module_tlv, u16 *module_tlv_len, u16 module_type);enum ice_status +ice_get_nvm_minsrevs (struct ice_hw *hw,struct ice_minsrev_info *minsrevs); +enum ice_status +ice_update_nvm_minsrevs (struct ice_hw *hw,struct ice_minsrev_info *minsrevs); +enum ice_status ice_read_pba_string (struct ice_hw *hw,u8 *pba_num,u32 pba_num_size);enum ice_status ice_init_nvm (struct ice_hw *hw);enum ice_status ice_read_sr_word (struct ice_hw *hw,u16 offset,u16 *data);
drivers/net/ethernet/intel/ice/ice_type.h +8 -0
@@ -322,6 +322,14 @@ struct ice_nvm_info {u8 minor; }; +/* Minimum Security Revision information */ +struct ice_minsrev_info { +u32 nvm; +u32 orom; +u8 nvm_valid :1 ; +u8 orom_valid :1 ; +}; +/* netlist version information */ struct ice_netlist_info {u32 major;/* major high/low */
Signature · 1 line
2.28.0.497.g54e85e7af1ac