With the removal of IPKDB on arm, the undefined stack is only used to

bounce into SVC32 mode, there is no per-process data stored on it.

We can therefore use the undefined stack setup by the platform machdep.c
as a system wide undefined stack.

This removes the need for a per-process undefined stack, and the processor
mode switching overhead it causes in cpu_switchto.

The space freed in the USPACE is used to increase the per process kernel
stack size.
This commit is contained in:
chris 2008-01-19 15:04:09 +00:00
parent 3618b9ac2c
commit 4e4f6b2828
6 changed files with 11 additions and 47 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arm32_machdep.c,v 1.54 2008/01/19 13:11:09 chris Exp $ */
/* $NetBSD: arm32_machdep.c,v 1.55 2008/01/19 15:04:09 chris Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.54 2008/01/19 13:11:09 chris Exp $");
__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.55 2008/01/19 15:04:09 chris Exp $");
#include "opt_md.h"
#include "opt_pmap_debug.h"
@ -273,8 +273,6 @@ cpu_startup()
curpcb = &lwp0.l_addr->u_pcb;
curpcb->pcb_flags = 0;
curpcb->pcb_un.un_32.pcb32_und_sp = (u_int)lwp0.l_addr +
USPACE_UNDEF_STACK_TOP;
curpcb->pcb_un.un_32.pcb32_sp = (u_int)lwp0.l_addr +
USPACE_SVC_STACK_TOP;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpuswitch.S,v 1.53 2008/01/13 02:43:53 chris Exp $ */
/* $NetBSD: cpuswitch.S,v 1.54 2008/01/19 15:04:10 chris Exp $ */
/*
* Copyright 2003 Wasabi Systems, Inc.
@ -230,15 +230,6 @@ ENTRY(cpu_switchto)
/* Get the user structure for the new process in r9 */
ldr r9, [r6, #(L_ADDR)]
/* fetch sp for the undefined instruction trap. */
mrs r3, cpsr
orr r2, r3, #(PSR_UND32_MODE | I32_bit)
msr cpsr_c, r2
str sp, [r8, #(PCB_UND_SP)]
msr cpsr_c, r3 /* Restore the old mode */
/* What else needs to be saved? Only FPA stuff when that is supported */
/* Restore saved context */
@ -258,15 +249,6 @@ ENTRY(cpu_switchto)
/* rem: r9 = new PCB */
/* rem: interrupts are enabled */
/* set sp for the undefined instruction trap. */
mrs r3, cpsr
orr r2, r3, #(PSR_UND32_MODE | I32_bit)
msr cpsr_c, r2
ldr sp, [r9, #(PCB_UND_SP)]
msr cpsr_c, r3 /* Restore the old mode */
/* Restore all the saved registers */
#ifndef __XSCALE__
add r7, r9, #PCB_R8

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.37 2008/01/08 02:07:50 matt Exp $
# $NetBSD: genassym.cf,v 1.38 2008/01/19 15:04:10 chris Exp $
# Copyright (c) 1982, 1990 The Regents of the University of California.
# All rights reserved.
@ -102,7 +102,6 @@ define PCB_R12 offsetof(struct pcb, pcb_un.un_32.pcb32_r12)
define PCB_SP offsetof(struct pcb, pcb_un.un_32.pcb32_sp)
define PCB_LR offsetof(struct pcb, pcb_un.un_32.pcb32_lr)
define PCB_PC offsetof(struct pcb, pcb_un.un_32.pcb32_pc)
define PCB_UND_SP offsetof(struct pcb, pcb_un.un_32.pcb32_und_sp)
define PCB_ONFAULT offsetof(struct pcb, pcb_onfault)
define PCB_NOALIGNFLT PCB_NOALIGNFLT

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.41 2008/01/12 20:50:24 skrll Exp $ */
/* $NetBSD: vm_machdep.c,v 1.42 2008/01/19 15:04:10 chris Exp $ */
/*
* Copyright (c) 1994-1998 Mark Brinicombe.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.41 2008/01/12 20:50:24 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.42 2008/01/19 15:04:10 chris Exp $");
#include "opt_armfpe.h"
#include "opt_pmap_debug.h"
@ -144,17 +144,12 @@ cpu_lwp_fork(struct lwp *l1, struct lwp *l2, void *stack, size_t stacksize,
*pcb = l1->l_addr->u_pcb;
/*
* Set up the undefined stack for the process.
* Set up the stack for the process.
* Note: this stack is not in use if we are forking from p1
*/
pcb->pcb_un.un_32.pcb32_und_sp = (u_int)l2->l_addr +
USPACE_UNDEF_STACK_TOP;
pcb->pcb_un.un_32.pcb32_sp = (u_int)l2->l_addr + USPACE_SVC_STACK_TOP;
#ifdef STACKCHECKS
/* Fill the undefined stack with a known pattern */
memset(((u_char *)l2->l_addr) + USPACE_UNDEF_STACK_BOTTOM, 0xdd,
(USPACE_UNDEF_STACK_TOP - USPACE_UNDEF_STACK_BOTTOM));
/* Fill the kernel stack with a known pattern */
memset(((u_char *)l2->l_addr) + USPACE_SVC_STACK_BOTTOM, 0xdd,
(USPACE_SVC_STACK_TOP - USPACE_SVC_STACK_BOTTOM));
@ -218,10 +213,6 @@ cpu_lwp_free(struct lwp *l, int proc)
u_char *ptr;
int loop;
ptr = ((u_char *)p2->p_addr) + USPACE_UNDEF_STACK_BOTTOM;
for (loop = 0; loop < (USPACE_UNDEF_STACK_TOP - USPACE_UNDEF_STACK_BOTTOM)
&& *ptr == 0xdd; ++loop, ++ptr) ;
log(LOG_INFO, "%d bytes of undefined stack fill pattern\n", loop);
ptr = ((u_char *)p2->p_addr) + USPACE_SVC_STACK_BOTTOM;
for (loop = 0; loop < (USPACE_SVC_STACK_TOP - USPACE_SVC_STACK_BOTTOM)
&& *ptr == 0xdd; ++loop, ++ptr) ;

View File

@ -1,4 +1,4 @@
/* $NetBSD: param.h,v 1.12 2005/12/11 12:16:47 christos Exp $ */
/* $NetBSD: param.h,v 1.13 2008/01/19 15:04:10 chris Exp $ */
/*
* Copyright (c) 1994,1995 Mark Brinicombe.
@ -86,18 +86,15 @@
* 1. the user structure for the process
* 2. the fp context for FP emulation
* 3. the kernel (svc) stack
* 4. the undefined instruction stack
*
* The layout of the area looks like this
*
* | user area | FP context | undefined stack | kernel stack |
* | user area | FP context | kernel stack |
*
* The size of the user area is known.
* The size of the FP context is variable depending of the FP emulator
* in use and whether there is hardware FP support. However we can put
* an upper limit on it.
* The undefined stack needs to be at least 512 bytes. This is a requirement
* if the FP emulators
* The kernel stack should be at least 4K is size.
*
* The stack top addresses are used to set the stack pointers. The stack bottom
@ -107,9 +104,7 @@
#define FPCONTEXTSIZE (0x100)
#define USPACE_SVC_STACK_TOP (USPACE)
#define USPACE_SVC_STACK_BOTTOM (USPACE_SVC_STACK_TOP - 0x1000)
#define USPACE_UNDEF_STACK_TOP (USPACE_SVC_STACK_BOTTOM - 0x10)
#define USPACE_UNDEF_STACK_BOTTOM (sizeof(struct user) + FPCONTEXTSIZE + 10)
#define USPACE_SVC_STACK_BOTTOM (sizeof(struct user) + FPCONTEXTSIZE + 10)
#define arm_btop(x) ((x) >> PGSHIFT)
#define arm_ptob(x) ((x) << PGSHIFT)

View File

@ -1,4 +1,4 @@
/* $NetBSD: pcb.h,v 1.16 2007/10/17 19:53:41 garbled Exp $ */
/* $NetBSD: pcb.h,v 1.17 2008/01/19 15:04:10 chris Exp $ */
/*
* Copyright (c) 2001 Matt Thomas <matt@3am-software.com>.
@ -57,7 +57,6 @@ struct pcb_arm32 {
u_int pcb32_sp; /* used */
u_int pcb32_lr;
u_int pcb32_pc;
u_int pcb32_und_sp;
};
#define pcb_pagedir pcb_un.un_32.pcb32_pagedir
#define pcb_pl1vec pcb_un.un_32.pcb32_pl1vec