Skip to content

Commit 1ef0761

Browse files
committed
bsdkm: update readme, cleanup overlong lines.
1 parent 10bd57c commit 1ef0761

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

bsdkm/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Supported features:
1010
- crypto acceleration: AES-NI, AVX, etc.
1111

1212
Planned features:
13-
- kernel opencrypto driver registration.
13+
- kernel opencrypto driver registration (supported for internal testing presently).
1414
- full wolfSSL in kernel (kernel TLS).
1515

1616
## Building and Installing
@@ -44,10 +44,12 @@ sudo kldunload libwolfssl
4444

4545
### options
4646

47-
| freebsdkm option | description |
48-
| :------------------------------- | :--------------------------------------- |
49-
| --with-bsd-export-syms=LIST | Export list of symbols as global. <br>. Options are 'all', 'none', or <br> comma separated list of symbols. |
50-
| --with-kernel-source=PATH | Path to kernel tree root (default `/usr/src/sys`) |
47+
| freebsdkm option | description |
48+
| :--------------------------------- | :--------------------------------------- |
49+
| --with-bsd-export-syms=LIST | Export list of symbols as global. <br>. Options are 'all', 'none', or <br> comma separated list of symbols. |
50+
| --with-kernel-source=PATH | Path to kernel tree root (default `/usr/src/sys`) |
51+
| --enable-kernel-benchmarks | Run wolfcrypt benchmark at module load |
52+
| --enable-freebsdkm-crypto-register | Register with the FreeBSD kernel opencrypto <br>framework (preliminary, for testing) |
5153

5254
### FIPS
5355

bsdkm/x86_vecreg.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,14 @@ int wolfkmod_vecreg_save(int flags_unused)
142142
if (is_fpu_kern_thread(0)) {
143143
/* kernel fpu threads are special, do nothing. They own a
144144
* persistent, dedicated fpu context. */
145+
#if defined(WOLFSSL_BSDKM_FPU_DEBUG)
145146
printf("info: wolfkmod_vecreg_save: is fpu kern thread\n");
147+
#endif
146148
return (0);
147149
}
148150

149151
if (curthread->td_pcb->pcb_flags & PCB_KERNFPU) {
150-
/* fpu context already active. check td_tid and
152+
/* kern fpu is active for this thread. check td_tid and
151153
* increment nesting level. */
152154
lwpid_t td_tid = wolfkmod_fpu_get_tid();
153155
if (td_tid != curthread->td_tid) {
@@ -158,7 +160,7 @@ int wolfkmod_vecreg_save(int flags_unused)
158160
fpu_states[PCPU_GET(cpuid)].nest++;
159161
}
160162
else {
161-
/* fpu context not active, call fpu_kern_enter().
163+
/* kern fpu not active for this thread, call fpu_kern_enter().
162164
* after calling fpu_kern_enter():
163165
* - kernel fpu is enabled
164166
* - migration is disabled
@@ -190,14 +192,18 @@ void wolfkmod_vecreg_restore(void)
190192
if (is_fpu_kern_thread(0)) {
191193
/* kernel fpu threads are special, do nothing. They own a
192194
* persistent, dedicated fpu context. */
195+
#if defined(WOLFSSL_BSDKM_FPU_DEBUG)
193196
printf("info: wolfkmod_vecreg_restore: is fpu kern thread\n");
197+
#endif
194198
return;
195199
}
196200

197201
if (curthread->td_pcb->pcb_flags & PCB_KERNFPU) {
198-
if (fpu_states[PCPU_GET(cpuid)].td_tid != curthread->td_tid) {
199-
printf("error: wolfkmod_vecreg_restore: got tid = %d, expected %d\n",
200-
fpu_states[PCPU_GET(cpuid)].td_tid, curthread->td_tid);
202+
/* kern fpu is active for this thread. check tid and nesting level. */
203+
lwpid_t td_tid = wolfkmod_fpu_get_tid();
204+
if (td_tid != curthread->td_tid) {
205+
printf("error: wolfkmod_vecreg_restore: got tid = %d, "
206+
"expected %d\n", td_tid, curthread->td_tid);
201207
return;
202208
}
203209

@@ -206,7 +212,7 @@ void wolfkmod_vecreg_restore(void)
206212
fpu_states[PCPU_GET(cpuid)].nest--;
207213
}
208214

209-
/* if last level, zero the thread id and call fpu_kern_leave */
215+
/* if last level, zero the thread id then call fpu_kern_leave */
210216
if (fpu_states[PCPU_GET(cpuid)].nest == 0) {
211217
fpu_states[PCPU_GET(cpuid)].td_tid = 0;
212218
wolfkmod_fpu_kern_leave();

configure.ac

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -832,17 +832,12 @@ AC_ARG_WITH([bsd-export-syms],
832832

833833
if test "x$ENABLED_BSDKM" = "xyes"
834834
then
835-
#AX_SIMD_CC_COMPILER_FLAGS
836-
# wolfcrypt only for now.
835+
# note: bsdkm is wolfcrypt only for now.
837836
HAVE_KERNEL_MODE=yes
838837
KERNEL_MODE_DEFAULTS=yes
839838
ENABLED_NO_LIBRARY=yes
840839
ENABLED_BENCHMARK=no
841840

842-
# todo: remove, leaving for notes for now.
843-
#ENABLED_ASM=no
844-
#AM_CFLAGS="$AM_CFLAGS -DTFM_NO_ASM -DWOLFSSL_NO_ASM"
845-
846841
output_objdir="$(realpath "$output_objdir")/bsdkm"
847842

848843
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_BSDKM -DWC_SIPHASH_NO_ASM"
@@ -862,7 +857,6 @@ then
862857
fi
863858
AC_SUBST([KERNEL_ROOT])
864859
AC_SUBST([BSDKM_EXPORT_SYMS])
865-
866860
fi
867861

868862
if test "x$ENABLED_BSDKM_REGISTER" = "xyes"

wolfcrypt/benchmark/benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,7 @@ static WC_INLINE void bench_stats_start(int* count, double* start)
26852685

26862686
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS)
26872687
#define bench_stats_start(count, start) do { \
2688-
SAVE_VECTOR_REGISTERS(WOLFSSL_DEBUG_PRINTF( \
2688+
SAVE_VECTOR_REGISTERS(WOLFSSL_DEBUG_PRINTF( \
26892689
"ERROR: SAVE_VECTOR_REGISTERS failed for benchmark run."); \
26902690
return; ); \
26912691
bench_stats_start(count, start); \

0 commit comments

Comments
 (0)