aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2019-08-06 18:10:11 +0800
committerKen Liu <ken.liu@arm.com>2019-08-13 10:32:15 +0000
commitcb05d972ca8711bfdb3af88c65150fdd5b26a26b (patch)
tree89cf54e0c29cc2815e162291ad0fbdfd490d1f82
parente348ebe969816d44b550bbae8cda19ae7ceb684e (diff)
downloadtrusted-firmware-m-cb05d972ca8711bfdb3af88c65150fdd5b26a26b.tar.gz
Core: Change buffer address type to const void * in memory access check
Change buffer base address type to const void * in tfm_memory_check() and tfm_core_has_write_access_to_region(). Remove unnecessary explicit type casts. Change-Id: I59d03871d35837c1deebe095aa88c255f120c111 Signed-off-by: David Hu <david.hu@arm.com>
-rw-r--r--secure_fw/core/ipc/tfm_svcalls.c20
-rw-r--r--secure_fw/core/tfm_secure_api.c2
-rw-r--r--secure_fw/core/tfm_secure_api.h2
-rw-r--r--secure_fw/spm/spm_api.h2
-rw-r--r--secure_fw/spm/spm_api_ipc.c2
5 files changed, 14 insertions, 14 deletions
diff --git a/secure_fw/core/ipc/tfm_svcalls.c b/secure_fw/core/ipc/tfm_svcalls.c
index e50705748..a5f32390d 100644
--- a/secure_fw/core/ipc/tfm_svcalls.c
+++ b/secure_fw/core/ipc/tfm_svcalls.c
@@ -186,11 +186,11 @@ psa_status_t tfm_svcall_psa_call(uint32_t *args, int32_t ns_caller, uint32_t lr)
* Read parameters from the arguments. It is a fatal error if the
* memory reference for buffer is invalid or not readable.
*/
- if (tfm_memory_check((void *)args[2], sizeof(uint32_t),
+ if (tfm_memory_check((const void *)args[2], sizeof(uint32_t),
ns_caller, TFM_MEMORY_ACCESS_RO, privileged) != IPC_SUCCESS) {
tfm_panic();
}
- if (tfm_memory_check((void *)args[3], sizeof(uint32_t),
+ if (tfm_memory_check((const void *)args[3], sizeof(uint32_t),
ns_caller, TFM_MEMORY_ACCESS_RO, privileged) != IPC_SUCCESS) {
tfm_panic();
}
@@ -218,8 +218,8 @@ psa_status_t tfm_svcall_psa_call(uint32_t *args, int32_t ns_caller, uint32_t lr)
* if the memory reference for the wrap input vector is invalid or not
* readable.
*/
- if (tfm_memory_check((void *)inptr, in_num * sizeof(psa_invec),
- ns_caller, TFM_MEMORY_ACCESS_RO, privileged) != IPC_SUCCESS) {
+ if (tfm_memory_check(inptr, in_num * sizeof(psa_invec), ns_caller,
+ TFM_MEMORY_ACCESS_RO, privileged) != IPC_SUCCESS) {
tfm_panic();
}
/*
@@ -227,8 +227,8 @@ psa_status_t tfm_svcall_psa_call(uint32_t *args, int32_t ns_caller, uint32_t lr)
* actual length later. It is a fatal error if the memory reference for
* the wrap output vector is invalid or not read-write.
*/
- if (tfm_memory_check((void *)outptr, out_num * sizeof(psa_outvec),
- ns_caller, TFM_MEMORY_ACCESS_RW, privileged) != IPC_SUCCESS) {
+ if (tfm_memory_check(outptr, out_num * sizeof(psa_outvec), ns_caller,
+ TFM_MEMORY_ACCESS_RW, privileged) != IPC_SUCCESS) {
tfm_panic();
}
@@ -244,8 +244,8 @@ psa_status_t tfm_svcall_psa_call(uint32_t *args, int32_t ns_caller, uint32_t lr)
* memory reference was invalid or not readable.
*/
for (i = 0; i < in_num; i++) {
- if (tfm_memory_check((void *)invecs[i].base, invecs[i].len,
- ns_caller, TFM_MEMORY_ACCESS_RO, privileged) != IPC_SUCCESS) {
+ if (tfm_memory_check(invecs[i].base, invecs[i].len, ns_caller,
+ TFM_MEMORY_ACCESS_RO, privileged) != IPC_SUCCESS) {
tfm_panic();
}
}
@@ -423,8 +423,8 @@ static psa_status_t tfm_svcall_psa_get(uint32_t *args)
* Write the message to the service buffer. It is a fatal error if the
* input msg pointer is not a valid memory reference or not read-write.
*/
- if (tfm_memory_check((void *)msg, sizeof(psa_msg_t),
- false, TFM_MEMORY_ACCESS_RW, privileged) != IPC_SUCCESS) {
+ if (tfm_memory_check(msg, sizeof(psa_msg_t), false, TFM_MEMORY_ACCESS_RW,
+ privileged) != IPC_SUCCESS) {
tfm_panic();
}
diff --git a/secure_fw/core/tfm_secure_api.c b/secure_fw/core/tfm_secure_api.c
index 3a262d42f..6555fcb86 100644
--- a/secure_fw/core/tfm_secure_api.c
+++ b/secure_fw/core/tfm_secure_api.c
@@ -166,7 +166,7 @@ enum tfm_status_e tfm_core_has_read_access_to_region(const void *p, size_t s,
return has_access_to_region(p, s, flags);
}
-enum tfm_status_e tfm_core_has_write_access_to_region(void *p, size_t s,
+enum tfm_status_e tfm_core_has_write_access_to_region(const void *p, size_t s,
uint32_t ns_caller,
uint32_t privileged)
{
diff --git a/secure_fw/core/tfm_secure_api.h b/secure_fw/core/tfm_secure_api.h
index 69828f069..c626df137 100644
--- a/secure_fw/core/tfm_secure_api.h
+++ b/secure_fw/core/tfm_secure_api.h
@@ -126,7 +126,7 @@ enum tfm_status_e tfm_core_has_read_access_to_region(const void *p, size_t s,
* \return TFM_SUCCESS if the partition has access to the memory range,
* TFM_ERROR_GENERIC otherwise.
*/
-enum tfm_status_e tfm_core_has_write_access_to_region(void *p, size_t s,
+enum tfm_status_e tfm_core_has_write_access_to_region(const void *p, size_t s,
uint32_t ns_caller,
uint32_t privileged);
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index 7f95339c0..02c5dbf1b 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -638,7 +638,7 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
* \retval IPC_ERROR_BAD_PARAMETERS Bad parameters input
* \retval IPC_ERROR_MEMORY_CHECK Check failed
*/
-int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller,
+int32_t tfm_memory_check(const void *buffer, size_t len, int32_t ns_caller,
enum tfm_memory_access_e access,
uint32_t privileged);
diff --git a/secure_fw/spm/spm_api_ipc.c b/secure_fw/spm/spm_api_ipc.c
index 98f6046cb..24fd179a9 100644
--- a/secure_fw/spm/spm_api_ipc.c
+++ b/secure_fw/spm/spm_api_ipc.c
@@ -450,7 +450,7 @@ static uint32_t tfm_spm_partition_get_priority(uint32_t partition_idx)
partition_priority;
}
-int32_t tfm_memory_check(void *buffer, size_t len, int32_t ns_caller,
+int32_t tfm_memory_check(const void *buffer, size_t len, int32_t ns_caller,
enum tfm_memory_access_e access,
uint32_t privileged)
{