firmware: smccc: Fix check for ARCH_SOC_ID not implemented
authorMichael Kelley <mikelley@microsoft.com>
Fri, 19 Nov 2021 23:39:01 +0000 (15:39 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:19:04 +0000 (09:19 +0100)
[ Upstream commit e95d8eaee21cd0d117d34125d4cdc97489c1ab82 ]

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")
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/smccc/soc_id.c

index 581aa5e9b0778bea6e7c853cd7c23a9bbc07f3e3..dd7c3d5e8b0bbabd32cf9395e3e39f6bf5c77d20 100644 (file)
@@ -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;
        }