Skip to content

Commit

Permalink
SMF: Distribute Secure Memory Among Procs
Browse files Browse the repository at this point in the history
Logic for distributing the requested amount of SMF memory between
the procs with memory on the system. The algorithm attempts to
allocate the memory in power-of-two increments of 256MB (such
is the HW limitation) under each proc until the requested
amount is satisfied or until we run out of procs with memory.

Change-Id: Ica3e1706bdb731762a3daf07c11d889fc7b6367f
RTC: 192411
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/68128
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Roland Veloz <rveloz@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
Ilya Smirnov authored and dcrowell77 committed Nov 27, 2018
1 parent cbf7565 commit 50182cf
Show file tree
Hide file tree
Showing 8 changed files with 428 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/include/usr/hbotcompid.H
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,14 @@ const char EXPSCOM_COMP_NAME[] = "expscom";
//@{
const compId_t NVRAM_COMP_ID = 0x3900;
const char NVRAM_COMP_NAME[] = "nvram";

/** @name SMF
* SMF Support component
*/
//@{
const compId_t SMF_COMP_ID = 0x4000;
const char SMF_COMP_NAME[] = "smf";

//@}

/** @name HDAT
Expand Down
1 change: 1 addition & 0 deletions src/include/usr/isteps/istep07list.H
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const DepModInfo g_istep07Dependancies = {
#ifndef CONFIG_FSP_BUILD
DEP_LIB(libnvram.so),
#endif
DEP_LIB(libsmf.so),
NULL
}
};
Expand Down
3 changes: 3 additions & 0 deletions src/include/usr/secureboot/secure_reasoncodes.H
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace SECUREBOOT
MOD_LOCK_ABUS_SEC_MAILBOXES = 0x11,
MOD_SECURE_LOG_PLAT_SECURITY_CONFIG = 0x12,
MOD_CHECK_RISK_LEVEL_FOR_SMF = 0x13,
MOD_SMF_SPLIT_SMF_MEM = 0x14,

// Use 0x20-0x2F range for Node Communications
MOD_NCDD_CHECK_FOR_ERRORS = 0x20,
Expand Down Expand Up @@ -91,6 +92,8 @@ namespace SECUREBOOT
RC_LOCK_MAILBOXES_FAILED = SECURE_COMP_ID | 0x14,
RC_SECURE_LOG_PLAT_SECURITY_CONFIG = SECURE_COMP_ID | 0x15,
RC_RISK_LEVEL_TOO_LOW = SECURE_COMP_ID | 0x16,
RC_COULD_NOT_ALLOCATE_SMF_MEM = SECURE_COMP_ID | 0x17,
RC_ALLOCATED_NE_REQUESTED = SECURE_COMP_ID | 0x18,

// Use 0x20-0x2F range for Node Communications
RC_NCDD_HW_ERROR_FOUND = SECURE_COMP_ID | 0x20,
Expand Down
66 changes: 66 additions & 0 deletions src/include/usr/secureboot/smf.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/secureboot/smf.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#ifndef __SMF_H
#define __SMF_H

#include <errl/errlentry.H>
#include <stdint.h>

namespace SMF_TRACE
{
extern trace_desc_t* g_trac_smf;
}

namespace SECUREBOOT
{
namespace SMF
{

/**
* @brief A function that destributes the requested amount of secure
* memory between the functional procs with memory on the system.
* The memory is distributed in power-of-two chunks of 256MB
* until either all memory is distributed or there are no procs
* remaining with memory available. The function returns predictive
* or informational errors in the following cases: there is no
* available memory behind the procs on the system (predictive error),
* the exact amount of secure mem allocated did not match the requested
* amount (informational error). If 0 is passed in to the function, no
* attempt at distribution occurs and the SMF mode is turned off.
*
* @param[in] i_requestedSmfMemAmtInBytes the amount of secure memory to be
* distributed (in bytes)
* among the procs on the system
*
* @return nullptr: the memory was successfully distributed as requested
* non-nullptr: a distribution error occurred (this error is never
* unrecoverable)
*/
errlHndl_t distributeSmfMem(uint64_t i_requestedSmfMemAmtInBytes);

} // namespace SMF
} // namespace SECUREBOOT

#endif
6 changes: 5 additions & 1 deletion src/include/usr/secureboot/smf_utils.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ namespace SMF
{

// HW limitations dictate that SMF memory needs to be a power-of-two
// multiple of 256MB starting with 256MB.
// multiple of 256MB starting with 256MB (amount in bytes).
extern const uint64_t MIN_SMF_MEMORY_AMT;

// The minimum amount of memory, in bytes, required for hostboot to run on
// master proc.
extern const uint64_t MIN_MEM_RESERVED_FOR_HB;

/**
* @brief Checks whether SMF mode is enabled on the system
*
Expand Down
1 change: 1 addition & 0 deletions src/usr/secureboot/smf/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ROOTPATH = ../../../..
MODULE = smf

OBJS += smf_utils.o
OBJS += smf.o

include ${ROOTPATH}/config.mk

0 comments on commit 50182cf

Please sign in to comment.