Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move the amd64 and i386 pcb to the bottom of the uarea, ...
details: https://anonhg.NetBSD.org/src/rev/0770d1ced531
branches: trunk
changeset: 326861:0770d1ced531
user: dsl <dsl%NetBSD.org@localhost>
date: Thu Feb 20 18:19:09 2014 +0000
description:
Move the amd64 and i386 pcb to the bottom of the uarea, and move the
kernel stack to the top.
Change the pcb layouts so that fpu save area is at the end and is
64byte aligned ready for xsave (saving the ymm registers).
Welcome to 6.99.32
diffstat:
sys/arch/amd64/amd64/genassym.cf | 3 +--
sys/arch/amd64/amd64/machdep.c | 6 +++---
sys/arch/amd64/include/pcb.h | 21 +++++++++------------
sys/arch/amd64/include/proc.h | 7 +------
sys/arch/i386/i386/locore.S | 10 +++++-----
sys/arch/i386/i386/machdep.c | 7 ++++---
sys/arch/i386/include/pcb.h | 25 +++++++++++++------------
sys/arch/i386/include/proc.h | 8 +-------
sys/arch/x86/x86/vm_machdep.c | 11 +++++++----
sys/sys/param.h | 4 ++--
10 files changed, 46 insertions(+), 56 deletions(-)
diffs (truncated from 324 to 300 lines):
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/amd64/amd64/genassym.cf
--- a/sys/arch/amd64/amd64/genassym.cf Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/amd64/amd64/genassym.cf Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.55 2014/02/15 10:11:14 dsl Exp $
+# $NetBSD: genassym.cf,v 1.56 2014/02/20 18:19:09 dsl Exp $
#
# Copyright (c) 1998, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -181,7 +181,6 @@
define PCB_CR3 offsetof(struct pcb, pcb_cr3)
define PCB_RBP offsetof(struct pcb, pcb_rbp)
define PCB_RSP offsetof(struct pcb, pcb_rsp)
-define PCB_USERSP offsetof(struct pcb, pcb_usersp)
define PCB_RSP0 offsetof(struct pcb, pcb_rsp0)
define PCB_CR0 offsetof(struct pcb, pcb_cr0)
define PCB_ONFAULT offsetof(struct pcb, pcb_onfault)
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.205 2014/02/15 22:20:41 dsl Exp $ */
+/* $NetBSD: machdep.c,v 1.206 2014/02/20 18:19:09 dsl 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.205 2014/02/15 22:20:41 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.206 2014/02/20 18:19:09 dsl Exp $");
/* #define XENDEBUG_LOW */
@@ -467,7 +467,7 @@
pcb->pcb_flags = 0;
pcb->pcb_fs = 0;
pcb->pcb_gs = 0;
- pcb->pcb_rsp0 = (uvm_lwp_getuarea(l) + KSTACK_SIZE - 16) & ~0xf;
+ pcb->pcb_rsp0 = (uvm_lwp_getuarea(l) + USPACE - 16) & ~0xf;
pcb->pcb_iopl = SEL_KPL;
pmap_kernel()->pm_ldt_sel = GSYSSEL(GLDT_SEL, SEL_KPL);
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/amd64/include/pcb.h
--- a/sys/arch/amd64/include/pcb.h Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/amd64/include/pcb.h Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.24 2014/02/11 20:17:16 dsl Exp $ */
+/* $NetBSD: pcb.h,v 1.25 2014/02/20 18:19:10 dsl Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -72,12 +72,7 @@
#ifdef __x86_64__
-#include <sys/signal.h>
-
-#include <machine/segments.h>
-#include <machine/tss.h>
-#include <x86/fpu.h>
-#include <machine/sysarch.h>
+#include <x86/cpu_extended_state.h>
#define NIOPORTS 1024 /* # of ports we allow to be mapped */
@@ -91,16 +86,18 @@
uint64_t pcb_cr3;
uint64_t pcb_rsp;
uint64_t pcb_rbp;
- uint64_t pcb_usersp;
- uint32_t pcb_unused[2]; /* unused */
- union savefpu pcb_savefpu __aligned(16); /* floating point state */
- uint32_t pcb_unused_1[4]; /* unused */
void *pcb_onfault; /* copyin/out fault recovery */
- struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
uint64_t pcb_fs;
uint64_t pcb_gs;
int pcb_iopl;
+
+ uint32_t pcb_unused[11]; /* unused */
+
+ struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
+ union savefpu pcb_savefpu __aligned(64); /* floating point state */
+ /* **** DO NOT ADD ANYTHING HERE **** */
};
+__CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) == 128);
#else /* __x86_64__ */
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/amd64/include/proc.h
--- a/sys/arch/amd64/include/proc.h Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/amd64/include/proc.h Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.18 2014/02/15 10:11:15 dsl Exp $ */
+/* $NetBSD: proc.h,v 1.19 2014/02/20 18:19:10 dsl Exp $ */
/*
* Copyright (c) 1991 Regents of the University of California.
@@ -65,11 +65,6 @@
/* md_flags */
#define MDP_USEDMTRR 0x0008 /* has set volatile MTRRs */
-#define UAREA_PCB_OFFSET (USPACE - ALIGN(sizeof(struct pcb)))
-#define KSTACK_LOWEST_ADDR(l) \
- ((void *)((vaddr_t)(l)->l_addr - UAREA_PCB_OFFSET))
-#define KSTACK_SIZE UAREA_PCB_OFFSET
-
#else /* __x86_64__ */
#include <i386/proc.h>
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/i386/i386/locore.S Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.111 2014/02/02 22:41:20 dsl Exp $ */
+/* $NetBSD: locore.S,v 1.112 2014/02/20 18:19:10 dsl Exp $ */
/*
* Copyright-o-rama!
@@ -129,7 +129,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.111 2014/02/02 22:41:20 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.112 2014/02/20 18:19:10 dsl Exp $");
#include "opt_compat_oldboot.h"
#include "opt_ddb.h"
@@ -727,8 +727,8 @@
/* Set up bootstrap stack. */
leal (PROC0_STK_OFF+KERNBASE)(%esi),%eax
movl %eax,_C_LABEL(lwp0uarea)
- leal (KSTACK_SIZE-FRAMESIZE)(%eax),%esp
- movl %esi,(KSTACK_SIZE+PCB_CR3)(%eax) # pcb->pcb_cr3
+ leal (USPACE-FRAMESIZE)(%eax),%esp
+ movl %esi,PCB_CR3(%eax) # pcb->pcb_cr3
xorl %ebp,%ebp # mark end of frames
#if defined(MULTIBOOT)
@@ -825,7 +825,7 @@
movl %esi, _C_LABEL(lwp0uarea)
/* Set up bootstrap stack. */
- leal (KSTACK_SIZE-FRAMESIZE)(%eax),%esp
+ leal (USPACE-FRAMESIZE)(%eax),%esp
xorl %ebp,%ebp # mark end of frames
addl $USPACE, %esi
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/i386/i386/machdep.c Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.749 2014/02/18 01:00:57 christos Exp $ */
+/* $NetBSD: machdep.c,v 1.750 2014/02/20 18:19:10 dsl 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.749 2014/02/18 01:00:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.750 2014/02/20 18:19:10 dsl Exp $");
#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
@@ -142,6 +142,7 @@
#include <machine/mtrr.h>
#include <x86/x86/tsc.h>
+#include <x86/fpu.h>
#include <x86/machdep.h>
#include <machine/multiboot.h>
@@ -500,7 +501,7 @@
pmap_kernel()->pm_ldt_sel = GSEL(GLDT_SEL, SEL_KPL);
pcb->pcb_cr0 = rcr0() & ~CR0_TS;
- pcb->pcb_esp0 = uvm_lwp_getuarea(l) + KSTACK_SIZE - 16;
+ pcb->pcb_esp0 = uvm_lwp_getuarea(l) + USPACE - 16;
pcb->pcb_iopl = SEL_KPL;
l->l_md.md_regs = (struct trapframe *)pcb->pcb_esp0 - 1;
memcpy(&pcb->pcb_fsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_fsd));
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/i386/include/pcb.h
--- a/sys/arch/i386/include/pcb.h Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/i386/include/pcb.h Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcb.h,v 1.52 2014/02/12 23:24:09 dsl Exp $ */
+/* $NetBSD: pcb.h,v 1.53 2014/02/20 18:19:10 dsl Exp $ */
/*-
* Copyright (c) 1998, 2009 The NetBSD Foundation, Inc.
@@ -74,34 +74,35 @@
#include "opt_multiprocessor.h"
#endif
-#include <sys/signal.h>
-
#include <machine/segments.h>
-#include <machine/tss.h>
-#include <x86/fpu.h>
-#include <i386/sysarch.h>
+#include <x86/cpu_extended_state.h>
struct pcb {
int pcb_esp0; /* ring0 esp */
int pcb_esp; /* kernel esp */
int pcb_ebp; /* kernel ebp */
- int pcb_unused; /* unused */
int pcb_cr0; /* saved image of CR0 */
int pcb_cr2; /* page fault address (CR2) */
int pcb_cr3; /* page directory pointer */
int pcb_iopl; /* i/o privilege level */
- /* floating point state for FPU */
- union savefpu pcb_savefpu __aligned(16);
-
struct segment_descriptor pcb_fsd; /* %fs descriptor */
struct segment_descriptor pcb_gsd; /* %gs descriptor */
- void * pcb_onfault; /* copyin/out fault recovery */
+ void *pcb_onfault; /* copyin/out fault recovery */
int vm86_eflags; /* virtual eflags for vm86 mode */
int vm86_flagmask; /* flag mask for vm86 mode */
void *vm86_userp; /* XXX performance hack */
- struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
char *pcb_iomap; /* I/O permission bitmap */
+
+ int not_used[15];
+
+ /* floating point state */
+ struct cpu_info *pcb_fpcpu; /* cpu holding our fp state. */
+ union savefpu pcb_savefpu __aligned(64);
+ /* **** DO NOT ADD ANYTHING HERE **** */
+
};
+/* This doesn't really matter, but there is a lot of implied padding */
+__CTASSERT(sizeof(struct pcb) - sizeof (union savefpu) == 128);
#endif /* _I386_PCB_H_ */
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/i386/include/proc.h
--- a/sys/arch/i386/include/proc.h Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/i386/include/proc.h Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.41 2014/02/15 10:11:15 dsl Exp $ */
+/* $NetBSD: proc.h,v 1.42 2014/02/20 18:19:10 dsl Exp $ */
/*
* Copyright (c) 1991 Regents of the University of California.
@@ -63,10 +63,4 @@
/* md_flags */
#define MDP_USEDMTRR 0x0002 /* has set volatile MTRRs */
-/* Kernel stack parameters. */
-#define UAREA_PCB_OFFSET (USPACE - ALIGN(sizeof(struct pcb)))
-#define KSTACK_LOWEST_ADDR(l) \
- ((void *)((vaddr_t)(l)->l_addr - UAREA_PCB_OFFSET))
-#define KSTACK_SIZE UAREA_PCB_OFFSET
-
#endif /* _I386_PROC_H_ */
diff -r a471351e28a0 -r 0770d1ced531 sys/arch/x86/x86/vm_machdep.c
--- a/sys/arch/x86/x86/vm_machdep.c Thu Feb 20 18:14:11 2014 +0000
+++ b/sys/arch/x86/x86/vm_machdep.c Thu Feb 20 18:19:09 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.22 2014/02/15 10:11:15 dsl Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.23 2014/02/20 18:19:10 dsl Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.22 2014/02/15 10:11:15 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.23 2014/02/20 18:19:10 dsl Exp $");
#include "opt_mtrr.h"
@@ -99,10 +99,13 @@
#include <machine/gdt.h>
#include <machine/reg.h>
#include <machine/specialreg.h>
+
#ifdef MTRR
#include <machine/mtrr.h>
#endif
+#include <x86/fpu.h>
+
void
cpu_proc_fork(struct proc *p1, struct proc *p2)
{
@@ -169,10 +172,10 @@
uv = uvm_lwp_getuarea(l2);
#ifdef __x86_64__
- pcb2->pcb_rsp0 = (uv + KSTACK_SIZE - 16) & ~0xf;
+ pcb2->pcb_rsp0 = (uv + USPACE - 16) & ~0xf;
tf = (struct trapframe *)pcb2->pcb_rsp0 - 1;
Home |
Main Index |
Thread Index |
Old Index