Skip to contentSkip to conversation

firmware: smccc: Fix check for ARCH_SOC_ID not implemented

PATCH In review Michael Kelley 3 participants 4 messages Nov 19, 2021 – Nov 22, 2021 Secure monitor call(SMC) calling convention (SMCCC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: smccc: Fix check for ARCH_SOC_ID not implemented

The ARCH_FEATURES function ID is a 32-bit SMC call, which returns a 32-bit result per the SMCCC spec. Current code is doing a 64-bit comparison against -1 (SMCCC_RET_NOT_SUPPORTED) to detect that the feature is unimplemented. That check doesn't work in a Hyper-V VM, where the upper 32-bits are zero as allowed by the spec.

Cast the result as an 'int' so the comparison works. The change also makes the code consistent with other similar checks in this file.

Fixes 821b67fa4639 ("firmware: smccc: Add ARCH_SOC_ID support")
---
 drivers/firmware/smccc/soc_id.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/smccc/soc_id.c +1 -1
index 581aa5e..dd7c3d5 100644
@@ -50,7 +50,7 @@ static int __init smccc_soc_init(void)
 	arm_smccc_1_1_invoke(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
 			     ARM_SMCCC_ARCH_SOC_ID, &res);
 
-	if (res.a0 == SMCCC_RET_NOT_SUPPORTED) {
+	if ((int)res.a0 == SMCCC_RET_NOT_SUPPORTED) {
 		pr_info("ARCH_SOC_ID not implemented, skipping ....\n");
 		return 0;
 	}
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Michael Kelley

The ARCH_FEATURES function ID is a 32-bit SMC call, which returns a 32-bit result per the SMCCC spec. Current code is doing a 64-bit comparison against -1 (SMCCC_RET_NOT_SUPPORTED) to detect that the feature is unimplemented. That check doesn't work in a Hyper-V VM, where the upper 32-bits are zero as allowed by the spec.

Cast the result as an 'int' so the comparison works. The change also makes the code consistent with other similar checks in this file.

Fixes 821b67fa4639 ("firmware: smccc: Add ARCH_SOC_ID support")

Good catch.

Can you please re-post with my review tag keeping [email protected] and [email protected] ? I don't have any other fixes at the moment, we can ask SoC maintainers to fix this up directly.

Signature · 2 lines
Regards,
Sudeep
#2 lore raw
Quoted 12 lines · Sudeep Holla
Quoted 10 lines · Michael Kelley

The ARCH_FEATURES function ID is a 32-bit SMC call, which returns a 32-bit result per the SMCCC spec. Current code is doing a 64-bit comparison against -1 (SMCCC_RET_NOT_SUPPORTED) to detect that the feature is unimplemented. That check doesn't work in a Hyper-V VM, where the upper 32-bits are zero as allowed by the spec.

Cast the result as an 'int' so the comparison works. The change also makes the code consistent with other similar checks in this file.

Fixes 821b67fa4639 ("firmware: smccc: Add ARCH_SOC_ID support")
Quoted 7 lines

Good catch.

Can you please re-post with my review tag keeping [email protected] and [email protected] ? I don't have any other fixes at the moment, we can ask SoC maintainers to fix this up directly.

In general, I think the easiest way would be for you to forward the patch with your Signed-off-by, when you don't have other material for a pull request.

I've applied this patch from the list now.

Arnd

#3 lore raw
Quoted 17 lines · Arnd Bergmann
Quoted 16 lines · Sudeep Holla
Quoted 10 lines · Michael Kelley

The ARCH_FEATURES function ID is a 32-bit SMC call, which returns a 32-bit result per the SMCCC spec. Current code is doing a 64-bit comparison against -1 (SMCCC_RET_NOT_SUPPORTED) to detect that the feature is unimplemented. That check doesn't work in a Hyper-V VM, where the upper 32-bits are zero as allowed by the spec.

Cast the result as an 'int' so the comparison works. The change also makes the code consistent with other similar checks in this file.

Fixes 821b67fa4639 ("firmware: smccc: Add ARCH_SOC_ID support")

Good catch.

Quoted 8 lines
Quoted 3 lines

Can you please re-post with my review tag keeping [email protected] and [email protected] ? I don't have any other fixes at the moment, we can ask SoC maintainers to fix this up directly.

In general, I think the easiest way would be for you to forward the patch with your Signed-off-by, when you don't have other material for a pull request.

Thanks for the tip, I will follow that in future.

Quoted 2 lines

I've applied this patch from the list now.

Thanks for that.

--
Regards,
Sudeep