diff options
author | Christian Geddes <crgeddes@us.ibm.com> | 2017-09-18 15:12:19 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-10-15 16:28:43 -0400 |
commit | e4610ec20b64512f20dee49449413e987670f3cd (patch) | |
tree | b7f6cba5fa24a2ec5cfa710ee6546f663d1312c9 /src/usr/sbeio | |
parent | a5d19110fd5dad891f8fe20c260fb7fb23051822 (diff) | |
download | talos-hostboot-e4610ec20b64512f20dee49449413e987670f3cd.tar.gz talos-hostboot-e4610ec20b64512f20dee49449413e987670f3cd.zip |
Add Hostboot infrastructure for secureHwp chipop request
Create structs and methods required for issuing a secureHwp chipop
request to the SBE.
Change-Id: Id493fc59346ee2c7155bd09a88ac0cba22a29c42
RTC: 179062
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/46365
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>
Reviewed-by: Brian E. Bakke <bbakke@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/sbeio')
-rw-r--r-- | src/usr/sbeio/makefile | 1 | ||||
-rw-r--r-- | src/usr/sbeio/sbe_fifodd.H | 77 | ||||
-rw-r--r-- | src/usr/sbeio/sbe_secureHwp.C | 140 |
3 files changed, 218 insertions, 0 deletions
diff --git a/src/usr/sbeio/makefile b/src/usr/sbeio/makefile index 77d151b0f..e48bab7c4 100644 --- a/src/usr/sbeio/makefile +++ b/src/usr/sbeio/makefile @@ -37,6 +37,7 @@ EXTRAINCDIR += ${PROCEDURES_PATH}/hwp/sbe/ OBJS += sbe_psudd.o OBJS += sbe_utils.o +OBJS += sbe_secureHwp.o OBJS += sbe_coreStateControl.o OBJS += sbe_psuQuiesce.o OBJS += sbe_stashKeyAddr.o diff --git a/src/usr/sbeio/sbe_fifodd.H b/src/usr/sbeio/sbe_fifodd.H index ac00ff872..ae921034a 100644 --- a/src/usr/sbeio/sbe_fifodd.H +++ b/src/usr/sbeio/sbe_fifodd.H @@ -78,6 +78,7 @@ class SbeFifo SBE_FIFO_CLASS_INSTRUCTION_CONTROL = 0xA7, SBE_FIFO_CLASS_GENERIC_MESSAGE = 0xA8, SBE_FIFO_CLASS_MPIPL_COMMANDS = 0xA9, + SBE_FIFO_CLASS_SECURE_HWP = 0xAA, }; /** @@ -100,6 +101,16 @@ class SbeFifo }; /** + * @brief enums for FIFO SECURE HWP Messages + */ + enum fifoSecureHwpMessage + { + //Replace this when we add real hwp support + SBE_FIFO_CMD_PLACEHOLDER_HWP = 0x00, + SBE_FIFO_CMD_UNSUPPORTED_HWP = 0xFF, + }; + + /** * @brief enums for FIFO MPIPL Messages */ enum fifoMpiplMessage @@ -110,6 +121,51 @@ class SbeFifo }; /** + * @brief enums used by secureHwp requests + */ + enum secureHwpDefines + { + REQUEST_SIZE_WITHOUT_DATA = 19, + BYTES_PER_WORD = 4, + }; + + /** + * @brief Struct for FIFO Secure Hwp request + * + */ + struct fifoSecureHwpRequest + { + uint32_t wordCnt; + uint16_t reserved; + uint8_t commandClass; + uint8_t command; + uint16_t targetType; + uint8_t chipletId; + uint8_t * dataPtr; + fifoSecureHwpRequest(uint64_t i_dataSizeBytes, + uint64_t i_hwpStringLen, + uint8_t * i_dataPtr) : + reserved(0), commandClass(SBE_FIFO_CLASS_SECURE_HWP), command(0), targetType(0), chipletId(0) + { + //Determine if we need to round up to next word + uint8_t needsRound = (REQUEST_SIZE_WITHOUT_DATA + i_dataSizeBytes) % BYTES_PER_WORD; + wordCnt = ( (REQUEST_SIZE_WITHOUT_DATA + i_dataSizeBytes) / BYTES_PER_WORD); + if(needsRound) + { + wordCnt++; + } + dataPtr = reinterpret_cast<uint8_t *>(malloc(i_dataSizeBytes)); + memcpy(dataPtr, i_dataPtr + i_hwpStringLen, i_dataSizeBytes); + } + ~fifoSecureHwpRequest(){ free(dataPtr);}; + + private: + fifoSecureHwpRequest(){}; + fifoSecureHwpRequest(const fifoSecureHwpRequest&); + fifoSecureHwpRequest& operator=(const fifoSecureHwpRequest&); + } PACKED; + + /** * @brief Struct for FIFO Continue MPIPL request * */ @@ -240,6 +296,27 @@ class SbeFifo } PACKED; /** + * @brief Struct for a standardFIFO response + * + * The actual number of returned words varies based on whether there was + * an error. + */ + struct fifoStandardResponse + { + statusHeader status; + struct fapi2::ffdc_struct ffdc; // ffdc data + uint32_t status_distance; // distance to status + fifoStandardResponse() {} // do nothing + ~fifoStandardResponse() {} // do nothing + + private: + //Make copy ctor and assignment operator private to + //avoid misuse + fifoStandardResponse(const fifoStandardResponse&); + fifoStandardResponse& operator=(const fifoStandardResponse&); + } PACKED; + + /** * @brief Struct for FIFO Put SCOM and Put SCOM under mask response * * The actual number of returned words varies based on whether there was diff --git a/src/usr/sbeio/sbe_secureHwp.C b/src/usr/sbeio/sbe_secureHwp.C new file mode 100644 index 000000000..208c853fb --- /dev/null +++ b/src/usr/sbeio/sbe_secureHwp.C @@ -0,0 +1,140 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/sbeio/sbe_secureHwp.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* [+] 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 */ +/** +* @file sbe_secureHwp.C +* @brief Send request to perform a HWP securely on SBE +*/ + +#include <config.h> +#include <trace/interface.H> +#include <errl/errlmanager.H> +#include <sbeio/sbeioif.H> +#include <sbeio/sbe_utils.H> +#include "sbe_fifodd.H" +#include <sbeio/sbeioreasoncodes.H> +#include <targeting/common/targetservice.H> + +extern trace_desc_t* g_trac_sbeio; + +#define SBE_TRACD(printf_string,args...) \ +TRACDCOMP(g_trac_sbeio,"secureHwp: " printf_string,##args) + +#define SBE_TRACF(printf_string,args...) \ +TRACFCOMP(g_trac_sbeio,"secureHwp: " printf_string,##args) + + +namespace SBEIO +{ + //List out name of valid hwps that have chipop equivalents + //these static variable will be used by + static const char* test_hwp = "p9_pm_ocb_indir_access"; // SBE_FIFO_CMD_PLACEHOLDER_HWP + + /** + * @brief Convert a hwp name passed in as a string to a chipOp code + * @param[in] i_hwpName name of hwp as a string + * @return fifoSecureHwpMessage returns a chipOp representing the HWP, if found + * otherwise returns UNSUPPORTED_HWP enum + */ + SbeFifo::fifoSecureHwpMessage convertHwpStringToOpCode(char* i_hwpName) + { + //Default to undefined HWP + SbeFifo::fifoSecureHwpMessage l_hwpOpCode = SbeFifo::fifoSecureHwpMessage::SBE_FIFO_CMD_UNSUPPORTED_HWP; + + //If we find a match, set the return value + if(strcmp(i_hwpName,test_hwp) == 0) + { + l_hwpOpCode = SbeFifo::fifoSecureHwpMessage::SBE_FIFO_CMD_PLACEHOLDER_HWP; + } + return l_hwpOpCode; + } + + /** + * @brief Request the SBE to do a specific chip op + * + * @param[in] i_target The target of which the HWP is intended to be called on, + * this must be the first param of the request HWP + * + * @param[in] i_dataPointer Pointer to a blob of data that contains additional parameters + * for the requests HWP + * + * @param[in] i_dataSize Size of blob of data that contains additional parameters + * for the requests HWP + * + * @param[in] i_hwpStringLen size of the hwp name string at beginning of data pointer + * + * @return errlHndl_t Error log handle on failure. + * + */ + errlHndl_t sendSecureHwpRequest(TARGETING::Target * i_target, + uint8_t * i_dataPointer, + uint64_t i_dataSize, + uint64_t i_hwpStringLen) + { + errlHndl_t errl = nullptr; + do + { + SBE_TRACD(ENTER_MRK "sendSecureHwpRequest"); + auto l_targType = i_target->getAttr<TARGETING::ATTR_TYPE>(); + TARGETING::Target * l_proc; + + //Copy out the hwp name string into a local buffer + char l_hwpName[i_hwpStringLen]; + memcpy(l_hwpName, i_dataPointer, i_hwpStringLen); + + if(l_targType == TARGETING::TYPE_PROC) + { + l_proc = i_target; + } + else + { + l_proc = const_cast<TARGETING::Target *>(getParentChip(i_target)); + } + + SbeFifo::fifoSecureHwpRequest l_fifoRequest(i_dataSize, i_hwpStringLen, i_dataPointer); + SbeFifo::fifoStandardResponse l_fifoResponse; + + //Command is computed by converting hwp string to function + l_fifoRequest.command = convertHwpStringToOpCode(l_hwpName); + l_fifoRequest.targetType = translateToSBETargetType(i_target); + l_fifoRequest.chipletId = getChipletIDForSBE(i_target); + + SBE_TRACD(ENTER_MRK "requesting secureHwp %d on proc %d HB -> SBE ", + l_fifoRequest.command, + l_proc->getAttr<TARGETING::ATTR_POSITION>()); + + errl = SbeFifo::getTheInstance().performFifoChipOp(l_proc, + (uint32_t *)&l_fifoRequest, + (uint32_t *)&l_fifoResponse, + sizeof(SbeFifo::fifoStandardResponse)); + + SBE_TRACD(EXIT_MRK "sendSecureHwpRequest"); + + }while(0); + + return errl; + }; + +} //end namespace SBEIO + |