Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/arch Pullup the following revisions via patch, reques...
details: https://anonhg.NetBSD.org/src/rev/d2b0400dbfbb
branches: netbsd-8
changeset: 434737:d2b0400dbfbb
user: martin <martin%NetBSD.org@localhost>
date: Tue Mar 13 15:47:44 2018 +0000
description:
Pullup the following revisions via patch, requested by maxv in ticket #629:
sys/arch/amd64/amd64/genassym.cf 1.63,1.64
sys/arch/amd64/amd64/locore.S 1.144
sys/arch/amd64/amd64/machdep.c 1.281-1.283
sys/arch/i386/i386/genassym.cf 1.105-1.106
sys/arch/i386/i386/locore.S 1.155
sys/arch/i386/i386/machdep.c 1.802 (adapted),1.803
sys/arch/x86/include/cpu.h 1.85
sys/arch/x86/x86/intr.c 1.115-1.116
sys/arch/x86/x86/pmap.c 1.275
sys/arch/x86/x86/sys_machdep.c 1.45
sys/arch/xen/x86/cpu.c 1.117
Stop sharing the double-fault stack.
Merge the TSS structures into one single cpu_tss structure, and
allocate it dynamically.
diffstat:
sys/arch/amd64/amd64/genassym.cf | 6 ++++--
sys/arch/amd64/amd64/locore.S | 5 +++--
sys/arch/amd64/amd64/machdep.c | 24 ++++++++++++++----------
sys/arch/i386/i386/genassym.cf | 11 ++++++-----
sys/arch/i386/i386/locore.S | 17 ++++++++++-------
sys/arch/i386/i386/machdep.c | 40 +++++++++++++++++++++++++---------------
sys/arch/x86/include/cpu.h | 25 +++++++++++++++----------
sys/arch/x86/x86/intr.c | 6 +++---
sys/arch/x86/x86/pmap.c | 8 ++++----
sys/arch/x86/x86/sys_machdep.c | 10 +++++-----
sys/arch/xen/x86/cpu.c | 5 +++--
11 files changed, 92 insertions(+), 65 deletions(-)
diffs (truncated from 454 to 300 lines):
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.60 2015/11/20 11:58:00 maxv Exp $
+# $NetBSD: genassym.cf,v 1.60.10.1 2018/03/13 15:47:44 martin Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -223,6 +223,8 @@
# Total size includes registers pushed by hardware
define FRAMESIZE sizeof(struct trapframe)
+define TSS_RSP0 offsetof(struct cpu_tss, tss.tss_rsp0)
+
define CPU_INFO_SCRATCH offsetof(struct cpu_info, ci_scratch)
define CPU_INFO_SELF offsetof(struct cpu_info, ci_self)
define CPU_INFO_RESCHED offsetof(struct cpu_info, ci_want_resched)
@@ -233,7 +235,7 @@
define CPU_INFO_CURLDT offsetof(struct cpu_info, ci_curldt)
define CPU_INFO_IDLELWP offsetof(struct cpu_info, ci_data.cpu_idlelwp)
define CPU_INFO_PMAP offsetof(struct cpu_info, ci_pmap)
-define CPU_INFO_RSP0 offsetof(struct cpu_info, ci_tss.tss_rsp0)
+define CPU_INFO_TSS offsetof(struct cpu_info, ci_tss)
define CPU_INFO_NSYSCALL offsetof(struct cpu_info, ci_data.cpu_nsyscall)
define CPU_INFO_NTRAP offsetof(struct cpu_info, ci_data.cpu_ntrap)
define CPU_INFO_NINTR offsetof(struct cpu_info, ci_data.cpu_nintr)
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/amd64/amd64/locore.S Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.123.6.3 2018/03/07 14:50:56 martin Exp $ */
+/* $NetBSD: locore.S,v 1.123.6.4 2018/03/13 15:47:44 martin Exp $ */
/*
* Copyright-o-rama!
@@ -1099,7 +1099,8 @@
/* Switch ring0 stack */
#ifndef XEN
movq PCB_RSP0(%r14),%rax
- movq %rax,CPUVAR(RSP0)
+ movq CPUVAR(TSS),%rdi
+ movq %rax,TSS_RSP0(%rdi)
#else
movq %r14,%rdi
callq _C_LABEL(x86_64_switch_context);
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.255.6.3 2018/01/01 19:09:03 snj Exp $ */
+/* $NetBSD: machdep.c,v 1.255.6.4 2018/03/13 15:47:44 martin Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.255.6.3 2018/01/01 19:09:03 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.255.6.4 2018/03/13 15:47:44 martin Exp $");
/* #define XENDEBUG_LOW */
@@ -291,8 +291,6 @@
phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
int mem_cluster_cnt;
-char x86_64_doubleflt_stack[4096];
-
int cpu_dump(void);
int cpu_dumpsize(void);
u_long cpu_dump_mempagecnt(void);
@@ -502,19 +500,25 @@
void
cpu_init_tss(struct cpu_info *ci)
{
- struct x86_64_tss *tss = &ci->ci_tss;
+ struct cpu_tss *cputss;
uintptr_t p;
- tss->tss_iobase = IOMAP_INVALOFF << 16;
- /* tss->tss_ist[0] is filled by cpu_intr_init */
+ cputss = (struct cpu_tss *)uvm_km_alloc(kernel_map,
+ sizeof(struct cpu_tss), 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
+
+ cputss->tss.tss_iobase = IOMAP_INVALOFF << 16;
+ /* cputss->tss.tss_ist[0] is filled by cpu_intr_init */
/* double fault */
- tss->tss_ist[1] = (uint64_t)x86_64_doubleflt_stack + PAGE_SIZE - 16;
+ p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED);
+ cputss->tss.tss_ist[1] = p + PAGE_SIZE - 16;
/* NMI */
p = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED);
- tss->tss_ist[2] = p + PAGE_SIZE - 16;
- ci->ci_tss_sel = tss_alloc(tss);
+ cputss->tss.tss_ist[2] = p + PAGE_SIZE - 16;
+
+ ci->ci_tss = cputss;
+ ci->ci_tss_sel = tss_alloc(&cputss->tss);
}
void
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/i386/i386/genassym.cf Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.99 2015/08/26 03:00:53 uebayasi Exp $
+# $NetBSD: genassym.cf,v 1.99.10.1 2018/03/13 15:47:44 martin Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -256,6 +256,11 @@
define IH_NEXT offsetof(struct intrhand, ih_next)
endif
+define TSS_TSS offsetof(struct cpu_tss, tss)
+define TSS_ESP0 offsetof(struct cpu_tss, tss.tss_esp0)
+define TSS_IOBASE offsetof(struct cpu_tss, tss.tss_iobase)
+define TSS_IOMAP offsetof(struct cpu_tss, iomap)
+
define CPU_INFO_SELF offsetof(struct cpu_info, ci_self)
define CPU_INFO_RESCHED offsetof(struct cpu_info, ci_want_resched)
define CPU_INFO_WANT_PMAPLOAD offsetof(struct cpu_info, ci_want_pmapload)
@@ -267,10 +272,6 @@
define CPU_INFO_IDLELWP offsetof(struct cpu_info, ci_data.cpu_idlelwp)
define CPU_INFO_PMAP offsetof(struct cpu_info, ci_pmap)
define CPU_INFO_TSS offsetof(struct cpu_info, ci_tss)
-define CPU_INFO_TSS_SEL offsetof(struct cpu_info, ci_tss_sel)
-define CPU_INFO_ESP0 offsetof(struct cpu_info, ci_tss.tss_esp0)
-define CPU_INFO_IOBASE offsetof(struct cpu_info, ci_tss.tss_iobase)
-define CPU_INFO_IOMAP offsetof(struct cpu_info, ci_iomap)
define IOMAP_INVALOFF IOMAP_INVALOFF
define CPU_INFO_NSYSCALL offsetof(struct cpu_info, ci_data.cpu_nsyscall)
define CPU_INFO_NTRAP offsetof(struct cpu_info, ci_data.cpu_ntrap)
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/i386/i386/locore.S Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.145.6.2 2017/09/09 17:29:40 snj Exp $ */
+/* $NetBSD: locore.S,v 1.145.6.3 2018/03/13 15:47:44 martin Exp $ */
/*
* Copyright-o-rama!
@@ -128,7 +128,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.145.6.2 2017/09/09 17:29:40 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.145.6.3 2018/03/13 15:47:44 martin Exp $");
#include "opt_compat_oldboot.h"
#include "opt_copy_symtab.h"
@@ -1112,7 +1112,8 @@
addl $4,%esp
#else
movl PCB_ESP0(%ebx),%eax
- movl %eax,CPUVAR(ESP0)
+ movl CPUVAR(TSS),%ecx
+ movl %eax,TSS_ESP0(%ecx)
#endif
/* Don't bother with the rest if switching to a system process. */
@@ -1136,7 +1137,8 @@
movl PCB_IOMAP(%ebx),%eax
orl %eax,%eax
jnz .Lcopy_iobitmap
- movl $(IOMAP_INVALOFF << 16),CPUVAR(IOBASE)
+ movl CPUVAR(TSS),%eax
+ movl $(IOMAP_INVALOFF << 16),TSS_IOBASE(%eax)
.Liobitmap_done:
/* Is this process using RAS (restartable atomic sequences)? */
@@ -1200,13 +1202,14 @@
pushl %esi
pushl %edi
movl %eax,%esi /* pcb_iomap */
- movl CPUVAR(SELF),%edi
- leal CPU_INFO_IOMAP(%edi),%edi
+ movl CPUVAR(TSS),%edi
+ leal TSS_IOMAP(%edi),%edi
rep
movsl
popl %edi
popl %esi
- movl $((CPU_INFO_IOMAP - CPU_INFO_TSS) << 16),CPUVAR(IOBASE)
+ movl CPUVAR(TSS),%eax
+ movl $((TSS_IOMAP - TSS_TSS) << 16),TSS_IOBASE(%eax)
jmp .Liobitmap_done
END(cpu_switchto)
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/i386/i386/machdep.c Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.782.6.3 2018/03/08 11:33:15 martin Exp $ */
+/* $NetBSD: machdep.c,v 1.782.6.4 2018/03/13 15:47:45 martin Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.782.6.3 2018/03/08 11:33:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.782.6.4 2018/03/13 15:47:45 martin Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -483,8 +483,8 @@
gdt_init();
i386_proc0_tss_ldt_init();
+ cpu_init_tss(&cpu_info_primary);
#ifndef XEN
- cpu_init_tss(&cpu_info_primary);
ltr(cpu_info_primary.ci_tss_sel);
#endif
@@ -618,10 +618,10 @@
ci->ci_doubleflt_stack = (char *)uvm_km_alloc(kernel_map, USPACE, 0,
UVM_KMF_WIRED);
+ tss_init(&ci->ci_tss->dblflt_tss, ci->ci_doubleflt_stack,
+ IDTVEC(tss_trap08));
- tss_init(&ci->ci_doubleflt_tss, ci->ci_doubleflt_stack,
- IDTVEC(tss_trap08));
- setsegment(&sd, &ci->ci_doubleflt_tss, sizeof(struct i386tss) - 1,
+ setsegment(&sd, &ci->ci_tss->dblflt_tss, sizeof(struct i386tss) - 1,
SDT_SYS386TSS, SEL_KPL, 0, 0);
ci->ci_gdt[GTRAPTSS_SEL].sd = sd;
@@ -638,10 +638,10 @@
*/
ci->ci_ddbipi_stack = (char *)uvm_km_alloc(kernel_map, USPACE, 0,
UVM_KMF_WIRED);
- tss_init(&ci->ci_ddbipi_tss, ci->ci_ddbipi_stack,
+ tss_init(&ci->ci_tss->ddbipi_tss, ci->ci_ddbipi_stack,
x2apic_mode ? Xx2apic_intrddbipi : Xintrddbipi);
- setsegment(&sd, &ci->ci_ddbipi_tss, sizeof(struct i386tss) - 1,
+ setsegment(&sd, &ci->ci_tss->ddbipi_tss, sizeof(struct i386tss) - 1,
SDT_SYS386TSS, SEL_KPL, 0, 0);
ci->ci_gdt[GIPITSS_SEL].sd = sd;
@@ -649,6 +649,7 @@
GSEL(GIPITSS_SEL, SEL_KPL));
#endif
}
+#endif /* XEN */
/*
* Set up TSS and I/O bitmap.
@@ -656,15 +657,24 @@
void
cpu_init_tss(struct cpu_info *ci)
{
- struct i386tss *tss = &ci->ci_tss;
+ struct cpu_tss *cputss;
+
+ cputss = (struct cpu_tss *)uvm_km_alloc(kernel_map,
+ sizeof(struct cpu_tss), 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
+
+ cputss->tss.tss_iobase = IOMAP_INVALOFF << 16;
- tss->tss_iobase = IOMAP_INVALOFF << 16;
- tss->tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- tss->tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
- tss->tss_cr3 = rcr3();
- ci->ci_tss_sel = tss_alloc(tss);
+#ifndef XEN
+ cputss->tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
+ cputss->tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
+ cputss->tss.tss_cr3 = rcr3();
+#endif
+
+ ci->ci_tss = cputss;
+#ifndef XEN
+ ci->ci_tss_sel = tss_alloc(&cputss->tss);
+#endif
}
-#endif /* XEN */
void *
getframe(struct lwp *l, int sig, int *onstack)
diff -r 2364b16fb158 -r d2b0400dbfbb sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h Tue Mar 13 15:40:25 2018 +0000
+++ b/sys/arch/x86/include/cpu.h Tue Mar 13 15:47:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.71.2.1 2018/03/08 11:33:15 martin Exp $ */
+/* $NetBSD: cpu.h,v 1.71.2.2 2018/03/13 15:47:45 martin Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -84,6 +84,15 @@
#define NIOPORTS 1024 /* # of ports we allow to be mapped */
#define IOMAPSIZE (NIOPORTS / 8) /* I/O bitmap size in bytes */
Home |
Main Index |
Thread Index |
Old Index