diff options
author | Nick Bofferding <bofferdn@us.ibm.com> | 2018-10-25 16:59:50 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2018-11-15 10:37:14 -0600 |
commit | 9b7da2e3c3a7127d39e6ba94be9dadc9ac3f273e (patch) | |
tree | f5be48ba5726506e93866b7a27038d98b87a4eb4 /src/usr/sbeio/sbe_getCapabilities.C | |
parent | 41e818515bd88e911a521b8b28d763bb61c24582 (diff) | |
download | talos-hostboot-9b7da2e3c3a7127d39e6ba94be9dadc9ac3f273e.tar.gz talos-hostboot-9b7da2e3c3a7127d39e6ba94be9dadc9ac3f273e.zip |
Support for putting fences around mallocs
This commit implements a compile time feature (set MALLOC_FENCING to
y in the src/lib/HBconfig file) which puts check bytes around each malloc.
Whenever an allocation is freed, if the check bytes have changed, the memory
manager immediate crashes Hostboot. It also fixes a heap corruption in
the SBE get capabilities command.
Change-Id: I3df96d5fce43c34d3574c47f3c674076842d90e1
CQ: SW442980
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/68214
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: Roland Veloz <rveloz@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr/sbeio/sbe_getCapabilities.C')
-rw-r--r-- | src/usr/sbeio/sbe_getCapabilities.C | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/usr/sbeio/sbe_getCapabilities.C b/src/usr/sbeio/sbe_getCapabilities.C index 4a0d7d90a..c681da07f 100644 --- a/src/usr/sbeio/sbe_getCapabilities.C +++ b/src/usr/sbeio/sbe_getCapabilities.C @@ -100,11 +100,16 @@ errlHndl_t getPsuSbeCapabilities(TargetHandle_t i_target) // Cache the SBE Capabilities' size for future uses size_t l_sbeCapabilitiesSize = sizeof(sbeCapabilities_t); - // Set up the buffer which the SBE will copy the capabilities info to + // The buffer must be a multiple of 128 bytes in size, and it must + // be aligned to a 128 byte boundary. + const size_t totalAlignedSize = ALIGN_X(l_sbeCapabilitiesSize, + SbePsu::SBE_CAPABILITIES_ALIGNMENT_SIZE_IN_BYTES) + + (SbePsu::SBE_CAPABILITIES_ALIGNMENT_SIZE_IN_BYTES - 1); + + // Set up the buffer which the SBE will copy the capabilities info to. // Create buffer with enough size to be properly aligned uint8_t * l_sbeCapabilitiesReadBuffer = static_cast<uint8_t*>( - malloc(l_sbeCapabilitiesSize + - (SbePsu::SBE_CAPABILITIES_ALIGNMENT_SIZE_IN_BYTES - 1)) ); + malloc(totalAlignedSize)); // Align the buffer uint64_t l_sbeCapabilitiesReadBufferAligned = |