diff options
| author | Ilya Smirnov <ismirno@us.ibm.com> | 2018-01-26 12:10:24 -0600 |
|---|---|---|
| committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2018-02-14 15:01:31 -0500 |
| commit | d9c127dca8312f119b379c83b361216b910f6748 (patch) | |
| tree | 8d37e7926981c115092a558daf36d8d02d405ae2 /src/usr/runtime/test | |
| parent | ddfe08755562f0bd6b2ec445972f4b2c751a5f80 (diff) | |
| download | talos-hostboot-d9c127dca8312f119b379c83b361216b910f6748.tar.gz talos-hostboot-d9c127dca8312f119b379c83b361216b910f6748.zip | |
Error when hb tries to access reserved memory past limit
An issue has recently occurred when hb reserved memory past
the allowed limit (256M-4K) and overwrote some of the PHYP
memory, which caused bugs that were difficult to debug. This
change is to check the memory address we are trying to reserve
and throw an error if the address is at or above the allowed
limit. We only execute this check if PHYP is running and only
on components not belonging to PHYP (PHYP components may be
placed outside of the limit).
Change-Id: Ic62a7b724abc3b29b7872d0af47de8c68cde2ea8
RTC:186332
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/52850
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Nicholas E. Bofferding <bofferdn@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: Michael Baiocchi <mbaiocch@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/runtime/test')
| -rw-r--r-- | src/usr/runtime/test/makefile | 3 | ||||
| -rw-r--r-- | src/usr/runtime/test/test_checkHbResMemLimit.H | 157 |
2 files changed, 159 insertions, 1 deletions
diff --git a/src/usr/runtime/test/makefile b/src/usr/runtime/test/makefile index 92715cf83..7eaaae928 100644 --- a/src/usr/runtime/test/makefile +++ b/src/usr/runtime/test/makefile @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2012,2017 +# Contributors Listed Below - COPYRIGHT 2012,2018 # [+] International Business Machines Corp. # # @@ -26,6 +26,7 @@ ROOTPATH = ../../../.. MODULE = testruntime TESTS += testpreverifiedlidmgr.H +TESTS += test_checkHbResMemLimit.H #@TODO RTC 132750 #TESTS += hdatservicetest.H #@TODO RTC:178802 diff --git a/src/usr/runtime/test/test_checkHbResMemLimit.H b/src/usr/runtime/test/test_checkHbResMemLimit.H new file mode 100644 index 000000000..e2ab9ca41 --- /dev/null +++ b/src/usr/runtime/test/test_checkHbResMemLimit.H @@ -0,0 +1,157 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/runtime/test/test_checkHbResMemLimit.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2018 */ +/* [+] 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 _TEST_CHECKHBRESMEMLIMIT_H +#define _TEST_CHECKHBRESMEMLIMIT_H + +#include <cxxtest/TestSuite.H> +#include <runtime/populate_hbruntime.H> +#include <errl/errlmanager.H> +#include <hdat/hdat.H> +#include <runtime/interface.h> +#include <runtime/runtime_reasoncodes.H> +#include <vmmconst.h> + +extern trace_desc_t* g_trac_runtime; + +class CheckHbResMemLimitTest : public CxxTest::TestSuite +{ +public: + + void testAddressWithinHbResMemRange() + { + TRACFCOMP(g_trac_runtime, "testAddressWithinHbResMemRange running"); + errlHndl_t l_errl = nullptr; + l_errl = RUNTIME::checkHbResMemLimit(RUNTIME::HB_RES_MEM_LOWER_LIMIT, //i_addr + 1); //i_size + if(l_errl) + { + TS_FAIL("testAddressWithinHbResMemRange: checkHbResMemLimit" + " returned an unexpected error"); + errlCommit(l_errl, CXXTEST_COMP_ID); + } + else + { + TRACDCOMP(g_trac_runtime, "testAddressWithinHbResMemRange:" + " no error returned (expected)"); + } + TRACFCOMP(g_trac_runtime, "testAddressWithinHbResMemRange finished"); + } + + void testAddressAboveHbResMemRange() + { + TRACFCOMP(g_trac_runtime, "testAddressAboveHbResMemRange running"); + errlHndl_t l_errl = nullptr; + l_errl = RUNTIME::checkHbResMemLimit(RUNTIME::HB_RES_MEM_UPPER_LIMIT, //i_addr + 10); //i_size + do{ + + if(l_errl) + { + TRACDCOMP(g_trac_runtime, "testAddressAboveHbResMemRange:" + " errl returned (expected)"); + + //Check module id and reason code + if((l_errl->moduleId() == RUNTIME::MOD_CHECK_HB_RES_MEM_LIMIT) and + (l_errl->reasonCode() == RUNTIME::RC_HB_RES_MEM_EXCEEDED)) + { + TRACDCOMP(g_trac_runtime, "testAddressAboveHbResMemRange:" + " error's module id and reason code match expected values"); + } + else + { + TS_FAIL("testAddressAboveHbResMemRange: error with unexpected" + " module id/reason code returned. Expected module id = " + "0x%x returned module id = 0x%x; expected reason code =" + " 0x%x returned reason code = 0x%x", + RUNTIME::MOD_CHECK_HB_RES_MEM_LIMIT, + l_errl->moduleId(), + RUNTIME::RC_HB_RES_MEM_EXCEEDED, + l_errl->reasonCode()); + errlCommit(l_errl, CXXTEST_COMP_ID); + break; + } + delete l_errl; + l_errl = nullptr; + } + else + { + TS_FAIL("testAddressAboveHbResMemRange: no errl returned from" + " checkHbResMemLimit under error condition"); + } + + }while(0); + TRACFCOMP(g_trac_runtime, "testAddressAboveHbResMemRange finished"); + } + + void testAddressBelowHbResMemRange() + { + TRACFCOMP(g_trac_runtime, "testAddressBelowHbResMemRange running"); + + errlHndl_t l_errl = nullptr; + l_errl = RUNTIME::checkHbResMemLimit(RUNTIME::HB_RES_MEM_LOWER_LIMIT + - 11, //i_addr + 10); //i_size + do{ + + if(l_errl) + { + TRACDCOMP(g_trac_runtime, "testAddressBelowHbResMemRange:" + " errl returned (expected)."); + //Check module id and reason code + if((l_errl->moduleId() == RUNTIME::MOD_CHECK_HB_RES_MEM_LIMIT) and + (l_errl->reasonCode() == RUNTIME::RC_HB_RES_MEM_EXCEEDED)) + { + TRACDCOMP(g_trac_runtime, "testAddressBelowHbResMemRange:" + " error's module id and reason code match expected values"); + } + else + { + TS_FAIL("testAddressBelowHbResMemRange: error with unexpected" + " module id/reason code returned. Expected module id = " + "0x%x returned module id = 0x%x; expected reason code =" + " 0x%x returned reason code = 0x%x", + RUNTIME::MOD_CHECK_HB_RES_MEM_LIMIT, + l_errl->moduleId(), + RUNTIME::RC_HB_RES_MEM_EXCEEDED, + l_errl->reasonCode()); + errlCommit(l_errl, CXXTEST_COMP_ID); + break; + } + delete l_errl; + l_errl = nullptr; + } + else + { + TS_FAIL("testAddressBelowHbResMemRange: no errl returned from" + " checkHbResMemLimit under error condition"); + } + + }while(0); + TRACFCOMP(g_trac_runtime, "testAddressBelowHbResMemRange finished"); + } +}; + + +#endif |

