Module Name: src
Committed By: maxv
Date: Sun May 19 08:17:02 UTC 2019
Modified Files:
src/sys/arch/amd64/amd64: cpufunc.S machdep.c
src/sys/arch/i386/i386: cpufunc.S locore.S machdep.c
src/sys/arch/x86/include: fpu.h
src/sys/arch/x86/x86: fpu.c x86_machdep.c
Log Message:
Misc changes in the x86 FPU code. Reduces a future diff. No real functional
change.
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/amd64/amd64/cpufunc.S
cvs rdiff -u -r1.329 -r1.330 src/sys/arch/amd64/amd64/machdep.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/i386/cpufunc.S
cvs rdiff -u -r1.167 -r1.168 src/sys/arch/i386/i386/locore.S
cvs rdiff -u -r1.818 -r1.819 src/sys/arch/i386/i386/machdep.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/include/fpu.h
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/x86/x86/fpu.c
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/x86/x86/x86_machdep.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/amd64/amd64/cpufunc.S
diff -u src/sys/arch/amd64/amd64/cpufunc.S:1.39 src/sys/arch/amd64/amd64/cpufunc.S:1.40
--- src/sys/arch/amd64/amd64/cpufunc.S:1.39 Sat May 4 07:20:22 2019
+++ src/sys/arch/amd64/amd64/cpufunc.S Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.S,v 1.39 2019/05/04 07:20:22 maxv Exp $ */
+/* $NetBSD: cpufunc.S,v 1.40 2019/05/19 08:17:02 maxv Exp $ */
/*
* Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -374,11 +374,6 @@ ENTRY(frstor)
ret
END(frstor)
-ENTRY(clts)
- clts
- ret
-END(clts)
-
ENTRY(stts)
movq %cr0, %rax
orq $CR0_TS, %rax
Index: src/sys/arch/amd64/amd64/machdep.c
diff -u src/sys/arch/amd64/amd64/machdep.c:1.329 src/sys/arch/amd64/amd64/machdep.c:1.330
--- src/sys/arch/amd64/amd64/machdep.c:1.329 Sun Mar 24 15:58:32 2019
+++ src/sys/arch/amd64/amd64/machdep.c Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.329 2019/03/24 15:58:32 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.330 2019/05/19 08:17:02 maxv Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.329 2019/03/24 15:58:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.330 2019/05/19 08:17:02 maxv Exp $");
#include "opt_modular.h"
#include "opt_user_ldt.h"
@@ -457,15 +457,15 @@ x86_64_tls_switch(struct lwp *l)
/* Update segment registers */
if (pcb->pcb_flags & PCB_COMPAT32) {
- update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &pcb->pcb_fs);
- update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &pcb->pcb_gs);
+ update_descriptor(&ci->ci_gdt[GUFS_SEL], &pcb->pcb_fs);
+ update_descriptor(&ci->ci_gdt[GUGS_SEL], &pcb->pcb_gs);
setds(GSEL(GUDATA32_SEL, SEL_UPL));
setes(GSEL(GUDATA32_SEL, SEL_UPL));
setfs(GSEL(GUDATA32_SEL, SEL_UPL));
HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, tf->tf_gs);
} else {
- update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &zero);
- update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &zero);
+ update_descriptor(&ci->ci_gdt[GUFS_SEL], &zero);
+ update_descriptor(&ci->ci_gdt[GUGS_SEL], &zero);
setds(GSEL(GUDATA_SEL, SEL_UPL));
setes(GSEL(GUDATA_SEL, SEL_UPL));
setfs(0);
Index: src/sys/arch/i386/i386/cpufunc.S
diff -u src/sys/arch/i386/i386/cpufunc.S:1.31 src/sys/arch/i386/i386/cpufunc.S:1.32
--- src/sys/arch/i386/i386/cpufunc.S:1.31 Sat May 4 07:20:22 2019
+++ src/sys/arch/i386/i386/cpufunc.S Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufunc.S,v 1.31 2019/05/04 07:20:22 maxv Exp $ */
+/* $NetBSD: cpufunc.S,v 1.32 2019/05/19 08:17:02 maxv Exp $ */
/*-
* Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#include <sys/errno.h>
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.31 2019/05/04 07:20:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.32 2019/05/19 08:17:02 maxv Exp $");
#include "opt_xen.h"
@@ -289,11 +289,6 @@ ENTRY(frstor)
ret
END(frstor)
-ENTRY(clts)
- clts
- ret
-END(clts)
-
ENTRY(stts)
movl %cr0, %eax
testl $CR0_TS, %eax
Index: src/sys/arch/i386/i386/locore.S
diff -u src/sys/arch/i386/i386/locore.S:1.167 src/sys/arch/i386/i386/locore.S:1.168
--- src/sys/arch/i386/i386/locore.S:1.167 Wed May 15 18:27:51 2019
+++ src/sys/arch/i386/i386/locore.S Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.167 2019/05/15 18:27:51 maxv Exp $ */
+/* $NetBSD: locore.S,v 1.168 2019/05/19 08:17:02 maxv Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.167 2019/05/15 18:27:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.168 2019/05/19 08:17:02 maxv Exp $");
#include "opt_copy_symtab.h"
#include "opt_ddb.h"
@@ -1199,7 +1199,7 @@ no_RAS:
pushl %edi
call _C_LABEL(i386_tls_switch)
addl $4,%esp
-#else /* !XENPV */
+#else
movl $IPL_HIGH,CPUVAR(ILEVEL)
movl PCB_CR0(%ebx),%ecx /* has CR0_TS clear */
movl %cr0,%edx
@@ -1217,7 +1217,7 @@ skip_TS:
cmpl %edx,%ecx
je switch_return
movl %ecx,%cr0
-#endif /* !XENPV */
+#endif
switch_return:
/* Return to the new LWP, returning 'oldlwp' in %eax. */
Index: src/sys/arch/i386/i386/machdep.c
diff -u src/sys/arch/i386/i386/machdep.c:1.818 src/sys/arch/i386/i386/machdep.c:1.819
--- src/sys/arch/i386/i386/machdep.c:1.818 Sat Mar 9 08:42:25 2019
+++ src/sys/arch/i386/i386/machdep.c Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.818 2019/03/09 08:42:25 maxv Exp $ */
+/* $NetBSD: machdep.c,v 1.819 2019/05/19 08:17:02 maxv Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.818 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.819 2019/05/19 08:17:02 maxv Exp $");
#include "opt_beep.h"
#include "opt_compat_freebsd.h"
@@ -507,28 +507,27 @@ i386_tls_switch(lwp_t *l)
{
struct cpu_info *ci = curcpu();
struct pcb *pcb = lwp_getpcb(l);
+
/*
- * Raise the IPL to IPL_HIGH.
+ * Raise the IPL to IPL_HIGH.
* FPU IPIs can alter the LWP's saved cr0. Dropping the priority
* is deferred until mi_switch(), when cpu_switchto() returns.
*/
(void)splhigh();
- /*
+ /*
* If our floating point registers are on a different CPU,
* set CR0_TS so we'll trap rather than reuse bogus state.
*/
-
if (l != ci->ci_fpcurlwp) {
HYPERVISOR_fpu_taskswitch(1);
}
/* Update TLS segment pointers */
update_descriptor(&ci->ci_gdt[GUFS_SEL],
- (union descriptor *) &pcb->pcb_fsd);
+ (union descriptor *)&pcb->pcb_fsd);
update_descriptor(&ci->ci_gdt[GUGS_SEL],
- (union descriptor *) &pcb->pcb_gsd);
-
+ (union descriptor *)&pcb->pcb_gsd);
}
#endif /* XENPV */
Index: src/sys/arch/x86/include/fpu.h
diff -u src/sys/arch/x86/include/fpu.h:1.14 src/sys/arch/x86/include/fpu.h:1.15
--- src/sys/arch/x86/include/fpu.h:1.14 Sun Jan 20 16:55:21 2019
+++ src/sys/arch/x86/include/fpu.h Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.h,v 1.14 2019/01/20 16:55:21 maxv Exp $ */
+/* $NetBSD: fpu.h,v 1.15 2019/05/19 08:17:02 maxv Exp $ */
#ifndef _X86_FPU_H_
#define _X86_FPU_H_
@@ -27,21 +27,16 @@ void fpu_set_default_cw(struct lwp *, un
void fputrap(struct trapframe *);
void fpudna(struct trapframe *);
-/* Set all to defaults (eg during exec) */
void fpu_save_area_clear(struct lwp *, unsigned int);
-/* Reset control words only - for signal handlers */
void fpu_save_area_reset(struct lwp *);
-/* Copy data outside pcb during fork */
void fpu_save_area_fork(struct pcb *, const struct pcb *);
-/* Load FP registers with user-supplied values */
-void process_write_fpregs_xmm(struct lwp *lwp, const struct fxsave *fpregs);
-void process_write_fpregs_s87(struct lwp *lwp, const struct save87 *fpregs);
-
-/* Save FP registers for copy to userspace */
-void process_read_fpregs_xmm(struct lwp *lwp, struct fxsave *fpregs);
-void process_read_fpregs_s87(struct lwp *lwp, struct save87 *fpregs);
+void process_write_fpregs_xmm(struct lwp *, const struct fxsave *);
+void process_write_fpregs_s87(struct lwp *, const struct save87 *);
+
+void process_read_fpregs_xmm(struct lwp *, struct fxsave *);
+void process_read_fpregs_s87(struct lwp *, struct save87 *);
#endif
Index: src/sys/arch/x86/x86/fpu.c
diff -u src/sys/arch/x86/x86/fpu.c:1.50 src/sys/arch/x86/x86/fpu.c:1.51
--- src/sys/arch/x86/x86/fpu.c:1.50 Mon Feb 11 14:59:33 2019
+++ src/sys/arch/x86/x86/fpu.c Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.50 2019/02/11 14:59:33 cherry Exp $ */
+/* $NetBSD: fpu.c,v 1.51 2019/05/19 08:17:02 maxv Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc. All
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.50 2019/02/11 14:59:33 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.51 2019/05/19 08:17:02 maxv Exp $");
#include "opt_multiprocessor.h"
@@ -185,8 +185,8 @@ fpuinit_mxcsr_mask(void)
#endif
}
-static void
-fpu_clear_amd(void)
+static inline void
+fpu_errata_amd(void)
{
/*
* AMD FPUs do not restore FIP, FDP, and FOP on fxrstor and xrstor
@@ -240,13 +240,13 @@ fpu_area_restore(void *area, uint64_t xs
break;
case FPU_SAVE_FXSAVE:
if (cpu_vendor == CPUVENDOR_AMD)
- fpu_clear_amd();
+ fpu_errata_amd();
fxrstor(area);
break;
case FPU_SAVE_XSAVE:
case FPU_SAVE_XSAVEOPT:
if (cpu_vendor == CPUVENDOR_AMD)
- fpu_clear_amd();
+ fpu_errata_amd();
xrstor(area, xsave_features);
break;
}
Index: src/sys/arch/x86/x86/x86_machdep.c
diff -u src/sys/arch/x86/x86/x86_machdep.c:1.125 src/sys/arch/x86/x86/x86_machdep.c:1.126
--- src/sys/arch/x86/x86/x86_machdep.c:1.125 Wed May 15 17:31:41 2019
+++ src/sys/arch/x86/x86/x86_machdep.c Sun May 19 08:17:02 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: x86_machdep.c,v 1.125 2019/05/15 17:31:41 maxv Exp $ */
+/* $NetBSD: x86_machdep.c,v 1.126 2019/05/19 08:17:02 maxv Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.125 2019/05/15 17:31:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.126 2019/05/19 08:17:02 maxv Exp $");
#include "opt_modular.h"
#include "opt_physmem.h"
@@ -1306,10 +1306,8 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
sysctl_speculation_init(clog);
#endif
-#ifndef XEN
void sysctl_eagerfpu_init(struct sysctllog **);
sysctl_eagerfpu_init(clog);
-#endif
/* None of these can ever change once the system has booted */
const_sysctl(clog, "fpu_present", CTLTYPE_INT, i386_fpu_present,