static void pefs_aesni_uninit(struct pefs_alg *pa) { struct fpu_kern_ctx *fpu_ctx; u_int cpuid; CPU_FOREACH(cpuid) { fpu_ctx = (void *)atomic_swap_ptr( (volatile void *)DPCPU_ID_PTR(cpuid, pefs_aesni_fpu), (uintptr_t)NULL); if (fpu_ctx != NULL) fpu_kern_free_ctx(fpu_ctx); } }
static int pefs_aesni_keysetup(const struct pefs_session *xses, struct pefs_ctx *xctx, const uint8_t *key, uint32_t keybits) { const struct pefs_aesni_ses *ses = &xses->o.ps_aesni; struct pefs_aesni_ctx *ctx = &xctx->o.pctx_aesni; struct fpu_kern_ctx *tmpctx = NULL; switch (keybits) { case 128: ctx->rounds = AES128_ROUNDS; break; case 192: ctx->rounds = AES192_ROUNDS; break; case 256: ctx->rounds = AES256_ROUNDS; break; default: printf("pefs: AESNI: invalid key length: %d", keybits); return (EINVAL); } if (ses->fpu_saved < 0) { tmpctx = fpu_kern_alloc_ctx(FPU_KERN_NORMAL); if (tmpctx == NULL) return (ENOMEM); fpu_kern_enter(curthread, tmpctx, FPU_KERN_NORMAL); } aesni_set_enckey(key, ctx->enc_schedule, ctx->rounds); aesni_set_deckey(ctx->enc_schedule, ctx->dec_schedule, ctx->rounds); rijndael_set_key(&ctx->sw, key, keybits); if (tmpctx != NULL) { fpu_kern_leave(curthread, tmpctx); fpu_kern_free_ctx(tmpctx); } return (0); }
int windrv_libfini(void) { struct drvdb_ent *d; #ifdef __amd64__ struct fpu_cc_ent *ent; #endif mtx_lock(&drvdb_mtx); while(STAILQ_FIRST(&drvdb_head) != NULL) { d = STAILQ_FIRST(&drvdb_head); STAILQ_REMOVE_HEAD(&drvdb_head, link); free(d, M_DEVBUF); } mtx_unlock(&drvdb_mtx); RtlFreeUnicodeString(&fake_pci_driver.dro_drivername); RtlFreeUnicodeString(&fake_pccard_driver.dro_drivername); mtx_destroy(&drvdb_mtx); #ifdef __i386__ smp_rendezvous(NULL, x86_oldldt, NULL, NULL); ExFreePool(my_tids); #endif #ifdef __amd64__ while ((ent = LIST_FIRST(&fpu_free_head)) != NULL) { LIST_REMOVE(ent, entries); fpu_kern_free_ctx(ent->ctx); free(ent, M_DEVBUF); } mtx_destroy(&fpu_free_mtx); ent = LIST_FIRST(&fpu_busy_head); KASSERT(ent == NULL, ("busy fpu context list is not empty")); mtx_destroy(&fpu_busy_mtx); #endif return (0); }
static void random_nehemiah_deinit(void) { fpu_kern_free_ctx(fpu_ctx_save); }