diff mbox series

smcc: fix sign bit expansion

Message ID 20210105200240.372419-1-volodymyr_babchuk@epam.com
State Accepted
Commit b7cfe32e186d453001a12ee0ee2c85d08a0ecd53
Delegated to: Tom Rini
Headers show
Series smcc: fix sign bit expansion | expand

Commit Message

Volodymyr Babchuk Jan. 5, 2021, 8:03 p.m. UTC
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.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
 include/linux/arm-smccc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jens Wiklander Jan. 21, 2021, 6:54 a.m. UTC | #1
On Tue, Jan 05, 2021 at 08:03:11PM +0000, Volodymyr Babchuk wrote:
> 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.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> ---
>  include/linux/arm-smccc.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

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

Cheers,
Jens

> 
> diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
> index 2d1e6cc156..7f2be23394 100644
> --- a/include/linux/arm-smccc.h
> +++ b/include/linux/arm-smccc.h
> @@ -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
> -- 
> 2.29.2
Tom Rini Jan. 28, 2021, 11:56 p.m. UTC | #2
On Tue, Jan 05, 2021 at 08:03:11PM +0000, Volodymyr Babchuk wrote:

> 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.
> 
> Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
index 2d1e6cc156..7f2be23394 100644
--- a/include/linux/arm-smccc.h
+++ b/include/linux/arm-smccc.h
@@ -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