You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VORTEXM4: s2_usable() runs RDSVL before the SME2 check (SIGILL without SME) #6150
s2_usable() in kernel/arm64/sme2_gemm_detect.h computes ok = sme2 && svcntsw() == 16;. Clang treats svcntsw() (RDSVL) as free of side effects and if-converts the expression, so RDSVL runs before the FEAT_SME2 result is tested. Disassembly of sme_sgemm_kernel.o (Apple clang 21):
bl _sysctlbyname
ldr w8, [sp, #0x8fc] ; FEAT_SME2 value
rdsvl x9, #0x1 ; runs whether or not SME is present
lsr x9, x9, #2
cmp x9, #0x10
cset w9, eq
cmp w8, #0x0
csel w8, wzr, w9, eq
On a CPU without SME this is SIGILL. A VORTEXM4 build is not meant to run on M1-M3, but before #6074 its level-3 routines still worked there on NEON kernels; now they reach the SME2 kernels' s2_usable() and crash. #6142 contains a fix (the vector length read in a separate noinline inline-asm function, called only when SME2 is present). That fix could also go in on its own, ahead of #6142.
Hmm. I'm not sure that this is an actual issue, nor a complete fix - a DYNAMIC_ARCH build isn't going to hit this predicament, and a dedicated build isn't expected to run on hardware that lacks the defining feature (SVE builds won't work on plain ARMV8-a, AVX512 builds won't work on Haswell or earlier). And on a host that does not support SME at all, there is no way back once it's clear that the kernel won't work - the only choice is between SME2 and SME (which I think does not even matter for the M4).
I do not think it has ever been possible to run a TARGET=VORTEXM4 build on M1-M3 and call SGEMM - it is simply that SSYMM, DGEMM etc. will have worked while there was still no SME kernel for them (and you'd probably still get away with calling only AXPY or DOT)
Agreed on both points. Without SME, a VORTEXM4 build also fails in the SME1 paths (sgemm_direct_arm64_sme1.c, and sme_[sd]gemm_kernel.c after the s2_usable() test), so the RDSVL order does not make it usable on M1-M3. With SME present, RDSVL is legal, so the early read does no harm, and DYNAMIC_ARCH picks the kernels from the CPU features. Closing this issue and #6153.
Activity
martin-frbg commentedon Nov 12, 2026
Hmm. I'm not sure that this is an actual issue, nor a complete fix - a DYNAMIC_ARCH build isn't going to hit this predicament, and a dedicated build isn't expected to run on hardware that lacks the defining feature (SVE builds won't work on plain ARMV8-a, AVX512 builds won't work on Haswell or earlier). And on a host that does not support SME at all, there is no way back once it's clear that the kernel won't work - the only choice is between SME2 and SME (which I think does not even matter for the M4).
I do not think it has ever been possible to run a TARGET=VORTEXM4 build on M1-M3 and call SGEMM - it is simply that SSYMM, DGEMM etc. will have worked while there was still no SME kernel for them (and you'd probably still get away with calling only AXPY or DOT)
tesch1 commentedon Nov 14, 2026
Agreed on both points. Without SME, a VORTEXM4 build also fails in the SME1 paths (
sgemm_direct_arm64_sme1.c, andsme_[sd]gemm_kernel.cafter thes2_usable()test), so the RDSVL order does not make it usable on M1-M3. With SME present, RDSVL is legal, so the early read does no harm, and DYNAMIC_ARCH picks the kernels from the CPU features. Closing this issue and #6153.