Tue Dec 15 18:24:47 2009 UTC ()
Make sure the pcb and initial frame area of lwp0 are zeroed since these will
be the basis for all future lwps.


(matt)
diff -r1.223 -r1.224 src/sys/arch/mips/mips/mips_machdep.c

cvs diff -r1.223 -r1.224 src/sys/arch/mips/mips/mips_machdep.c (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips_machdep.c 2009/12/14 00:46:06 1.223
+++ src/sys/arch/mips/mips/mips_machdep.c 2009/12/15 18:24:47 1.224
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mips_machdep.c,v 1.223 2009/12/14 00:46:06 matt Exp $ */ 1/* $NetBSD: mips_machdep.c,v 1.224 2009/12/15 18:24:47 matt Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Wasabi Systems, Inc. 4 * Copyright 2002 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Simon Burge for Wasabi Systems, Inc. 7 * Written by Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -102,27 +102,27 @@ @@ -102,27 +102,27 @@
102 * Junior University. All Rights Reserved. 102 * Junior University. All Rights Reserved.
103 * 103 *
104 * Permission to use, copy, modify, and distribute this 104 * Permission to use, copy, modify, and distribute this
105 * software and its documentation for any purpose and without 105 * software and its documentation for any purpose and without
106 * fee is hereby granted, provided that the above copyright 106 * fee is hereby granted, provided that the above copyright
107 * notice appear in all copies. Stanford University 107 * notice appear in all copies. Stanford University
108 * makes no representations about the suitability of this 108 * makes no representations about the suitability of this
109 * software for any purpose. It is provided "as is" without 109 * software for any purpose. It is provided "as is" without
110 * express or implied warranty. 110 * express or implied warranty.
111 */ 111 */
112 112
113#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 113#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
114 114
115__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.223 2009/12/14 00:46:06 matt Exp $"); 115__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.224 2009/12/15 18:24:47 matt Exp $");
116 116
117#include "opt_cputype.h" 117#include "opt_cputype.h"
118#include "opt_compat_netbsd32.h" 118#include "opt_compat_netbsd32.h"
119 119
120#include <sys/param.h> 120#include <sys/param.h>
121#include <sys/systm.h> 121#include <sys/systm.h>
122#include <sys/proc.h> 122#include <sys/proc.h>
123#include <sys/exec.h> 123#include <sys/exec.h>
124#include <sys/reboot.h> 124#include <sys/reboot.h>
125#include <sys/mount.h> /* fsid_t for syscallargs */ 125#include <sys/mount.h> /* fsid_t for syscallargs */
126#include <sys/lwp.h> 126#include <sys/lwp.h>
127#include <sys/sysctl.h> 127#include <sys/sysctl.h>
128#include <sys/msgbuf.h> 128#include <sys/msgbuf.h>
@@ -1639,26 +1639,31 @@ mips_init_msgbuf(void) @@ -1639,26 +1639,31 @@ mips_init_msgbuf(void)
1639 printf("WARNING: %"PRIdVSIZE" bytes not available for msgbuf " 1639 printf("WARNING: %"PRIdVSIZE" bytes not available for msgbuf "
1640 "in last cluster (%"PRIdVSIZE" used)\n", reqsz, sz); 1640 "in last cluster (%"PRIdVSIZE" used)\n", reqsz, sz);
1641} 1641}
1642 1642
1643void 1643void
1644mips_init_lwp0_uarea(void) 1644mips_init_lwp0_uarea(void)
1645{ 1645{
1646 vaddr_t v = uvm_pageboot_alloc(USPACE); 1646 vaddr_t v = uvm_pageboot_alloc(USPACE);
1647 1647
1648 uvm_lwp_setuarea(&lwp0, v); 1648 uvm_lwp_setuarea(&lwp0, v);
1649 1649
1650 struct pcb * const pcb0 = lwp_getpcb(&lwp0); 1650 struct pcb * const pcb0 = lwp_getpcb(&lwp0);
1651 lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1; 1651 lwp0.l_md.md_regs = (struct frame *)(v + USPACE) - 1;
 1652 /*
 1653 * Now zero out the only two areas of the uarea that we care about.
 1654 */
 1655 memset(lwp0.l_md.md_regs, 0, sizeof(*lwp0.l_md.md_regs));
 1656 memset(pcb0, 0, sizeof(*pcb0));
1652#ifdef _LP64 1657#ifdef _LP64
1653 lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX; 1658 lwp0.l_md.md_regs->f_regs[_R_SR] = MIPS_SR_KX;
1654#endif 1659#endif
1655 pcb0->pcb_context.val[_L_SR] = 1660 pcb0->pcb_context.val[_L_SR] =
1656#ifdef _LP64 1661#ifdef _LP64
1657 MIPS_SR_KX | 1662 MIPS_SR_KX |
1658#endif 1663#endif
1659 MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */ 1664 MIPS_INT_MASK | MIPS_SR_INT_IE; /* SR */
1660} 1665}
1661 1666
1662void 1667void
1663savefpregs(struct lwp *l) 1668savefpregs(struct lwp *l)
1664{ 1669{