diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-03-13 13:51:06 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-03-13 13:51:06 +0000 |
commit | d0f73983bbaf73f2ac481f54e354a1d3c85dd116 (patch) | |
tree | c7b56f49521b2f48dc5a6af177349ea444d63755 /sys/arch/i386/include | |
parent | 8449427a6bcd373843363cf05df2497f09bff926 (diff) |
Preparation for i386 Meltdown fix:
- provide a cpu_softc for cpu_attach() etc.
- replace per PCB TSS with per CPU TSS
The first change prepares for cpu_info being embedded in a
cpu_full_info. Therefore during autoconf/cpu_attach we hand down
a softc.
The second change removes the per PCB TSS. We now have one TSS per
CPU, thus in cpu_switchto() we only have to patch the ring 0 stack
pointer instead of loading a new TSS. This also allows for cleaning
up the GDT, so we only have a single slot for the TSS.
from hshoexer@; OK deraadt@
Diffstat (limited to 'sys/arch/i386/include')
-rw-r--r-- | sys/arch/i386/include/cpu.h | 9 | ||||
-rw-r--r-- | sys/arch/i386/include/gdt.h | 12 | ||||
-rw-r--r-- | sys/arch/i386/include/pcb.h | 17 | ||||
-rw-r--r-- | sys/arch/i386/include/proc.h | 3 | ||||
-rw-r--r-- | sys/arch/i386/include/segments.h | 11 | ||||
-rw-r--r-- | sys/arch/i386/include/tss.h | 16 |
6 files changed, 29 insertions, 39 deletions
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index e89d43951c0..f3294535bde 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.158 2017/10/17 14:25:35 visa Exp $ */ +/* $OpenBSD: cpu.h,v 1.159 2018/03/13 13:51:05 bluhm Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -46,6 +46,7 @@ #include <machine/psl.h> #include <machine/segments.h> #include <machine/intrdefs.h> +#include <machine/tss.h> #ifdef MULTIPROCESSOR #include <machine/i82489reg.h> @@ -102,7 +103,7 @@ union vmm_cpu_cap { #ifdef _KERNEL /* XXX stuff to move to cpuvar.h later */ struct cpu_info { - struct device ci_dev; /* our device */ + struct device *ci_dev; /* our device */ struct cpu_info *ci_self; /* pointer to this structure */ struct schedstate_percpu ci_schedstate; /* scheduler state */ struct cpu_info *ci_next; /* next cpu */ @@ -129,7 +130,6 @@ struct cpu_info { struct pcb *ci_curpcb; /* VA of current HW PCB */ struct pcb *ci_idle_pcb; /* VA of current PCB */ - int ci_idle_tss_sel; /* TSS selector of idle PCB */ struct pmap *ci_curpmap; struct intrsource *ci_isources[MAX_INTR_SOURCES]; @@ -175,6 +175,7 @@ struct cpu_info { int ci_want_resched; union descriptor *ci_gdt; + struct i386tss *ci_tss; volatile int ci_ddb_paused; /* paused due to other proc in ddb */ #define CI_DDB_RUNNING 0 @@ -230,7 +231,7 @@ extern struct cpu_info *cpu_info_list; #define CPU_INFO_FOREACH(cii, ci) for (cii = 0, ci = cpu_info_list; \ ci != NULL; ci = ci->ci_next) -#define CPU_INFO_UNIT(ci) ((ci)->ci_dev.dv_unit) +#define CPU_INFO_UNIT(ci) ((ci)->ci_dev ? (ci)->ci_dev->dv_unit : 0) #ifdef MULTIPROCESSOR diff --git a/sys/arch/i386/include/gdt.h b/sys/arch/i386/include/gdt.h index 2b5d0dcf3b3..fc7fe20f587 100644 --- a/sys/arch/i386/include/gdt.h +++ b/sys/arch/i386/include/gdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gdt.h,v 1.13 2016/03/03 12:41:30 naddy Exp $ */ +/* $OpenBSD: gdt.h,v 1.14 2018/03/13 13:51:05 bluhm Exp $ */ /* $NetBSD: gdt.h,v 1.7.10.6 2002/08/19 01:22:36 sommerfeld Exp $ */ /*- @@ -35,21 +35,11 @@ struct cpu_info; struct pcb; struct pmap; -union descriptor; void gdt_alloc_cpu(struct cpu_info *); int gdt_get_slot(void); void gdt_init(void); void gdt_init_cpu(struct cpu_info *); void gdt_reload_cpu(/* XXX struct cpu_info * */ void); -int tss_alloc(struct pcb *); -void tss_free(int); void setgdt(int, void *, size_t, int, int, int, int); #endif - -/* - * Maximum GDT size. It cannot exceed 65536 since the selector field of - * a descriptor is just 16 bits, and used as free list link. - */ - -#define MAXGDTSIZ 65536 diff --git a/sys/arch/i386/include/pcb.h b/sys/arch/i386/include/pcb.h index 6e6f5a578e7..a01afaed5ad 100644 --- a/sys/arch/i386/include/pcb.h +++ b/sys/arch/i386/include/pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcb.h,v 1.20 2016/03/24 04:56:08 guenther Exp $ */ +/* $OpenBSD: pcb.h,v 1.21 2018/03/13 13:51:05 bluhm Exp $ */ /* $NetBSD: pcb.h,v 1.21 1996/01/08 13:51:42 mycroft Exp $ */ /*- @@ -46,19 +46,20 @@ #include <sys/signal.h> #include <machine/segments.h> -#include <machine/tss.h> #include <machine/npx.h> #include <machine/sysarch.h> +/* + * Please not that pcb_savefpu must be aligend to 16 bytes. + */ struct pcb { - struct i386tss pcb_tss; -#define pcb_cr3 pcb_tss.tss_cr3 -#define pcb_esp pcb_tss.tss_esp -#define pcb_ebp pcb_tss.tss_ebp -#define pcb_cs pcb_tss.tss_cs + union savefpu pcb_savefpu; /* floating point state for FPU */ + int pcb_cr3; + int pcb_esp; + int pcb_ebp; + int pcb_kstack; /* kernel stack address */ int pcb_cr0; /* saved image of CR0 */ caddr_t pcb_onfault; /* copyin/out fault recovery */ - union savefpu pcb_savefpu; /* floating point state for FPU */ struct segment_descriptor pcb_threadsegs[2]; /* per-thread descriptors */ int vm86_eflags; /* virtual eflags for vm86 mode */ diff --git a/sys/arch/i386/include/proc.h b/sys/arch/i386/include/proc.h index 811577a20ea..9f3645a0f3b 100644 --- a/sys/arch/i386/include/proc.h +++ b/sys/arch/i386/include/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.7 2017/04/13 03:52:25 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.8 2018/03/13 13:51:05 bluhm Exp $ */ /* $NetBSD: proc.h,v 1.10 1995/08/06 05:33:23 mycroft Exp $ */ /* @@ -38,7 +38,6 @@ struct mdproc { struct trapframe *md_regs; /* registers on current frame */ int md_flags; /* machine-dependent flags */ - int md_tss_sel; /* TSS selector */ int md_astpending; }; diff --git a/sys/arch/i386/include/segments.h b/sys/arch/i386/include/segments.h index 8fe19ab2299..7c1a7bc4a47 100644 --- a/sys/arch/i386/include/segments.h +++ b/sys/arch/i386/include/segments.h @@ -1,4 +1,4 @@ -/* $OpenBSD: segments.h,v 1.21 2016/03/15 03:17:51 guenther Exp $ */ +/* $OpenBSD: segments.h,v 1.22 2018/03/13 13:51:05 bluhm Exp $ */ /* $NetBSD: segments.h,v 1.23 1996/02/01 22:31:03 mycroft Exp $ */ /*- @@ -221,11 +221,10 @@ void idt_vec_free(int); #define GICODE_SEL 10 /* Interrupt code descriptor (same as Kernel code) */ #define GUFS_SEL 11 /* User per-thread (%fs) descriptor */ #define GUGS_SEL 12 /* User per-thread (%gs) descriptor */ -#define NGDT 13 +#define GTSS_SEL 13 /* common TSS */ +#define GBIOS32_SEL 14 /* spare slot for 32 bit BIOS calls */ +#define NGDT 15 -/* - * Entries in the Local Descriptor Table (LDT) - */ -#define NLDT 17 +#define GDT_SIZE (NGDT << 3) #endif /* _MACHINE_SEGMENTS_H_ */ diff --git a/sys/arch/i386/include/tss.h b/sys/arch/i386/include/tss.h index 705d62b6b18..93efe7f7457 100644 --- a/sys/arch/i386/include/tss.h +++ b/sys/arch/i386/include/tss.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tss.h,v 1.8 2011/03/23 16:54:35 pirofti Exp $ */ +/* $OpenBSD: tss.h,v 1.9 2018/03/13 13:51:05 bluhm Exp $ */ /* $NetBSD: tss.h,v 1.6 1995/10/11 04:20:28 mycroft Exp $ */ /*- @@ -50,24 +50,24 @@ struct i386tss { int __tss_ss1; int __tss_esp2; int __tss_ss2; - int tss_cr3; /* page directory [pointer] paddr */ + int __tss_cr3; int __tss_eip; int __tss_eflags; int __tss_eax; int __tss_ecx; int __tss_edx; int __tss_ebx; - int tss_esp; /* saved stack pointer */ - int tss_ebp; /* saved frame pointer */ + int __tss_esp; + int __tss_ebp; int __tss_esi; int __tss_edi; int __tss_es; - int tss_cs; + int __tss_cs; int __tss_ss; int __tss_ds; - int tss_fs; /* saved segment register */ - int tss_gs; /* saved segment register */ - int tss_ldt; /* LDT selector */ + int __tss_fs; + int __tss_gs; + int __tss_ldt; int tss_ioopt; /* options and I/O permission map offset */ }; |