Module Name:    src
Committed By:   riastradh
Date:           Mon Jul 13 16:52:23 UTC 2020

Modified Files:
        src/sys/arch/aarch64/aarch64: fpu.c

Log Message:
Limit aarch64 fpu_kern_enter/leave to IPL_VM or below.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/aarch64/aarch64/fpu.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/arch/aarch64/aarch64/fpu.c
diff -u src/sys/arch/aarch64/aarch64/fpu.c:1.5 src/sys/arch/aarch64/aarch64/fpu.c:1.6
--- src/sys/arch/aarch64/aarch64/fpu.c:1.5	Mon Jun 29 23:53:12 2020
+++ src/sys/arch/aarch64/aarch64/fpu.c	Mon Jul 13 16:52:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.5 2020/06/29 23:53:12 riastradh Exp $ */
+/* $NetBSD: fpu.c,v 1.6 2020/07/13 16:52:23 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.5 2020/06/29 23:53:12 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.6 2020/07/13 16:52:23 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -184,14 +184,15 @@ fpu_kern_enter(void)
 	int s;
 
 	/*
-	 * Block all interrupts.  We must block preemption since -- if
-	 * this is a user thread -- there is nowhere to save the kernel
-	 * fpu state, and if we want this to be usable in interrupts,
-	 * we can't let interrupts interfere with the fpu state in use
-	 * since there's nowhere for them to save it.
+	 * Block interrupts up to IPL_VM.  We must block preemption
+	 * since -- if this is a user thread -- there is nowhere to
+	 * save the kernel fpu state, and if we want this to be usable
+	 * in interrupts, we can't let interrupts interfere with the
+	 * fpu state in use since there's nowhere for them to save it.
 	 */
-	s = splhigh();
+	s = splvm();
 	ci = curcpu();
+	KASSERTMSG(ci->ci_cpl <= IPL_VM, "cpl=%d", ci->ci_cpl);
 	KASSERT(ci->ci_kfpu_spl == -1);
 	ci->ci_kfpu_spl = s;
 
@@ -219,7 +220,7 @@ fpu_kern_leave(void)
 	struct cpu_info *ci = curcpu();
 	int s;
 
-	KASSERT(ci->ci_cpl == IPL_HIGH);
+	KASSERT(ci->ci_cpl == IPL_VM);
 	KASSERT(ci->ci_kfpu_spl != -1);
 
 	/*

Reply via email to