diff options
author | Jaymes Wilks <mjwilks@us.ibm.com> | 2017-06-16 11:22:44 -0500 |
---|---|---|
committer | Daniel M. Crowell <dcrowell@us.ibm.com> | 2017-07-18 09:54:30 -0400 |
commit | 45c8a43a7be3115a056b8fca842d158cae80cb3a (patch) | |
tree | 78fcc5885b818d4c51de2b5808f791ad347188fa /src/include | |
parent | 986dd162063beef24cf9c28391ae19ead61a0116 (diff) | |
download | talos-hostboot-45c8a43a7be3115a056b8fca842d158cae80cb3a.tar.gz talos-hostboot-45c8a43a7be3115a056b8fca842d158cae80cb3a.zip |
Generate verification code for enum-based persistent r/w attributes
This updates xmltohb.pl to generate code to verify that all
enum-based persistent r/w attributes have valid values.
Change-Id: I07e2c99a6b2ca7afe1de20baffa16ad667bc9e79
RTC:163084
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/42374
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>
Reviewed-by: Stephen M. Cprek <smcprek@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/usr/targeting/common/target.H | 71 | ||||
-rw-r--r-- | src/include/usr/targeting/common/targreasoncodes.H | 22 |
2 files changed, 82 insertions, 11 deletions
diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index 7452a4946..bbbfe089d 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -389,6 +389,44 @@ class Target bool _tryGetAttr( ATTRIBUTE_ID i_attr, uint32_t i_size, + void* io_attrData) const + #ifdef __HOSTBOOT_MODULE + ; // not inlined for hostboot case, defined in persistrwattrcheck.C + // where the enum value and range checks are performed + // runtime case is handled there separately + #else + { + // inlined to _tryGetAttrUnsafe for FSP case + return _tryGetAttrUnsafe(i_attr, i_size, io_attrData); + } + #endif + + + /** + * @brief Tries to get the target's specified attribute value without + * checking for valid values. Do not call this function + * directly. This function is private. + * + * Tries to get the target's specified attribute value + * + * @param[in] i_attr Attribute to retrieve + * @param[in] i_size Size of the attribute + * @param[in/out] io_attrData On input, location to store the attribute + * On output, location updated with attribute data + * + * @pre Target service must be initialized + * + * @post Caller notified if attribute retrieval succeeded or not. If + * so, the attribute data is stored at io_addrData + * + * @return bool indicating if attribute retrieval succeeded or not + * + * @retval true Attribute retrieval succeeded + * @retval false Attribute retrieval failed + */ + bool _tryGetAttrUnsafe( + ATTRIBUTE_ID i_attr, + uint32_t i_size, void* io_attrData) const; /** @@ -632,6 +670,7 @@ bool Target::trySetAttr(typename AttributeTraits<A>::Type const& i_attrValue) return _trySetAttr(A,sizeof(i_attrValue),&i_attrValue); } + template<const ATTRIBUTE_ID A> typename AttributeTraits<A>::Type Target::getAttr() const { @@ -709,11 +748,41 @@ const char* Target::getAttrAsString() const void setFrequencyAttributes(Target * i_sys, uint32_t i_newNestFreq); - // WARNING: The following #include imports any platform specific template // specializations for getAttr and tryGetAttr #include <targeting/adapters/targetadapter.H> +// Keep secureboot-related attribute value checking code out of runtime and FSP +#ifndef __HOSTBOOT_RUNTIME +#ifdef __HOSTBOOT_MODULE + +// Function to handle secureboot attribute enum check failures +/** + * @brief Creates an error log with target and attribute information + * and halts the IPL. + * + * @param[in] i_pTarget The target associated with the attribute that failed + * enum value checking. + * @param[in] i_attr The attribute id of the attribute that failed enum + * value checking. + * @param[in] i_invalidValue The invalid value that failed the enum check. + */ +void handleEnumCheckFailure(const Target* i_pTarget, + const ATTRIBUTE_ID i_attr, + const uint64_t i_invalidValue); + +// The following #include ensures that persistent read/write attributes are +// value-checked for validity upon calling getAttr. This is done via +// autogenerated template specializations for each attribute. External calls +// directly to _tryGetAttr would bypass these specializations and are handled +// separately via an autogenerated wrapper around _tryGetAttr. See the +// definition of _tryGetAttr and autogenerated file persistrwattrcheck.C +// for details. +#include <persistrwattrcheck.H> + +#endif +#endif +// end of secureboot-related attribute value checking code } // End namespace TARGETING #endif // __TARGETING_COMMON_TARGET_H diff --git a/src/include/usr/targeting/common/targreasoncodes.H b/src/include/usr/targeting/common/targreasoncodes.H index 0652c730d..18d7c6726 100644 --- a/src/include/usr/targeting/common/targreasoncodes.H +++ b/src/include/usr/targeting/common/targreasoncodes.H @@ -38,16 +38,17 @@ namespace TARGETING enum TargetingModuleId { - TARG_MOD_TEST = 0x01, - TARG_MOD_ATTR_SYNC = 0x02, - TARG_RT_GET_RT_TARGET = 0x03, - TARG_RT_GET_HB_TARGET = 0x04, - TARG_GET_ATTR_OVER = 0x05, - TARG_WRITE_PERM_ATTR = 0x06, - TARG_PARSE_ATTR_SECT_HEADER = 0x07, - TARG_MSG_SERVICE_TASK = 0x08, - TARG_CREATE_VMM_SECTIONS = 0x09, - TARG_APPLY_ATTR_OVER = 0x0A, + TARG_MOD_TEST = 0x01, + TARG_MOD_ATTR_SYNC = 0x02, + TARG_RT_GET_RT_TARGET = 0x03, + TARG_RT_GET_HB_TARGET = 0x04, + TARG_GET_ATTR_OVER = 0x05, + TARG_WRITE_PERM_ATTR = 0x06, + TARG_PARSE_ATTR_SECT_HEADER = 0x07, + TARG_MSG_SERVICE_TASK = 0x08, + TARG_CREATE_VMM_SECTIONS = 0x09, + TARG_APPLY_ATTR_OVER = 0x0A, + TARG_HANDLE_ENUM_CHECK_FAILURE = 0x0B, }; enum TargetingReasonCode @@ -73,6 +74,7 @@ enum TargetingReasonCode TARG_RC_MM_BLOCK_MAP_FAIL = TARG_COMP_ID | 0x13, TARG_RC_APPLY_ATTR_OVER_NOT_ALLOWED = TARG_COMP_ID | 0x14, TARG_RC_MM_BLOCK_UNMAP_FAIL = TARG_COMP_ID | 0x15, + TARG_RC_ATTRIBUTE_ENUM_CHECK_FAIL = TARG_COMP_ID | 0x16, }; }; // End TARGETING namespace |