Skip to contentSkip to conversation

firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit

PATCH Applied Kathiravan Thirumoorthy 2 participants 2 messages Sep 25, 2023 – Sep 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit

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.

Fixes 9a434cee773a ("firmware: qcom_scm: Dynamically support SMCCC and legacy conventions")

---
Changes in V3:
- reworded the commit title and msg
- pick up the R-b tag

Changes in V2:
- Added the Fixes tag and cc'd stable mailing list

---
 drivers/firmware/qcom_scm.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/firmware/qcom_scm.c +7 -0
index c2c7fafef34b..520de9b5633a 100644
@@ -215,6 +215,12 @@ static enum qcom_scm_convention __get_convention(void)
 	if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
 		return qcom_scm_convention;
 
+	/*
+	 * Per the "SMC calling convention specification", the 64-bit calling
+	 * convention can only be used when the client is 64-bit, otherwise
+	 * system will encounter the undefined behaviour.
+	 */
+#if IS_ENABLED(CONFIG_ARM64)
 	/*
 	 * Device isn't required as there is only one argument - no device
 	 * needed to dma_map_single to secure world
@@ -235,6 +241,7 @@ static enum qcom_scm_convention __get_convention(void)
 		forced = true;
 		goto found;
 	}
+#endif
 
 	probed_convention = SMC_CONVENTION_ARM_32;
 	ret = __scm_smc_call(NULL, &desc, probed_convention, &res, true);

---
base-commit: 8fff9184d1b5810dca5dd1a02726d4f844af88fc
change-id: 20230925-scm-d62c6cd1947b

Best regards,

Signature · 1 line
Kathiravan Thirumoorthy <[email protected]>
#1 lore raw
Quoted 10 lines · Kathiravan Thirumoorthy

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.

[...]

Applied, thanks!

[1/1] firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit

      commit: 3337a6fea25370d3d244ec6bb38c71ee86fcf837

Best regards,

Signature · 1 line
Bjorn Andersson <[email protected]>