summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManish Pandey <manish.pandey2@arm.com>2026-01-08 16:31:44 +0000
committerTrustedFirmware Code Review <review@review.trustedfirmware.org>2026-01-08 16:31:44 +0000
commit048cb1dd5ddd487561b4b5ac89b8f795d6115da7 (patch)
tree3e0d9521a81aeffc318ee39b8c078595ef5768ef
parentdee3312e6c62a078c3204bf715248dfdf7288906 (diff)
parentada9e227e90f78dfe36ffe924faba3747a988745 (diff)
downloadarm-trusted-firmware-048cb1dd5ddd487561b4b5ac89b8f795d6115da7.tar.gz
arm-trusted-firmware-048cb1dd5ddd487561b4b5ac89b8f795d6115da7.zip
Merge changes from topic "xlnx_fix_misra_opteed" into integration
* changes: fix(optee): initialize the structure fix(optee): add missing curly braces fix(optee): add parenthesis for macro expressions fix(optee): move function to conditional block fix(optee): add boolean type for expressions fix(optee): evaluate condition for boolean fix(optee): typecast operands to match data type fix(el3-runtime): resolve essential-type mismatch
-rw-r--r--include/lib/smccc.h4
-rw-r--r--plat/xilinx/versal/sip_svc_setup.c2
-rw-r--r--plat/xilinx/zynqmp/sip_svc_setup.c2
-rw-r--r--services/arm_arch_svc/arm_arch_svc_setup.c2
-rw-r--r--services/spd/opteed/opteed_common.c9
-rw-r--r--services/spd/opteed/opteed_main.c18
-rw-r--r--services/spd/opteed/opteed_pm.c2
-rw-r--r--services/spd/opteed/opteed_private.h22
-rw-r--r--services/spd/opteed/teesmc_opteed.h18
-rw-r--r--services/spd/opteed/teesmc_opteed_macros.h2
10 files changed, 42 insertions, 39 deletions
diff --git a/include/lib/smccc.h b/include/lib/smccc.h
index 775c2b21b..2ba3351d8 100644
--- a/include/lib/smccc.h
+++ b/include/lib/smccc.h
@@ -107,7 +107,7 @@
#define SMC_64 U(1)
#define SMC_32 U(0)
-#define SMC_TYPE_FAST UL(1)
+#define SMC_TYPE_FAST U(1)
#define SMC_TYPE_YIELD UL(0)
#define SMC_OK ULL(0)
@@ -178,7 +178,7 @@
/* The macro below is used to identify a valid Fast SMC call */
#define is_valid_fast_smc(_fid) ((!(((_fid) >> 16) & U(0xff))) && \
(GET_SMC_TYPE(_fid) \
- == (uint32_t)SMC_TYPE_FAST))
+ == SMC_TYPE_FAST))
/*
* Macro to define UUID for services. Apart from defining and initializing a
diff --git a/plat/xilinx/versal/sip_svc_setup.c b/plat/xilinx/versal/sip_svc_setup.c
index ac4f5e02b..b7f56aa87 100644
--- a/plat/xilinx/versal/sip_svc_setup.c
+++ b/plat/xilinx/versal/sip_svc_setup.c
@@ -122,6 +122,6 @@ DECLARE_RT_SVC(
sip_svc,
OEN_SIP_START,
OEN_SIP_END,
- (uint8_t)SMC_TYPE_FAST,
+ SMC_TYPE_FAST,
sip_svc_setup,
sip_svc_smc_handler);
diff --git a/plat/xilinx/zynqmp/sip_svc_setup.c b/plat/xilinx/zynqmp/sip_svc_setup.c
index 534eb33cc..74c13aacf 100644
--- a/plat/xilinx/zynqmp/sip_svc_setup.c
+++ b/plat/xilinx/zynqmp/sip_svc_setup.c
@@ -121,6 +121,6 @@ DECLARE_RT_SVC(
sip_svc,
OEN_SIP_START,
OEN_SIP_END,
- (uint8_t)SMC_TYPE_FAST,
+ SMC_TYPE_FAST,
sip_svc_setup,
sip_svc_smc_handler);
diff --git a/services/arm_arch_svc/arm_arch_svc_setup.c b/services/arm_arch_svc/arm_arch_svc_setup.c
index a2ff69aea..0221db078 100644
--- a/services/arm_arch_svc/arm_arch_svc_setup.c
+++ b/services/arm_arch_svc/arm_arch_svc_setup.c
@@ -337,7 +337,7 @@ DECLARE_RT_SVC(
arm_arch_svc,
OEN_ARM_START,
OEN_ARM_END,
- (uint8_t)SMC_TYPE_FAST,
+ SMC_TYPE_FAST,
NULL,
arm_arch_svc_smc_handler
);
diff --git a/services/spd/opteed/opteed_common.c b/services/spd/opteed/opteed_common.c
index 8a769fb0b..4778b5f8f 100644
--- a/services/spd/opteed/opteed_common.c
+++ b/services/spd/opteed/opteed_common.c
@@ -40,19 +40,22 @@ void opteed_init_optee_ep_state(struct entry_point_info *optee_entry_point,
/* initialise an entrypoint to set up the CPU context */
ep_attr = SECURE | EP_ST_ENABLE;
- if (read_sctlr_el3() & SCTLR_EE_BIT)
+ if ((read_sctlr_el3() & SCTLR_EE_BIT) != 0U) {
ep_attr |= EP_EE_BIG;
+ }
SET_PARAM_HEAD(optee_entry_point, PARAM_EP, VERSION_1, ep_attr);
optee_entry_point->pc = pc;
- if (rw == OPTEE_AARCH64)
+ if (rw == OPTEE_AARCH64) {
optee_entry_point->spsr = SPSR_64(MODE_EL1, MODE_SP_ELX,
DISABLE_ALL_EXCEPTIONS);
- else
+ } else {
optee_entry_point->spsr = SPSR_MODE32(MODE32_svc, SPSR_T_ARM,
SPSR_E_LITTLE,
DAIF_FIQ_BIT |
DAIF_IRQ_BIT |
DAIF_ABT_BIT);
+ }
+
zeromem(&optee_entry_point->args, sizeof(optee_entry_point->args));
optee_entry_point->args.arg0 = arg0;
optee_entry_point->args.arg1 = arg1;
diff --git a/services/spd/opteed/opteed_main.c b/services/spd/opteed/opteed_main.c
index b682a698d..c43a4cc23 100644
--- a/services/spd/opteed/opteed_main.c
+++ b/services/spd/opteed/opteed_main.c
@@ -64,18 +64,17 @@ DEFINE_SVC_UUID2(optee_image_load_uuid,
0xb1eafba3, 0x5d31, 0x4612, 0xb9, 0x06,
0xc4, 0xc7, 0xa4, 0xbe, 0x3c, 0xc0);
+static uint64_t dual32to64(uint32_t high, uint32_t low)
+{
+ return ((uint64_t)high << 32) | low;
+}
+
#define OPTEED_FDT_SIZE 1024
static uint8_t fdt_buf[OPTEED_FDT_SIZE] __aligned(CACHE_WRITEBACK_GRANULE);
#else
static int32_t opteed_init(void);
#endif
-
-uint64_t dual32to64(uint32_t high, uint32_t low)
-{
- return ((uint64_t)high << 32) | low;
-}
-
/*******************************************************************************
* This function is the handler registered for S-EL1 interrupts by the
* OPTEED. It validates the interrupt and upon success arranges entry into
@@ -177,7 +176,7 @@ static int32_t opteed_setup(void)
* conditionally include the SPD service
*/
optee_ep_info = bl31_plat_get_next_image_ep_info(SECURE);
- if (!optee_ep_info) {
+ if (optee_ep_info == NULL) {
WARN("No OPTEE provided by BL2 boot loader, Booting device"
" without OPTEE initialization. SMC`s destined for OPTEE"
" will return SMC_UNK\n");
@@ -189,8 +188,9 @@ static int32_t opteed_setup(void)
* signalling failure initializing the service. We bail out without
* registering any handlers
*/
- if (!optee_ep_info->pc)
+ if (optee_ep_info->pc == 0U) {
return 1;
+ }
#if TRANSFER_LIST
tl = (void *)optee_ep_info->args.arg3;
@@ -741,7 +741,7 @@ static uintptr_t opteed_smc_handler(uint32_t smc_fid,
assert(optee_vector_table == NULL);
optee_vector_table = (optee_vectors_t *) x1;
- if (optee_vector_table) {
+ if (optee_vector_table != NULL) {
set_optee_pstate(optee_ctx->state, OPTEE_PSTATE_ON);
/*
diff --git a/services/spd/opteed/opteed_pm.c b/services/spd/opteed/opteed_pm.c
index c4a79f58a..a3eac2650 100644
--- a/services/spd/opteed/opteed_pm.c
+++ b/services/spd/opteed/opteed_pm.c
@@ -105,7 +105,7 @@ void opteed_cpu_on_finish_handler(u_register_t unused)
int32_t rc = 0;
uint32_t linear_id = plat_my_core_pos();
optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
- entry_point_info_t optee_on_entrypoint;
+ entry_point_info_t optee_on_entrypoint = {};
assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_OFF ||
diff --git a/services/spd/opteed/opteed_private.h b/services/spd/opteed/opteed_private.h
index c484516d3..312f2bf13 100644
--- a/services/spd/opteed/opteed_private.h
+++ b/services/spd/opteed/opteed_private.h
@@ -18,21 +18,21 @@
* OPTEE PM state information e.g. OPTEE is suspended, uninitialised etc
* and macros to access the state information in the per-cpu 'state' flags
******************************************************************************/
-#define OPTEE_PSTATE_OFF 1
-#define OPTEE_PSTATE_ON 2
-#define OPTEE_PSTATE_SUSPEND 3
-#define OPTEE_PSTATE_UNKNOWN 0
-#define OPTEE_PSTATE_SHIFT 0
-#define OPTEE_PSTATE_MASK 0x3
-#define get_optee_pstate(state) ((state >> OPTEE_PSTATE_SHIFT) & \
+#define OPTEE_PSTATE_OFF 1U
+#define OPTEE_PSTATE_ON 2U
+#define OPTEE_PSTATE_SUSPEND 3U
+#define OPTEE_PSTATE_UNKNOWN 0U
+#define OPTEE_PSTATE_SHIFT 0U
+#define OPTEE_PSTATE_MASK 0x3U
+#define get_optee_pstate(state) (((state) >> OPTEE_PSTATE_SHIFT) & \
OPTEE_PSTATE_MASK)
#define clr_optee_pstate(state) (state &= ~(OPTEE_PSTATE_MASK \
<< OPTEE_PSTATE_SHIFT))
#define set_optee_pstate(st, pst) do { \
- clr_optee_pstate(st); \
- st |= (pst & OPTEE_PSTATE_MASK) << \
- OPTEE_PSTATE_SHIFT; \
- } while (0)
+ clr_optee_pstate((st)); \
+ (st) |= (((pst) & OPTEE_PSTATE_MASK) << \
+ OPTEE_PSTATE_SHIFT); \
+ } while (false)
/*******************************************************************************
diff --git a/services/spd/opteed/teesmc_opteed.h b/services/spd/opteed/teesmc_opteed.h
index 4026fa4da..254261a72 100644
--- a/services/spd/opteed/teesmc_opteed.h
+++ b/services/spd/opteed/teesmc_opteed.h
@@ -30,7 +30,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ENTRY_DONE
* r1/x1 Pointer to entry vector
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0
+#define TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE 0U
#define TEESMC_OPTEED_RETURN_ENTRY_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ENTRY_DONE)
@@ -43,7 +43,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_ON_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1
+#define TEESMC_OPTEED_FUNCID_RETURN_ON_DONE 1U
#define TEESMC_OPTEED_RETURN_ON_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_ON_DONE)
@@ -54,7 +54,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_OFF_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2
+#define TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE 2U
#define TEESMC_OPTEED_RETURN_OFF_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_OFF_DONE)
@@ -65,7 +65,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SUSPEND_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3
+#define TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE 3U
#define TEESMC_OPTEED_RETURN_SUSPEND_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SUSPEND_DONE)
@@ -76,7 +76,7 @@
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_RESUME_DONE
* r1/x1 0 on success and anything else to indicate error condition
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4
+#define TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE 4U
#define TEESMC_OPTEED_RETURN_RESUME_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_RESUME_DONE)
@@ -88,7 +88,7 @@
* r1-4/x1-4 Return value 0-3 which will passed to normal world in
* r0-3/x0-3
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5
+#define TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE 5U
#define TEESMC_OPTEED_RETURN_CALL_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_CALL_DONE)
@@ -98,7 +98,7 @@
* Register usage:
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_FIQ_DONE
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6
+#define TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE 6U
#define TEESMC_OPTEED_RETURN_FIQ_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_FIQ_DONE)
@@ -108,7 +108,7 @@
* Register usage:
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7
+#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE 7U
#define TEESMC_OPTEED_RETURN_SYSTEM_OFF_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_OFF_DONE)
@@ -118,7 +118,7 @@
* Register usage:
* r0/x0 SMC Function ID, TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE
*/
-#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8
+#define TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE 8U
#define TEESMC_OPTEED_RETURN_SYSTEM_RESET_DONE \
TEESMC_OPTEED_RV(TEESMC_OPTEED_FUNCID_RETURN_SYSTEM_RESET_DONE)
diff --git a/services/spd/opteed/teesmc_opteed_macros.h b/services/spd/opteed/teesmc_opteed_macros.h
index 721914063..f87faa88b 100644
--- a/services/spd/opteed/teesmc_opteed_macros.h
+++ b/services/spd/opteed/teesmc_opteed_macros.h
@@ -11,7 +11,7 @@
#define TEESMC_OPTEED_RV(func_num) \
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
((SMC_32) << FUNCID_CC_SHIFT) | \
- (62 << FUNCID_OEN_SHIFT) | \
+ (62U << FUNCID_OEN_SHIFT) | \
((func_num) & FUNCID_NUM_MASK))
#define NSSMC_OPTEED_CALL(func_num) \