Skip to content

bsdkm x86_vecreg: nest counter, and other improvements. - #10987

Merged
SparkiDev merged 1 commit into
wolfSSL:masterfrom
philljj:nest_counter
Jul 28, 2026
Merged

bsdkm x86_vecreg: nest counter, and other improvements.#10987
SparkiDev merged 1 commit into
wolfSSL:masterfrom
philljj:nest_counter

Conversation

@philljj

@philljj philljj commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Add a nesting counter max (WOLFKMOD_FPU_MAX_NEST 128) for fpu state management in freebsdkm, and a few small improvements.

Fixes F-655.

note: typical nesting values when running benchmark / wolfcrypt test with intel-asm are 2-3 at most. Anything much larger would indicate runaway behavior, like infinite looping, recursion, etc.

@philljj philljj self-assigned this Jul 23, 2026
Copilot AI review requested due to automatic review settings July 23, 2026 22:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the FreeBSD kernel-module vector/FPU state management helpers to better guard against runaway save/restore nesting and to slightly optimize error-path branching.

Changes:

  • Add WOLFKMOD_FPU_MAX_NEST and enforce an upper bound on fpu_states[].nest during nested wolfkmod_vecreg_save() calls.
  • Add __predict_false(...) annotations to several error checks to bias branch prediction toward the success path.
Comments suppressed due to low confidence (1)

bsdkm/x86_vecreg.c:197

  • On the error path after calling wolfkmod_fpu_kern_enter(), the function returns EINVAL without calling wolfkmod_fpu_kern_leave(). That can leave PCB_KERNFPU set and keep migration/preemption restrictions in effect for the current thread, potentially causing hard-to-debug scheduler/FPU state issues.
        if (__predict_false(fpu_states[PCPU_GET(cpuid)].nest != 0 ||
            td_tid != 0)) {
            printf("error: wolfkmod_fpu_kern_enter() with nest: %d, %d\n",
                   fpu_states[PCPU_GET(cpuid)].nest, td_tid);
            return (EINVAL);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bsdkm/x86_vecreg.c
@philljj

philljj commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Retest this please.

java.io.IOException: Unexpected EOF.

@philljj philljj assigned wolfSSL-Bot and unassigned philljj Jul 24, 2026
@SparkiDev SparkiDev self-assigned this Jul 27, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #10987

Scan targets checked: bsdkm-bugs, bsdkm-src

No new issues found in the changed files. ✅

@SparkiDev
SparkiDev merged commit 2ac1991 into wolfSSL:master Jul 28, 2026
340 of 341 checks passed
@philljj
philljj deleted the nest_counter branch July 28, 2026 02:15
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.

5 participants