Module Name: src Committed By: riastradh Date: Sat Aug 1 22:30:57 UTC 2020
Modified Files: src/sys/rump/librump/rumpkern: threads.c Log Message: Define kthread_fpu_enter/exit for rump. XXX Not 100% sure that it's safe to touch curlwp->l_flag in this context, but this change will make progress, at least. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/rump/librump/rumpkern/threads.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/rump/librump/rumpkern/threads.c diff -u src/sys/rump/librump/rumpkern/threads.c:1.26 src/sys/rump/librump/rumpkern/threads.c:1.27 --- src/sys/rump/librump/rumpkern/threads.c:1.26 Fri Apr 21 19:16:10 2017 +++ src/sys/rump/librump/rumpkern/threads.c Sat Aug 1 22:30:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: threads.c,v 1.26 2017/04/21 19:16:10 kamil Exp $ */ +/* $NetBSD: threads.c,v 1.27 2020/08/01 22:30:57 riastradh Exp $ */ /* * Copyright (c) 2007-2009 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.26 2017/04/21 19:16:10 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: threads.c,v 1.27 2020/08/01 22:30:57 riastradh Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -247,6 +247,32 @@ kthread_join(struct lwp *l) return rv; } +int +kthread_fpu_enter(void) +{ + struct lwp *l = curlwp; + int s; + + KASSERTMSG(l->l_flag & LW_SYSTEM, + "%s is allowed only in kthreads", __func__); + s = l->l_flag & LW_SYSTEM_FPU; + l->l_flag |= LW_SYSTEM_FPU; + + return s; +} + +void +kthread_fpu_exit(int s) +{ + struct lwp *l = curlwp; + + KASSERT(s == (s & LW_SYSTEM_FPU)); + KASSERTMSG(l->l_flag & LW_SYSTEM, + "%s is allowed only in kthreads", __func__); + KASSERT(l->l_flag & LW_SYSTEM_FPU); + l->l_flag ^= s ^ LW_SYSTEM_FPU; +} + /* * Create a non-kernel thread that is scheduled by a rump kernel hypercall. *