summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/amd64/include')
-rw-r--r--sys/arch/amd64/include/codepatch.h4
-rw-r--r--sys/arch/amd64/include/cpu.h10
-rw-r--r--sys/arch/amd64/include/fpu.h28
-rw-r--r--sys/arch/amd64/include/intrdefs.h8
-rw-r--r--sys/arch/amd64/include/pcb.h5
-rw-r--r--sys/arch/amd64/include/proc.h3
-rw-r--r--sys/arch/amd64/include/specialreg.h4
7 files changed, 22 insertions, 40 deletions
diff --git a/sys/arch/amd64/include/codepatch.h b/sys/arch/amd64/include/codepatch.h
index 185b5b73abc..159d9109451 100644
--- a/sys/arch/amd64/include/codepatch.h
+++ b/sys/arch/amd64/include/codepatch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: codepatch.h,v 1.4 2017/08/25 19:28:48 guenther Exp $ */
+/* $OpenBSD: codepatch.h,v 1.5 2018/06/05 06:39:11 guenther Exp $ */
/*
* Copyright (c) 2014-2015 Stefan Fritsch <sf@sfritsch.de>
*
@@ -50,6 +50,8 @@ void codepatch_call(uint16_t tag, void *func);
#define CPTAG_STAC 1
#define CPTAG_CLAC 2
#define CPTAG_EOI 3
+#define CPTAG_XRSTOR 4
+#define CPTAG_XSAVE 5
/*
* As stac/clac SMAP instructions are 3 bytes, we want the fastest
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index 70e2d4642f7..b9520284548 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.122 2018/05/26 18:02:01 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.123 2018/06/05 06:39:11 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -115,10 +115,6 @@ struct cpu_info {
u_int64_t ci_intr_rsp; /* U<-->K trampoline stack */
u_int64_t ci_user_cr3; /* U-K page table */
- struct proc *ci_fpcurproc;
- struct proc *ci_fpsaveproc;
- int ci_fpsaving;
-
struct pcb *ci_curpcb;
struct pcb *ci_idle_pcb;
@@ -215,9 +211,9 @@ struct cpu_info {
#define CPUF_IDENTIFIED 0x0020 /* CPU has been identified */
#define CPUF_CONST_TSC 0x0040 /* CPU has constant TSC */
-#define CPUF_USERSEGS_BIT 7 /* CPU has curproc's segments */
-#define CPUF_USERSEGS (1<<CPUF_USERSEGS_BIT) /* and FS.base */
+#define CPUF_USERSEGS 0x0080 /* CPU has curproc's segs and FS.base */
#define CPUF_INVAR_TSC 0x0100 /* CPU has invariant TSC */
+#define CPUF_USERXSTATE 0x0200 /* CPU has curproc's xsave state */
#define CPUF_PRESENT 0x1000 /* CPU is present */
#define CPUF_RUNNING 0x2000 /* CPU is running */
diff --git a/sys/arch/amd64/include/fpu.h b/sys/arch/amd64/include/fpu.h
index 96536774abc..78db1e413d3 100644
--- a/sys/arch/amd64/include/fpu.h
+++ b/sys/arch/amd64/include/fpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: fpu.h,v 1.13 2018/05/26 17:28:17 guenther Exp $ */
+/* $OpenBSD: fpu.h,v 1.14 2018/06/05 06:39:11 guenther Exp $ */
/* $NetBSD: fpu.h,v 1.1 2003/04/26 18:39:40 fvdl Exp $ */
#ifndef _MACHINE_FPU_H_
@@ -64,23 +64,22 @@ extern uint32_t fpu_mxcsr_mask;
extern uint64_t xsave_mask;
void fpuinit(struct cpu_info *);
-void fpudrop(void);
-void fpudiscard(struct proc *);
void fputrap(struct trapframe *);
-void fpusave_proc(struct proc *, int);
-void fpusave_cpu(struct cpu_info *, int);
+void fpusave(struct savefpu *);
+void fpusavereset(struct savefpu *);
void fpu_kernel_enter(void);
void fpu_kernel_exit(void);
+int xrstor_user(struct savefpu *_addr, uint64_t _mask);
+#define fpureset() \
+ xrstor_user(&proc0.p_addr->u_pcb.pcb_savefpu, xsave_mask)
+
#define fninit() __asm("fninit")
#define fwait() __asm("fwait")
-#define fnclex() __asm("fnclex")
+/* should be fxsave64, but where we use this it doesn't matter */
#define fxsave(addr) __asm("fxsave %0" : "=m" (*addr))
-#define fxrstor(addr) __asm("fxrstor %0" : : "m" (*addr))
#define ldmxcsr(addr) __asm("ldmxcsr %0" : : "m" (*addr))
#define fldcw(addr) __asm("fldcw %0" : : "m" (*addr))
-#define clts() __asm("clts")
-#define stts() lcr0(rcr0() | CR0_TS)
static inline void
xsave(struct savefpu *addr, uint64_t mask)
@@ -89,20 +88,11 @@ xsave(struct savefpu *addr, uint64_t mask)
lo = mask;
hi = mask >> 32;
+ /* should be xsave64, but where we use this it doesn't matter */
__asm volatile("xsave %0" : "=m" (*addr) : "a" (lo), "d" (hi) :
"memory");
}
-static inline void
-xrstor(struct savefpu *addr, uint64_t mask)
-{
- uint32_t lo, hi;
-
- lo = mask;
- hi = mask >> 32;
- __asm volatile("xrstor %0" : : "m" (*addr), "a" (lo), "d" (hi));
-}
-
#endif
#endif /* _MACHINE_FPU_H_ */
diff --git a/sys/arch/amd64/include/intrdefs.h b/sys/arch/amd64/include/intrdefs.h
index f435c672b6e..ca1ec3bf84e 100644
--- a/sys/arch/amd64/include/intrdefs.h
+++ b/sys/arch/amd64/include/intrdefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: intrdefs.h,v 1.17 2018/01/13 15:18:11 mpi Exp $ */
+/* $OpenBSD: intrdefs.h,v 1.18 2018/06/05 06:39:11 guenther Exp $ */
/* $NetBSD: intrdefs.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */
#ifndef _AMD64_INTRDEFS_H
@@ -76,8 +76,6 @@
#define X86_IPI_HALT 0x00000001
#define X86_IPI_NOP 0x00000002
-#define X86_IPI_FLUSH_FPU 0x00000004
-#define X86_IPI_SYNCH_FPU 0x00000008
#define X86_IPI_TLB 0x00000010
#define X86_IPI_MTRR 0x00000020
#define X86_IPI_SETPERF 0x00000040
@@ -87,8 +85,8 @@
#define X86_NIPI 10
-#define X86_IPI_NAMES { "halt IPI", "nop IPI", "FPU flush IPI", \
- "FPU synch IPI", "TLB shootdown IPI", \
+#define X86_IPI_NAMES { "halt IPI", "nop IPI", NULL, \
+ NULL, "TLB shootdown IPI", \
"MTRR update IPI", "setperf IPI", "ddb IPI", \
"VMM start IPI", "VMM stop IPI" }
diff --git a/sys/arch/amd64/include/pcb.h b/sys/arch/amd64/include/pcb.h
index a4a1d752d95..d974172cf0f 100644
--- a/sys/arch/amd64/include/pcb.h
+++ b/sys/arch/amd64/include/pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pcb.h,v 1.16 2017/04/26 07:05:24 mlarkin Exp $ */
+/* $OpenBSD: pcb.h,v 1.17 2018/06/05 06:39:11 guenther Exp $ */
/* $NetBSD: pcb.h,v 1.1 2003/04/26 18:39:45 fvdl Exp $ */
/*-
@@ -69,7 +69,6 @@
#include <sys/signal.h>
-#include <machine/tss.h>
#include <machine/fpu.h>
/*
@@ -84,9 +83,7 @@ struct pcb {
u_int64_t pcb_kstack; /* kernel stack address */
u_int64_t pcb_fsbase; /* per-thread offset: %fs */
caddr_t pcb_onfault; /* copyin/out fault recovery */
- struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
struct pmap *pcb_pmap; /* back pointer to our pmap */
- int pcb_cr0; /* saved image of CR0 */
};
#ifdef _KERNEL
diff --git a/sys/arch/amd64/include/proc.h b/sys/arch/amd64/include/proc.h
index 9cb65df8735..a2ca633f601 100644
--- a/sys/arch/amd64/include/proc.h
+++ b/sys/arch/amd64/include/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.9 2017/04/13 03:52:25 guenther Exp $ */
+/* $OpenBSD: proc.h,v 1.10 2018/06/05 06:39:11 guenther Exp $ */
/* $NetBSD: proc.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */
/*
@@ -46,7 +46,6 @@ struct mdproc {
};
/* md_flags */
-#define MDP_USEDFPU 0x0001 /* has used the FPU */
#define MDP_IRET 0x0002 /* return via iret, not sysret */
/* (iret can restore r11 and rcx) */
diff --git a/sys/arch/amd64/include/specialreg.h b/sys/arch/amd64/include/specialreg.h
index 9a298597abf..f0933c7de99 100644
--- a/sys/arch/amd64/include/specialreg.h
+++ b/sys/arch/amd64/include/specialreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: specialreg.h,v 1.72 2018/05/23 05:37:01 guenther Exp $ */
+/* $OpenBSD: specialreg.h,v 1.73 2018/06/05 06:39:11 guenther Exp $ */
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
@@ -1400,5 +1400,5 @@
/*
* Default cr0 and cr4 flags.
*/
-#define CR0_DEFAULT (CR0_PE|CR0_PG|CR0_NE|CR0_TS|CR0_MP|CR0_WP)
+#define CR0_DEFAULT (CR0_PE|CR0_PG|CR0_NE|CR0_WP)
#define CR4_DEFAULT (CR4_PAE|CR4_PGE|CR4_PSE|CR4_OSFXSR|CR4_OSXMMEXCPT)