Remove unused error return from API that cannot fail
No implementation of fpu_kern_enter() can fail, and it was causing needless error checking boilerplate and confusion. Change the return code to void to match reality. (This trivial change took nine days to land because of the commit hook on sys/dev/random. Please consider removing the hook or otherwise lowering the bar -- secteam never seems to have free time to review patches.) Reported by: Lachlan McIlroy <Lachlan.McIlroy AT isilon.com> Reviewed by: delphij Approved by: secteam (delphij) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14380
This commit is contained in:
parent
5e246cb89b
commit
849ce31a82
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329878
@ -965,7 +965,7 @@ fpu_kern_ctx_savefpu(struct fpu_kern_ctx *ctx)
|
|||||||
return ((struct savefpu *)p);
|
return ((struct savefpu *)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
||||||
{
|
{
|
||||||
struct pcb *pcb;
|
struct pcb *pcb;
|
||||||
@ -997,11 +997,11 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
|||||||
fpurestore(fpu_initialstate);
|
fpurestore(fpu_initialstate);
|
||||||
set_pcb_flags(pcb, PCB_KERNFPU | PCB_FPUNOSAVE |
|
set_pcb_flags(pcb, PCB_KERNFPU | PCB_FPUNOSAVE |
|
||||||
PCB_FPUINITDONE);
|
PCB_FPUINITDONE);
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
|
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
|
||||||
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
|
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
|
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
|
||||||
get_pcb_user_save_pcb(pcb), ("mangled pcb_save"));
|
get_pcb_user_save_pcb(pcb), ("mangled pcb_save"));
|
||||||
@ -1013,7 +1013,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
|||||||
pcb->pcb_save = fpu_kern_ctx_savefpu(ctx);
|
pcb->pcb_save = fpu_kern_ctx_savefpu(ctx);
|
||||||
set_pcb_flags(pcb, PCB_KERNFPU);
|
set_pcb_flags(pcb, PCB_KERNFPU);
|
||||||
clear_pcb_flags(pcb, PCB_FPUINITDONE);
|
clear_pcb_flags(pcb, PCB_FPUINITDONE);
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -72,7 +72,7 @@ int fputrap_x87(void);
|
|||||||
void fpuuserinited(struct thread *td);
|
void fpuuserinited(struct thread *td);
|
||||||
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
|
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
|
||||||
void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
|
void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
|
||||||
int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
|
void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
|
||||||
u_int flags);
|
u_int flags);
|
||||||
int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
|
int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
|
||||||
int fpu_kern_thread(u_int flags);
|
int fpu_kern_thread(u_int flags);
|
||||||
|
@ -256,7 +256,7 @@ fpu_kern_free_ctx(struct fpu_kern_ctx *ctx)
|
|||||||
free(ctx, M_FPUKERN_CTX);
|
free(ctx, M_FPUKERN_CTX);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
||||||
{
|
{
|
||||||
struct pcb *pcb;
|
struct pcb *pcb;
|
||||||
@ -279,12 +279,12 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
|||||||
vfp_enable();
|
vfp_enable();
|
||||||
pcb->pcb_fpflags |= PCB_FP_KERN | PCB_FP_NOSAVE |
|
pcb->pcb_fpflags |= PCB_FP_KERN | PCB_FP_NOSAVE |
|
||||||
PCB_FP_STARTED;
|
PCB_FP_STARTED;
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
|
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
|
||||||
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
|
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Check either we are already using the VFP in the kernel, or
|
* Check either we are already using the VFP in the kernel, or
|
||||||
@ -300,7 +300,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
|||||||
pcb->pcb_fpflags |= PCB_FP_KERN;
|
pcb->pcb_fpflags |= PCB_FP_KERN;
|
||||||
pcb->pcb_fpflags &= ~PCB_FP_STARTED;
|
pcb->pcb_fpflags &= ~PCB_FP_STARTED;
|
||||||
|
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -60,7 +60,7 @@ struct fpu_kern_ctx;
|
|||||||
|
|
||||||
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int);
|
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int);
|
||||||
void fpu_kern_free_ctx(struct fpu_kern_ctx *);
|
void fpu_kern_free_ctx(struct fpu_kern_ctx *);
|
||||||
int fpu_kern_enter(struct thread *, struct fpu_kern_ctx *, u_int);
|
void fpu_kern_enter(struct thread *, struct fpu_kern_ctx *, u_int);
|
||||||
int fpu_kern_leave(struct thread *, struct fpu_kern_ctx *);
|
int fpu_kern_leave(struct thread *, struct fpu_kern_ctx *);
|
||||||
int fpu_kern_thread(u_int);
|
int fpu_kern_thread(u_int);
|
||||||
int is_fpu_kern_thread(u_int);
|
int is_fpu_kern_thread(u_int);
|
||||||
|
@ -577,10 +577,8 @@ aesni_cipher_setup(struct aesni_session *ses, struct cryptoini *encini,
|
|||||||
kt = is_fpu_kern_thread(0) || (encini == NULL);
|
kt = is_fpu_kern_thread(0) || (encini == NULL);
|
||||||
if (!kt) {
|
if (!kt) {
|
||||||
ACQUIRE_CTX(ctxidx, ctx);
|
ACQUIRE_CTX(ctxidx, ctx);
|
||||||
error = fpu_kern_enter(curthread, ctx,
|
fpu_kern_enter(curthread, ctx,
|
||||||
FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
||||||
if (error != 0)
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error = 0;
|
error = 0;
|
||||||
@ -590,7 +588,6 @@ aesni_cipher_setup(struct aesni_session *ses, struct cryptoini *encini,
|
|||||||
|
|
||||||
if (!kt) {
|
if (!kt) {
|
||||||
fpu_kern_leave(curthread, ctx);
|
fpu_kern_leave(curthread, ctx);
|
||||||
out:
|
|
||||||
RELEASE_CTX(ctxidx, ctx);
|
RELEASE_CTX(ctxidx, ctx);
|
||||||
}
|
}
|
||||||
return (error);
|
return (error);
|
||||||
@ -730,10 +727,8 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
|
|||||||
kt = is_fpu_kern_thread(0);
|
kt = is_fpu_kern_thread(0);
|
||||||
if (!kt) {
|
if (!kt) {
|
||||||
ACQUIRE_CTX(ctxidx, ctx);
|
ACQUIRE_CTX(ctxidx, ctx);
|
||||||
error = fpu_kern_enter(curthread, ctx,
|
fpu_kern_enter(curthread, ctx,
|
||||||
FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
||||||
if (error != 0)
|
|
||||||
goto out2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do work */
|
/* Do work */
|
||||||
@ -761,7 +756,6 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
|
|||||||
out:
|
out:
|
||||||
if (!kt) {
|
if (!kt) {
|
||||||
fpu_kern_leave(curthread, ctx);
|
fpu_kern_leave(curthread, ctx);
|
||||||
out2:
|
|
||||||
RELEASE_CTX(ctxidx, ctx);
|
RELEASE_CTX(ctxidx, ctx);
|
||||||
}
|
}
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -467,7 +467,7 @@ armv8_crypto_cipher_process(struct armv8_crypto_session *ses,
|
|||||||
struct fpu_kern_ctx *ctx;
|
struct fpu_kern_ctx *ctx;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
uint8_t iv[AES_BLOCK_LEN];
|
uint8_t iv[AES_BLOCK_LEN];
|
||||||
int allocated, error, i;
|
int allocated, i;
|
||||||
int encflag, ivlen;
|
int encflag, ivlen;
|
||||||
int kt;
|
int kt;
|
||||||
|
|
||||||
@ -477,15 +477,11 @@ armv8_crypto_cipher_process(struct armv8_crypto_session *ses,
|
|||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
|
||||||
error = 0;
|
|
||||||
|
|
||||||
kt = is_fpu_kern_thread(0);
|
kt = is_fpu_kern_thread(0);
|
||||||
if (!kt) {
|
if (!kt) {
|
||||||
AQUIRE_CTX(i, ctx);
|
AQUIRE_CTX(i, ctx);
|
||||||
error = fpu_kern_enter(curthread, ctx,
|
fpu_kern_enter(curthread, ctx,
|
||||||
FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
||||||
if (error != 0)
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((enccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0) {
|
if ((enccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0) {
|
||||||
@ -534,14 +530,13 @@ armv8_crypto_cipher_process(struct armv8_crypto_session *ses,
|
|||||||
|
|
||||||
if (!kt) {
|
if (!kt) {
|
||||||
fpu_kern_leave(curthread, ctx);
|
fpu_kern_leave(curthread, ctx);
|
||||||
out:
|
|
||||||
RELEASE_CTX(i, ctx);
|
RELEASE_CTX(i, ctx);
|
||||||
}
|
}
|
||||||
if (allocated) {
|
if (allocated) {
|
||||||
bzero(buf, enccrd->crd_len);
|
bzero(buf, enccrd->crd_len);
|
||||||
free(buf, M_ARMV8_CRYPTO);
|
free(buf, M_ARMV8_CRYPTO);
|
||||||
}
|
}
|
||||||
return (error);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t armv8_crypto_methods[] = {
|
static device_method_t armv8_crypto_methods[] = {
|
||||||
|
@ -246,12 +246,10 @@ padlock_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri)
|
|||||||
|
|
||||||
if (macini != NULL) {
|
if (macini != NULL) {
|
||||||
td = curthread;
|
td = curthread;
|
||||||
error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL |
|
fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL |
|
||||||
FPU_KERN_KTHR);
|
FPU_KERN_KTHR);
|
||||||
if (error == 0) {
|
error = padlock_hash_setup(ses, macini);
|
||||||
error = padlock_hash_setup(ses, macini);
|
fpu_kern_leave(td, ses->ses_fpu_ctx);
|
||||||
fpu_kern_leave(td, ses->ses_fpu_ctx);
|
|
||||||
}
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
padlock_freesession_one(sc, ses, 0);
|
padlock_freesession_one(sc, ses, 0);
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -205,7 +205,7 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
|
|||||||
struct thread *td;
|
struct thread *td;
|
||||||
u_char *buf, *abuf;
|
u_char *buf, *abuf;
|
||||||
uint32_t *key;
|
uint32_t *key;
|
||||||
int allocated, error;
|
int allocated;
|
||||||
|
|
||||||
buf = padlock_cipher_alloc(enccrd, crp, &allocated);
|
buf = padlock_cipher_alloc(enccrd, crp, &allocated);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
@ -250,10 +250,7 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
td = curthread;
|
td = curthread;
|
||||||
error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL |
|
fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
||||||
FPU_KERN_KTHR);
|
|
||||||
if (error != 0)
|
|
||||||
goto out;
|
|
||||||
padlock_cbc(abuf, abuf, enccrd->crd_len / AES_BLOCK_LEN, key, cw,
|
padlock_cbc(abuf, abuf, enccrd->crd_len / AES_BLOCK_LEN, key, cw,
|
||||||
ses->ses_iv);
|
ses->ses_iv);
|
||||||
fpu_kern_leave(td, ses->ses_fpu_ctx);
|
fpu_kern_leave(td, ses->ses_fpu_ctx);
|
||||||
@ -270,10 +267,9 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
|
|||||||
AES_BLOCK_LEN, ses->ses_iv);
|
AES_BLOCK_LEN, ses->ses_iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
if (allocated) {
|
if (allocated) {
|
||||||
bzero(buf, enccrd->crd_len + 16);
|
bzero(buf, enccrd->crd_len + 16);
|
||||||
free(buf, M_PADLOCK);
|
free(buf, M_PADLOCK);
|
||||||
}
|
}
|
||||||
return (error);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -377,10 +377,7 @@ padlock_hash_process(struct padlock_session *ses, struct cryptodesc *maccrd,
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
td = curthread;
|
td = curthread;
|
||||||
error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL |
|
fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL | FPU_KERN_KTHR);
|
||||||
FPU_KERN_KTHR);
|
|
||||||
if (error != 0)
|
|
||||||
return (error);
|
|
||||||
if ((maccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0)
|
if ((maccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0)
|
||||||
padlock_hash_key_setup(ses, maccrd->crd_key, maccrd->crd_klen);
|
padlock_hash_key_setup(ses, maccrd->crd_key, maccrd->crd_klen);
|
||||||
|
|
||||||
|
@ -194,7 +194,6 @@ efi_enter(void)
|
|||||||
{
|
{
|
||||||
struct thread *td;
|
struct thread *td;
|
||||||
pmap_t curpmap;
|
pmap_t curpmap;
|
||||||
int error;
|
|
||||||
|
|
||||||
if (efi_runtime == NULL)
|
if (efi_runtime == NULL)
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
@ -202,12 +201,7 @@ efi_enter(void)
|
|||||||
curpmap = &td->td_proc->p_vmspace->vm_pmap;
|
curpmap = &td->td_proc->p_vmspace->vm_pmap;
|
||||||
PMAP_LOCK(curpmap);
|
PMAP_LOCK(curpmap);
|
||||||
mtx_lock(&efi_lock);
|
mtx_lock(&efi_lock);
|
||||||
error = fpu_kern_enter(td, NULL, FPU_KERN_NOCTX);
|
fpu_kern_enter(td, NULL, FPU_KERN_NOCTX);
|
||||||
if (error != 0) {
|
|
||||||
PMAP_UNLOCK(curpmap);
|
|
||||||
return (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (efi_arch_enter());
|
return (efi_arch_enter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,17 +101,14 @@ random_nehemiah_read(void *buf, u_int c)
|
|||||||
size_t count, ret;
|
size_t count, ret;
|
||||||
uint64_t tmp;
|
uint64_t tmp;
|
||||||
|
|
||||||
if ((fpu_kern_enter(curthread, fpu_ctx_save, FPU_KERN_NORMAL) == 0)) {
|
fpu_kern_enter(curthread, fpu_ctx_save, FPU_KERN_NORMAL);
|
||||||
b = buf;
|
b = buf;
|
||||||
for (count = c; count > 0; count -= ret) {
|
for (count = c; count > 0; count -= ret) {
|
||||||
ret = MIN(VIA_RNG_store(&tmp), count);
|
ret = MIN(VIA_RNG_store(&tmp), count);
|
||||||
memcpy(b, &tmp, ret);
|
memcpy(b, &tmp, ret);
|
||||||
b += ret;
|
b += ret;
|
||||||
}
|
|
||||||
fpu_kern_leave(curthread, fpu_ctx_save);
|
|
||||||
}
|
}
|
||||||
else
|
fpu_kern_leave(curthread, fpu_ctx_save);
|
||||||
c = 0;
|
|
||||||
|
|
||||||
return (c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
@ -1325,7 +1325,7 @@ fpu_kern_ctx_savefpu(struct fpu_kern_ctx *ctx)
|
|||||||
return ((union savefpu *)p);
|
return ((union savefpu *)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
||||||
{
|
{
|
||||||
struct pcb *pcb;
|
struct pcb *pcb;
|
||||||
@ -1334,7 +1334,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
|||||||
|
|
||||||
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
|
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
|
||||||
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
|
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
pcb = td->td_pcb;
|
pcb = td->td_pcb;
|
||||||
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
|
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
|
||||||
@ -1347,7 +1347,7 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
|
|||||||
pcb->pcb_save = fpu_kern_ctx_savefpu(ctx);
|
pcb->pcb_save = fpu_kern_ctx_savefpu(ctx);
|
||||||
pcb->pcb_flags |= PCB_KERNNPX;
|
pcb->pcb_flags |= PCB_KERNNPX;
|
||||||
pcb->pcb_flags &= ~PCB_NPXINITDONE;
|
pcb->pcb_flags &= ~PCB_NPXINITDONE;
|
||||||
return (0);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -76,7 +76,7 @@ void npx_set_fpregs_xmm(struct save87 *, struct savexmm *);
|
|||||||
|
|
||||||
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
|
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
|
||||||
void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
|
void fpu_kern_free_ctx(struct fpu_kern_ctx *ctx);
|
||||||
int fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
|
void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx,
|
||||||
u_int flags);
|
u_int flags);
|
||||||
int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
|
int fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx);
|
||||||
int fpu_kern_thread(u_int flags);
|
int fpu_kern_thread(u_int flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user