summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCorey Swenson <cswenson@us.ibm.com>2019-07-24 13:05:54 -0500
committerDaniel M Crowell <dcrowell@us.ibm.com>2019-07-31 16:04:54 -0500
commitf088a0dc26ed66496d593af1c0c291ac44f4cb4f (patch)
treedc13b4fa2ef07ed14eb9999a11702264618a771a /src
parent44c6d599b85ac7a9c0a4dea70ea49a7a7916f128 (diff)
downloadtalos-hostboot-f088a0dc26ed66496d593af1c0c291ac44f4cb4f.tar.gz
talos-hostboot-f088a0dc26ed66496d593af1c0c291ac44f4cb4f.zip
Miscellaneous NVDIMM cleanup
- Move constants to .C file - Use constants for NVDIMM states - Clean up rt_cmds NVDIMM protection function Change-Id: I3ff81c76971e962eb99e2f3b6ea1f109355d337a Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/81261 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Roland Veloz <rveloz@us.ibm.com> Reviewed-by: Matt Derksen <mderkse1@us.ibm.com> Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/isteps/nvdimm/nvdimm.H2
-rw-r--r--src/usr/isteps/nvdimm/nvdimm.C15
-rw-r--r--src/usr/isteps/nvdimm/nvdimm.H11
-rw-r--r--src/usr/isteps/nvdimm/runtime/nvdimm_rt.C3
-rw-r--r--src/usr/util/runtime/rt_cmds.C65
5 files changed, 30 insertions, 66 deletions
diff --git a/src/include/usr/isteps/nvdimm/nvdimm.H b/src/include/usr/isteps/nvdimm/nvdimm.H
index 68f1b1c13..c07df0420 100644
--- a/src/include/usr/isteps/nvdimm/nvdimm.H
+++ b/src/include/usr/isteps/nvdimm/nvdimm.H
@@ -204,6 +204,7 @@ bool nvdimmDisarm(TARGETING::TargetHandleList &i_nvdimmTargetList);
* OCC_INACTIVE - set inactive state
* NVDIMM_FATAL_HW_ERROR - set fatal hw state
* NVDIMM_RISKY_HW_ERROR - set risky hw state
+ * NVDIMM_ENCRYPTION_ERROR - set encryption state
* Note: fatal error will stay with target preventing
* PROTECTED status until power is cycled again
*/
@@ -215,6 +216,7 @@ enum nvdimm_protection_t
OCC_INACTIVE = 3,
NVDIMM_FATAL_HW_ERROR = 4,
NVDIMM_RISKY_HW_ERROR = 5,
+ NVDIMM_ENCRYPTION_ERROR = 6,
/* deprecated, still used by PRD */
UNPROTECTED_BECAUSE_ERROR = 4,
};
diff --git a/src/usr/isteps/nvdimm/nvdimm.C b/src/usr/isteps/nvdimm/nvdimm.C
index 984105408..8f839af32 100644
--- a/src/usr/isteps/nvdimm/nvdimm.C
+++ b/src/usr/isteps/nvdimm/nvdimm.C
@@ -110,6 +110,8 @@ typedef union {
// Valid bits to check against (skips reserved and unsupported)
static constexpr uint8_t ENCRYPTION_STATUS_CHECK_MASK = 0x3F;
+static constexpr uint8_t ENCRYPTION_STATUS_DISABLED = 0x01;
+static constexpr uint8_t ENCRYPTION_STATUS_ENABLED = 0x1F;
// NV_STATUS masks
static constexpr uint8_t NV_STATUS_OR_MASK = 0xFB;
@@ -119,6 +121,12 @@ static constexpr uint8_t NV_STATUS_UNPROTECTED_CLEAR = 0xFE;
static constexpr uint8_t NV_STATUS_POSSIBLY_UNPROTECTED_SET = 0x40;
static constexpr uint8_t NV_STATUS_POSSIBLY_UNPROTECTED_CLEAR = 0xBF;
+// NVDIMM key consts
+static constexpr size_t NUM_KEYS_IN_ATTR = 3;
+static constexpr size_t MAX_TPM_SIZE = 34;
+static constexpr uint8_t KEY_TERMINATE_BYTE = 0x00;
+static constexpr uint8_t KEY_ABORT_BYTE = 0xFF;
+
// Definition of ENCRYPTION_KEY_VALIDATION -- page 5 offset 0x2A
typedef union {
uint8_t whole;
@@ -2639,7 +2647,7 @@ bool nvdimm_encrypt_enable(TargetHandleList &i_nvdimmList)
// Need to handle these cases?
if (!((l_encStatus.whole & ENCRYPTION_STATUS_CHECK_MASK)
- == 0x01))
+ == ENCRYPTION_STATUS_DISABLED))
{
TRACFCOMP(g_trac_nvdimm, "nvdimm_encrypt_enable() nvdimm[%X] unsupported state 0x%.02X",get_huid(l_nvdimm),l_encStatus.whole);
continue;
@@ -2702,7 +2710,7 @@ bool nvdimm_encrypt_enable(TargetHandleList &i_nvdimmList)
continue;
}
if (!((l_encStatus.whole & ENCRYPTION_STATUS_CHECK_MASK)
- == 0x1F))
+ == ENCRYPTION_STATUS_ENABLED))
{
TRACFCOMP(g_trac_nvdimm, ERR_MRK"nvdimm_encrypt_enable() nvdimm[%X] encryption enable failed, ENCRYPTION_CONFIG_STATUS=0x%.02X, expected=0x1F ",get_huid(l_nvdimm),l_encStatus.whole);
/*@
@@ -3039,6 +3047,9 @@ errlHndl_t notifyNvdimmProtectionChange(Target* i_target,
case NVDIMM_RISKY_HW_ERROR:
l_armed_state.risky_error_detected = 1;
break;
+ case NVDIMM_ENCRYPTION_ERROR:
+ l_armed_state.encryption_error_detected = 1;
+ break;
}
// Set the attribute and send it to the FSP if needed
diff --git a/src/usr/isteps/nvdimm/nvdimm.H b/src/usr/isteps/nvdimm/nvdimm.H
index 11642217a..947cfdc99 100644
--- a/src/usr/isteps/nvdimm/nvdimm.H
+++ b/src/usr/isteps/nvdimm/nvdimm.H
@@ -378,19 +378,10 @@ enum misc
HIGH = 1,
};
-const size_t NUM_KEYS_IN_ATTR = 3;
-const size_t ENC_KEY_SIZE = 32;
-const size_t MAX_TPM_SIZE = 34;
-const uint8_t KEY_TERMINATE_BYTE = 0x00;
-const uint8_t KEY_ABORT_BYTE = 0xFF;
-const uint64_t DARN_ERROR_CODE = 0xFFFFFFFFFFFFFFFFull;
-const uint32_t MAX_DARN_ERRORS = 10;
-const uint32_t MAX_RANDOM_ATTEMPTS = 100;
-
-
/**
* @brief Encryption key data
*/
+static constexpr size_t ENC_KEY_SIZE = 32;
struct nvdimmKeyData_t
{
uint8_t rs[ENC_KEY_SIZE]; // Random String (RS)
diff --git a/src/usr/isteps/nvdimm/runtime/nvdimm_rt.C b/src/usr/isteps/nvdimm/runtime/nvdimm_rt.C
index 78aab4712..97f6efedf 100644
--- a/src/usr/isteps/nvdimm/runtime/nvdimm_rt.C
+++ b/src/usr/isteps/nvdimm/runtime/nvdimm_rt.C
@@ -50,6 +50,9 @@ using namespace TARGETING;
namespace NVDIMM
{
+static constexpr uint64_t DARN_ERROR_CODE = 0xFFFFFFFFFFFFFFFFull;
+static constexpr uint32_t MAX_DARN_ERRORS = 10;
+
/**
* @brief This function polls the command status register for arm completion
* (does not indicate success or fail)
diff --git a/src/usr/util/runtime/rt_cmds.C b/src/usr/util/runtime/rt_cmds.C
index fa50b0684..032559644 100644
--- a/src/usr/util/runtime/rt_cmds.C
+++ b/src/usr/util/runtime/rt_cmds.C
@@ -1162,63 +1162,20 @@ void cmd_nvdimm_protection_msg( char* &o_output, uint32_t i_huid,
{
errlHndl_t l_err = nullptr;
o_output = new char[500];
- uint8_t l_notifyType = 0;
TARGETING::Target* l_targ{};
l_targ = getTargetFromHUID(i_huid);
- if (l_targ != NULL)
- {
- if (protection == NVDIMM::NVDIMM_ARMED)
- {
- l_notifyType = NVDIMM::NVDIMM_ARMED;
- l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::NVDIMM_ARMED);
- }
- else if (protection == NVDIMM::NVDIMM_DISARMED)
- {
- l_notifyType = NVDIMM::NVDIMM_DISARMED;
- l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::NVDIMM_DISARMED);
- }
- else if (protection == NVDIMM::OCC_ACTIVE)
- {
- l_notifyType = NVDIMM::OCC_ACTIVE;
- l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::OCC_ACTIVE);
- }
- else if (protection == NVDIMM::OCC_INACTIVE)
- {
- l_notifyType = NVDIMM::OCC_INACTIVE;
- l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::OCC_INACTIVE);
- }
- else if (protection == NVDIMM::NVDIMM_FATAL_HW_ERROR)
- {
- l_notifyType = NVDIMM::NVDIMM_FATAL_HW_ERROR;
- l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::NVDIMM_FATAL_HW_ERROR);
- }
- else if (protection == NVDIMM::NVDIMM_RISKY_HW_ERROR)
- {
- l_notifyType = NVDIMM::NVDIMM_RISKY_HW_ERROR;
- l_err = notifyNvdimmProtectionChange(l_targ, NVDIMM::NVDIMM_RISKY_HW_ERROR);
- }
- else
- {
- sprintf( o_output,
- "cmd_nvdimm_protection_msg: HUID 0x%.8X "
- "unknown protection type 0x%.2X",
- i_huid, protection );
- }
- if (l_err)
- {
- sprintf( o_output, "Error on call to notifyNvdimmProtectionChange"
- "(0x%.8X, %d), rc=0x%.8X, plid=0x%.8X",
- i_huid, l_notifyType, ERRL_GETRC_SAFE(l_err), l_err->plid() );
- errlCommit(l_err, UTIL_COMP_ID);
- return;
- }
- }
- else
+
+ // protection should match enum from nvdimm_protection_t
+ // No match will just return, no error generated
+ l_err = notifyNvdimmProtectionChange( l_targ,
+ (NVDIMM::nvdimm_protection_t)protection);
+ if (l_err)
{
- sprintf( o_output, "cmd_nvdimm_protection_msg: HUID 0x%.8X not found",
- i_huid );
- return;
+ sprintf( o_output, "Error on call to notifyNvdimmProtectionChange"
+ "(0x%.8X, %d), rc=0x%.8X, plid=0x%.8X",
+ i_huid, protection, ERRL_GETRC_SAFE(l_err), l_err->plid() );
+ errlCommit(l_err, UTIL_COMP_ID);
}
}
#endif
@@ -1543,7 +1500,7 @@ int hbrtCommand( int argc,
}
}
#ifdef CONFIG_NVDIMM
- else if( !strcmp( argv[0], "nvdimm_protection" ) )
+ else if( !strcmp( argv[0], "nvdimm_protection" ) )
{
if (argc >= 3)
{
OpenPOWER on IntegriCloud