Skip to content

Commit

Permalink
Key Clear Request Sensor Support
Browse files Browse the repository at this point in the history
This commit:
 - Adds the ability to read and clear the new Key Clear Request
   sensor on OpenPower systems.
 - Adds a new 'soft' power off methodology for OpenPower-based
   systems based off of IPMI Chassis Commands
 - Improved some of the error logging for the key clear request functions

Change-Id: Ib9f1691ffcd322173bee2f7ea419972b223479e6
RTC:210301
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/93682
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: Ilya Smirnov <ismirno@us.ibm.com>
Reviewed-by: Christopher J Engel <cjengel@us.ibm.com>
Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com>
  • Loading branch information
mabaiocchi authored and Nicholas E Bofferding committed Mar 27, 2020
1 parent 27e689c commit 14846f0
Show file tree
Hide file tree
Showing 15 changed files with 466 additions and 142 deletions.
8 changes: 7 additions & 1 deletion src/include/usr/initservice/istepdispatcherif.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2018 */
/* Contributors Listed Below - COPYRIGHT 2012,2020 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -107,6 +107,12 @@ void requestReboot( void );
* initiate a system power off via IPMI commands
*/
void requestPowerOff( void );

/**
* @brief This function is to be used by external code to
* initiate a soft system power off via IPMI commands
*/
void requestSoftPowerOff( void );
#endif

/**
Expand Down
18 changes: 15 additions & 3 deletions src/include/usr/ipmi/ipmiif.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2019 */
/* Contributors Listed Below - COPYRIGHT 2012,2020 */
/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* [+] Maxim Polyakov */
Expand Down Expand Up @@ -57,8 +57,11 @@ namespace IPMI
// initiate a reboot request
MSG_STATE_INITIATE_POWER_CYCLE,

// initiate a soft power off
MSG_STATE_INITIATE_SOFT_POWER_OFF,

// Used to check range. Leave as last.
MSG_LAST_TYPE = MSG_STATE_INITIATE_POWER_CYCLE,
MSG_LAST_TYPE = MSG_STATE_INITIATE_SOFT_POWER_OFF,
};

/**
Expand All @@ -74,16 +77,20 @@ namespace IPMI
{
return ( (i_msgType == MSG_STATE_SHUTDOWN)
|| (i_msgType == MSG_STATE_GRACEFUL_SHUTDOWN)
|| (i_msgType == MSG_STATE_INITIATE_SOFT_POWER_OFF)
|| (i_msgType == MSG_STATE_INITIATE_POWER_CYCLE));
}

// chassis power off request types
// See Section 28.3, Table 28 "Chassis Control Command" in IPMI spec v2.0
enum power_request_type
{
CHASSIS_POWER_OFF = 0x00,
CHASSIS_POWER_SOFT_RESET = 0x01,
CHASSIS_POWER_ON = 0x01,
CHASSIS_POWER_CYCLE = 0x02,
CHASSIS_POWER_RESET = 0x03,
CHASSIS_POWER_PULSE_DIAGNOSTIC_INTR = 0x04,
CHASSIS_POWER_SOFT_OFF_VIA_OVER_TEMP = 0x05, // Use for Soft Power Off
};

// Used in the factory for creating the proper subclass.
Expand Down Expand Up @@ -418,6 +425,11 @@ namespace IPMI
*/
void initiatePowerOff();

/**
* @brief Initiate a soft power off sequence via the IPMI resource provider
*/
void initiateSoftPowerOff();

/**
* Structure to return BMC/IPMI information in
*/
Expand Down
62 changes: 61 additions & 1 deletion src/include/usr/ipmi/ipmisensor.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2014,2018 */
/* Contributors Listed Below - COPYRIGHT 2014,2020 */
/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* */
Expand Down Expand Up @@ -1058,6 +1058,66 @@ namespace SENSOR

};

/**
* @class KeyClearRequestSensor
*
* @brief Specialized class for the key clear request sensor
*
* @par Detailed Description:
* Provides the functionality needed to set the key clear request
* sensor. The key clear request sensor is a special sensor
* maintained by the BMC.
*
* Usage:
* uint8_t key_clear_request_value = 0x0100;
* KeyClearRequestSensor l_sensor;
* l_sensor.setKeyClearRequestValue( key_clear_request_value );
*
*/
class KeyClearRequestSensor : public SensorBase
{

public:

/**
* @brief Constructor for the KeyClearRequestSensor
*
* The key clear request sensor is used to notify various firmware
* levels (like hostboot, OPAL, PHYP, etc) if there is a request
* to clear certain security keys or certificates.
*
* The system target holds the IPMI sensor number for this sensor.
*/
KeyClearRequestSensor();

/**
* @brief Destructor for the KeyClearRequestSensor
*
*/
~KeyClearRequestSensor();

/**
* @brief Set the value for the key clear request sensor on the BMC.
*
* @param[in] i_value - new key clear sensor value.
*
* @return Errorlog handle
*
*/
errlHndl_t setKeyClearRequest( uint8_t i_value );

/**
* @brief Get the value of the key clear request sensor from the BMC
*
* @param[o] o_value - new key clear request value.
*
* @return Errorlog handle
*
*/
errlHndl_t getKeyClearRequest( uint8_t & o_value );

};

/*
* @brief Return the fault sensor number for a target
* Will return either the status sensor or Fault sensor number for a
Expand Down
21 changes: 13 additions & 8 deletions src/include/usr/secureboot/key_clear_if.H
Expand Up @@ -45,17 +45,22 @@ namespace SECUREBOOT
* @brief Returns Key Clear Request information and if a Physical Presence
* check is requested
*
* @param[out] o_requestPhysPresence - If true, then physical presence
* assertion is requested; otherwise
* false
* @param[out] o_requestPhysPresence - If true, then physical presence
* assertion is requested; otherwise
* false
*
* @param[out] o_keyClearRequests - Struct containing the specifics of
* the key clear requests
*
* @note Any error logs generated will be handled internally
*
* @note The associated ATTR_KEY_CLEAR_REQUEST will also be updated by
* this function
*
* @param[out] o_keyClearRequests - Struct containing the specifics of
* the key clear requests
* @return errlHndl_t nullptr on success; non-nullptr on error.
*/
errlHndl_t getKeyClearRequest(
bool & o_requestPhysPresence,
TARGETING::KEY_CLEAR_REQUEST & o_keyClearRequests);
void getKeyClearRequest(bool & o_requestPhysPresence,
TARGETING::KEY_CLEAR_REQUEST & o_keyClearRequests);

#ifdef CONFIG_BMC_IPMI
/*
Expand Down
4 changes: 2 additions & 2 deletions src/include/usr/secureboot/secure_reasoncodes.H
Expand Up @@ -75,7 +75,7 @@ namespace SECUREBOOT
// Requests
MOD_DETECT_PHYS_PRES = 0x40,
MOD_HANDLE_PHYS_PRES_WINDOW = 0x41,

MOD_CLEAR_KEY_CLEAR_SENSOR = 0x42,
};

enum SECUREReasonCode
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace SECUREBOOT
RC_PHYS_PRES_WINDOW_NOT_OPENED = SECURE_COMP_ID | 0x43,
RC_PHYS_PRES_ASSERTED = SECURE_COMP_ID | 0x44,
RC_PHYS_PRES_REIPL = SECURE_COMP_ID | 0x45,

RC_CLEARING_KEY_CLEAR_SENSOR_FAILED = SECURE_COMP_ID | 0x46,

// Reason codes 0xA0 - 0xEF reserved for trustedboot_reasoncodes.H
};
Expand Down
16 changes: 15 additions & 1 deletion src/usr/initservice/istepdispatcher/istepdispatcher.C
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* Contributors Listed Below - COPYRIGHT 2011,2020 */
/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* */
Expand Down Expand Up @@ -1845,6 +1845,15 @@ void IStepDispatcher::requestPowerOff()
// Send a power off message to the BMC
(void)IPMI::initiatePowerOff();
}

void IStepDispatcher::requestSoftPowerOff()
{
// Always stop dispatching isteps before calling for the power off
INITSERVICE::stopIpl();

// Send a soft power off message to the BMC
(void)IPMI::initiateSoftPowerOff();
}
#endif
// ----------------------------------------------------------------------------
// IStepDispatcher::shutdownDuringIpl()
Expand Down Expand Up @@ -2764,6 +2773,11 @@ void requestPowerOff()
{
IStepDispatcher::getTheInstance().requestPowerOff();
}

void requestSoftPowerOff()
{
IStepDispatcher::getTheInstance().requestSoftPowerOff();
}
#endif


Expand Down
7 changes: 6 additions & 1 deletion src/usr/initservice/istepdispatcher/istepdispatcher.H
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2019 */
/* Contributors Listed Below - COPYRIGHT 2011,2020 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -227,6 +227,11 @@ public:
* @brief Trigger a power off via IPMI commands
*/
void requestPowerOff();

/**
* @brief Trigger a soft power off via IPMI commands
*/
void requestSoftPowerOff();
#endif

/**
Expand Down
41 changes: 25 additions & 16 deletions src/usr/ipmibase/ipmirp.C
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2012,2019 */
/* Contributors Listed Below - COPYRIGHT 2012,2020 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -461,18 +461,6 @@ void IpmiRP::handlePowerMessage( IPMI::oemSEL* i_event )
CONSOLE::flush();
#endif

}
// If the event type is a power soft reset, send a chasis reset
// update the modifier to send to the BMC
else if( i_event->iv_cmd[1] == IPMI::CHASSIS_POWER_SOFT_RESET )
{
// handle the message as a power reset request
IPMI_TRAC("IPMI power reset request received");
iv_chassis_power_mod = IPMI::CHASSIS_POWER_RESET;
#ifdef CONFIG_CONSOLE
CONSOLE::displayf(NULL, "IPMI: power cycle requested");
CONSOLE::flush();
#endif
}
else
{
Expand Down Expand Up @@ -725,16 +713,32 @@ void IpmiRP::execute(void)

// begin a graceful reboot initiated by us
case IPMI::MSG_STATE_INITIATE_POWER_CYCLE:
case IPMI::MSG_STATE_INITIATE_SOFT_POWER_OFF:
{
msg_free(msg);

#ifdef CONFIG_CONSOLE
CONSOLE::displayf(NULL, "IPMI: Initiate power cycle");
if (msg_type == IPMI::MSG_STATE_INITIATE_POWER_CYCLE)
{
CONSOLE::displayf(NULL, "IPMI: Initiate power cycle");
}
else // == IPMI::MSG_STATE_INITIATE_SOFT_POWER_OFF
{
CONSOLE::displayf(NULL, "IPMI: Initiate soft power off");
}
CONSOLE::flush();
#endif
// setup the power cmd modifier to tell the bmc to
// do a power reset
iv_chassis_power_mod = IPMI::CHASSIS_POWER_RESET;
// do a power reset or soft power off
if (msg_type == IPMI::MSG_STATE_INITIATE_POWER_CYCLE)
{
iv_chassis_power_mod = IPMI::CHASSIS_POWER_RESET;
}
else // == IPMI::MSG_STATE_INITIATE_SOFT_POWER_OFF
{
iv_chassis_power_mod =
IPMI::CHASSIS_POWER_SOFT_OFF_VIA_OVER_TEMP;
}

// register for the post memory flush callback
INITSERVICE::registerShutdownEvent(IPMI_COMP_ID, iv_msgQ,
Expand Down Expand Up @@ -1100,6 +1104,11 @@ namespace IPMI
(void)initiateShutdownOrReboot(MSG_STATE_GRACEFUL_SHUTDOWN);
}

void initiateSoftPowerOff()
{
(void)initiateShutdownOrReboot(MSG_STATE_INITIATE_SOFT_POWER_OFF);
}

///
/// @brief Maximum buffer for data (max xport - header)
///
Expand Down

0 comments on commit 14846f0

Please sign in to comment.