Skip to content

Commit

Permalink
Improve FFDC for new Node Comm Device Driver
Browse files Browse the repository at this point in the history
This commit adds a new custom Node Comm Device Driver error log
user details section and its parser code.  It also adds a function
to add the target and important HW registers to an error log.

Change-Id: I11893af06b7a097b43106117d648e9a431c4f3ea
RTC:191008
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/59079
Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-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>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
  • Loading branch information
mabaiocchi authored and wghoffa committed May 24, 2018
1 parent 3ad299a commit a1e236a
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/include/usr/secureboot/secure_reasoncodes.H
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ namespace SECUREBOOT
SECURE_UDT_TARGET_HW_KEY_HASH = 0x2,
SECURE_UDT_SECURITY_SETTINGS = 0x3,
SECURE_UDT_VERIFY_INFO = 0x4,
SECURE_UDT_NODECOMM_INFO = 0x5,
};

}
Expand Down
76 changes: 76 additions & 0 deletions src/usr/secureboot/common/errlud_secure.C
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include <securerom/ROM.H>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <devicefw/driverif.H>
#include <secureboot/nodecommif.H>

namespace SECUREBOOT
{
Expand All @@ -43,6 +45,7 @@ namespace SECUREBOOT
//------------------------------------------------------------------------------
enum {
PARSER_SIZEOF_SHA512_t = 64,
PARSER_SIZEOF_UINT64_t = 8,
PARSER_SIZEOF_UINT32_t = 4,
PARSER_SIZEOF_UINT8_t = 1,
PARSER_SIZEOF_TARGET_HKH_SECTION = 69,
Expand Down Expand Up @@ -219,5 +222,78 @@ UdVerifyInfo::UdVerifyInfo(const char* i_compId,
l_pBuf+=PARSER_SIZEOF_SHA512_t;
}


//------------------------------------------------------------------------------
// SECURE Node Communications Info User Details
//------------------------------------------------------------------------------
UdNodeCommInfo::UdNodeCommInfo(const uint8_t i_opType,
const uint64_t i_buflen,
const int64_t i_accessType,
const NODECOMM::node_comm_args_t i_args )

{
// Set up Ud instance variables
iv_CompId = SECURE_COMP_ID;
iv_Version = SECURE_UDT_VERSION_1;
iv_SubSection = SECURE_UDT_NODECOMM_INFO;

//***** Node Comm SECURE_UDT_VERSION_1 Memory Layout *****
// 4 bytes : Target HUID
// 8 bytes : Length of In/Out Buffer
// 8 bytes : Access Type (DeviceFW::AccessType)
// 1 byte : Op Type (DeviceFW::OperationType)
// 1 byte : Mode (XBUS or ABUS)
// 1 byte : LinkId
// 1 byte : MboxId

static_assert(sizeof(uint64_t)==PARSER_SIZEOF_UINT64_t,
"Expected sizeof(uint64_t) is 8");

// These are necessary to keep the parsing in errludP_secure.H correct
static_assert(DeviceFW::READ==0, "Expected opType READ == 0");
static_assert(DeviceFW::WRITE==1, "Expected opType WRITE == 1");
static_assert(SECUREBOOT::NODECOMM::NCDD_MODE_XBUS==0,
"Expected NCDD_MODE_XBUS==0");
static_assert(SECUREBOOT::NODECOMM::NCDD_MODE_ABUS==1,
"Expected NCDD_MODE_ABUS==1");

char * l_pBuf = reinterpret_cast<char *>(
reallocUsrBuf(sizeof(uint32_t)
+sizeof(uint64_t)*2
+sizeof(uint8_t)*4 ) );
uint64_t tmp64 = 0;
uint32_t tmp32 = 0;
uint8_t tmp8 = 0;

tmp32 = i_args.tgt_huid;
memcpy(l_pBuf, &tmp32, sizeof(tmp32));
l_pBuf += sizeof(tmp32);

tmp64 = i_buflen;
memcpy(l_pBuf, &tmp64, sizeof(tmp64));
l_pBuf += sizeof(tmp64);

tmp64 = i_accessType;
memcpy(l_pBuf, &tmp64, sizeof(tmp64));
l_pBuf += sizeof(tmp64);

tmp8 = i_opType;
memcpy(l_pBuf, &tmp8, sizeof(tmp8));
l_pBuf += sizeof(tmp8);

tmp8 = i_args.mode;
memcpy(l_pBuf, &tmp8, sizeof(tmp8));
l_pBuf += sizeof(tmp8);

tmp8 = i_args.linkId;
memcpy(l_pBuf, &tmp8, sizeof(tmp8));
l_pBuf += sizeof(tmp8);

tmp8 = i_args.mboxId;
memcpy(l_pBuf, &tmp8, sizeof(tmp8));
l_pBuf += sizeof(tmp8);

};

} // end SECUREBOOT namespace

50 changes: 50 additions & 0 deletions src/usr/secureboot/common/errlud_secure.H
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include <secureboot/service.H>
#include <errl/errluserdetails.H>
#include <devicefw/driverif.H>
#include "../node_comm/node_comm_dd.H"

namespace SECUREBOOT
{
Expand Down Expand Up @@ -223,6 +225,54 @@ class UdVerifyInfo : public ERRORLOG::ErrlUserDetails
UdVerifyInfo& operator = (UdVerifyInfo&&) = delete;
};

/**
* @class UdNodeCommInfo
*
* Adds information about the Node Communications Operation to an
* error log as user detail data
*/
class UdNodeCommInfo : public ERRORLOG::ErrlUserDetails
{
public:
/**
* @brief Constructor
*
* @param i_opType Operation Type
* @param i_buflen Length of In/Out Buffer
* @param i_accessType Access Type
* @param i_args Miscellaneous Parameters
*/
UdNodeCommInfo(const uint8_t i_opType,
const uint64_t i_buflen,
const int64_t i_accessType,
const NODECOMM::node_comm_args_t i_args );

/**
* @brief Destructor
*/
virtual ~UdNodeCommInfo() {}

/**
* Delete Copy Constructor
*/
UdNodeCommInfo(const UdNodeCommInfo&) = delete;

/**
* Delete Copy Assignment
*/
UdNodeCommInfo& operator= (const UdNodeCommInfo&) = delete;

/**
* Delete Move Constructor
*/
UdNodeCommInfo (UdNodeCommInfo&&) = delete;

/**
* Delete Move Assignment
*/
UdNodeCommInfo& operator = (UdNodeCommInfo&&) = delete;
};

} // end SECUREBOOT namespace

#endif
102 changes: 102 additions & 0 deletions src/usr/secureboot/common/plugins/errludP_secure.H
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,108 @@ class UdParserVerifyInfo : public ERRORLOG::ErrlUserDetailsParser
UdParserVerifyInfo & operator=(const UdParserVerifyInfo&);
};

/**
* @class UdParserNodeCommInfo
*
* Parses UdSecureNodeCommInfo
*/
class UdParserNodeCommInfo : public ERRORLOG::ErrlUserDetailsParser
{
public:
/**
* @brief Constructor
*/
UdParserNodeCommInfo() {}

/**
* @brief Destructor
*/
virtual ~UdParserNodeCommInfo() {}

/**
* @brief Parses information from Node Communications operation
* user detail data from an error log
*
* @param i_version Version of the data
* @param i_parse ErrlUsrParser object for outputting information
* @param i_pBuffer Pointer to buffer containing detail data
* @param i_buflen Length of the buffer
*/
virtual void parse(errlver_t i_version,
ErrlUsrParser & i_parser,
void * i_pBuffer,
const uint32_t i_buflen) const
{

//***** Node Comm SECURE_UDT_VERSION_1 Memory Layout *****
// 4 bytes : Target HUID
// 8 bytes : Length of In/Out Buffer
// 8 bytes : Access Type (DeviceFW::AccessType)
// 1 byte : Op Type (DeviceFW::OperationType)
// 1 byte : Mode (XBUS or ABUS)
// 1 byte : LinkId
// 1 byte : MboxId

char* l_databuf = static_cast<char*>(i_pBuffer);
bool l_parseError = false;

do
{
i_parser.PrintHeading("Secure Node Comm Info");

i_parser.PrintNumber("Target HUID 0x","%.8lX",TO_UINT32(l_databuf));
l_databuf += sizeof(uint32_t);
i_parser.PrintNumber("Length I/O Buff 0x","%.16lX",TO_UINT64(l_databuf));
l_databuf += sizeof(uint64_t);
i_parser.PrintNumber("Access Type 0x","%.16lX",TO_UINT64(l_databuf));
l_databuf += sizeof(uint64_t);

uint8_t op = TO_UINT8(l_databuf);
if( op == 0 )
{
i_parser.PrintHeading("Node Comm Read");
}
else if( op == 1 )
{
i_parser.PrintHeading("Node Comm Write");
}
else
{
i_parser.PrintHeading("Unknown Node Comm Operation");
}
i_parser.PrintNumber("Op Type Value 0x","%.2lX",TO_UINT8(l_databuf));
l_databuf += sizeof(uint8_t);


op = TO_UINT8(l_databuf);
if( op == 0 )
{
i_parser.PrintHeading("Node Comm Mode: XBUS");
}
else if( op == 1 )
{
i_parser.PrintHeading("Node Comm Mode: ABUS");
}
else
{
i_parser.PrintHeading("INVALID Node Comm Mode");
}
i_parser.PrintNumber("MODE 0x","%.2lX",TO_UINT8(l_databuf));
l_databuf += sizeof(uint8_t);

i_parser.PrintNumber("LinkId 0x","%.2lX",TO_UINT8(l_databuf));
l_databuf += sizeof(uint8_t);
i_parser.PrintNumber("MboxId 0x","%.2lX",TO_UINT8(l_databuf));
l_databuf += sizeof(uint8_t);

} while(0);
}

private:
// Disabled
UdParserNodeCommInfo(const UdParserNodeCommInfo&);
UdParserNodeCommInfo & operator=(const UdParserNodeCommInfo&);
};

} // end SECUREBOOT namespace

Expand Down
3 changes: 3 additions & 0 deletions src/usr/secureboot/common/plugins/secureUdParserFactory.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ namespace SECUREBOOT

registerParser<SECUREBOOT::UdParserVerifyInfo>
(SECURE_UDT_VERIFY_INFO);

registerParser<SECUREBOOT::UdParserNodeCommInfo>
(SECURE_UDT_NODECOMM_INFO);
}

private:
Expand Down
70 changes: 69 additions & 1 deletion src/usr/secureboot/node_comm/node_comm.C
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <errl/errludtarget.H>
#include <errl/errludlogregister.H>
#include <targeting/common/targetservice.H>
#include <devicefw/userif.H>
#include <devicefw/driverif.H>
Expand All @@ -46,7 +47,6 @@

#include "node_comm.H"


using namespace TARGETING;

namespace SECUREBOOT
Expand Down Expand Up @@ -162,6 +162,9 @@ errlHndl_t nodeCommMapAttn(TARGETING::Target* i_pProc,
HWAS::NO_DECONFIG,
HWAS::GARD_NULL );

// Collect FFDC
getNodeCommFFDC(i_mode, i_pProc, err);

err->collectTrace(SECURE_COMP_NAME);
err->collectTrace(NODECOMM_TRACE_NAME);

Expand Down Expand Up @@ -194,6 +197,71 @@ errlHndl_t nodeCommMapAttn(TARGETING::Target* i_pProc,

} // end of nodeCommMapAttn


/**
* @brief Add FFDC for the target to an error log
*/
void getNodeCommFFDC( node_comm_modes_t i_mode,
TARGETING::Target* i_pProc,
errlHndl_t &io_log)
{
TRACFCOMP(g_trac_nc,ENTER_MRK
"getNodeCommFFDC: tgt=0x%X, mode=%s, err_plid=0x%X",
get_huid(i_pProc),
(i_mode == NCDD_MODE_ABUS)
? NCDD_ABUS_STRING : NCDD_XBUS_STRING,
ERRL_GETPLID_SAFE(io_log));

do
{
if (io_log == nullptr)
{
TRACFCOMP(g_trac_nc,INFO_MRK"getNodeCommFFDC: io_log==nullptr, so "
"no FFDC has been collected for tgt=0x%X, mode=%s",
get_huid(i_pProc),
(i_mode == NCDD_MODE_ABUS)
? NCDD_ABUS_STRING : NCDD_XBUS_STRING);
break;
}

// Add Target to log
ERRORLOG::ErrlUserDetailsTarget(i_pProc,"Proc Target").addToLog(io_log);

// Add HW regs
ERRORLOG::ErrlUserDetailsLogRegister ffdc(i_pProc);

// FIR/Control/Status/Data Registers
ffdc.addData(DEVICE_SCOM_ADDRESS(getLinkMboxRegAddr(NCDD_REG_FIR,i_mode)));
ffdc.addData(DEVICE_SCOM_ADDRESS(getLinkMboxRegAddr(NCDD_REG_CTRL,i_mode)));
ffdc.addData(DEVICE_SCOM_ADDRESS(getLinkMboxRegAddr(NCDD_REG_DATA,i_mode)));

// Loop Through All of the Mailbox Registers Where the Data Could End Up
uint64_t l_reg = 0;
const auto max_linkId = (i_mode==NCDD_MODE_ABUS)
? NCDD_MAX_ABUS_LINK_ID
: NCDD_MAX_XBUS_LINK_ID;

for (size_t linkId=0; linkId <= max_linkId ; ++linkId)
{
for (size_t mboxId=0; mboxId <= NCDD_MAX_MBOX_ID; ++mboxId)
{
l_reg = getLinkMboxReg(linkId, mboxId);
ffdc.addData(DEVICE_SCOM_ADDRESS(getLinkMboxRegAddr(l_reg,i_mode)));
}
}

ffdc.addToLog(io_log);


} while( 0 );

TRACFCOMP(g_trac_nc,EXIT_MRK"getNodeCommFFDC");

return;

} // end of getNodeCommFFDC


} // End NODECOMM namespace

} // End SECUREBOOT namespace
Expand Down

0 comments on commit a1e236a

Please sign in to comment.