Skip to content

Commit df4133e

Browse files
Kathiravan Thirumoorthygregkh
authored andcommitted
firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit
commit 3337a6f upstream. Per the "SMC calling convention specification", the 64-bit calling convention can only be used when the client is 64-bit. Whereas the 32-bit calling convention can be used by either a 32-bit or a 64-bit client. Currently during SCM probe, irrespective of the client, 64-bit calling convention is made, which is incorrect and may lead to the undefined behaviour when the client is 32-bit. Let's fix it. Cc: [email protected] Fixes: 9a434ce ("firmware: qcom_scm: Dynamically support SMCCC and legacy conventions") Reviewed-By: Elliot Berman <[email protected]> Signed-off-by: Kathiravan Thirumoorthy <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 76211f1 commit df4133e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/firmware/qcom_scm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ static enum qcom_scm_convention __get_convention(void)
136136
if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
137137
return qcom_scm_convention;
138138

139+
/*
140+
* Per the "SMC calling convention specification", the 64-bit calling
141+
* convention can only be used when the client is 64-bit, otherwise
142+
* system will encounter the undefined behaviour.
143+
*/
144+
#if IS_ENABLED(CONFIG_ARM64)
139145
/*
140146
* Device isn't required as there is only one argument - no device
141147
* needed to dma_map_single to secure world
@@ -156,6 +162,7 @@ static enum qcom_scm_convention __get_convention(void)
156162
forced = true;
157163
goto found;
158164
}
165+
#endif
159166

160167
probed_convention = SMC_CONVENTION_ARM_32;
161168
ret = __scm_smc_call(NULL, &desc, probed_convention, &res, true);

0 commit comments

Comments
 (0)