summaryrefslogtreecommitdiffstats
path: root/sys/amd64/amd64/fpu.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-06-30 09:48:44 +0000
committerkib <kib@FreeBSD.org>2014-06-30 09:48:44 +0000
commitd02ef38799408e3a6c8914dd8899d6e33a18b99e (patch)
tree1cdbf0e90185182bff0bf7d098f7d52a156ffe79 /sys/amd64/amd64/fpu.c
parentff62446f9059b50fbd507dbd0d14404a62eb1691 (diff)
downloadFreeBSD-src-d02ef38799408e3a6c8914dd8899d6e33a18b99e.zip
FreeBSD-src-d02ef38799408e3a6c8914dd8899d6e33a18b99e.tar.gz
MFC r267767:
Add FPU_KERN_KTHR flag to fpu_kern_enter(9). Apply the flag to padlock(4) and aesni(4). In aesni_cipher_process(), do not leak FPU context state on error.
Diffstat (limited to 'sys/amd64/amd64/fpu.c')
-rw-r--r--sys/amd64/amd64/fpu.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index d2d506a..0f4b2b5 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -890,6 +890,7 @@ static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx",
"Kernel contexts for FPU state");
#define FPU_KERN_CTX_FPUINITDONE 0x01
+#define FPU_KERN_CTX_DUMMY 0x02 /* avoided save for the kern thread */
struct fpu_kern_ctx {
struct savefpu *prev;
@@ -933,6 +934,10 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags)
{
struct pcb *pcb;
+ if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
+ ctx->flags = FPU_KERN_CTX_DUMMY;
+ return (0);
+ }
pcb = td->td_pcb;
KASSERT(!PCB_USER_FPU(pcb) || pcb->pcb_save ==
get_pcb_user_save_pcb(pcb), ("mangled pcb_save"));
@@ -952,6 +957,9 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx)
{
struct pcb *pcb;
+ if (is_fpu_kern_thread(0) && (ctx->flags & FPU_KERN_CTX_DUMMY) != 0)
+ return (0);
+ KASSERT((ctx->flags & FPU_KERN_CTX_DUMMY) == 0, ("dummy ctx"));
pcb = td->td_pcb;
critical_enter();
if (curthread == PCPU_GET(fpcurthread))
OpenPOWER on IntegriCloud