aboutsummaryrefslogtreecommitdiff
path: root/secure_fw
diff options
context:
space:
mode:
authorTTornblom <thomas.tornblom@iar.com>2020-03-04 17:56:27 +0100
committerTTornblom <thomas.tornblom@iar.com>2020-04-23 13:06:20 +0200
commitfaf74f575a7edf7410ade35ceb79cd7a63b3dc02 (patch)
tree102cd919fdd3e90712b47486a68dfe72004309c7 /secure_fw
parentb9e5ed000321d757b7ef2e59d2fabc8af60f0a53 (diff)
downloadtrusted-firmware-m-faf74f575a7edf7410ade35ceb79cd7a63b3dc02.tar.gz
Build: Major warnings cleanup
This is a major type-mismatch cleanup and warnings elimination. The IAR toolchain runs with more warnings enabled than ARMCLANG or GNUARM, which has resulted in this effort. This should make it easier to enable "pedantic" mode also for GNUARM. There are still a few warnings about jumping past variable initialization and falling off the end of non-void functions, but there are comments in some of these parts that implies that this is done to catch programming errors, like having case labels for all possible enum values. Reordered initializer in tfm_attestation_req_mngr.c to eliminate CI warning. Disabled "Pe940" warnings in CommonConfig.cmake to suppress warnings about inline assembly functions declared to return value that doesn't declare a return value in the __ASM() statement. Disabled "Pe546" warnings to supress warnings about jumping over unused initializers. Fixed what appears to be a copy/paste bug in tfm_ss_core_test.c. Removed unused variable "ret" in Driver_PPC.c for AN519 and AN521, to make it similar to AN524. Signed-off-by: TTornblom <thomas.tornblom@iar.com> Change-Id: I2b729c73e4b004cff6b0530cc1350fcf900e4272
Diffstat (limited to 'secure_fw')
-rw-r--r--secure_fw/core/include/tfm_irq_list.h4
-rw-r--r--secure_fw/core/ipc/tfm_multi_core.c3
-rw-r--r--secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc2
-rw-r--r--secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc.template2
-rw-r--r--secure_fw/core/ipc/tfm_spe_mailbox.c4
-rw-r--r--secure_fw/core/tfm_boot_data.c4
-rw-r--r--secure_fw/core/tfm_core_svcalls_ipc.c4
-rw-r--r--secure_fw/services/crypto/crypto_init.c8
-rw-r--r--secure_fw/services/crypto/crypto_key.c1
-rw-r--r--secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c8
-rw-r--r--secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c2
-rw-r--r--secure_fw/services/platform/platform_sp.c14
-rw-r--r--secure_fw/services/secure_storage/tfm_sst_req_mngr.c3
-rw-r--r--secure_fw/spm/spm_func.c12
-rw-r--r--secure_fw/spm/spm_ipc.c12
15 files changed, 41 insertions, 42 deletions
diff --git a/secure_fw/core/include/tfm_irq_list.h b/secure_fw/core/include/tfm_irq_list.h
index ab22ca75d6..fbad8f4932 100644
--- a/secure_fw/core/include/tfm_irq_list.h
+++ b/secure_fw/core/include/tfm_irq_list.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -15,7 +15,7 @@
struct tfm_core_irq_signal_data_t {
int32_t partition_id;
psa_signal_t signal_value;
- int32_t irq_line;
+ IRQn_Type irq_line;
uint32_t irq_priority;
};
diff --git a/secure_fw/core/ipc/tfm_multi_core.c b/secure_fw/core/ipc/tfm_multi_core.c
index 75db3bee59..0678509bb7 100644
--- a/secure_fw/core/ipc/tfm_multi_core.c
+++ b/secure_fw/core/ipc/tfm_multi_core.c
@@ -42,7 +42,8 @@ void tfm_nspm_thread_entry(void)
while (1) {
}
- /* Should not run here */
+
+ /* NOTREACHED */
TFM_ASSERT(false);
}
diff --git a/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc b/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc
index d44f7c66cb..0c86e72ef0 100644
--- a/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc
+++ b/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc
@@ -29,7 +29,7 @@ const struct tfm_core_irq_signal_data_t tfm_core_irq_signals[] = {
#ifdef TFM_ENABLE_IRQ_TEST
{ TFM_IRQ_TEST_1, SPM_CORE_IRQ_TEST_1_SIGNAL_TIMER_0_IRQ, TFM_TIMER0_IRQ, 64 },
#endif /* TFM_ENABLE_IRQ_TEST */
- {0, 0, 0, 0} /* add dummy element to avoid non-standard empty array */
+ {0, 0, (IRQn_Type) 0, 0} /* add dummy element to avoid non-standard empty array */
};
const size_t tfm_core_irq_signals_count = (sizeof(tfm_core_irq_signals) /
diff --git a/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc.template b/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc.template
index 5e9d44cee7..e5a7d6b252 100644
--- a/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc.template
+++ b/secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc.template
@@ -41,7 +41,7 @@ const struct tfm_core_irq_signal_data_t tfm_core_irq_signals[] = {
{% endif %}
{% endif %}
{% endfor %}
- {0, 0, 0, 0} /* add dummy element to avoid non-standard empty array */
+ {0, 0, (IRQn_Type) 0, 0} /* add dummy element to avoid non-standard empty array */
};
const size_t tfm_core_irq_signals_count = (sizeof(tfm_core_irq_signals) /
diff --git a/secure_fw/core/ipc/tfm_spe_mailbox.c b/secure_fw/core/ipc/tfm_spe_mailbox.c
index edc5eeb177..baa02c7023 100644
--- a/secure_fw/core/ipc/tfm_spe_mailbox.c
+++ b/secure_fw/core/ipc/tfm_spe_mailbox.c
@@ -19,7 +19,7 @@ static struct secure_mailbox_queue_t spe_mailbox_queue;
static int32_t tfm_mailbox_dispatch(uint32_t call_type,
const struct psa_client_params_t *params,
- int32_t client_id, uint32_t *psa_ret)
+ int32_t client_id, int32_t *psa_ret)
{
struct client_call_params_t spm_params = {0};
@@ -183,7 +183,7 @@ int32_t tfm_mailbox_handle_msg(void)
{
uint8_t idx;
int32_t result;
- uint32_t psa_ret = PSA_ERROR_GENERIC_ERROR;
+ int32_t psa_ret = PSA_ERROR_GENERIC_ERROR;
mailbox_queue_status_t mask_bits, pend_slots, reply_slots = 0;
struct ns_mailbox_queue_t *ns_queue = spe_mailbox_queue.ns_queue;
struct mailbox_msg_t *msg_ptr;
diff --git a/secure_fw/core/tfm_boot_data.c b/secure_fw/core/tfm_boot_data.c
index 02bcc1fbe1..84a7825f95 100644
--- a/secure_fw/core/tfm_boot_data.c
+++ b/secure_fw/core/tfm_boot_data.c
@@ -138,9 +138,9 @@ void tfm_core_get_boot_data_handler(uint32_t args[])
uint8_t tlv_major = (uint8_t)args[0];
uint8_t *buf_start = (uint8_t *)args[1];
uint16_t buf_size = (uint16_t)args[2];
- uint8_t *ptr;
struct tfm_boot_data *boot_data;
#ifdef BOOT_DATA_AVAILABLE
+ uint8_t *ptr;
struct shared_data_tlv_entry tlv_entry;
uintptr_t tlv_end, offset;
#endif /* BOOT_DATA_AVAILABLE */
@@ -210,10 +210,10 @@ void tfm_core_get_boot_data_handler(uint32_t args[])
boot_data = (struct tfm_boot_data *)buf_start;
boot_data->header.tlv_magic = SHARED_DATA_TLV_INFO_MAGIC;
boot_data->header.tlv_tot_len = SHARED_DATA_HEADER_SIZE;
- ptr = boot_data->data;
}
#ifdef BOOT_DATA_AVAILABLE
+ ptr = boot_data->data;
/* Iterates over the TLV section and copy TLVs with requested major
* type to the provided buffer.
*/
diff --git a/secure_fw/core/tfm_core_svcalls_ipc.c b/secure_fw/core/tfm_core_svcalls_ipc.c
index 202b517367..7cbf9079a6 100644
--- a/secure_fw/core/tfm_core_svcalls_ipc.c
+++ b/secure_fw/core/tfm_core_svcalls_ipc.c
@@ -120,7 +120,7 @@ static int32_t SVC_Handler_IPC(tfm_svc_number_t svc_num, uint32_t *ctx,
uint32_t tfm_core_svc_handler(uint32_t *svc_args, uint32_t exc_return)
{
- uint8_t svc_number = 0;
+ tfm_svc_number_t svc_number = TFM_SVC_SFN_REQUEST;
/*
* Stack contains:
* r0, r1, r2, r3, r12, r14 (lr), the return address and xPSR
@@ -130,7 +130,7 @@ uint32_t tfm_core_svc_handler(uint32_t *svc_args, uint32_t exc_return)
/* SV called directly from secure context. Check instruction for
* svc_number
*/
- svc_number = ((uint8_t *)svc_args[6])[-2];
+ svc_number = ((tfm_svc_number_t *)svc_args[6])[-2];
} else {
/* Secure SV executing with NS return.
* NS cannot directly trigger S SVC so this should not happen. This is
diff --git a/secure_fw/services/crypto/crypto_init.c b/secure_fw/services/crypto/crypto_init.c
index b3acd556f3..743ce1d71e 100644
--- a/secure_fw/services/crypto/crypto_init.c
+++ b/secure_fw/services/crypto/crypto_init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -113,7 +113,7 @@ static psa_status_t tfm_crypto_call_sfn(psa_msg_t *msg,
const uint32_t sfn_id)
{
psa_status_t status = PSA_SUCCESS;
- size_t in_len = PSA_MAX_IOVEC, out_len = PSA_MAX_IOVEC, i, read_size;
+ size_t in_len = PSA_MAX_IOVEC, out_len = PSA_MAX_IOVEC, i;
psa_invec in_vec[PSA_MAX_IOVEC] = { {0} };
psa_outvec out_vec[PSA_MAX_IOVEC] = { {0} };
void *alloc_buf_ptr = NULL;
@@ -140,7 +140,7 @@ static psa_status_t tfm_crypto_call_sfn(psa_msg_t *msg,
return status;
}
/* Read from the IPC framework inputs into the scratch */
- read_size = psa_read(msg->handle, i, alloc_buf_ptr, msg->in_size[i]);
+ (void) psa_read(msg->handle, i, alloc_buf_ptr, msg->in_size[i]);
/* Populate the fields of the input to the secure function */
in_vec[i].base = alloc_buf_ptr;
in_vec[i].len = msg->in_size[i];
@@ -258,7 +258,7 @@ static void tfm_crypto_ipc_handler(void)
}
}
- /* This is unreachable */
+ /* NOTREACHED */
return;
}
#endif /* TFM_PSA_API */
diff --git a/secure_fw/services/crypto/crypto_key.c b/secure_fw/services/crypto/crypto_key.c
index e88040d097..ef3b309f45 100644
--- a/secure_fw/services/crypto/crypto_key.c
+++ b/secure_fw/services/crypto/crypto_key.c
@@ -577,7 +577,6 @@ psa_status_t tfm_crypto_copy_key(psa_invec in_vec[],
return status;
#endif /* TFM_CRYPTO_KEY_MODULE_DISABLED */
- return PSA_ERROR_NOT_SUPPORTED;
}
psa_status_t tfm_crypto_generate_key(psa_invec in_vec[],
diff --git a/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c b/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c
index 07d9a80541..8366bfb79a 100644
--- a/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c
+++ b/secure_fw/services/initial_attestation/tfm_attestation_req_mngr.c
@@ -171,13 +171,10 @@ static void attest_signal_handle(psa_signal_t signal, attest_func_t pfn)
psa_status_t attest_partition_init(void)
{
- psa_status_t err = PSA_SUCCESS;
+ psa_status_t err = attest_init();
#ifdef TFM_PSA_API
psa_signal_t signals;
-#endif
- err = attest_init();
-#ifdef TFM_PSA_API
if (err != PSA_SUCCESS) {
tfm_abort();
}
@@ -197,6 +194,7 @@ psa_status_t attest_partition_init(void)
tfm_abort();
}
}
-#endif
+#else
return err;
+#endif
}
diff --git a/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c b/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c
index 518f877b74..eb634b83ec 100644
--- a/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c
+++ b/secure_fw/services/internal_trusted_storage/tfm_its_req_mngr.c
@@ -349,8 +349,8 @@ psa_status_t tfm_its_req_mngr_init(void)
return PSA_ERROR_GENERIC_ERROR;
}
its_is_init = true;
-#endif
return PSA_SUCCESS;
+#endif
}
size_t its_req_mngr_read(uint8_t *buf, size_t num_bytes)
diff --git a/secure_fw/services/platform/platform_sp.c b/secure_fw/services/platform/platform_sp.c
index f5d0973254..b17e62e690 100644
--- a/secure_fw/services/platform/platform_sp.c
+++ b/secure_fw/services/platform/platform_sp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -102,16 +102,16 @@ platform_sp_ioctl_ipc(const psa_msg_t *msg)
num = psa_read(msg->handle, 0, &request, sizeof(request));
if (num != sizeof(request)) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
if (in_len > 1) {
if (msg->in_size[1] > INPUT_BUFFER_SIZE) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
num = psa_read(msg->handle, 1, &input_buffer, msg->in_size[1]);
if (num != msg->in_size[1]) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
invec.base = input_buffer;
invec.len = msg->in_size[1];
@@ -120,7 +120,7 @@ platform_sp_ioctl_ipc(const psa_msg_t *msg)
if (out_len > 0) {
if (msg->out_size[0] > OUTPUT_BUFFER_SIZE) {
- return PSA_ERROR_PROGRAMMER_ERROR;
+ return (enum tfm_platform_err_t) PSA_ERROR_PROGRAMMER_ERROR;
}
outvec.base = output_buffer;
outvec.len = msg->out_size[0];
@@ -188,7 +188,7 @@ enum tfm_platform_err_t platform_sp_init(void)
}
}
-#endif /* TFM_PSA_API */
-
+#else
return TFM_PLATFORM_ERR_SUCCESS;
+#endif /* TFM_PSA_API */
}
diff --git a/secure_fw/services/secure_storage/tfm_sst_req_mngr.c b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
index ec9635d0de..94a0e780b2 100644
--- a/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
+++ b/secure_fw/services/secure_storage/tfm_sst_req_mngr.c
@@ -418,12 +418,13 @@ psa_status_t tfm_sst_req_mngr_init(void)
tfm_abort();
}
}
-#endif
+#else
/* In library mode, initialisation is delayed until the first secure
* function call, as calls to the Crypto service are required for
* initialisation.
*/
return PSA_SUCCESS;
+#endif
}
psa_status_t sst_req_mngr_read_asset_data(uint8_t *out_data, uint32_t size)
diff --git a/secure_fw/spm/spm_func.c b/secure_fw/spm/spm_func.c
index 6b9c46b372..afb0479abe 100644
--- a/secure_fw/spm/spm_func.c
+++ b/secure_fw/spm/spm_func.c
@@ -411,7 +411,7 @@ static enum tfm_status_e tfm_start_partition_for_irq_handling(
uint32_t handler_partition_id = svc_ctx->r0;
sfn_t unpriv_handler = (sfn_t)svc_ctx->r1;
uint32_t irq_signal = svc_ctx->r2;
- uint32_t irq_line = svc_ctx->r3;
+ IRQn_Type irq_line = (IRQn_Type) svc_ctx->r3;
enum tfm_status_e res;
uint32_t psp = __get_PSP();
uint32_t handler_partition_psp;
@@ -922,7 +922,7 @@ uint32_t tfm_spm_depriv_return_handler(uint32_t *irq_svc_args, uint32_t lr)
* \retval >=0 The IRQ line number associated with a signal in the partition
* \retval <0 error
*/
-static int32_t get_irq_line_for_signal(int32_t partition_id,
+static IRQn_Type get_irq_line_for_signal(int32_t partition_id,
psa_signal_t signal)
{
size_t i;
@@ -933,7 +933,7 @@ static int32_t get_irq_line_for_signal(int32_t partition_id,
return tfm_core_irq_signals[i].irq_line;
}
}
- return -1;
+ return (IRQn_Type) -1;
}
void tfm_spm_enable_irq_handler(uint32_t *svc_args)
@@ -945,7 +945,7 @@ void tfm_spm_enable_irq_handler(uint32_t *svc_args)
tfm_spm_partition_get_running_partition_idx();
uint32_t running_partition_id =
tfm_spm_partition_get_partition_id(running_partition_idx);
- int32_t irq_line;
+ IRQn_Type irq_line;
/* Only a single signal is allowed */
if (!tfm_is_one_bit_set(irq_signal)) {
@@ -972,7 +972,7 @@ void tfm_spm_disable_irq_handler(uint32_t *svc_args)
tfm_spm_partition_get_running_partition_idx();
uint32_t running_partition_id =
tfm_spm_partition_get_partition_id(running_partition_idx);
- int32_t irq_line;
+ IRQn_Type irq_line;
/* Only a single signal is allowed */
if (!tfm_is_one_bit_set(irq_signal)) {
@@ -1030,7 +1030,7 @@ void tfm_spm_psa_eoi(uint32_t *svc_args)
uint32_t running_partition_idx;
uint32_t running_partition_id;
const struct spm_partition_runtime_data_t *curr_part_data;
- int32_t irq_line;
+ IRQn_Type irq_line;
running_partition_idx = tfm_spm_partition_get_running_partition_idx();
running_partition_id =
diff --git a/secure_fw/spm/spm_ipc.c b/secure_fw/spm/spm_ipc.c
index 90e688fca6..d6e707d016 100644
--- a/secure_fw/spm/spm_ipc.c
+++ b/secure_fw/spm/spm_ipc.c
@@ -47,7 +47,7 @@ TFM_POOL_DECLARE(conn_handle_pool, sizeof(struct tfm_conn_handle_t),
TFM_CONN_HANDLE_MAX_NUM);
void tfm_irq_handler(uint32_t partition_id, psa_signal_t signal,
- int32_t irq_line);
+ IRQn_Type irq_line);
#include "tfm_secure_irq_handlers_ipc.inc"
@@ -1392,7 +1392,7 @@ void tfm_spm_psa_notify(uint32_t *args)
* \retval "Does not return" Partition ID is invalid
*/
void tfm_irq_handler(uint32_t partition_id, psa_signal_t signal,
- int32_t irq_line)
+ IRQn_Type irq_line)
{
tfm_spm_hal_disable_irq(irq_line);
notify_with_signal(partition_id, signal);
@@ -1441,7 +1441,7 @@ void tfm_spm_psa_panic(void)
*/
static int32_t get_irq_line_for_signal(int32_t partition_id,
psa_signal_t signal,
- int32_t *irq_line)
+ IRQn_Type *irq_line)
{
size_t i;
@@ -1458,7 +1458,7 @@ static int32_t get_irq_line_for_signal(int32_t partition_id,
void tfm_spm_psa_eoi(uint32_t *args)
{
psa_signal_t irq_signal;
- int32_t irq_line = 0;
+ IRQn_Type irq_line = (IRQn_Type) 0;
int32_t ret;
struct spm_partition_desc_t *partition = NULL;
@@ -1497,7 +1497,7 @@ void tfm_spm_enable_irq(uint32_t *args)
{
struct tfm_state_context_t *svc_ctx = (struct tfm_state_context_t *)args;
psa_signal_t irq_signal = svc_ctx->r0;
- int32_t irq_line = 0;
+ IRQn_Type irq_line = (IRQn_Type) 0;
int32_t ret;
struct spm_partition_desc_t *partition = NULL;
@@ -1525,7 +1525,7 @@ void tfm_spm_disable_irq(uint32_t *args)
{
struct tfm_state_context_t *svc_ctx = (struct tfm_state_context_t *)args;
psa_signal_t irq_signal = svc_ctx->r0;
- int32_t irq_line = 0;
+ IRQn_Type irq_line = (IRQn_Type) 0;
int32_t ret;
struct spm_partition_desc_t *partition = NULL;