summaryrefslogtreecommitdiffstats
path: root/src/usr/fapi2
diff options
context:
space:
mode:
authorChristian Geddes <crgeddes@us.ibm.com>2017-09-21 14:09:56 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2017-10-17 11:46:45 -0400
commitebea5e69f6c3a86de8103126dc69a3d8942227e9 (patch)
treeeaee57dd1aeaebb80489b2fdec42c46e300e10a7 /src/usr/fapi2
parent17dda04f37485b693eca1ebc29bdc9026bcfda04 (diff)
downloadtalos-hostboot-ebea5e69f6c3a86de8103126dc69a3d8942227e9.tar.gz
talos-hostboot-ebea5e69f6c3a86de8103126dc69a3d8942227e9.zip
Implement FAPI_PLAT_CALL_SUBROUTINE macro
HWP writers need a way to request certain HWPs to run on the SBE for non-master processor targets while we are in secureBoot mode. This macro will check these conditions and if we are on a non-master in secureMode then we will issue a fifo chipop to the slave sbe in order to request the SBE to perform the HWP. This commit also adds some simple test cases to verify the failure paths. Also fapi2 test cases are re-enabled in this commit. Change-Id: Ic42fe2df5692fb5994985d92b2fd767ea7c1234a RTC: 179062 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/46580 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/fapi2')
-rw-r--r--src/usr/fapi2/plat_hw_access.C44
-rw-r--r--src/usr/fapi2/runtime/test/makefile2
-rw-r--r--src/usr/fapi2/test/fapi2SubroutineExecutorTest.H215
3 files changed, 259 insertions, 2 deletions
diff --git a/src/usr/fapi2/plat_hw_access.C b/src/usr/fapi2/plat_hw_access.C
index d0969d760..e39632ccc 100644
--- a/src/usr/fapi2/plat_hw_access.C
+++ b/src/usr/fapi2/plat_hw_access.C
@@ -362,7 +362,7 @@ void checkPibMask(errlHndl_t& io_errLog )
errlHndl_t getCfamChipTarget(const TARGETING::Target* i_target,
TARGETING::Target*& o_chipTarget)
{
- errlHndl_t l_err = NULL;
+ errlHndl_t l_err = nullptr;
// Default to input target
o_chipTarget = const_cast<TARGETING::Target*>(i_target);
@@ -389,6 +389,22 @@ errlHndl_t getCfamChipTarget(const TARGETING::Target* i_target,
{
// Something is wrong here, can't have more than one parent chip
FAPI_ERR("getCfamChipTarget: Invalid number of parent chip for this target chiplet - # parent chips %d", l_list.size());
+ /*@
+ * @errortype
+ * @moduleid fapi2::MOD_FAPI2_GET_CHIP_CFAM_TARGET
+ * @reasoncode fapi2::RC_INVALID_PARENT_TARGET_FOUND
+ * @userdata1 Number of parent proc chips found
+ * @userdata2 HUID of input target
+ * @devdesc Detecting more than 1 parent proc targets
+ * @custdesc Internal firmware error
+ */
+ l_err = new ERRORLOG::ErrlEntry(ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi2::MOD_FAPI2_GET_CHIP_CFAM_TARGET,
+ fapi2::RC_INVALID_PARENT_TARGET_FOUND,
+ l_list.size(),
+ TARGETING::get_huid(i_target),
+ true /*SW error*/);
+ l_err->collectTrace(FAPI_TRACE_NAME);
}
}
return l_err;
@@ -1039,6 +1055,32 @@ uint8_t platGetPIBErrorMask(void)
// No spy access interface as HB doesn't allow spy access.
// --------------------------------------------------------------------------
+/**
+* @brief Determine if a given target is on the master proc chip
+* @param[in] i_Target TARGETING::Target which op is being called on
+* @param[out] i_isMaster True if on master proc chip, false if not
+* @return errlHndl_t
+*/
+errlHndl_t isOnMasterProc(TARGETING::Target * i_target, bool & o_isMaster)
+{
+ errlHndl_t l_errl = nullptr;
+ assert(i_target != nullptr, "isOnMasterProc:: Cannot pass nullptr target to isOnMasterProc");
+ TARGETING::Target* l_pMasterProcChip = nullptr;
+ TARGETING::Target* l_pParentProcChip = nullptr;
+ TARGETING::targetService().masterProcChipTargetHandle( l_pMasterProcChip );
+ assert(l_pMasterProcChip != nullptr, "isOnMasterProc:: Unable to find the system's master proc chip target handle");
+ o_isMaster = false;
+ l_errl = getCfamChipTarget(i_target, l_pMasterProcChip);
+
+ if(l_errl == nullptr)
+ {
+ if(l_pMasterProcChip == l_pParentProcChip)
+ {
+ o_isMaster = true;
+ }
+ }
+ return l_errl;
+}
} // End namespace
diff --git a/src/usr/fapi2/runtime/test/makefile b/src/usr/fapi2/runtime/test/makefile
index 88cb33044..a8a44b36c 100644
--- a/src/usr/fapi2/runtime/test/makefile
+++ b/src/usr/fapi2/runtime/test/makefile
@@ -35,7 +35,7 @@ include ../../test/fapi2Test.mk
$(info TESTS before is ${TESTS})
TMPVAR1 := ${TESTS}
#RTC: 181003 need to determine why fapi2HwpErrorBufferTest.H is getting data storage exception in RT
-TESTS = $(filter-out ${ROOTPATH}/src/usr/fapi2/test/getVpdTest.H ${ROOTPATH}/src/usr/fapi2/test/fapi2GetVpdTest.H ${ROOTPATH}/src/usr/fapi2/test/fapi2HwpErrorBufferTest.H , ${TMPVAR1})
+TESTS = $(filter-out ${ROOTPATH}/src/usr/fapi2/test/getVpdTest.H ${ROOTPATH}/src/usr/fapi2/test/fapi2GetVpdTest.H ${ROOTPATH}/src/usr/fapi2/test/fapi2HwpErrorBufferTest.H ${ROOTPATH}/src/usr/fapi2/test/fapi2SubroutineExecutorTest.H , ${TMPVAR1})
TMPVAR2 := ${OBJS}
OBJS = $(filter-out getVpdTest.o, ${TMPVAR2})
include ${ROOTPATH}/config.mk
diff --git a/src/usr/fapi2/test/fapi2SubroutineExecutorTest.H b/src/usr/fapi2/test/fapi2SubroutineExecutorTest.H
new file mode 100644
index 000000000..5cb044ae5
--- /dev/null
+++ b/src/usr/fapi2/test/fapi2SubroutineExecutorTest.H
@@ -0,0 +1,215 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/fapi2/test/fapi2SubroutineExecutorTest.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2016,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 */
+#include <fapi2.H>
+#include <fapi2_subroutine_executor.H>
+
+//--------------------------------------------------------------------------
+/// @file fapi2SubroutineExecutorTest.C
+///
+/// @brief This does tests of the FAPI try and FAPI assert MACROs without
+/// needing full ReturnCode support.
+//--------------------------------------------------------------------------
+
+namespace fapi2
+{
+
+ class Fapi2SubroutineExecutorTest : public CxxTest::TestSuite
+{
+ private:
+
+ // a pretend HWP that we will use for simple testing
+ //note that function name does not match anything defined as acceptable hwp names in sbe_secureHwp.C
+ fapi2::ReturnCode procedure_to_call(TARGETING::Target * i_target, uint32_t i_data, uint32_t& o_data )
+ {
+ fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS;
+
+ if(i_data == 0 )
+ {
+ o_data = 1;
+ }
+ else if( i_data == 1 )
+ {
+ l_rc = FAPI2_RC_FALSE;
+ }
+ return l_rc;
+ }
+
+ // a pretend HWP that we will use for simple testing
+ //note that function name matches what is defined as acceptable hwp name in sbe_secureHwp.C
+ fapi2::ReturnCode test_hwp(TARGETING::Target * i_target, uint32_t i_data, uint32_t& o_data )
+ {
+ fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS;
+
+ if(i_data == 0 )
+ {
+ o_data = 1;
+ }
+ else if( i_data == 1 )
+ {
+ l_rc = FAPI2_RC_FALSE;
+ }
+ return l_rc;
+ }
+
+ // Request to run a hwp that is on Hostboot's supported list
+ // We expect that hostboot will send a secureHwp chip op
+ // but it will fail because SBE doesn't support and instead
+ // we will just run hwp on host
+ // Test that the function runs okay
+ fapi2::ReturnCode p9_fapi_subroutineExecutor_ValidHwp( )
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_ValidHwp starting ... ");
+ fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS;
+ // Get a list of all of the proc chips and use the first we find as our target
+ // then cast it to a fapi2 target
+ TARGETING::TargetHandleList l_chipList;
+ TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, true);
+ assert(l_chipList.size() > 0, "Could not find a functional proc chip, something is wrong");
+ TARGETING::Target * l_proc = l_chipList[0];
+
+ Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_proc);
+
+ uint32_t l_var1 = 0;
+ uint32_t l_var2 = 0;
+
+
+ FAPI_PLAT_CALL_SUBROUTINE(l_rc, test_hwp, fapi2_procTarget, l_var1, l_var2);
+
+ if(l_var2 != 1)
+ {
+ l_rc = 0xDEAD;
+ }
+ FAPI_INF("p9_fapi_subroutineExecutor_ValidHwp complete ... ");
+ return l_rc;
+ }
+
+ // Request to run a hwp that isn't on Hostboot's supported list
+ // We expect that hostboot will still send secureHwp chip op
+ // but it will fail and instead we will just run hwp on host
+ // Test that the function runs okay
+ fapi2::ReturnCode p9_fapi_subroutineExecutor_InvalidHwp( )
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp starting ... ");
+ fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS;
+ // Get a list of all of the proc chips and use the first we find as our target
+ // then cast it to a fapi2 target
+ TARGETING::TargetHandleList l_chipList;
+ TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, true);
+ assert(l_chipList.size() > 0, "Could not find a functional proc chip, something is wrong");
+ TARGETING::Target * l_proc = l_chipList[0];
+ Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_proc);
+
+ uint32_t l_var1 = 0;
+ uint32_t l_var2 = 0;
+ FAPI_PLAT_CALL_SUBROUTINE(l_rc, procedure_to_call, fapi2_procTarget, l_var1, l_var2);
+
+ if(l_rc == FAPI2_RC_FALSE)
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp:: l_var1: %x l_var2: %x l_rc: FALSE", l_var1, l_var2);
+ }
+ else
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp:: l_var1: %x l_var2: %x l_rc: SUCESS", l_var1, l_var2);
+ }
+
+ if(l_var2 != 1)
+ {
+ l_rc = 0xDEAD;
+ }
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp complete ... ");
+ return l_rc;
+ }
+
+ // Request to run a hwp that isn't on Hostboot's supported list
+ // We expect that hostboot will still send secureHwp chip op
+ // but it will fail and instead we will just run hwp on host
+ // This test checks that if the hwp fails we get the RC correctly
+ fapi2::ReturnCode p9_fapi_subroutineExecutor_InvalidHwp_RcCheck( )
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp_RcCheck started ... ");
+ fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS;
+ // Get a list of all of the proc chips and use the first we find as our target
+ // then cast it to a fapi2 target
+ TARGETING::TargetHandleList l_chipList;
+ TARGETING::getAllChips(l_chipList, TARGETING::TYPE_PROC, true);
+ TARGETING::Target * l_proc = l_chipList[0];
+ assert(l_chipList.size() > 0, "Could not find a functional proc chip, something is wrong");
+ Target<fapi2::TARGET_TYPE_PROC_CHIP> fapi2_procTarget(l_proc);
+
+ uint32_t l_var1 = 1;
+ uint32_t l_var2 = 1;
+ FAPI_PLAT_CALL_SUBROUTINE(l_rc, procedure_to_call, fapi2_procTarget, l_var1, l_var2);
+ if(l_rc == FAPI2_RC_FALSE)
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp_RcCheck:: l_var1: %x l_var2: %x l_rc: FALSE", l_var1, l_var2);
+ }
+ else
+ {
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp_RcCheck:: l_var1: %x l_var2: %x l_rc: SUCESS", l_var1, l_var2);
+ }
+ FAPI_INF("p9_fapi_subroutineExecutor_InvalidHwp_RcCheck complete ... ");
+ return l_rc;
+ }
+
+ public:
+ //******************************************************************************
+ // test_fapi2SubroutineExecutor
+ //******************************************************************************
+
+ void test_fapi2SubroutineExecutor()
+ {
+ int numTests = 0;
+ int numFails = 0;
+ fapi2::ReturnCode l_rc = FAPI2_RC_SUCCESS;
+
+ FAPI_INF("test_fapi2SubroutineExecutor starting ... ");
+ numTests++;
+ l_rc = p9_fapi_subroutineExecutor_InvalidHwp();
+ if (l_rc != FAPI2_RC_SUCCESS)
+ {
+ numFails++;
+ TS_FAIL(" p9_fapi_subroutineExecutor_InvalidHwp returned bad RC!");
+ }
+
+ numTests++;
+ l_rc = p9_fapi_subroutineExecutor_InvalidHwp_RcCheck();
+ if (l_rc != FAPI2_RC_FALSE)
+ {
+ numFails++;
+ TS_FAIL(" p9_fapi_subroutineExecutor_InvalidHwp_RcCheck failed to return bad RC!");
+ }
+
+ //TODO RTC:180100 once the SBE support comes in we want SBE team to add support
+ //for a test HWP so we can validate the chipOp request path works. This also
+ //requires a 2 socket sytem model (might not be ready until cumulus)
+ //p9_fapi_subroutineExecutor_ValidHwp
+
+ FAPI_INF("test_fapi2SubroutineExecutor:: Test Complete. %d/%d fails", numFails, numTests);
+
+ } // end main testcase driver
+
+}; // end class
+
+} // end namespace fapi2
OpenPOWER on IntegriCloud