Skip to content

Commit

Permalink
Handle Compatability issues for new BltoHbData location
Browse files Browse the repository at this point in the history
Change-Id: I9ec35ca8dd513a5e31f69cd899fa5d1e00d41c63
RTC: 175114
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/42442
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: Martin Gloff <mgloff@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: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Stephen Cprek authored and dcrowell77 committed Jul 20, 2017
1 parent 6744879 commit 22d6e46
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/bootloader/bootloader.C
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ namespace Bootloader{
g_blData->blToHbData.sizeOfStructure = sizeof(BlToHbData);
}

// Place structure into proper location for HB to find
memcpy(reinterpret_cast<void *>(BLTOHB_COMM_DATA_ADDR |
// Place BlToHb into proper location for HB to find
memcpy(reinterpret_cast<void *>(BLTOHB_COMM_DATA_ADDR_LATEST |
IGNORE_HRMOR_MASK),
&g_blData->blToHbData,
sizeof(BlToHbData));
Expand Down
8 changes: 2 additions & 6 deletions src/include/bootloader/bootloader.H
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ namespace Bootloader{
#define HW_KEYS_HASH_ADDR (getHRMOR() + HBBL_EXCEPTION_VECTOR_SIZE \
+ MAX_HBBL_SIZE - 64)
/** Location of working copy of HBB with ECC */
#define HBB_ECC_WORKING_ADDR (getHRMOR() + ( 1*MEGABYTE))
#define HBB_ECC_WORKING_ADDR (getHRMOR() - ( 1*MEGABYTE))

/** Location of working copy of HBB without ECC */
#define HBB_WORKING_ADDR (getHRMOR() - ( 1*MEGABYTE))
#define HBB_WORKING_ADDR (getHRMOR() + ( 1*MEGABYTE))

/** Location of HBBL data */
#define HBBL_DATA_ADDR (getHRMOR() + HBBL_EXCEPTION_VECTOR_SIZE \
Expand All @@ -238,10 +238,6 @@ namespace Bootloader{
/** Location of HBBL scratch space */
#define HBBL_SCRATCH_SPACE_ADDR (getHRMOR() + (64*KILOBYTE))

/** Location of running copy of HBB */
#define HBB_HRMOR (getHRMOR() - ( 2*MEGABYTE))
#define HBB_RUNNING_ADDR (getHRMOR() - ( 2*MEGABYTE))

/** Location of SBE HB communication area
Defined in SBE code and bootloader.ld */
#define SBE_HB_COMM_ADDR (getHRMOR() + 0x4)
Expand Down
14 changes: 11 additions & 3 deletions src/include/bootloader/bootloaderif.H
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ namespace Bootloader{

#define MAX_HBB_SIZE (512 * KILOBYTE)

// The Bootloader to Hostboot communication area exists after the working HBB
// Location of running copy of HBB
#ifdef BOOTLOADER
#define BLTOHB_COMM_DATA_ADDR (getHRMOR() - ( 2*MEGABYTE) + MAX_HBB_SIZE)
#define HBB_HRMOR (getHRMOR() - ( 2*MEGABYTE))
#define HBB_RUNNING_ADDR (getHRMOR() - ( 2*MEGABYTE))
#else
#define BLTOHB_COMM_DATA_ADDR (getHRMOR() + MAX_HBB_SIZE)
#define HBB_HRMOR (getHRMOR())
#define HBB_RUNNING_ADDR (getHRMOR())
#endif

// Different Locations of BlToHBData struct over time.
// New values make "_LATEST" and switch current "_LATEST" to "V<N>"
// NOTE: Done this way to limit code space.
#define BLTOHB_COMM_DATA_ADDR_V1 (HBB_HRMOR + 512*KILOBYTE)
#define BLTOHB_COMM_DATA_ADDR_LATEST (HBB_HRMOR + MAX_HBB_SIZE)

// Expected BlToHbData eye catch
const uint64_t BLTOHB_EYECATCHER = 0x23626C746F686200; // #BLTOHB\0

Expand Down
46 changes: 41 additions & 5 deletions src/kernel/kernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,43 @@ class Kernel
Kernel() {};
};


/**
* @brief Searches multiple locations for the BlToHbData structure.
*
* @description Due to the possibility of a mismatch between the bootloader and
* hostboot, we must check every location of this structure in
* history. Searches latest to oldest.
*
* @return if found, pointer to structure
* otherwise nullptr
*/
const Bootloader::BlToHbData* getBlToHbData()
{
const Bootloader::BlToHbData* l_resultBltoHbData = nullptr;

// Order bootloader addr versions from most recent to oldest
// Note: Defined here to limit code space in bootloader code
static const std::array<uint64_t,2> BlToHbDataAddrs =
{
BLTOHB_COMM_DATA_ADDR_LATEST,
BLTOHB_COMM_DATA_ADDR_V1
};

for (auto addr : BlToHbDataAddrs)
{
const auto l_bltoHbData =
reinterpret_cast<const Bootloader::BlToHbData*>(addr);
if(Bootloader::BlToHbDataValid(l_bltoHbData))
{
l_resultBltoHbData = l_bltoHbData;
break;
}
}

return l_resultBltoHbData;
}

extern "C"
int main()
{
Expand All @@ -75,13 +112,12 @@ int main()
Kernel& kernel = Singleton<Kernel>::instance();
kernel.cppBootstrap();

// Get pointer to BL and HB comm data
const auto l_pBltoHbData = reinterpret_cast<const Bootloader::BlToHbData*>(
BLTOHB_COMM_DATA_ADDR);

if ( Bootloader::BlToHbDataValid(l_pBltoHbData) )
// Get pointer to BL and HB comm data
const auto l_pBltoHbData = getBlToHbData();
if ( l_pBltoHbData != nullptr )
{
printk("BL to HB comm valid\n");
printk("Valid BlToHbData found at 0x%lX\n", reinterpret_cast<uint64_t>(l_pBltoHbData));
// Initialize Secureboot Data class
g_BlToHbDataManager.initValid(*l_pBltoHbData);
}
Expand Down

0 comments on commit 22d6e46

Please sign in to comment.