Skip to contentSkip to conversation

smcc: fix sign bit expansion

PATCH New Volodymyr Babchuk 3 participants 3 messages Jan 5, 2021 – Jan 28, 2021 Secure monitor call(SMC) calling convention (SMCCC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smcc: fix sign bit expansion

Signed ARM_SMCCC_FAST_CALL value is shifted to 31'st bit. Then, it is expanded to 64 bit value, which results in 1s in higher 32 bits.

This causes corrupted values in 64-bit SMC IDs and issues in buggy handlers of 32-bit calls.

We need to make ARM_SMCCC_FAST_CALL unsigned long, so it would work properly on 32 bit architectures.

---
 include/linux/arm-smccc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/arm-smccc.h +2 -2
index 2d1e6cc156..7f2be23394 100644
@@ -11,8 +11,8 @@
  * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
  */
 
-#define ARM_SMCCC_STD_CALL		0
-#define ARM_SMCCC_FAST_CALL		1
+#define ARM_SMCCC_STD_CALL		0UL
+#define ARM_SMCCC_FAST_CALL		1UL
 #define ARM_SMCCC_TYPE_SHIFT		31
 
 #define ARM_SMCCC_SMC_32		0
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/1 smcc: fix sign bit expansion

Quoted 6 lines · Volodymyr Babchuk

Signed ARM_SMCCC_FAST_CALL value is shifted to 31'st bit. Then, it is expanded to 64 bit value, which results in 1s in higher 32 bits.

This causes corrupted values in 64-bit SMC IDs and issues in buggy handlers of 32-bit calls.

Quoted 7 lines

We need to make ARM_SMCCC_FAST_CALL unsigned long, so it would work properly on 32 bit architectures.

---
 include/linux/arm-smccc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

You may want to make the prefix "smccc:" (note the extra c) instead.

Cheers,
Jens

Quoted 18 lines
include/linux/arm-smccc.h +2 -2
index 2d1e6cc156..7f2be23394 100644
@@ -11,8 +11,8 @@
  * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
  */
 
-#define ARM_SMCCC_STD_CALL		0
-#define ARM_SMCCC_FAST_CALL		1
+#define ARM_SMCCC_STD_CALL		0UL
+#define ARM_SMCCC_FAST_CALL		1UL
 #define ARM_SMCCC_TYPE_SHIFT		31
 
 #define ARM_SMCCC_SMC_32		0
Signature · 1 line
2.29.2
#2 lore raw

PATCH 1/1 smccc: fix sign bit expansion

In reply to Volodymyr Babchuk
Quoted 11 lines · Volodymyr Babchuk

Signed ARM_SMCCC_FAST_CALL value is shifted to 31'st bit. Then, it is expanded to 64 bit value, which results in 1s in higher 32 bits.

This causes corrupted values in 64-bit SMC IDs and issues in buggy handlers of 32-bit calls.

We need to make ARM_SMCCC_FAST_CALL unsigned long, so it would work properly on 32 bit architectures.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210128/a0e4c28d/attachment.sig>