summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bl1/aarch32/bl1_arch_setup.c1
-rw-r--r--bl1/aarch32/bl1_context_mgmt.c5
-rw-r--r--bl1/aarch64/bl1_arch_setup.c1
-rw-r--r--bl1/aarch64/bl1_context_mgmt.c1
-rw-r--r--bl1/bl1_fwu.c25
-rw-r--r--bl32/sp_min/sp_min_main.c4
-rw-r--r--drivers/delay_timer/delay_timer.c8
-rw-r--r--drivers/delay_timer/generic_delay_timer.c1
-rw-r--r--drivers/io/io_dummy.c3
-rw-r--r--drivers/io/io_storage.c2
-rw-r--r--include/lib/aarch32/smcc_helpers.h4
-rw-r--r--include/lib/el3_runtime/context_mgmt.h1
-rw-r--r--lib/aarch32/cache_helpers.S4
-rw-r--r--lib/aarch64/cache_helpers.S3
-rw-r--r--lib/psci/psci_system_off.c4
-rw-r--r--plat/arm/board/juno/aarch64/juno_helpers.S12
-rw-r--r--plat/arm/board/juno/juno_bl2_setup.c26
-rw-r--r--plat/nvidia/tegra/platform.mk2
18 files changed, 79 insertions, 28 deletions
diff --git a/bl1/aarch32/bl1_arch_setup.c b/bl1/aarch32/bl1_arch_setup.c
index 23a65648..ce04aaab 100644
--- a/bl1/aarch32/bl1_arch_setup.c
+++ b/bl1/aarch32/bl1_arch_setup.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "../bl1_private.h"
/*******************************************************************************
* TODO: Function that does the first bit of architectural setup.
diff --git a/bl1/aarch32/bl1_context_mgmt.c b/bl1/aarch32/bl1_context_mgmt.c
index cbf5cb69..6623dfc4 100644
--- a/bl1/aarch32/bl1_context_mgmt.c
+++ b/bl1/aarch32/bl1_context_mgmt.c
@@ -11,6 +11,7 @@
#include <debug.h>
#include <platform.h>
#include <smcc_helpers.h>
+#include "../bl1_private.h"
/*
* Following arrays will be used for context management.
@@ -26,13 +27,13 @@ static void *bl1_next_cpu_context_ptr;
static void *bl1_next_smc_context_ptr;
/* Following functions are used for SMC context handling */
-void *smc_get_ctx(int security_state)
+void *smc_get_ctx(unsigned int security_state)
{
assert(sec_state_is_valid(security_state));
return &bl1_smc_context[security_state];
}
-void smc_set_next_ctx(int security_state)
+void smc_set_next_ctx(unsigned int security_state)
{
assert(sec_state_is_valid(security_state));
bl1_next_smc_context_ptr = &bl1_smc_context[security_state];
diff --git a/bl1/aarch64/bl1_arch_setup.c b/bl1/aarch64/bl1_arch_setup.c
index a7a45225..624bd80f 100644
--- a/bl1/aarch64/bl1_arch_setup.c
+++ b/bl1/aarch64/bl1_arch_setup.c
@@ -6,6 +6,7 @@
#include <arch.h>
#include <arch_helpers.h>
+#include "../bl1_private.h"
/*******************************************************************************
* Function that does the first bit of architectural setup that affects
diff --git a/bl1/aarch64/bl1_context_mgmt.c b/bl1/aarch64/bl1_context_mgmt.c
index 2c7fe070..b9304dcf 100644
--- a/bl1/aarch64/bl1_context_mgmt.c
+++ b/bl1/aarch64/bl1_context_mgmt.c
@@ -10,6 +10,7 @@
#include <context_mgmt.h>
#include <debug.h>
#include <platform.h>
+#include "../bl1_private.h"
/*
* Following array will be used for context management.
diff --git a/bl1/bl1_fwu.c b/bl1/bl1_fwu.c
index 205ea922..8dfc55f6 100644
--- a/bl1/bl1_fwu.c
+++ b/bl1/bl1_fwu.c
@@ -52,8 +52,6 @@ static unsigned int sec_exec_image_id = INVALID_IMAGE_ID;
/* Authentication status of each image. */
extern unsigned int auth_img_flags[];
-void cm_set_next_context(void *cpu_context);
-
/*******************************************************************************
* Top level handler for servicing FWU SMCs.
******************************************************************************/
@@ -176,18 +174,19 @@ static int bl1_fwu_image_check_overlaps(int image_id)
checked_image_base = checked_info->image_base;
checked_image_end = checked_image_base + checked_info->image_size - 1;
- /* No need to check for overlaps, it's done in bl1_fwu_image_copy(). */
+ /* No need to check for overflows, it's done in bl1_fwu_image_copy(). */
for (int i = 0; i < FWU_MAX_SIMULTANEOUS_IMAGES; i++) {
- /* Don't check image against itself. */
- if (bl1_fwu_loaded_ids[i] == image_id)
+ /* Skip INVALID_IMAGE_IDs and don't check image against itself */
+ if ((bl1_fwu_loaded_ids[i] == INVALID_IMAGE_ID) ||
+ (bl1_fwu_loaded_ids[i] == image_id))
continue;
image_desc = bl1_plat_get_image_desc(bl1_fwu_loaded_ids[i]);
/* Only check images that are loaded or being loaded. */
- assert (image_desc->state != IMAGE_STATE_RESET);
+ assert (image_desc && image_desc->state != IMAGE_STATE_RESET);
info = &image_desc->image_info;
@@ -704,11 +703,15 @@ static int bl1_fwu_image_reset(unsigned int image_id, unsigned int flags)
return -EPERM;
}
- /* Clear the memory.*/
- zero_normalmem((void *)image_desc->image_info.image_base,
- image_desc->copied_size);
- flush_dcache_range(image_desc->image_info.image_base,
- image_desc->copied_size);
+ if (image_desc->copied_size) {
+ /* Clear the memory if the image is copied */
+ assert(GET_SECURITY_STATE(image_desc->ep_info.h.attr) == SECURE);
+
+ zero_normalmem((void *)image_desc->image_info.image_base,
+ image_desc->copied_size);
+ flush_dcache_range(image_desc->image_info.image_base,
+ image_desc->copied_size);
+ }
/* Reset status variables */
image_desc->copied_size = 0;
diff --git a/bl32/sp_min/sp_min_main.c b/bl32/sp_min/sp_min_main.c
index d27c0233..1c83cbe1 100644
--- a/bl32/sp_min/sp_min_main.c
+++ b/bl32/sp_min/sp_min_main.c
@@ -34,13 +34,13 @@ static smc_ctx_t sp_min_smc_context[PLATFORM_CORE_COUNT];
/******************************************************************************
* Define the smcc helper library API's
*****************************************************************************/
-void *smc_get_ctx(int security_state)
+void *smc_get_ctx(unsigned int security_state)
{
assert(security_state == NON_SECURE);
return &sp_min_smc_context[plat_my_core_pos()];
}
-void smc_set_next_ctx(int security_state)
+void smc_set_next_ctx(unsigned int security_state)
{
assert(security_state == NON_SECURE);
/* SP_MIN stores only non secure smc context. Nothing to do here */
diff --git a/drivers/delay_timer/delay_timer.c b/drivers/delay_timer/delay_timer.c
index 403c60fd..43f5af7b 100644
--- a/drivers/delay_timer/delay_timer.c
+++ b/drivers/delay_timer/delay_timer.c
@@ -19,10 +19,10 @@ static const timer_ops_t *ops;
***********************************************************/
void udelay(uint32_t usec)
{
- assert(ops != 0 &&
+ assert(ops != NULL &&
(ops->clk_mult != 0) &&
(ops->clk_div != 0) &&
- (ops->get_timer_value != 0));
+ (ops->get_timer_value != NULL));
uint32_t start, delta, total_delta;
@@ -57,10 +57,10 @@ void mdelay(uint32_t msec)
***********************************************************/
void timer_init(const timer_ops_t *ops_ptr)
{
- assert(ops_ptr != 0 &&
+ assert(ops_ptr != NULL &&
(ops_ptr->clk_mult != 0) &&
(ops_ptr->clk_div != 0) &&
- (ops_ptr->get_timer_value != 0));
+ (ops_ptr->get_timer_value != NULL));
ops = ops_ptr;
}
diff --git a/drivers/delay_timer/generic_delay_timer.c b/drivers/delay_timer/generic_delay_timer.c
index 6a9d3147..8a36c8ab 100644
--- a/drivers/delay_timer/generic_delay_timer.c
+++ b/drivers/delay_timer/generic_delay_timer.c
@@ -9,6 +9,7 @@
#include <bl_common.h>
#include <debug.h>
#include <delay_timer.h>
+#include <generic_delay_timer.h>
#include <platform.h>
/* Ticks elapsed in one second by a signal of 1 MHz */
diff --git a/drivers/io/io_dummy.c b/drivers/io/io_dummy.c
index a06aeb9c..d4020e3a 100644
--- a/drivers/io/io_dummy.c
+++ b/drivers/io/io_dummy.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <debug.h>
#include <io_driver.h>
+#include <io_dummy.h>
#include <io_storage.h>
#include <string.h>
@@ -18,7 +19,7 @@ struct file_state {
static struct file_state current_file = {0};
/* Identify the device type as dummy */
-io_type_t device_type_dummy(void)
+static io_type_t device_type_dummy(void)
{
return IO_TYPE_DUMMY;
}
diff --git a/drivers/io/io_storage.c b/drivers/io/io_storage.c
index fe654236..0918de0a 100644
--- a/drivers/io/io_storage.c
+++ b/drivers/io/io_storage.c
@@ -94,7 +94,7 @@ static void set_handle(uintptr_t *handle, io_entity_t *entity)
static int find_first_entity(const io_entity_t *entity, unsigned int *index_out)
{
int result = -ENOENT;
- for (int index = 0; index < MAX_IO_HANDLES; ++index) {
+ for (unsigned int index = 0; index < MAX_IO_HANDLES; ++index) {
if (entity_map[index] == entity) {
result = 0;
*index_out = index;
diff --git a/include/lib/aarch32/smcc_helpers.h b/include/lib/aarch32/smcc_helpers.h
index 5fb5a964..1bc84381 100644
--- a/include/lib/aarch32/smcc_helpers.h
+++ b/include/lib/aarch32/smcc_helpers.h
@@ -144,10 +144,10 @@ CASSERT(SMC_CTX_SIZE == sizeof(smc_ctx_t), assert_smc_ctx_size_mismatch);
*/
/* Get the pointer to `smc_ctx_t` corresponding to the security state. */
-void *smc_get_ctx(int security_state);
+void *smc_get_ctx(unsigned int security_state);
/* Set the next `smc_ctx_t` corresponding to the security state. */
-void smc_set_next_ctx(int security_state);
+void smc_set_next_ctx(unsigned int security_state);
/* Get the pointer to next `smc_ctx_t` already set by `smc_set_next_ctx()`. */
void *smc_get_next_ctx(void);
diff --git a/include/lib/el3_runtime/context_mgmt.h b/include/lib/el3_runtime/context_mgmt.h
index 94798691..eb7a9534 100644
--- a/include/lib/el3_runtime/context_mgmt.h
+++ b/include/lib/el3_runtime/context_mgmt.h
@@ -86,6 +86,7 @@ static inline void cm_set_next_context(void *context)
#else
void *cm_get_next_context(void);
+void cm_set_next_context(void *context);
#endif /* AARCH32 */
#endif /* __CM_H__ */
diff --git a/lib/aarch32/cache_helpers.S b/lib/aarch32/cache_helpers.S
index 57b6b384..810af0f0 100644
--- a/lib/aarch32/cache_helpers.S
+++ b/lib/aarch32/cache_helpers.S
@@ -20,6 +20,9 @@
* This macro can be used for implementing various data cache operations `op`
*/
.macro do_dcache_maintenance_by_mva op, coproc, opc1, CRn, CRm, opc2
+ /* Exit early if size is zero */
+ cmp r1, #0
+ beq exit_loop_\op
dcache_line_size r2, r3
add r1, r0, r1
sub r3, r2, #1
@@ -30,6 +33,7 @@ loop_\op:
cmp r0, r1
blo loop_\op
dsb sy
+exit_loop_\op:
bx lr
.endm
diff --git a/lib/aarch64/cache_helpers.S b/lib/aarch64/cache_helpers.S
index eef07a8b..9c40b9db 100644
--- a/lib/aarch64/cache_helpers.S
+++ b/lib/aarch64/cache_helpers.S
@@ -20,6 +20,8 @@
* This macro can be used for implementing various data cache operations `op`
*/
.macro do_dcache_maintenance_by_mva op
+ /* Exit early if size is zero */
+ cbz x1, exit_loop_\op
dcache_line_size x2, x3
add x1, x0, x1
sub x3, x2, #1
@@ -30,6 +32,7 @@ loop_\op:
cmp x0, x1
b.lo loop_\op
dsb sy
+exit_loop_\op:
ret
.endm
/* ------------------------------------------
diff --git a/lib/psci/psci_system_off.c b/lib/psci/psci_system_off.c
index f5237919..4a55248d 100644
--- a/lib/psci/psci_system_off.c
+++ b/lib/psci/psci_system_off.c
@@ -12,7 +12,7 @@
#include <platform.h>
#include "psci_private.h"
-void psci_system_off(void)
+void __dead2 psci_system_off(void)
{
psci_print_power_domain_map();
@@ -31,7 +31,7 @@ void psci_system_off(void)
/* This function does not return. We should never get here */
}
-void psci_system_reset(void)
+void __dead2 psci_system_reset(void)
{
psci_print_power_domain_map();
diff --git a/plat/arm/board/juno/aarch64/juno_helpers.S b/plat/arm/board/juno/aarch64/juno_helpers.S
index 8d00a1a7..5e7f08e7 100644
--- a/plat/arm/board/juno/aarch64/juno_helpers.S
+++ b/plat/arm/board/juno/aarch64/juno_helpers.S
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -266,6 +266,16 @@ endfunc plat_get_my_entrypoint
* to AArch32 mode is then requested by writing into RMR_EL3.
*/
func juno_reset_to_aarch32_state
+ /*
+ * Invalidate all caches before the warm reset to AArch32 state.
+ * This is required on the Juno AArch32 boot flow because the L2
+ * unified cache may contain code and data from when the processor
+ * was still executing in AArch64 state. This code only runs on
+ * the primary core, all other cores are powered down.
+ */
+ mov x0, #DCISW
+ bl dcsw_op_all
+
emit_movw w0, BL32_BASE
emit_movt w1, BL32_BASE
/* opcode "bx r0" to branch using r0 in AArch32 mode */
diff --git a/plat/arm/board/juno/juno_bl2_setup.c b/plat/arm/board/juno/juno_bl2_setup.c
index 8f18531a..abceb0f5 100644
--- a/plat/arm/board/juno/juno_bl2_setup.c
+++ b/plat/arm/board/juno/juno_bl2_setup.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -29,4 +29,28 @@ int bl2_plat_handle_post_image_load(unsigned int image_id)
return err;
}
+
+/*
+ * We need to override some of the platform functions when booting SP_MIN
+ * on Juno AArch32.
+ */
+
+static unsigned int scp_boot_config;
+
+void bl2_early_platform_setup(meminfo_t *mem_layout)
+{
+ arm_bl2_early_platform_setup(mem_layout);
+
+ /* Save SCP Boot config before it gets overwritten by SCP_BL2 loading */
+ VERBOSE("BL2: Saving SCP Boot config = 0x%x\n", scp_boot_config);
+ scp_boot_config = mmio_read_32(SCP_BOOT_CFG_ADDR);
+}
+
+void bl2_platform_setup(void)
+{
+ arm_bl2_platform_setup();
+
+ mmio_write_32(SCP_BOOT_CFG_ADDR, scp_boot_config);
+ VERBOSE("BL2: Restored SCP Boot config = 0x%x\n", scp_boot_config);
+}
#endif /* JUNO_AARCH32_EL3_RUNTIME */
diff --git a/plat/nvidia/tegra/platform.mk b/plat/nvidia/tegra/platform.mk
index eaf10914..9a9e79e2 100644
--- a/plat/nvidia/tegra/platform.mk
+++ b/plat/nvidia/tegra/platform.mk
@@ -36,4 +36,4 @@ include ${SOC_DIR}/platform_${TARGET_SOC}.mk
BUILD_PLAT := ${BUILD_BASE}/${PLAT}/${TARGET_SOC}/${BUILD_TYPE}
# enable signed comparison checks
-CFLAGS += -Wsign-compare
+TF_CFLAGS += -Wsign-compare