mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto
@ 2026-11-05 15:41 Emanuele Rocca
  2026-11-05 19:42 ` Eric Biggers
  2026-11-06  8:57 ` Ard Biesheuvel
  0 siblings, 2 replies; 4+ messages in thread
From: Emanuele Rocca @ 2026-11-05 15:41 UTC (permalink / raw)
  To: Eric Biggers; +Cc: Ard Biesheuvel, linux-crypto, linux-kernel

Instead of using ".cpu generic+crc+crypto", use ".arch_extension crc" and
".arch_extension crypto" to enable the required instructions.

The ".cpu generic+crc+crypto" directive replaces the assembler's current
feature set with generic+crc+crypto, dropping any other features that were
previously enabled, for example by -march or by a toolchain configured with
--with-arch=armv9-a. In contrast, ".arch_extension" enables the requested
extensions while preserving the current feature set.

This is not a functional change: crc32-core.S only uses base A64
instructions plus CRC32 and PMULL, which remain available, and BTI landing
pads are emitted as HINT instructions. However, using .arch_extension
avoids the pitfall of silently disabling features. See commit 9142c2f8f84b
("octeontx2: use arch_extension to enable LSE").

Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>
---
 lib/crc/arm64/crc32-core.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/crc/arm64/crc32-core.S b/lib/crc/arm64/crc32-core.S
index 49d02cc485b3..0877d07ed1bf 100644
--- a/lib/crc/arm64/crc32-core.S
+++ b/lib/crc/arm64/crc32-core.S
@@ -11,7 +11,8 @@
 #include <linux/linkage.h>
 #include <asm/assembler.h>
 
-	.cpu		generic+crc+crypto
+	.arch_extension	crc
+	.arch_extension	crypto
 
 	.macro		bitle, reg
 	.endm
-- 
2.55.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto
  2026-11-05 15:41 [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto Emanuele Rocca
@ 2026-11-05 19:42 ` Eric Biggers
  2026-11-06  8:16   ` Emanuele Rocca
  2026-11-06  8:57 ` Ard Biesheuvel
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Biggers @ 2026-11-05 19:42 UTC (permalink / raw)
  To: Emanuele Rocca; +Cc: Ard Biesheuvel, linux-crypto, linux-kernel

On Thu, Nov 05, 2026 at 03:41:45PM +0000, Emanuele Rocca wrote:
> Instead of using ".cpu generic+crc+crypto", use ".arch_extension crc" and
> ".arch_extension crypto" to enable the required instructions.
> 
> The ".cpu generic+crc+crypto" directive replaces the assembler's current
> feature set with generic+crc+crypto, dropping any other features that were
> previously enabled, for example by -march or by a toolchain configured with
> --with-arch=armv9-a. In contrast, ".arch_extension" enables the requested
> extensions while preserving the current feature set.
> 
> This is not a functional change: crc32-core.S only uses base A64
> instructions plus CRC32 and PMULL, which remain available, and BTI landing
> pads are emitted as HINT instructions. However, using .arch_extension
> avoids the pitfall of silently disabling features. See commit 9142c2f8f84b
> ("octeontx2: use arch_extension to enable LSE").
> 
> Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>

Thanks.  Just to confirm, all supported versions of binutils and clang
support this?  (As per Documentation/process/changes.rst, the kernel
currently supports binutils 2.30 and later, and clang 17.0.1 and later.)

A lot of the arm64 crypto code uses ".arch armv8-a+crypto".  Should
those be replaced with ".arch_extension	crypto" for the same reason?

- Eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto
  2026-11-05 19:42 ` Eric Biggers
@ 2026-11-06  8:16   ` Emanuele Rocca
  0 siblings, 0 replies; 4+ messages in thread
From: Emanuele Rocca @ 2026-11-06  8:16 UTC (permalink / raw)
  To: Eric Biggers; +Cc: Ard Biesheuvel, linux-crypto, linux-kernel

Hi Eric,

On 2026-11-05 07:42, Eric Biggers wrote:
> Thanks.  Just to confirm, all supported versions of binutils and clang
> support this?  (As per Documentation/process/changes.rst, the kernel
> currently supports binutils 2.30 and later, and clang 17.0.1 and later.)

Yes, binutils supports .arch_extension since 2.26:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ae527cd876fe35de72d876d3484e194ccc66232f

$ git tag --contains ae527cd876fe35de72d876d3484e194ccc66232f | head -1
binutils-2_26

clang added support in 8.0.0:
https://releases.llvm.org/8.0.0/docs/ReleaseNotes.html#changes-to-the-aarch64-target

> A lot of the arm64 crypto code uses ".arch armv8-a+crypto".  Should
> those be replaced with ".arch_extension	crypto" for the same reason?

I think so, yes. Let me look more closely, I'll send another series for
those if they need changing as well.

Thanks!
  Emanuele

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto
  2026-11-05 15:41 [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto Emanuele Rocca
  2026-11-05 19:42 ` Eric Biggers
@ 2026-11-06  8:57 ` Ard Biesheuvel
  1 sibling, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2026-11-06  8:57 UTC (permalink / raw)
  To: Emanuele Rocca, Eric Biggers; +Cc: linux-crypto, linux-kernel

Hello Emanuele,

On Thu, 5 Nov 2026, at 16:41, Emanuele Rocca wrote:
> Instead of using ".cpu generic+crc+crypto", use ".arch_extension crc" and
> ".arch_extension crypto" to enable the required instructions.
>
> The ".cpu generic+crc+crypto" directive replaces the assembler's current
> feature set with generic+crc+crypto, dropping any other features that were
> previously enabled, for example by -march or by a toolchain configured with
> --with-arch=armv9-a. In contrast, ".arch_extension" enables the requested
> extensions while preserving the current feature set.
>
> This is not a functional change: crc32-core.S only uses base A64
> instructions plus CRC32 and PMULL, which remain available, and BTI landing
> pads are emitted as HINT instructions. However, using .arch_extension
> avoids the pitfall of silently disabling features. See commit 9142c2f8f84b
> ("octeontx2: use arch_extension to enable LSE").
>

I don't mind the patch, but I will point out that issues such as these can
never occur in .S sources. The emitted instructions are always the same, and
the only reason we need the .arch is so that the assembler permits the use
of the special ones.

Commit 9142c2f8f84b is different because it uses .arch in inline asm, where
it switches the assembler into a different mode behind the back of the
compiler, leading it to reject instructions generated by the compiler.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-06  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 15:41 [PATCH] lib/crc: arm64: use .arch_extension to enable CRC and crypto Emanuele Rocca
2026-11-05 19:42 ` Eric Biggers
2026-11-06  8:16   ` Emanuele Rocca
2026-11-06  8:57 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®