Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/aarch64/aarch64 Add kthread_fpu_enter/exit support ...
details: https://anonhg.NetBSD.org/src/rev/df66e6daacbf
branches: trunk
changeset: 974445:df66e6daacbf
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Aug 01 02:06:59 2020 +0000
description:
Add kthread_fpu_enter/exit support to aarch64.
diffstat:
sys/arch/aarch64/aarch64/fpu.c | 50 +++++++++++++++++++++++++++++++++++++---
sys/arch/aarch64/aarch64/trap.c | 10 ++++++-
2 files changed, 54 insertions(+), 6 deletions(-)
diffs (124 lines):
diff -r 3c8673011c76 -r df66e6daacbf sys/arch/aarch64/aarch64/fpu.c
--- a/sys/arch/aarch64/aarch64/fpu.c Sat Aug 01 02:05:45 2020 +0000
+++ b/sys/arch/aarch64/aarch64/fpu.c Sat Aug 01 02:06:59 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.7 2020/07/13 16:54:03 riastradh Exp $ */
+/* $NetBSD: fpu.c,v 1.8 2020/08/01 02:06:59 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,10 +31,12 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.7 2020/07/13 16:54:03 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.8 2020/08/01 02:06:59 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
+#include <sys/cpu.h>
+#include <sys/kthread.h>
#include <sys/lwp.h>
#include <sys/evcnt.h>
@@ -176,12 +178,30 @@
__asm __volatile ("isb");
}
+static const struct fpreg zero_fpreg;
+
+/*
+ * True if this is a system thread with its own private FPU state.
+ */
+static inline bool
+lwp_system_fpu_p(struct lwp *l)
+{
+
+ return (l->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) ==
+ (LW_SYSTEM|LW_SYSTEM_FPU);
+}
+
void
fpu_kern_enter(void)
{
struct cpu_info *ci;
int s;
+ if (lwp_system_fpu_p(curlwp) && !cpu_intr_p()) {
+ KASSERT(!cpu_softintr_p());
+ return;
+ }
+
/*
* Block interrupts up to IPL_VM. We must block preemption
* since -- if this is a user thread -- there is nowhere to
@@ -209,10 +229,16 @@
void
fpu_kern_leave(void)
{
- static const struct fpreg zero_fpreg;
- struct cpu_info *ci = curcpu();
+ struct cpu_info *ci;
int s;
+ if (lwp_system_fpu_p(curlwp) && !cpu_intr_p()) {
+ KASSERT(!cpu_softintr_p());
+ return;
+ }
+
+ ci = curcpu();
+
KASSERT(ci->ci_cpl == IPL_VM);
KASSERT(ci->ci_kfpu_spl != -1);
@@ -234,3 +260,19 @@
ci->ci_kfpu_spl = -1;
splx(s);
}
+
+void
+kthread_fpu_enter_md(void)
+{
+
+ fpu_load(curlwp);
+}
+
+void
+kthread_fpu_exit_md(void)
+{
+
+ /* XXX Should fpu_state_release zero the registers itself? */
+ load_fpregs(&zero_fpreg);
+ fpu_discard(curlwp, 0);
+}
diff -r 3c8673011c76 -r df66e6daacbf sys/arch/aarch64/aarch64/trap.c
--- a/sys/arch/aarch64/aarch64/trap.c Sat Aug 01 02:05:45 2020 +0000
+++ b/sys/arch/aarch64/aarch64/trap.c Sat Aug 01 02:06:59 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.34 2020/07/27 07:32:48 ryo Exp $ */
+/* $NetBSD: trap.c,v 1.35 2020/08/01 02:06:59 riastradh Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.34 2020/07/27 07:32:48 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.35 2020/08/01 02:06:59 riastradh Exp $");
#include "opt_arm_intr_impl.h"
#include "opt_compat_netbsd32.h"
@@ -242,6 +242,12 @@
break;
case ESR_EC_FP_ACCESS:
+ if ((curlwp->l_flag & (LW_SYSTEM|LW_SYSTEM_FPU)) ==
+ (LW_SYSTEM|LW_SYSTEM_FPU)) {
+ fpu_load(curlwp);
+ break;
+ }
+ /*FALLTHROUGH*/
case ESR_EC_FP_TRAP_A64:
case ESR_EC_PC_ALIGNMENT:
case ESR_EC_SP_ALIGNMENT:
Home |
Main Index |
Thread Index |
Old Index