Skip to contentSkip to conversation

driver: rng: Do not check ARM_SMCCC_TRNG_VERSION

PATCH In review Leo Yan 3 participants 3 messages Jul 9, 2024 – Jul 18, 2024

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH 1/1 driver: rng: Do not check ARM_SMCCC_TRNG_VERSION

As described in the document SMC Calling Convention (ARM DEN 0028 1.5 F), section 7 "Arm Architecture Calls", the SMC call SMCCC_ARCH_FEATURES is not expected to support the function ID ARM_SMCCC_TRNG_VERSION. Trusted Firmware-A follows up the specification in its implementation.

This commit removes the invocation to avoid the failure - which is a wrong calling in U-boot. The later code invokes ARM_SMCCC_TRNG_VERSION for retrieving the TRNG version, except it can read back the version number, it also can be used to detect whether the TRNG is supported or not.

---
 drivers/rng/smccc_trng.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/rng/smccc_trng.c +0 -4
index f59b80666b..1da1affd8e 100644
@@ -135,10 +135,6 @@ static bool smccc_trng_is_supported(void (*invoke_fn)(unsigned long a0, unsigned
 {
 	struct arm_smccc_res res;
 
-	(*invoke_fn)(ARM_SMCCC_ARCH_FEATURES, ARM_SMCCC_TRNG_VERSION, 0, 0, 0, 0, 0, 0, &res);
-	if (res.a0 == ARM_SMCCC_RET_NOT_SUPPORTED)
-		return false;
-
 	(*invoke_fn)(ARM_SMCCC_TRNG_VERSION, 0, 0, 0, 0, 0, 0, 0, &res);
 	if (res.a0 & BIT(31))
 		return false;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Leo Yan

As described in the document SMC Calling Convention (ARM DEN 0028 1.5 F), section 7 "Arm Architecture Calls", the SMC call SMCCC_ARCH_FEATURES is not expected to support the function ID ARM_SMCCC_TRNG_VERSION. Trusted Firmware-A follows up the specification in its implementation.

This commit removes the invocation to avoid the failure - which is a wrong calling in U-boot. The later code invokes ARM_SMCCC_TRNG_VERSION for retrieving the TRNG version, except it can read back the version number, it also can be used to detect whether the TRNG is supported or not.

LGTM.

BR,
Weizhao

Quoted 24 lines
---
 drivers/rng/smccc_trng.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/rng/smccc_trng.c +0 -5
index f59b80666b..1da1affd8e 100644
@@ -135,10 +135,6 @@ static bool smccc_trng_is_supported(void (*invoke_fn)(unsigned long a0, unsigned
 {
        struct arm_smccc_res res;
 
-       (*invoke_fn)(ARM_SMCCC_ARCH_FEATURES, ARM_SMCCC_TRNG_VERSION, 0, 0, 0, 0, 0, 0, &res);
-       if (res.a0 == ARM_SMCCC_RET_NOT_SUPPORTED)
-               return false;
-
        (*invoke_fn)(ARM_SMCCC_TRNG_VERSION, 0, 0, 0, 0, 0, 0, 0, &res);
        if (res.a0 & BIT(31))
                return false;
--

2.34.1

#2 lore raw
In reply to Leo Yan
Quoted 5 lines · Leo Yan

As described in the document SMC Calling Convention (ARM DEN 0028 1.5 F), section 7 "Arm Architecture Calls", the SMC call SMCCC_ARCH_FEATURES is not expected to support the function ID ARM_SMCCC_TRNG_VERSION. Trusted Firmware-A follows up the specification in its implementation.

Quoted 7 lines

This commit removes the invocation to avoid the failure - which is a wrong calling in U-boot. The later code invokes ARM_SMCCC_TRNG_VERSION for retrieving the TRNG version, except it can read back the version number, it also can be used to detect whether the TRNG is supported or not.

[...]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom