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

Open
#6,150 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@tesch1 is already working on this.

Since Oct 21, 2026.

  • #6153 by @tesch1 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c

Research direction

Start by reading kernel/arm64/sme2_gemm_detect.h and inspect how s2_usable() evaluates the SME2 check and svcntsw(). The issue points to disassembly of sme_sgemm_kernel.o as evidence of the SIGILL; compare that behavior with the fix described in linked pull request #6153. Done means s2_usable() does not execute RDSVL when SME2 is absent.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C
Stars
7.7k
Forks
1.7k
Avg merge
1d 1m
Merged PRs (30d)
61

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenMathLib/OpenBLAS

All issues in OpenMathLib/OpenBLAS

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.