From 42f654a26b59563091edc7e54cc237674ad4b261 Mon Sep 17 00:00:00 2001 From: yamt Date: Tue, 8 Jan 2008 13:15:01 +0000 Subject: [PATCH] change the layout in u-area and reduce UPAGES. --- sys/arch/amd64/amd64/machdep.c | 6 +++--- sys/arch/amd64/amd64/vm_machdep.c | 12 +++++++----- sys/arch/amd64/include/param.h | 4 ++-- sys/arch/amd64/include/proc.h | 7 ++++++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 027dcb01e285..1aed95450506 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.81 2008/01/05 22:48:31 yamt Exp $ */ +/* $NetBSD: machdep.c,v 1.82 2008/01/08 13:15:01 yamt Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007 @@ -120,7 +120,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.81 2008/01/05 22:48:31 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.82 2008/01/08 13:15:01 yamt Exp $"); /* #define XENDEBUG_LOW */ @@ -432,7 +432,7 @@ x86_64_proc0_tss_ldt_init(void) pcb->pcb_flags = 0; pcb->pcb_fs = 0; pcb->pcb_gs = 0; - pcb->pcb_rsp0 = (u_int64_t)l->l_addr + USPACE - 16; + pcb->pcb_rsp0 = (USER_TO_UAREA(l->l_addr) + KSTACK_SIZE - 16) & ~0xf; pcb->pcb_iopl = SEL_KPL; pcb->pcb_ldt_sel = pmap_kernel()->pm_ldt_sel = diff --git a/sys/arch/amd64/amd64/vm_machdep.c b/sys/arch/amd64/amd64/vm_machdep.c index 712cb5095444..4fb25156cff2 100644 --- a/sys/arch/amd64/amd64/vm_machdep.c +++ b/sys/arch/amd64/amd64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.28 2008/01/05 21:47:19 yamt Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.29 2008/01/08 13:15:01 yamt Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.28 2008/01/05 21:47:19 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.29 2008/01/08 13:15:01 yamt Exp $"); #include "opt_coredump.h" #include "opt_user_ldt.h" @@ -175,7 +175,7 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize, */ l2->l_md.md_astpending = 0; - pcb->pcb_rsp0 = (u_int64_t)l2->l_addr + USPACE - 16; + pcb->pcb_rsp0 = (USER_TO_UAREA(l2->l_addr) + KSTACK_SIZE - 16) & ~0xf; /* * Copy the trapframe. @@ -303,8 +303,10 @@ cpu_coredump(struct lwp *l, void *iocookie, struct core *chdr) static void setredzone(struct lwp *l) { - pmap_remove(pmap_kernel(), (vaddr_t)l->l_addr + PAGE_SIZE, - (vaddr_t)l->l_addr + 2 * PAGE_SIZE); + vaddr_t addr; + + addr = USER_TO_UAREA(l->l_addr); + pmap_remove(pmap_kernel(), addr, addr + PAGE_SIZE); pmap_update(pmap_kernel()); } diff --git a/sys/arch/amd64/include/param.h b/sys/arch/amd64/include/param.h index 8af04d458db5..28898c4896df 100644 --- a/sys/arch/amd64/include/param.h +++ b/sys/arch/amd64/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.7 2008/01/05 21:47:19 yamt Exp $ */ +/* $NetBSD: param.h,v 1.8 2008/01/08 13:15:02 yamt Exp $ */ #ifdef _KERNEL #include @@ -56,7 +56,7 @@ #define SSIZE 1 /* initial stack size/NBPG */ #define SINCR 1 /* increment of stack/NBPG */ -#define UPAGES 5 /* pages of u-area */ +#define UPAGES 3 /* pages of u-area */ #define USPACE (UPAGES * NBPG) /* total size of u-area */ #define INTRSTACKSIZE 4096 diff --git a/sys/arch/amd64/include/proc.h b/sys/arch/amd64/include/proc.h index d40584662880..57bdbb9b7279 100644 --- a/sys/arch/amd64/include/proc.h +++ b/sys/arch/amd64/include/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.8 2008/01/05 21:47:20 yamt Exp $ */ +/* $NetBSD: proc.h,v 1.9 2008/01/08 13:15:02 yamt Exp $ */ /* * Copyright (c) 1991 Regents of the University of California. @@ -34,6 +34,7 @@ #ifndef _AMD64_PROC_H #define _AMD64_PROC_H +#include /* for sizeof(struct user) */ #include /* @@ -58,4 +59,8 @@ struct mdproc { #define MDP_USEDMTRR 0x0008 /* has set volatile MTRRs */ #define MDP_IRET 0x0010 /* return via iret, not sysret */ +#define UAREA_USER_OFFSET (USPACE - ALIGN(sizeof(struct user))) +#define KSTACK_LOWEST_ADDR(l) ((void *)USER_TO_UAREA((l)->l_addr)) +#define KSTACK_SIZE UAREA_USER_OFFSET + #endif /* _AMD64_PROC_H */