Skip to content

Commit

Permalink
Support reading UCD flash update LIDs
Browse files Browse the repository at this point in the history
- Added support to read a single LID container and securely verify it
- Added new compile flag CONFIG_UCD_FLASH_UPDATES to enable/disable
future TI UCD9090/UCD90120A flash updates
- Created shell function to hold the UCD flash update logic

Change-Id: I94f3e43558af5d7951febdf6ff0685c120d2db0e
RTC: 201992
CMVC-Prereq: 1076388
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/71945
Reviewed-by: Marshall J. Wilks <mjwilks@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@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: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Nick Bofferding authored and dcrowell77 committed Feb 19, 2019
1 parent 02f3329 commit b61b496
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/build/configs/fsprelease.config
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set FSP_BUILD
set NVDIMM

set CONFIG_NVDIMM
set UCD_FLASH_UPDATES

# OpenPower checkstop analysis
unset ENABLE_CHECKSTOP_ANALYSIS
Expand Down
4 changes: 3 additions & 1 deletion src/include/usr/util/util_reasoncodes.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* Contributors Listed Below - COPYRIGHT 2012,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -52,6 +52,7 @@ namespace Util
UTIL_MCL_PROCESS_COMP = 0x12, // MasterContainerLidMgr::processComponent
UTIL_MOD_GET_OBUS_PLL_BUCKET = 0x14, // UtilCommonAttr::getObusPllBucket
UTIL_LIDMGR_CSTOR = 0x15, // UtilLidMgr::UtilLidMgr
UTIL_MCL_PROCESS_SINGLE_COMP = 0x16, // UtilLidMgr::processSingleComponent
};

enum ReasonCode
Expand Down Expand Up @@ -83,6 +84,7 @@ namespace Util
UTIL_ERC_NO_FREQ_LIST = UTIL_COMP_ID | 0x1A,
UTIL_ERC_NO_MATCHING_FREQ = UTIL_COMP_ID | 0x1B,
UTIL_LIDMGR_INVAL_LID_REQUEST = UTIL_COMP_ID | 0x1C,
UTIL_LIDMGR_INVAL_COMP = UTIL_COMP_ID | 0x1D,
};
};

Expand Down
79 changes: 69 additions & 10 deletions src/include/usr/util/utilmclmgr.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* Contributors Listed Below - COPYRIGHT 2017,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -39,17 +39,39 @@ class MasterContainerLidMgrTest;
namespace MCL
{

/**
* @brief Structure used to hold information about a container loaded into
* memory using the MCL manager
*/
struct LoadedContainerInfo_t
{
void* pSecureHeader; ///< Virtual address of secure header; nullptr if N/A
void* pContent; ///< Virtual address of container logical content
size_t size; ///< Size of container logical content in bytes

/**
* @brief Builds a default LoadedContainerInfo_t
*/
LoadedContainerInfo_t()
: pSecureHeader(nullptr),
pContent(nullptr),
size(0)
{
}
};

// Component ID(name) within MCL
typedef std::array<uint8_t,16> ComponentID;

// Component ID in string form
// NOTE: ComponentID in the MCL does not include NULL terminator so include room
typedef char CompIdString[17];

// Constants to simplify checking for the MCL and POWERVM comp ids
// Constants to simplify checking for the MCL and POWERVM/UCD9090 comp ids
extern const ComponentID g_MclCompId;
extern const ComponentID g_PowervmCompId;
extern const ComponentID g_OpalCompId;
extern const ComponentID g_UcdCompId;

// @enum Permission Types for MCL Component
enum class CompFlags : uint16_t
Expand Down Expand Up @@ -118,12 +140,14 @@ extern const size_t MclCompSectionPadSize;
// @brief Structure that holds lid ids and sizes
struct LidInfo
{
LidInfo(): id(0), size(0) {}
LidInfo(uint32_t i_id): id(i_id), size(0) {}
LidInfo(uint32_t i_id, size_t i_size): id(i_id), size(i_size) {}
LidInfo(): id(0), size(0), vAddr(nullptr) {}
LidInfo(uint32_t i_id): id(i_id), size(0), vAddr(nullptr) {}
LidInfo(uint32_t i_id, size_t i_size): id(i_id), size(i_size),
vAddr(nullptr) {}

uint32_t id;
size_t size;
uint32_t id; // LID ID
size_t size; // Size of LID
void* vAddr; // Virtual address where LID was loaded

/**
* @brief Lid Info equality comparison
Expand All @@ -133,7 +157,9 @@ struct LidInfo
*/
bool operator==(const LidInfo& rhs) const
{
return (id == rhs.id && size == rhs.size);
return ( (id == rhs.id)
&& (size == rhs.size)
&& (vAddr == rhs.vAddr));
}

/**
Expand Down Expand Up @@ -242,9 +268,13 @@ class MasterContainerLidMgr

/**
* @brief Default Constructor
* Initializes memory spaces, loads, and parses the MCL.
* Initializes memory spaces, loads, and parses the MCL.
*
* @param[in] i_loadOnly Only load content into memory on subsequent
* requests to process components. Do not not move the content to
* Hostboot reserved memory.
*/
MasterContainerLidMgr();
MasterContainerLidMgr(bool i_loadOnly = false);

/**
* @brief Destructor. Cleans up memory allocated for class
Expand All @@ -257,6 +287,31 @@ class MasterContainerLidMgr
*/
errlHndl_t processComponents();

/**
* @brief Process a single, named component from the MCL.
* Loads the specified component into the managed mainstore memory
* region. If component is marked pre-verified, cryptographically
* verifies the component and extends its measurement to the TPM.
* If MCL manager is in non-load-only mode, copies the content into
* Hostboot reserved memory region as well.
*
* @param[in] i_compId Component ID to load
* @param[out] o_info Information (LID ID, size, virtual address, etc.)
* for the LIDs that were loaded.
*
* @note: The container will go out of scope if another container is loaded
* or the MCL manager goes out of scope.
*
* @note: Component info will be reset on each call
*
* @return errlHndl_t Error log handle
* @retval nullptr Success
* @retval !nullptr Error; Error log handle points to valid error log
*/
errlHndl_t processSingleComponent(
const ComponentID& i_compId,
CompInfo& o_info);

/**
* @brief TPM extend information for secure components
*
Expand Down Expand Up @@ -428,6 +483,10 @@ class MasterContainerLidMgr
// Cache current comp id string for easy tracing
CompIdString iv_curCompIdStr;

// When processing a component, only load the component and verify / measure
// it (do not copy it to reserved memory).
bool iv_loadOnly;

// Cached PHyp header
static uint8_t cv_pPhypHeader[PAGE_SIZE];

Expand Down
11 changes: 10 additions & 1 deletion src/usr/isteps/istep21/call_host_runtime_setup.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand All @@ -23,6 +23,7 @@
/* */
/* IBM_PROLOG_END_TAG */

#include <config.h>
#include <errl/errlentry.H>
#include <errl/errlmanager.H>
#include <initservice/isteps_trace.H>
Expand Down Expand Up @@ -61,6 +62,10 @@
#include <isteps/pm/occCheckstop.H>
#endif

#ifdef CONFIG_UCD_FLASH_UPDATES
#include "call_update_ucd_flash.H"
#endif

using namespace ERRORLOG;
using namespace ISTEP;
using namespace ISTEP_ERROR;
Expand Down Expand Up @@ -666,6 +671,10 @@ void* call_host_runtime_setup (void *io_pArgs)
break;
}

#ifdef CONFIG_UCD_FLASH_UPDATES
POWER_SEQUENCER::TI::UCD::call_update_ucd_flash();
#endif

// Fill in Hostboot runtime data if there is a PAYLOAD
if( !(TARGETING::is_no_load()) )
{
Expand Down
101 changes: 101 additions & 0 deletions src/usr/isteps/istep21/call_update_ucd_flash.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/isteps/istep21/call_update_ucd_flash.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */

#include <errl/errlentry.H>
#include <trace/interface.H>
#include <initservice/initserviceif.H>
#include <util/utilmclmgr.H>
#include <errl/errlmanager.H>
#include <hbotcompid.H>
#include <config.h>
#include <initservice/isteps_trace.H>

#include "call_update_ucd_flash.H"

namespace POWER_SEQUENCER
{

namespace TI
{

namespace UCD
{

void call_update_ucd_flash(void)
{
errlHndl_t pError = nullptr;

TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, ENTER_MRK
"call_update_ucd_flash");

do {

// Update UCD flash images, if needed
if (INITSERVICE::spBaseServicesEnabled())
{
// @TODO RTC 201991
// break early if no UCD devices

// Load the UCD flash binary via the MCL in load only mode
MCL::MasterContainerLidMgr mclManager(true);
MCL::CompInfo info;
pError = mclManager.processSingleComponent(MCL::g_UcdCompId,info);
if(pError)
{
break;
}

// @TODO RTC 201990 add flash update algorithm and make trace TRACDBIN
for(const auto& lid : info.lidIds)
{
TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace,"LID ID=0x%08X, "
"size=%d, vAddr=%p",
lid.id, lid.size, lid.vAddr);
TRACFBIN(ISTEPS_TRACE::g_trac_isteps_trace,"LID",lid.vAddr,64);
}

// Destructor automatically unloads the UCD flash binary
}

} while(0);

if(pError)
{
TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, ERR_MRK
"call_update_ucd_flash failed");
errlCommit(pError, ISTEP_COMP_ID);
}

TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, EXIT_MRK
"call_update_ucd_flash" );
}

} // End UCD namespace

} // End TI namespace

} // End POWER_SEQUENCER namespace


49 changes: 49 additions & 0 deletions src/usr/isteps/istep21/call_update_ucd_flash.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/isteps/istep21/call_update_ucd_flash.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */

#ifndef __CALL_UPDATE_UCD_FLASH_H
#define __CALL_UPDATE_UCD_FLASH_H

namespace POWER_SEQUENCER
{

namespace TI // Texas Instruments devices
{

namespace UCD // UCD* series
{
/**
* @brief Updates the data flash of applicable Texas Instruments UCD
* power sequencer ASICs.
*/
void call_update_ucd_flash();

} // End UCD namespace

} // End TI namespace

} // End POWER_SEQUENCER namespace

#endif
3 changes: 2 additions & 1 deletion src/usr/isteps/istep21/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2015,2018
# Contributors Listed Below - COPYRIGHT 2015,2019
# [+] International Business Machines Corp.
#
#
Expand Down Expand Up @@ -42,5 +42,6 @@ OBJS += call_host_runtime_setup.o
OBJS += freqAttrData.o
OBJS += call_host_verify_hdat.o
OBJS += call_host_start_payload.o
OBJS += $(if $(CONFIG_UCD_FLASH_UPDATES),call_update_ucd_flash.o,)

include ${ROOTPATH}/config.mk
4 changes: 4 additions & 0 deletions src/usr/isteps/ucd/HBconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config UCD_FLASH_UPDATES
default n
help
Enable UCD power sequencer flash updates

0 comments on commit b61b496

Please sign in to comment.