Skip to content

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

Open
philljj wants to merge 1 commit into
wolfSSL:masterfrom
philljj:nest_counter
Open

bsdkm x86_vecreg: nest counter, and other improvements.#10987
philljj wants to merge 1 commit into
wolfSSL:masterfrom
philljj:nest_counter

Conversation

@philljj

@philljj philljj commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Description

Adding a nesting counter max for fpu state management in freebsdkm.

Testing

@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
Comment on lines +175 to +176
printf("error: wolfkmod_vecreg_save: excessive fpu nesting (%u)\n",
WOLFKMOD_FPU_MAX_NEST);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's fine. The point is we're over that high water mark which is very bad.

@philljj

philljj commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Retest this please.

java.io.IOException: Unexpected EOF.

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.

2 participants