sme: Fix sign-extension bug in SMCR_EL3 write
PATCH 1/1 sme: Fix sign-extension bug in SMCR_EL3 write
To enable the full AArch64 ISA support in streaming SVE mode, we need to set bit 31 in the SMCR_EL3 system register. However ORing (1 << 31) into an unsigned long variable will lead to all upper 32 bits becoming 1, which is not what we want. We are just saved by those bits being RES0, at least for now.
Explicitly use an unsigned base for the shift, to avoid the sign extension.
--- arch/aarch64/include/asm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/aarch64/include/asm/cpu.h +1 -1
@@ -117,7 +117,7 @@#define ZCR_EL3_LEN_MAX 0xf#define SMCR_EL3 s3_6_c1_c2_6 -#define SMCR_EL3_FA64 (1 << 31) +#define SMCR_EL3_FA64 (1U << 31)#define SMCR_EL3_LEN_MAX 0xf#define ID_AA64ISAR2_EL1 s3_0_c0_c6_2
Signature · 7 lines
2.25.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 19 lines · Andre Przywara
To enable the full AArch64 ISA support in streaming SVE mode, we need to set bit 31 in the
SMCR_EL3system register. However ORing (1 << 31) into an unsigned long variable will lead to all upper 32 bits becoming 1, which is not what we want. We are just saved by those bits being RES0, at least for now.Explicitly use an unsigned base for the shift, to avoid the sign extension.
Signed-off-by Andre Przywara <[email protected]>--- arch/aarch64/include/asm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/aarch64/include/asm/cpu.h +0
-0
arch/aarch64/include/asm/cpu.h line 120
Quoted 5 lines
arch/aarch64/include/asm/cpu.h +1
-1@@ -117,7 +117,7 @@#define ZCR_EL3_LEN_MAX 0xf#define SMCR_EL3 s3_6_c1_c2_6 -#define SMCR_EL3_FA64 (1 << 31) +#define SMCR_EL3_FA64 (1U << 31)
This looks good, but I'd prefer if we used BIT(31) here; that'll do the right thing internally.
Are you happy if I fix that up when applying?
Thanks,
Mark.
Quoted 6 lines
arch/aarch64/include/asm/cpu.h +0
-0#define SMCR_EL3_LEN_MAX 0xf#define ID_AA64ISAR2_EL1 s3_0_c0_c6_2Signature · 1 line
2.25.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 22 lines · On Tue, 4 Oct 2022 16:01:23 +0100 Mark Rutland <[email protected]> wrote:
Quoted 21 lines · Andre Przywara
To enable the full AArch64 ISA support in streaming SVE mode, we need to set bit 31 in the
SMCR_EL3system register. However ORing (1 << 31) into an unsigned long variable will lead to all upper 32 bits becoming 1, which is not what we want. We are just saved by those bits being RES0, at least for now.Explicitly use an unsigned base for the shift, to avoid the sign extension.
Signed-off-by Andre Przywara <[email protected]>--- arch/aarch64/include/asm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/aarch64/include/asm/cpu.h +0
-0@@ -117,7 +117,7 @@#define ZCR_EL3_LEN_MAX 0xf
Quoted 8 lines
arch/aarch64/include/asm/cpu.h line 120
Quoted 3 lines
arch/aarch64/include/asm/cpu.h +1
-1#define SMCR_EL3 s3_6_c1_c2_6 -#define SMCR_EL3_FA64 (1 << 31) +#define SMCR_EL3_FA64 (1U << 31)This looks good, but I'd prefer if we used BIT(31) here; that'll do the right thing internally.
Are you happy if I fix that up when applying?
Yes, sure.
Thanks for taking care!
Cheers,
Andre
Quoted 7 lines
Quoted 7 lines
arch/aarch64/include/asm/cpu.h +0
-0#define SMCR_EL3_LEN_MAX 0xf#define ID_AA64ISAR2_EL1 s3_0_c0_c6_2Signature · 1 line
2.25.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 32 lines · Andre Przywara
Quoted 29 lines · On Tue, 4 Oct 2022 16:01:23 +0100 Mark Rutland <[email protected]> wrote:
Quoted 19 lines · Andre Przywara
To enable the full AArch64 ISA support in streaming SVE mode, we need to set bit 31 in the
SMCR_EL3system register. However ORing (1 << 31) into an unsigned long variable will lead to all upper 32 bits becoming 1, which is not what we want. We are just saved by those bits being RES0, at least for now.Explicitly use an unsigned base for the shift, to avoid the sign extension.
Signed-off-by Andre Przywara <[email protected]>--- arch/aarch64/include/asm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/aarch64/include/asm/cpu.h +0
-0arch/aarch64/include/asm/cpu.h line 120
Quoted 5 lines
arch/aarch64/include/asm/cpu.h +1
-1@@ -117,7 +117,7 @@#define ZCR_EL3_LEN_MAX 0xf#define SMCR_EL3 s3_6_c1_c2_6 -#define SMCR_EL3_FA64 (1 << 31) +#define SMCR_EL3_FA64 (1U << 31)This looks good, but I'd prefer if we used BIT(31) here; that'll do the right thing internally.
Quoted 5 lines
Quoted 1 line
Are you happy if I fix that up when applying?
Yes, sure.
Thanks for taking care!
Thanks; applied.
Mark.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel