Module Name: src
Committed By: riastradh
Date: Sat Feb 25 18:35:54 UTC 2023
Modified Files:
src/sys/arch/i386/i386: genassym.cf locore.S
Log Message:
x86: Add kthread_fpu_enter/exit support, take two -- forgot i386 bits.
To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/i386/i386/genassym.cf
cvs rdiff -u -r1.191 -r1.192 src/sys/arch/i386/i386/locore.S
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/i386/i386/genassym.cf
diff -u src/sys/arch/i386/i386/genassym.cf:1.131 src/sys/arch/i386/i386/genassym.cf:1.132
--- src/sys/arch/i386/i386/genassym.cf:1.131 Tue Dec 27 08:40:40 2022
+++ src/sys/arch/i386/i386/genassym.cf Sat Feb 25 18:35:54 2023
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.131 2022/12/27 08:40:40 msaitoh Exp $
+# $NetBSD: genassym.cf,v 1.132 2023/02/25 18:35:54 riastradh Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -175,6 +175,7 @@ define L_MD_FLAGS offsetof(struct lwp,
define L_MD_ASTPENDING offsetof(struct lwp, l_md.md_astpending)
define LW_SYSTEM LW_SYSTEM
+define LW_SYSTEM_FPU LW_SYSTEM_FPU
define MDL_FPU_IN_CPU MDL_FPU_IN_CPU
define P_FLAG offsetof(struct proc, p_flag)
Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.191 src/sys/arch/i386/i386/locore.S:1.192
--- src/sys/arch/i386/i386/locore.S:1.191 Fri Feb 3 09:21:58 2023
+++ src/sys/arch/i386/i386/locore.S Sat Feb 25 18:35:54 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $ */
+/* $NetBSD: locore.S,v 1.192 2023/02/25 18:35:54 riastradh Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.191 2023/02/03 09:21:58 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.192 2023/02/25 18:35:54 riastradh Exp $");
#include "opt_copy_symtab.h"
#include "opt_ddb.h"
@@ -1447,7 +1447,7 @@ ENTRY(cpu_switchto)
/* Don't bother with the rest if switching to a system process. */
testl $LW_SYSTEM,L_FLAG(%edi)
- jnz switch_return
+ jnz .Lswitch_system
#ifndef XENPV
/* Restore thread-private %fs/%gs descriptors. */
@@ -1501,6 +1501,21 @@ switch_return:
popl %ebx
ret
+.Lswitch_system:
+ /*
+ * If it has LWP_SYSTEM_FPU set, meaning it's running in
+ * kthread_fpu_enter/exit, we need to restore the FPU state
+ * and enable FPU instructions with fpu_handle_deferred.
+ *
+ * No need to test MDL_FPU_IN_CPU via HANDLE_DEFERRED_FPU --
+ * fpu_switch guarantees it is clear, so we can just call
+ * fpu_handle_deferred unconditionally.
+ */
+ testl $LW_SYSTEM_FPU,L_FLAG(%edi)
+ jz switch_return
+ call _C_LABEL(fpu_handle_deferred)
+ jmp switch_return
+
.Lcopy_iobitmap:
/* Copy I/O bitmap. */
incl _C_LABEL(pmap_iobmp_evcnt)+EV_COUNT