Platform: Adjust HAL API to fit for FI hardening
The FI hardening code requires to have a special return type of the
protected functions: fih_int. Modify critical HAL and memory isolation
APIs to use this return type when TFM_FIH_PROFILE is enabled.
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
Co-authorized-by: David Hu <david.hu@arm.com>
Change-Id: I592bf3b365354f04f37eff5fad20bdefaa5b8978
diff --git a/platform/include/tfm_hal_isolation.h b/platform/include/tfm_hal_isolation.h
index 442abd7..18a8c50 100644
--- a/platform/include/tfm_hal_isolation.h
+++ b/platform/include/tfm_hal_isolation.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -10,6 +10,7 @@
#include <stddef.h>
#include <stdint.h>
+#include "fih.h"
#include "tfm_hal_defs.h"
#ifdef __cplusplus
@@ -24,6 +25,7 @@
#define TFM_HAL_ACCESS_DEVICE (1UL << 4)
#define TFM_HAL_ACCESS_NS (1UL << 5)
+#ifdef TFM_FIH_PROFILE_ON
/**
* \brief Sets up the static isolation boundaries which are constant throughout
* the runtime of the system, including the SPE/NSPE and partition
@@ -32,8 +34,60 @@
* \return TFM_HAL_SUCCESS - the isolation boundaries have been set up.
* TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundaries.
*/
+fih_int tfm_hal_set_up_static_boundaries(void);
+
+#if TFM_LVL == 3
+/**
+ * \brief Updates the partition isolation boundary for isolation level 3.
+ * The boundary protects the private data of the running partition.
+ * The boundary is updated with SPM switching partition in level 3.
+ *
+ * \param[in] start start address of the partition boundary.
+ * \param[in] end end address of the partition boundary.
+ *
+ * \return TFM_HAL_SUCCESS - the isolation boundary has been set up.
+ * TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundary.
+ *
+ * \note When FIH_ENABLE_DOUBLE_VARS is enabled, the return code will be
+ * wrapped and protected in \ref fih_int structure.
+ */
+fih_int tfm_hal_mpu_update_partition_boundary(uintptr_t start,
+ uintptr_t end);
+#endif
+#else /* TFM_FIH_PROFILE_ON */
+/**
+ * \brief Sets up the static isolation boundaries which are constant throughout
+ * the runtime of the system, including the SPE/NSPE and partition
+ * boundaries.
+ *
+ * \return TFM_HAL_SUCCESS - the isolation boundaries have been set up.
+ * TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundaries.
+ *
+ * \note When FIH_ENABLE_DOUBLE_VARS is enabled, the return code will be
+ * wrapped and protected in \ref fih_int structure.
+ */
enum tfm_hal_status_t tfm_hal_set_up_static_boundaries(void);
+#if TFM_LVL == 3
+/**
+ * \brief Updates the partition isolation boundary for isolation level 3.
+ * The boundary protects the private data of the running partition.
+ * The boundary is updated with SPM switching partition in level 3.
+ *
+ * \param[in] start start address of the partition boundary.
+ * \param[in] end end address of the partition boundary.
+ *
+ * \return TFM_HAL_SUCCESS - the isolation boundary has been set up.
+ * TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundary.
+ *
+ * \note When FIH_ENABLE_DOUBLE_VARS is enabled, the return code will be
+ * wrapped and protected in \ref fih_int structure.
+ */
+enum tfm_hal_status_t tfm_hal_mpu_update_partition_boundary(uintptr_t start,
+ uintptr_t end);
+#endif
+#endif /* TFM_FIH_PROFILE_ON */
+
/**
* \brief This API checks if the memory region defined by base and size
* matches the given attributes - attr.
@@ -54,22 +108,6 @@
size_t size,
uint32_t attr);
-#if TFM_LVL == 3
-/**
- * \brief Updates the partition isolation boundary for isolation level 3.
- * The boundary protects the private data of the running partition.
- * The boundary is updated with SPM switching partition in level 3.
- *
- * \param[in] start start address of the partition boundary.
- * \param[in] end end address of the partition boundary.
- *
- * \return TFM_HAL_SUCCESS - the isolation boundary has been set up.
- * TFM_HAL_ERROR_GENERIC - failed to set up the isolation boundary.
- */
-enum tfm_hal_status_t tfm_hal_mpu_update_partition_boundary(uintptr_t start,
- uintptr_t end);
-#endif
-
#ifdef __cplusplus
}
#endif