Skip to content

Commit

Permalink
Support selecting fips or op-build for signing process
Browse files Browse the repository at this point in the history
Adds a new '--build-type' option to genPnorImages.pl to specify
either fspbuild or opbuild, which adds the appropriate magic
value to the secure header during the signing process.

Change-Id: I46a97f88666a5cc925797d3ad0e870a5f5bac89a
RTC:163655
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/48930
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: Stephen M. Cprek <smcprek@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
  • Loading branch information
popfuture authored and wghoffa committed Nov 9, 2017
1 parent 3378748 commit 5fa02a9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
24 changes: 20 additions & 4 deletions src/build/buildpnor/genPnorImages.pl
Expand Up @@ -79,16 +79,18 @@
use constant OP_SIGNING_FLAG => " --flags ";
# Security bits HW flag strings
use constant OP_BUILD_FLAG => 0x80000000;
use constant FIPS_BUILD_FLAG => 0x40000000;
# TODO 1633655 For now, as a workaround FIPS_BUILD_FLAG will be the same as
# OP_BUILD_FLAG until the larger team is ready to take on the new value.
use constant FIPS_BUILD_FLAG => 0x80000000;
# use constant FIPS_BUILD_FLAG => 0x40000000;
# Applies to SBE image only
use constant LAB_SECURITY_OVERRIDE_FLAG => 0x00080000;
use constant KEY_TRANSITION_FLAG => 0x00000001;
# Size of HW keys' Hash
use constant HW_KEYS_HASH_SIZE => 64;

# TODO: RTC 163655
# Implement dynamic support for choosing FSP or op-build flag type.
# For now, assume OP build
# Dynamic support for choosing FSP or op-build flag type.
# Default to OP build
my $buildFlag = OP_BUILD_FLAG;

# Corrupt parameter strings
Expand Down Expand Up @@ -122,6 +124,7 @@
my $sign_mode = $DEVELOPMENT;
my $hwKeyHashFile = "";
my $hb_standalone="";
my $buildType="";

# @TODO RTC 170650: Set default to 0 after all environments provide external
# control over this policy, plus remove '!' from 'lab-security-override'
Expand All @@ -143,6 +146,7 @@
"hb-standalone" => \$hb_standalone,
"lab-security-override!" => \$labSecurityOverride,
"emit-eccless" => \$emitEccless,
"build-type:s" => \$buildType,
"help" => \$help);

if ($help)
Expand All @@ -155,6 +159,12 @@
# Environment Setup, Checking, and Variable Initialization
################################################################################

# Get the build type
if ($buildType eq "fspbuild")
{
$buildFlag = FIPS_BUILD_FLAG;
}

# Put mode transition input into a hash and ensure a valid signing mode
my %signMode = ( $DEVELOPMENT => 1,
$PRODUCTION => 0 );
Expand Down Expand Up @@ -1313,6 +1323,12 @@ sub usage
physical jumpers on the system planar.
--emit-eccless In addition to typical output, also emit
ECC-less versions of any input binaries
--build-type Specify whether the type of build is FIPS or
OpenPower, indicated by either 'fspbuild'
or 'opbuild' immediately following the
switch (separated with a space and not
including the single quotes). OpenPower is
the default.
Current Limitations:
- Issues with dependency on ENGD build for certain files such as SBE. This is why [--build-all | --install-all ] are used.
Expand Down
8 changes: 6 additions & 2 deletions src/build/mkrules/hbfw/img/makefile
Expand Up @@ -176,6 +176,10 @@ PNOR_LAYOUT = ${pnorLayoutFSP.xml:P}
PNOR_LAYOUT = ${defaultPnorLayout.xml:P}
.endif

# Since this makefile is only ever used for an FSP signing environment, then
# we can just specify that we want an fspbuild here without any condition.
BUILD_TYPE_PARAMS = --build-type fspbuild

# Decide which PNOR to build
.if(${FAKEPNOR} == "")
# Parameters passed into GEN_PNOR_IMAGE_SCRIPT.
Expand Down Expand Up @@ -226,7 +230,7 @@ gen_default_images: ${GEN_DEFAULT_IMAGES_DEPS}
# result [hbbl][pad:8:if-applicable][securerom-size:8][securerom]

# Call script to generate final bin files for default images
export LD_PRELOAD=${SIGNING_LIBS} && ${GEN_PNOR_IMAGE_SCRIPT} ${DEFAULT_PARAMS}
export LD_PRELOAD=${SIGNING_LIBS} && ${GEN_PNOR_IMAGE_SCRIPT} ${DEFAULT_PARAMS} ${BUILD_TYPE_PARAMS}

clobber_cp_hbfiles:
rm -f ${ALL_DEFAULT_IMAGES}
Expand Down Expand Up @@ -379,7 +383,7 @@ ZEPPELIN_HBD_FINAL_IMG = ZEPPELIN.HBD.bin

gen_system_specific_images_bypass_cache : dump-secureboot-config
# Call script to generate final bin file for chip/system specific images
export LD_PRELOAD=${SIGNING_LIBS} && ${GEN_PNOR_IMAGE_SCRIPT} ${SYSTEM_SPECIFIC_PARAMS}
export LD_PRELOAD=${SIGNING_LIBS} && ${GEN_PNOR_IMAGE_SCRIPT} ${SYSTEM_SPECIFIC_PARAMS} ${BUILD_TYPE_PARAMS}

#for NIMBUS fake pnor skip version header
.if(${FAKEPNOR} != "")
Expand Down
7 changes: 7 additions & 0 deletions src/include/usr/secureboot/containerheader.H
Expand Up @@ -74,6 +74,13 @@ class ContainerHeader
*/
size_t totalContainerSize() const;

/**
* @brief Retrieves the prefix header flags
*
* @return uint32_t containing prefix header flags
*/
uint32_t prefixHeaderFlags() const;

/**
* @brief Retrieves pointer to first hw key
* @return ecc_key_t* - ptr to first hw key
Expand Down
3 changes: 3 additions & 0 deletions src/usr/pnor/spnorrp.C
Expand Up @@ -425,6 +425,9 @@ uint64_t SPnorRP::verifySections(SectionId i_id,

SECUREBOOT::ContainerHeader l_conHdr(l_tempAddr);
size_t l_totalContainerSize = l_conHdr.totalContainerSize();
auto l_prefixHdrFlags = l_conHdr.prefixHeaderFlags();

TRACFCOMP(g_trac_pnor, "Prefix hdr flags:0x%X",l_prefixHdrFlags);

TRACFCOMP(g_trac_pnor, "SPnorRP::verifySections "
"Total container size = 0x%.16llX", l_totalContainerSize);
Expand Down
5 changes: 5 additions & 0 deletions src/usr/secureboot/common/containerheader.C
Expand Up @@ -152,6 +152,11 @@ size_t ContainerHeader::totalContainerSize() const
return iv_headerInfo.hw_hdr.container_size;
}

uint32_t ContainerHeader::prefixHeaderFlags() const
{
return iv_headerInfo.hw_prefix_hdr.flags;
}

const ecc_key_t* ContainerHeader::hw_keys() const
{
return &iv_headerInfo.hw_hdr.hw_pkey_a;
Expand Down

0 comments on commit 5fa02a9

Please sign in to comment.