Skip to content

20260821-linuxkm-WC_SVR_USE_NATIVE_REG_BUFS - #11240

Open
douzzer wants to merge 3 commits into
wolfSSL:masterfrom
douzzer:20260821-linuxkm-WC_SVR_USE_NATIVE_REG_BUFS
Open

20260821-linuxkm-WC_SVR_USE_NATIVE_REG_BUFS#11240
douzzer wants to merge 3 commits into
wolfSSL:masterfrom
douzzer:20260821-linuxkm-WC_SVR_USE_NATIVE_REG_BUFS

Conversation

@douzzer

@douzzer douzzer commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

linuxkm/x86_vector_register_glue.c: add WC_SVR_USE_NATIVE_REG_BUFS: per-CPU
native vector register save buffers, serving hardirq and softirq contexts
where kernel_fpu_begin() is unusable.

previously these contexts were refused (WC_ACCEL_INHIBIT_E): hardirq
outright, softirq whenever !may_use_simd() (pre-6.15, a softirq
interrupting a foreign kernel_fpu section). an exact save/compute/restore
cycle is invisible to the interrupted context and to kernel FPU
bookkeeping, and run-to-completion freezes the blocking condition beneath
the section, so both classes are natively serviceable.

  • per-CPU {softirq, hardirq} state, each {depth, pin_preempt, save_area};
    xsave64/xrstor64 with RFBM 0xe7 & XCR0 (fxsave64 fallback), plain XSAVE
    only; feature detection by direct CPUID/XGETBV, independent of kernel
    cpufeature machinery.

  • recursion is a per-(CPU, class) depth count -- save on the 0->1 edge,
    restore on 1->0; softirq sections hold preempt_disable() (load-bearing
    on PREEMPT_RT).

  • hardirq serves plain saves; softirq serves plain and _MAYBE_INHIBIT
    (its legacy short-circuit is bypassed when native is ready); _INHIBIT,
    hardirq _MAYBE, and NMI keep refusal semantics; task context is
    untouched.

  • wc_svr_native_init() activates in place from
    wc_linuxkm_allocate_svr_states() in any context but NMI -- the FIPS
    pre-Init lazy allocation arrives inside the outermost save's own
    bracket, and wolfCrypt_Init() has been observed with irqs disabled. a
    self-bracketed register round-trip selftest gates wc_svr_native_ready;
    on any failure the long-standing refusal semantics remain fully in
    force.

  • wc_linuxkm_svr_native_is_ready(): runtime readiness accessor for policy
    decisions elsewhere (e.g. the FIPS<v7 default-bank NO_VECTOR_OPS pin).

  • WOLFSSL_LINUXKM_VERBOSE_DEBUG: split the softirq WC_ACCEL_INHIBIT_E
    counter into per-class counters (softirq, hardirq, NMI, other),
    reported at module shutdown.

in non-VERBOSE builds with WC_SVR_DONT_USE_NATIVE_REG_BUFS (or in non-SVR
builds), generated object code is byte-identical to the previous revision.

also add linuxkm/simd_hammer/, a stress testing tool for kernel FPU/SIMD context handling.

tested with

wolfssl-multi-test.sh ...
check-source-text
'.*dev.*cust-kern.*'
'linuxkm-legacy-.*'
quantum-safe-wolfssl-all-crypto-only-intelasm-sp-asm-sp-fips-dev-linuxkm-next-insmod
quantum-safe-wolfssl-all-crypto-only-intelasm-sp-asm-fips-dev-linuxkm-next-clang-tidy

…er-CPU

native vector register save buffers, serving hardirq and softirq contexts
where kernel_fpu_begin() is unusable.

previously these contexts were refused (WC_ACCEL_INHIBIT_E): hardirq
outright, softirq whenever !may_use_simd() (pre-6.15, a softirq
interrupting a foreign kernel_fpu section).  an exact save/compute/restore
cycle is invisible to the interrupted context and to kernel FPU
bookkeeping, and run-to-completion freezes the blocking condition beneath
the section, so both classes are natively serviceable.

- per-CPU {softirq, hardirq} state, each {depth, pin_preempt, save_area};
  xsave64/xrstor64 with RFBM 0xe7 & XCR0 (fxsave64 fallback), plain XSAVE
  only; feature detection by direct CPUID/XGETBV, independent of kernel
  cpufeature machinery.

- recursion is a per-(CPU, class) depth count -- save on the 0->1 edge,
  restore on 1->0; softirq sections hold preempt_disable() (load-bearing
  on PREEMPT_RT).

- hardirq serves plain saves; softirq serves plain and _MAYBE_INHIBIT
  (its legacy short-circuit is bypassed when native is ready); _INHIBIT,
  hardirq _MAYBE, and NMI keep refusal semantics; task context is
  untouched.

- wc_svr_native_init() activates in place from
  wc_linuxkm_allocate_svr_states() in any context but NMI -- the FIPS
  pre-Init lazy allocation arrives inside the outermost save's own
  bracket, and wolfCrypt_Init() has been observed with irqs disabled.  a
  self-bracketed register round-trip selftest gates wc_svr_native_ready;
  on any failure the long-standing refusal semantics remain fully in
  force.

- wc_linuxkm_svr_native_is_ready(): runtime readiness accessor for policy
  decisions elsewhere (e.g. the FIPS<v7 default-bank NO_VECTOR_OPS pin).

- WOLFSSL_LINUXKM_VERBOSE_DEBUG: split the softirq WC_ACCEL_INHIBIT_E
  counter into per-class counters (softirq, hardirq, NMI, other),
  reported at module shutdown.

in non-VERBOSE builds with WC_SVR_DONT_USE_NATIVE_REG_BUFS (or in non-SVR
builds), generated object code is byte-identical to the previous revision.
@douzzer douzzer self-assigned this Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

@douzzer

douzzer commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

retest this please
(no logs)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant