From b04343f3c912c8abc1a37b0ebe461ab574959ecd Mon Sep 17 00:00:00 2001 From: Raghu Krishnamurthy Date: Mon, 25 Sep 2023 13:05:55 -0700 Subject: [PATCH] fix(spmd): coverity scan issues Coverity defects fixed by this patch are: *** CID 400208: Performance inefficiencies (PASS_BY_VALUE) /include/services/el3_spmd_logical_sp.h: 108 in ffa_partition_info_regs_get_last_idx() *** CID 400207: Performance inefficiencies (PASS_BY_VALUE) /services/std_svc/spmd/spmd_logical_sp.c: 359 in ffa_partition_info_regs_get_part_info() Signed-off-by: Raghu Krishnamurthy Change-Id: I9597377a8ec3d5519995e1619d99ee7102f33939 --- include/services/el3_spmd_logical_sp.h | 18 +++++++++--------- plat/arm/board/fvp/fvp_spmd_logical_sp.c | 4 ++-- services/std_svc/spmd/spmd_logical_sp.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/services/el3_spmd_logical_sp.h b/include/services/el3_spmd_logical_sp.h index 1f9ef0d4e..15bea9f5f 100644 --- a/include/services/el3_spmd_logical_sp.h +++ b/include/services/el3_spmd_logical_sp.h @@ -105,33 +105,33 @@ static inline bool is_ffa_direct_msg_resp(struct ffa_value *retval) } static inline uint16_t ffa_partition_info_regs_get_last_idx( - struct ffa_value args) + struct ffa_value *args) { - return (uint16_t)(args.arg2 & 0xFFFFU); + return (uint16_t)(args->arg2 & 0xFFFFU); } static inline uint16_t ffa_partition_info_regs_get_curr_idx( - struct ffa_value args) + struct ffa_value *args) { - return (uint16_t)((args.arg2 >> 16) & 0xFFFFU); + return (uint16_t)((args->arg2 >> 16) & 0xFFFFU); } -static inline uint16_t ffa_partition_info_regs_get_tag(struct ffa_value args) +static inline uint16_t ffa_partition_info_regs_get_tag(struct ffa_value *args) { - return (uint16_t)((args.arg2 >> 32) & 0xFFFFU); + return (uint16_t)((args->arg2 >> 32) & 0xFFFFU); } static inline uint16_t ffa_partition_info_regs_get_desc_size( - struct ffa_value args) + struct ffa_value *args) { - return (uint16_t)(args.arg2 >> 48); + return (uint16_t)(args->arg2 >> 48); } uint64_t spmd_el3_populate_logical_partition_info(void *handle, uint64_t x1, uint64_t x2, uint64_t x3); bool ffa_partition_info_regs_get_part_info( - struct ffa_value args, uint8_t idx, + struct ffa_value *args, uint8_t idx, struct ffa_partition_info_v1_1 *partition_info); bool spmd_el3_invoke_partition_info_get( diff --git a/plat/arm/board/fvp/fvp_spmd_logical_sp.c b/plat/arm/board/fvp/fvp_spmd_logical_sp.c index 37b44669a..8841fc18d 100644 --- a/plat/arm/board/fvp/fvp_spmd_logical_sp.c +++ b/plat/arm/board/fvp/fvp_spmd_logical_sp.c @@ -32,7 +32,7 @@ static void fvp_get_partition_info(void) panic(); } - num_partitions = ffa_partition_info_regs_get_last_idx(ret) + 1; + num_partitions = ffa_partition_info_regs_get_last_idx(&ret) + 1; if (num_partitions > SPMD_LP_MAX_SUPPORTED_SP) { panic(); } @@ -41,7 +41,7 @@ static void fvp_get_partition_info(void) for (uint16_t i = 0; i < num_partitions; i++) { INFO("***Start Partition***\n"); - if (!ffa_partition_info_regs_get_part_info(ret, i, &part_info[i])) + if (!ffa_partition_info_regs_get_part_info(&ret, i, &part_info[i])) panic(); INFO("\tPartition ID: 0x%x\n", part_info[i].ep_id); INFO("\tvCPU count:0x%x\n", part_info[i].execution_ctx_count); diff --git a/services/std_svc/spmd/spmd_logical_sp.c b/services/std_svc/spmd/spmd_logical_sp.c index 964b36b4d..d992187db 100644 --- a/services/std_svc/spmd/spmd_logical_sp.c +++ b/services/std_svc/spmd/spmd_logical_sp.c @@ -356,7 +356,7 @@ void spmd_logical_sp_set_spmc_failure(void) * other code to consume. */ bool ffa_partition_info_regs_get_part_info( - struct ffa_value args, uint8_t idx, + struct ffa_value *args, uint8_t idx, struct ffa_partition_info_v1_1 *partition_info) { uint64_t *arg_ptrs; @@ -375,7 +375,7 @@ bool ffa_partition_info_regs_get_part_info( * function, arg1 is reserved, arg2 encodes indices. arg3 and greater * values reflect partition properties. */ - arg_ptrs = (uint64_t *)&args + ((idx * 3) + 3); + arg_ptrs = (uint64_t *)args + ((idx * 3) + 3); info = *arg_ptrs; arg_ptrs++;