Skip to content

Commit

Permalink
Secure Boot: Support Phyp debug flag in HDAT
Browse files Browse the repository at this point in the history
PHYP needs a way to know if SBE security backdoor is enabled
for debug purposes. This change creates a flag in TPM instance
data structure to indicate whether the backdoor is enabled. This
flag is passed by SBE to the hb bootloader; also added the flag
to indicate whether PCR is poisoned (default of 0).
The population of this flag will be implemented on Fleetwood.

Change-Id: I22305dbc9651134ba7dfe3b0bd3c760fe53c2c85
RTC: 188961
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/56045
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: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com>
CI-Ready: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Ilya Smirnov authored and dcrowell77 committed Apr 9, 2018
1 parent 5192636 commit da8911c
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 11 deletions.
11 changes: 10 additions & 1 deletion src/bootloader/bootloader.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2015,2017 */
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -85,6 +85,12 @@ namespace Bootloader{
l_blConfigData->secureSettings.allowAttrOverrides;
}

if(l_blConfigData->version >= SBE_BACKDOOR_BIT_ADDED)
{
g_blData->blToHbData.secBackdoorBit =
l_blConfigData->secureSettings.secBackdoorBit;
}

// Find secure ROM addr
// Get starting address of ROM size and code which is the next 8 byte
// aligned address after the bootloader end.
Expand Down Expand Up @@ -113,6 +119,9 @@ namespace Bootloader{
case ADDR_STASH_SUPPORT_ADDED:
g_blData->blToHbData.version = BLTOHB_KEYADDR;
break;
case SBE_BACKDOOR_BIT_ADDED:
g_blData->blToHbData.version = BLTOHB_BACKDOOR;
break;
default:
g_blData->blToHbData.version = BLTOHB_SIZE;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/build/debug/Hostboot/BlData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# OpenPOWER HostBoot Project
#
# Contributors Listed Below - COPYRIGHT 2017
# Contributors Listed Below - COPYRIGHT 2017,2018
# [+] International Business Machines Corp.
#
#
Expand Down Expand Up @@ -208,7 +208,7 @@ sub main

my $blToHbAddr = $dataAddr + $dataOffset;
my $blToHbAddrStr = sprintf("0x%08X", $blToHbAddr);
my $blToHbSize = 171;
my $blToHbSize = 172;
my $blToHb = ::readData($blToHbAddr,$blToHbSize);
my $blToHbData = formatData($blToHb);
$dataOffset += ::alignUp($blToHbSize, 16);
Expand Down
4 changes: 2 additions & 2 deletions src/include/bootloader/bootloader_data.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace Bootloader{
// Object that will be stored where the SBE HB structure indicates
BlToHbData blToHbData;
uint8_t bl_reserved5[(512 - sizeof(BlToHbData)) % 16];
static_assert( sizeof(BlToHbData) == 171, "BlToHbData "
static_assert( sizeof(BlToHbData) == 172, "BlToHbData "
"size changed. Check bootloader_data.H alignment. "
"Fix BlData.pm processing.");
} blData_t;
Expand Down
8 changes: 6 additions & 2 deletions src/include/bootloader/bootloaderif.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -74,6 +74,7 @@ enum BlToHbDataVersion
BLTOHB_SECURE_OVERRIDES = 0x0000000900000004,
BLTOHB_SIZE = 0x0000000900000005,
BLTOHB_KEYADDR = 0x0000000900000006,
BLTOHB_BACKDOOR = 0x0000000900000007,
};

enum
Expand Down Expand Up @@ -123,7 +124,8 @@ struct BlToHbData
xscomBAR(MMIO_GROUP0_CHIP0_XSCOM_BASE_ADDR),
lpcBAR(MMIO_GROUP0_CHIP0_LPC_BASE_ADDR),
securityOverride(0), allowAttrOverrides(0),
sizeOfStructure(0), keyAddrStashData(0) {}
sizeOfStructure(0), keyAddrStashData(0),
secBackdoorBit(0) {}

// Simple way to tell if data is valid
uint64_t eyeCatch;
Expand Down Expand Up @@ -157,6 +159,8 @@ struct BlToHbData
size_t sizeOfStructure;
//keyAddr stash data
keyAddrPair_t keyAddrStashData;
// Secure Setting - SBE Security Backdoor
bool secBackdoorBit;
} __attribute__((packed));

/**
Expand Down
9 changes: 8 additions & 1 deletion src/include/kernel/bltohbdatamgr.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -209,6 +209,13 @@ class BlToHbDataManager
* @return keyAddrPair_t Key Address Pairs Struct
*/
const Bootloader::keyAddrPair_t getKeyAddrPairs() const;

/*
* @brief Returns the value of SBE security backdoor enabled bit
*
* @return bool true if enabled; false otherwise
*/
const bool getSecBackdoor() const;
};

// Extern global instance of the class
Expand Down
6 changes: 6 additions & 0 deletions src/include/usr/secureboot/service.H
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ namespace SECUREBOOT
*/
bool allowAttrOverrides();

/*
* @brief Determines if SBE security backdoor bit is set
* @return bool TRUE if SBE security backdoor is enabled; FALSE otherwise
*/
bool getSbeSecurityBackdoor();

/*
* @brief Gets the current SBE security mode value from the secureboot
* subsystem
Expand Down
10 changes: 10 additions & 0 deletions src/kernel/bltohbdatamgr.C
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ printk("Version=%lX\n",i_data.version);
sizeof(Bootloader::keyAddrPair_t));
}

if(iv_data.version >= Bootloader::BLTOHB_BACKDOOR)
{
iv_data.secBackdoorBit = i_data.secBackdoorBit;
}

// Size of data that needs to be preserved and pinned.
iv_preservedSize = ALIGN_PAGE(iv_data.secureRomSize +
iv_data.hwKeysHashSize +
Expand Down Expand Up @@ -378,3 +383,8 @@ const size_t BlToHbDataManager::getBlToHbDataSize() const
return iv_data.sizeOfStructure;
}

const bool BlToHbDataManager::getSecBackdoor() const
{
return iv_data.secBackdoorBit;
}

14 changes: 13 additions & 1 deletion src/usr/hdat/hdattpmdata.H
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ struct hdatTpmData_t
uint8_t hdatReserved1[8]; // Padding for alignment and growth/compatibility
} __attribute__ ((packed));

/**
* @brief Structure definition for TPM Configuration Flags
*
*/
struct hdatTpmConfigFlags_t
{
uint8_t pcrPoisonedFlag : 1; // Intentionally break remote attestation
// of this TPM
uint8_t reserved : 7;
} __attribute__ ((packed));

/**
* @brief Structure definition for Secureboot TPM Instance Info
*/
Expand All @@ -97,7 +108,8 @@ struct hdatSbTpmInstInfo_t
uint8_t hdatLocality3Addr;
uint8_t hdatLocality4Addr;
uint8_t hdatFunctionalStatus;
uint8_t reserved[3];
struct hdatTpmConfigFlags_t hdatTpmConfigFlags;
uint8_t reserved[2];
uint32_t hdatTpmSrtmEventLogOffset;
uint32_t hdatTpmSrtmEventLogEntrySize;
uint32_t hdatTpmDrtmEventLogOffset;
Expand Down
12 changes: 11 additions & 1 deletion src/usr/runtime/populate_hbruntime.C
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,11 @@ errlHndl_t populate_hbSecurebootData ( void )
uint16_t secureboot : 1;
// bit 1: Measurements Extended to Secure Boot TPM
uint16_t trustedboot : 1;
uint16_t reserved : 14;
// bit 2: SBE Security Backdoor bit.
// NOTE: This bit is labeled "Platform Security Overrides Allowed"
// in the section 6.1.1 of HDAT spec.
uint16_t sbeSecBackdoor : 1;
uint16_t reserved : 13;
} SysSecSets;

// populate system security settings in hdat
Expand All @@ -1451,6 +1455,9 @@ errlHndl_t populate_hbSecurebootData ( void )
#endif
l_sysSecSets->secureboot = secure? 1: 0;

// populate security override setting
l_sysSecSets->sbeSecBackdoor = SECUREBOOT::getSbeSecurityBackdoor();

// populate TPM config bits in hdat
bool tpmRequired = false;
#ifdef CONFIG_TPMDD
Expand Down Expand Up @@ -1768,6 +1775,9 @@ errlHndl_t populate_TpmInfoByNode(const uint64_t i_instance)
l_tpmInstInfo->hdatFunctionalStatus = HDAT::TpmNonPresent;
}

// Set TPM configuration flag
l_tpmInstInfo->hdatTpmConfigFlags.pcrPoisonedFlag = 0;

// advance the current offset to account for this tpm instance info
l_currOffset += sizeof(*l_tpmInstInfo);

Expand Down
19 changes: 18 additions & 1 deletion src/usr/secureboot/base/service.C
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2013,2017 */
/* Contributors Listed Below - COPYRIGHT 2013,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
Expand Down Expand Up @@ -637,6 +637,23 @@ bool allowAttrOverrides()
};
#endif

bool getSbeSecurityBackdoor()
{
bool l_backdoorEnabled = false;

if(g_BlToHbDataManager.getSecBackdoor())
{
l_backdoorEnabled = true;
SB_INF("getSbeSecurityBackdoor: SBE Security Backdoor is enabled.");
}
else
{
l_backdoorEnabled = false;
SB_INF("getSbeSecurityBackdoor: SBE Security Backdoor is disabled.");
}
return l_backdoorEnabled;
}

uint8_t getSbeSecurityMode()
{
return g_sbeSecurityMode;
Expand Down

0 comments on commit da8911c

Please sign in to comment.