summaryrefslogtreecommitdiffstats
path: root/src/include/usr/runtime/populate_hbruntime.H
diff options
context:
space:
mode:
authorIlya Smirnov <ismirno@us.ibm.com>2018-01-26 12:10:24 -0600
committerDaniel M. Crowell <dcrowell@us.ibm.com>2018-02-14 15:01:31 -0500
commitd9c127dca8312f119b379c83b361216b910f6748 (patch)
tree8d37e7926981c115092a558daf36d8d02d405ae2 /src/include/usr/runtime/populate_hbruntime.H
parentddfe08755562f0bd6b2ec445972f4b2c751a5f80 (diff)
downloadtalos-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/include/usr/runtime/populate_hbruntime.H')
-rw-r--r--src/include/usr/runtime/populate_hbruntime.H41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/include/usr/runtime/populate_hbruntime.H b/src/include/usr/runtime/populate_hbruntime.H
index c2c0c224e..5a8f17279 100644
--- a/src/include/usr/runtime/populate_hbruntime.H
+++ b/src/include/usr/runtime/populate_hbruntime.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2017 */
+/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -22,6 +22,8 @@
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
+#ifndef POPULATE_HBRUNTIME_H
+#define POPULATE_HBRUNTIME_H
#include <hdat/hdat.H>
#include <vector>
#include <utility>
@@ -29,6 +31,9 @@
namespace RUNTIME
{
+extern const uint64_t HB_RES_MEM_UPPER_LIMIT;
+extern const uint64_t HB_RES_MEM_LOWER_LIMIT;
+
/**
* @brief Get the next Reserved HB memory range and set all member variables
* of struct. Additionally trace out relevant parts of the struct
@@ -38,16 +43,19 @@ namespace RUNTIME
* @param[in] i_size, Size of address space to reserve
* @param[in] i_label, Label String Ptr
* @param[in] i_permission, HDAT permission type [default read/write]
+ * @param[in] i_checkMemoryLimit, check if we overflow the limit for hb reserved
+ * memory. False for PHYP component
*
* @return errlHndl_t, nullptr on success; otherwise errlog
*/
-errlHndl_t setNextHbRsvMemEntry(const HDAT::hdatMsVpdRhbAddrRangeType i_type,
- const uint16_t i_rangeId,
- const uint64_t i_startAddr,
- const uint64_t i_size,
+errlHndl_t setNextHbRsvMemEntry(HDAT::hdatMsVpdRhbAddrRangeType i_type,
+ uint16_t i_rangeId,
+ uint64_t i_startAddr,
+ uint64_t i_size,
const char* i_label,
- const HDAT::hdatRhbPermType i_permission =
- HDAT::RHB_READ_WRITE
+ HDAT::hdatRhbPermType i_permission =
+ HDAT::RHB_READ_WRITE,
+ bool i_checkMemoryLimit = true
);
/**
@@ -76,7 +84,20 @@ errlHndl_t unmapVirtAddr(uint64_t i_addr);
*
* @return Error handle if error
*/
-errlHndl_t hbResvLoadSecureSection (const PNOR::SectionId i_sec,
- const bool i_secHdrExpected);
+errlHndl_t hbResvLoadSecureSection (PNOR::SectionId i_sec,
+ bool i_secHdrExpected);
+
+/**
+ * @brief Check whether the given addr falls withing allowed hb reserved memory
+ * range.
+ * @param[in] i_addr - phys address to check
+ * @param[in] i_size - the size of the section starting with i_addr (needed to
+ * verify the end limit of the section)
+ * @return Error handle if error
+ */
+errlHndl_t checkHbResMemLimit(uint64_t i_addr,
+ uint64_t i_size);
+
+} // End of Namespace
+#endif
-} // End of Namespace \ No newline at end of file
OpenPOWER on IntegriCloud