summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/framework/register
diff options
context:
space:
mode:
authorZane Shelley <zshelle@us.ibm.com>2017-01-19 11:27:45 -0600
committerWilliam G. Hoffa <wghoffa@us.ibm.com>2017-01-20 11:15:49 -0500
commit06e5c5eb5192aa01ac6c4868141fa7ae49547acc (patch)
tree7862928a04d57693580bd5511b00727d8864efad /src/usr/diag/prdf/common/framework/register
parente3ea834342ff7a223e4ff2b39546af788e0a0f25 (diff)
downloadtalos-hostboot-06e5c5eb5192aa01ac6c4868141fa7ae49547acc.tar.gz
talos-hostboot-06e5c5eb5192aa01ac6c4868141fa7ae49547acc.zip
PRD: Data Storage exception in BitString class
We found a bug where a BitString object was used on an area of memory that was not CPU_WORD aligned. This memory was also allocated at the very end of a page and the next page was not accessible by Hostboot. So as when the last CPU_WORD of the data was accessed it crossed over into the unaccessible page and cause and exception. Change-Id: I71e87aeb4feaea1ea977d3b396674073a3d03e7b CQ: SW352432 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/35011 Reviewed-by: Brian J. Stegmiller <bjs@us.ibm.com> Reviewed-by: Caleb N. Palmer <cnpalmer@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Zane C. Shelley <zshelle@us.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/35012 Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Diffstat (limited to 'src/usr/diag/prdf/common/framework/register')
-rwxr-xr-xsrc/usr/diag/prdf/common/framework/register/iipCaptureData.h14
-rwxr-xr-xsrc/usr/diag/prdf/common/framework/register/prdfCaptureData.C158
2 files changed, 64 insertions, 108 deletions
diff --git a/src/usr/diag/prdf/common/framework/register/iipCaptureData.h b/src/usr/diag/prdf/common/framework/register/iipCaptureData.h
index 4395ce38b..b8aeac652 100755
--- a/src/usr/diag/prdf/common/framework/register/iipCaptureData.h
+++ b/src/usr/diag/prdf/common/framework/register/iipCaptureData.h
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2015 */
+/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -230,7 +230,7 @@ public:
</ul><br>
*/
void Add( TARGETING::TargetHandle_t i_pchipHandle, int scomId,
- BIT_STRING_CLASS & bs, Place place = BACK);
+ const BIT_STRING_CLASS & bs, Place place = BACK);
// dg02 end
@@ -338,11 +338,11 @@ private:
DataContainerType data;
- /**
- Private function to facilitate the adding of caputre data to the internal vector
- */
- void AddDataElement(Data &dataElement, SCAN_COMM_REGISTER_CLASS & scr, Place place, RegType type);
- //$TEMP @jl04 Changed AddDataElement to include a Register type.
+ /** Private function to facilitate the adding of caputre data to the
+ * internal vector */
+ void AddDataElement( TARGETING::TargetHandle_t i_trgt, int i_scomId,
+ const BIT_STRING_CLASS * i_bs, Place i_place,
+ RegType i_type = PRIMARY );
// Predicate for deciding to delete an element of data from a Capture Data list.
class prdfCompareCaptureDataType : public std::unary_function<Data &, bool>
diff --git a/src/usr/diag/prdf/common/framework/register/prdfCaptureData.C b/src/usr/diag/prdf/common/framework/register/prdfCaptureData.C
index cf5442f7c..803e9e622 100755
--- a/src/usr/diag/prdf/common/framework/register/prdfCaptureData.C
+++ b/src/usr/diag/prdf/common/framework/register/prdfCaptureData.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2014 */
+/* Contributors Listed Below - COPYRIGHT 2012,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -39,6 +39,8 @@
#include <string.h>
#include <algorithm> // @jl04 a Add this for the Drop function.
+using namespace TARGETING;
+
namespace PRDF
{
@@ -74,63 +76,69 @@ void CaptureData::Clear(void)
} /* if not empty */
}
+//------------------------------------------------------------------------------
-// @jl04 c Changed this to add the type parm.
-void CaptureData::Add( TARGETING::TargetHandle_t i_pchipHandle, int scomId,
- SCAN_COMM_REGISTER_CLASS & scr, Place place, RegType type)
+void CaptureData::AddDataElement( TargetHandle_t i_trgt, int i_scomId,
+ const BIT_STRING_CLASS * i_bs,
+ Place i_place, RegType i_type )
{
- uint16_t bufferLength = scr.GetBitLength() / 8;
-
- if((scr.GetBitLength() % 8) != 0)
- bufferLength += 1;
-
- Data dataElement(i_pchipHandle, scomId, bufferLength, NULL);
+ // Initial values of the bit string buffer if i_bs has a zero value.
+ uint8_t * buf = nullptr;
+ size_t sz_buf = 0;
- AddDataElement(dataElement, scr, place, type);
+ // Add buffer only if the value is non-zero.
+ if ( !i_bs->IsZero() )
+ {
+ // Get the size of i_bs and ensure byte alignment.
+ sz_buf = (i_bs->GetLength() + 8-1) / 8;
+
+ // Since we are using a BitString below, which does everything on a
+ // CPU_WORD boundary, we must make sure the buffer is CPU_WORD aligned.
+ const size_t sz_word = sizeof(CPU_WORD);
+ sz_buf = ((sz_buf + sz_word-1) / sz_word) * sz_word;
+
+ // Allocate memory for the buffer.
+ buf = new uint8_t[sz_buf];
+ memset( buf, 0x00, sz_buf );
+
+ // Use a BitString to copy i_bs to the buffer.
+ BIT_STRING_ADDRESS_CLASS bs ( 0, i_bs->GetLength(), (CPU_WORD *)buf );
+ bs.SetBits( *i_bs );
+
+ // Create the new data element.
+ Data element( i_trgt, i_scomId, sz_buf, buf );
+ element.registerType = i_type;
+
+ // Add the new element to the data.
+ if ( FRONT == i_place )
+ data.insert( data.begin(), element );
+ else
+ data.push_back( element );
+ }
}
-// start dg02
-void CaptureData::Add( TARGETING::TargetHandle_t i_pchipHandle, int scomId,
- BIT_STRING_CLASS & bs, Place place)
-{
- uint16_t bufferLength = bs.GetLength() / 8;
-
- if((bs.GetLength() % 8) != 0)
- bufferLength += 1;
-
- Data dataElement(i_pchipHandle, scomId, bufferLength, NULL);
+//------------------------------------------------------------------------------
- DataIterator dataIterator;
-
- if(place == FRONT)
- {
- data.insert(data.begin(), dataElement);
- dataIterator = data.begin();
- }
- else
- {
- data.push_back(dataElement);
- dataIterator = data.end();
- dataIterator--;
- }
- if(!bs.IsZero())
- {
- uint8_t *bufferPtr = new uint8_t[(*dataIterator).dataByteLength];
- BIT_STRING_ADDRESS_CLASS bitString(0, bs.GetLength(), (CPU_WORD *) bufferPtr);
-
- bitString.SetBits(bs);
- (*dataIterator).dataPtr = bufferPtr;
- }
- else
- {
- (*dataIterator).dataByteLength = 0;
- }
+void CaptureData::Add( TargetHandle_t i_trgt, int32_t i_scomId,
+ SCAN_COMM_REGISTER_CLASS & io_scr,
+ Place i_place, RegType i_type )
+{
+ if ( SUCCESS == io_scr.Read() )
+ {
+ AddDataElement( i_trgt, i_scomId, io_scr.GetBitString(),
+ i_place, i_type );
+ }
+}
+//------------------------------------------------------------------------------
+void CaptureData::Add( TargetHandle_t i_trgt, int i_scomId,
+ const BIT_STRING_CLASS & i_bs, Place i_place )
+{
+ AddDataElement( i_trgt, i_scomId, &i_bs, i_place );
}
-// end dg02
-
+//------------------------------------------------------------------------------
// start jl04a
void CaptureData::Drop(RegType i_type)
@@ -145,55 +153,7 @@ void CaptureData::Drop(RegType i_type)
}
// end jl04a
-// @jl04 c Changed the AddDataElement to include a type.
-void CaptureData::AddDataElement( Data & dataElement,
- SCAN_COMM_REGISTER_CLASS & scr,
- Place place, RegType type )
-{
- DataIterator dataIterator;
-
- if(place == FRONT)
- {
- data.insert(data.begin(), dataElement);
- dataIterator = data.begin();
- }
- else
- {
- data.push_back(dataElement);
- dataIterator = data.end();
- dataIterator--;
- }
-
-//$TEMP @jl04 or @jl05.
- (*dataIterator).registerType = type;
-//$TEMP @jl04 or @jl05.
-
- if(scr.Read() == SUCCESS)
- {
- const BIT_STRING_CLASS *bitStringPtr = scr.GetBitString();
-
- if(!bitStringPtr->IsZero())
- {
- uint8_t *bufferPtr = new uint8_t[(*dataIterator).dataByteLength];
- BIT_STRING_ADDRESS_CLASS bitString(0, bitStringPtr->GetLength(),
- (CPU_WORD *) bufferPtr);
-
- bitString.SetBits(*bitStringPtr);
- (*dataIterator).dataPtr = bufferPtr;
- }
- else
- {
- (*dataIterator).dataByteLength = 0;
- }
- }
- else
- {
- // Zero out data length if SCRs failed
- (*dataIterator).dataByteLength = 0;
- }
-
-}
-// ------------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
/* CaptureData Format:
* capture data -> ( <chip header> <registers> )*
@@ -202,8 +162,6 @@ void CaptureData::AddDataElement( Data & dataElement,
*/
unsigned int CaptureData::Copy(uint8_t *i_buffer, unsigned int i_bufferSize) const
{
- using namespace TARGETING;
-
TargetHandle_t l_pcurrentChipHandle =NULL ;
uint8_t * l_entryCountPos = NULL;
uint32_t l_regEntries = 0;
@@ -300,8 +258,6 @@ unsigned int CaptureData::Copy(uint8_t *i_buffer, unsigned int i_bufferSize) con
// dg08a -->
CaptureData & CaptureData::operator=(const uint8_t *i_flatdata)
{
- using namespace TARGETING;
-
uint32_t l_tmp32 = 0;
uint16_t l_tmp16 = 0;
OpenPOWER on IntegriCloud