Skip to contentSkip to conversation

arm64: lib: Use .arch_extension

PATCH In review Mark Brown 3 participants 9 messages Mar 23, 2020 – Mar 25, 2020

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/2 arm64: lib: Use .arch_extension

Currently when implementing optimised assembler routines using architecture extensions we override the base architecture along with enabling the new extensions, causing problems for in kernel BTI support which needs to raise the base architecture level for assembler files in order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

---
 arch/arm64/lib/crc32.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/lib/crc32.S +1 -1
index 243e107e9896..7420dea6afc1 100644
@@ -9,7 +9,7 @@
 #include <asm/alternative.h>
 #include <asm/assembler.h>
 
-	.cpu		generic+crc
+	.arch_extension crc
 
 	.macro		__crc32, c
 	cmp		x2, #16
Signature · 7 lines
2.20.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#1 lore raw

PATCH 2/2 arm64: crypto: Use .arch_extension

Currently when implementing optimised assembler routines using architecture extensions we override the base architecture along with enabling the new extensions, causing problems for in kernel BTI support which needs to raise the base architecture level for assembler files in order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

---
 arch/arm64/crypto/aes-ce-ccm-core.S   | 2 +-
 arch/arm64/crypto/aes-ce-core.S       | 2 +-
 arch/arm64/crypto/aes-ce.S            | 2 +-
 arch/arm64/crypto/crct10dif-ce-core.S | 2 +-
 arch/arm64/crypto/ghash-ce-core.S     | 2 +-
 arch/arm64/crypto/sha1-ce-core.S      | 2 +-
 arch/arm64/crypto/sha2-ce-core.S      | 2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
arch/arm64/crypto/aes-ce-ccm-core.S +1 -1
index 99a028e298ed..90fde12f8253 100644
@@ -9,7 +9,7 @@
 #include <asm/assembler.h>
 
 	.text
-	.arch	armv8-a+crypto
+	.arch_extension crypto
 
 	/*
 	 * void ce_aes_ccm_auth_data(u8 mac[], u8 const in[], u32 abytes,
arch/arm64/crypto/aes-ce-core.S +1 -1
index e52e13eb8fdb..4dbc0052ffbe 100644
@@ -6,7 +6,7 @@
 #include <linux/linkage.h>
 #include <asm/assembler.h>
 
-	.arch		armv8-a+crypto
+	.arch_extension crypto
 
 SYM_FUNC_START(__aes_ce_encrypt)
 	sub		w3, w3, #2
arch/arm64/crypto/aes-ce.S +1 -1
index 1dc5bbbfeed2..d57516308cf1 100644
@@ -12,7 +12,7 @@
 #define AES_FUNC_START(func)		SYM_FUNC_START(ce_ ## func)
 #define AES_FUNC_END(func)		SYM_FUNC_END(ce_ ## func)
 
-	.arch		armv8-a+crypto
+	.arch_extension crypto
 
 	xtsmask		.req	v16
 	cbciv		.req	v16
arch/arm64/crypto/crct10dif-ce-core.S +1 -1
index 5a95c2628fbf..c6b8b387f3bd 100644
@@ -66,7 +66,7 @@
 #include <asm/assembler.h>
 
 	.text
-	.cpu		generic+crypto
+	.arch_extension crypto
 
 	init_crc	.req	w19
 	buf		.req	x20
arch/arm64/crypto/ghash-ce-core.S +1 -1
index 6b958dcdf136..65ed5690735a 100644
@@ -57,7 +57,7 @@
 	HH34		.req	v19
 
 	.text
-	.arch		armv8-a+crypto
+	.arch_extension crypto
 
 	.macro		__pmull_p64, rd, rn, rm
 	pmull		\rd\().1q, \rn\().1d, \rm\().1d
arch/arm64/crypto/sha1-ce-core.S +1 -1
index 92d0d2753e81..8cfd30c5f605 100644
@@ -9,7 +9,7 @@
 #include <asm/assembler.h>
 
 	.text
-	.arch		armv8-a+crypto
+	.arch_extension crypto
 
 	k0		.req	v0
 	k1		.req	v1
arch/arm64/crypto/sha2-ce-core.S +1 -1
index 3f9d0f326987..a7ea4fc8d570 100644
@@ -9,7 +9,7 @@
 #include <asm/assembler.h>
 
 	.text
-	.arch		armv8-a+crypto
+	.arch_extension crypto
 
 	dga		.req	q20
 	dgav		.req	v20
Signature · 7 lines
2.20.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] arm64: crypto: Use .arch_extension

Quoted 10 lines · Mark Brown

Currently when implementing optimised assembler routines using architecture extensions we override the base architecture along with enabling the new extensions, causing problems for in kernel BTI support which needs to raise the base architecture level for assembler files in order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

It make sense (I got burnt by this with the MTE patches).

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#3 lore raw
In reply to Mark Brown
Quoted 10 lines · Mark Brown

Currently when implementing optimised assembler routines using architecture extensions we override the base architecture along with enabling the new extensions, causing problems for in kernel BTI support which needs to raise the base architecture level for assembler files in order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

I'll queue this through the arm64 tree. Thanks.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#4 lore raw
In reply to Mark Brown
Quoted 9 lines · Mark Brown

Currently when implementing optimised assembler routines using architecture extensions we override the base architecture along with enabling the new extensions, causing problems for in kernel BTI support which needs to raise the base architecture level for assembler files in order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

This is not 100% accurate. Support for .arch_extension was added to GAS/aarch64 much later, so we should at least double check that it works on the oldest binutils that we do support.

Quoted 20 lines
---
 arch/arm64/lib/crc32.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/lib/crc32.S +1 -2
index 243e107e9896..7420dea6afc1 100644
@@ -9,7 +9,7 @@
 #include <asm/alternative.h>
 #include <asm/assembler.h>
 
-       .cpu            generic+crc
+       .arch_extension crc
 
        .macro          __crc32, c
        cmp             x2, #16
--
Quoted 2 lines

2.20.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#5 lore raw
Quoted 10 lines · Ard Biesheuvel
Quoted 4 lines · Mark Brown

order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

This is not 100% accurate. Support for .arch_extension was added to GAS/aarch64 much later, so we should at least double check that it works on the oldest binutils that we do support.

Ah, OK - the information I figured out from history was misleading sorry.

We've already got quite a lot of usages of .arch_extension in the kernel for arm and a couple for arm64 (one in TF and another for LSE). It looks like the feature was added in binutils 2.26 which is newer than the current advertised minimum binutils version of 2.21 but dates from 2016 (the code was added in 2014 and looks like it might've appeared in downstream releases earlier) so is pretty old in arm64 terms. If that's not OK I've got an open coded version for BTI that does this with macros but it's obviously not as nice.

I do wish the binutils docs included information on when features were added, it'd make life easier :/

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw
Quoted 13 lines · Mark Brown
Quoted 10 lines · Ard Biesheuvel
Quoted 4 lines · Mark Brown

order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

This is not 100% accurate. Support for .arch_extension was added to GAS/aarch64 much later, so we should at least double check that it works on the oldest binutils that we do support.

Quoted 5 lines

Ah, OK - the information I figured out from history was misleading sorry.

We've already got quite a lot of usages of .arch_extension in the kernel for arm and a couple for arm64 (one in TF and another for LSE).

ARM had support for this way before it was added to AArch64 as well. In the LSE case, it doesn't matter since LSE itself was not implemented by the assembler before that. For other things, we should really avoid .arch_extension as long as we still support binutils < 2.26

Quoted 10 lines

It
looks like the feature was added in binutils 2.26 which is newer than the current advertised minimum binutils version of 2.21 but dates from 2016 (the code was added in 2014 and looks like it might've appeared in downstream releases earlier) so is pretty old in arm64 terms. If that's not OK I've got an open coded version for BTI that does this with macros but it's obviously not as nice.

I do wish the binutils docs included information on when features were added, it'd make life easier :/

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#7 lore raw
Quoted 17 lines · Ard Biesheuvel
Quoted 16 lines · Mark Brown
Quoted 10 lines · Ard Biesheuvel
Quoted 4 lines · Mark Brown

order to generate BTI landing pads. We did this due to a lack of support for the .arch_extension gas feature in older versions of the clang built in assembler but since current versions of clang now have support for .arch_extension we can use that.

This is not 100% accurate. Support for .arch_extension was added to GAS/aarch64 much later, so we should at least double check that it works on the oldest binutils that we do support.

Ah, OK - the information I figured out from history was misleading sorry.

Quoted 8 lines
Quoted 2 lines

We've already got quite a lot of usages of .arch_extension in the kernel for arm and a couple for arm64 (one in TF and another for LSE).

ARM had support for this way before it was added to AArch64 as well. In the LSE case, it doesn't matter since LSE itself was not implemented by the assembler before that. For other things, we should really avoid .arch_extension as long as we still support binutils < 2.26

Good point. So we can add .arch_extension for new features which are already dependent on newer gas options.

I'll drop this patch for now but we should try to find a solution because of the overriding effect of .arch. In self-contained .S files (like crypto) that's not an issue but once we start adding more architecture feature in a single file, things will get more complicated.

Signature · 6 lines
Catalin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#8 lore raw
Quoted 4 lines · Catalin Marinas

I'll drop this patch for now but we should try to find a solution because of the overriding effect of .arch. In self-contained .S files (like crypto) that's not an issue but once we start adding more architecture feature in a single file, things will get more complicated.

It's fine I think, you can open code .arch_extension in the assembler.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel