mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-08-10 19:21:23 +02:00
Every fpr backend except the default integer-emulated one runs on the FP/vector register file: WOLFSSL_FALCON_FPR_DOUBLE (C double -> SSE) and the generated x86-64 fpr asm use xmm, and the folded AVX2/NEON FFT uses ymm / Q registers. All of them must save and restore those registers around the work that uses fpr -- kernel FPU state under WOLFSSL_LINUXKM and the DEBUG_VECTOR_REGISTER_ACCESS check. A single gate, WOLFSSL_FALCON_SAVE_VREGS (set for FPR_DOUBLE, FPR_ASM, FFT_AVX2 or FFT_NEON), drives the wrapping so the emulated integer build stays untouched. The saves sit at the two int-returning orchestrators (falcon_native_make_key around falcon_keygen; falcon_native_sign_msg around the tree build + ffSampling loop) and read like every other fallible step: "ret = SAVE_VECTOR_REGISTERS2(); if (ret != 0) goto out;", propagating a save failure through normal cleanup. Nested saves inside SHAKE256 are reference-counted. Verified with DEBUG_VECTOR_REGISTER_ACCESS (+ABORT_ON_FAIL and fuzzing) on the double, asm and avx2 backends: balanced counts, no unsaved FP/SIMD, graceful failure path.