Skip to content

VORTEXM4: s2_usable() runs RDSVL before the SME2 check (SIGILL without SME) #6150

Open

Description

@tesch1

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions