From 945553cc05cf2ab168a6dc435e8160997402be10 Mon Sep 17 00:00:00 2001 From: Dan Crowell Date: Thu, 8 Mar 2018 15:26:29 -0600 Subject: Force single-threaded access to HWPs in PRD Hostboot does not support thread local storage, however several HWPs use this concept. Specifically the memory HWPs use it for their c_str() function that prints out target strings. If these HWPs are called in multiple threads there is a chance of a buffer overrun that leads to a crash. The fix is to create a new INVOKE-style macro that befores the same mutex lock as a regular FAPI_INVOKE_HWP call. Change-Id: I550fc752f6a6b1bb51ecb4f9c8a7011f98bb8cd3 CQ: SW420212 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/55289 Tested-by: Jenkins Server Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Tested-by: FSP CI Jenkins Reviewed-by: Daniel M. Crowell Tested-by: Daniel M. Crowell --- src/include/usr/fapi2/plat_hwp_invoker.H | 36 +++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/usr/fapi2/plat_hwp_invoker.H b/src/include/usr/fapi2/plat_hwp_invoker.H index c7ababf18..a0b335a1e 100644 --- a/src/include/usr/fapi2/plat_hwp_invoker.H +++ b/src/include/usr/fapi2/plat_hwp_invoker.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2017 */ +/* Contributors Listed Below - COPYRIGHT 2015,2018 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -79,4 +79,38 @@ void hwpLock( bool i_lock ); fapi2::hwpLock(false); \ } +/** + * @brief Pseudo-HWP Invoker macro + * + * This macro is called by HostBoot PLAT code to invoke a HW Procedure (HWP) + * that does not return a ReturnCode + * + * RETURN - Local var to store the return value + * FUNC - HWP function name + * _args_... - Any additional arguments that the HWP requires + */ +#define FAPI_CALL_HWP( RETURN, FUNC, _args_...) \ + {\ + fapi2::hwpLock(true); \ + RETURN = FUNC(_args_); \ + fapi2::hwpLock(false); \ + } + +/** + * @brief Pseudo-HWP Invoker macro + * + * This macro is called by HostBoot PLAT code to invoke a HW Procedure (HWP) + * that does not return a ReturnCode + * + * FUNC - HWP function name + * _args_... - Any additional arguments that the HWP requires + */ +#define FAPI_CALL_HWP_NORETURN( FUNC, _args_...) \ + {\ + fapi2::hwpLock(true); \ + FUNC(_args_); \ + fapi2::hwpLock(false); \ + } + + #endif // PLATHWPINVOKER_H_ -- cgit v1.2.1