summaryrefslogtreecommitdiffstats
path: root/sys/sparc64
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2007-11-05 11:36:16 +0000
committerkib <kib@FreeBSD.org>2007-11-05 11:36:16 +0000
commit9ae733819b7cdf0eef51ba1b18d39feb136a9dbf (patch)
treecccec36134d2cab5ce1eabb67dcaab5981e9beb0 /sys/sparc64
parentf3f033b9b90ea07350fbe7483af3d9636cb31d1d (diff)
downloadFreeBSD-src-9ae733819b7cdf0eef51ba1b18d39feb136a9dbf.zip
FreeBSD-src-9ae733819b7cdf0eef51ba1b18d39feb136a9dbf.tar.gz
Fix for the panic("vm_thread_new: kstack allocation failed") and
silent NULL pointer dereference in the i386 and sparc64 pmap_pinit() when the kmem_alloc_nofault() failed to allocate address space. Both functions now return error instead of panicing or dereferencing NULL. As consequence, vmspace_exec() and vmspace_unshare() returns the errno int. struct vmspace arg was added to vm_forkproc() to avoid dealing with failed allocation when most of the fork1() job is already done. The kernel stack for the thread is now set up in the thread_alloc(), that itself may return NULL. Also, allocation of the first process thread is performed in the fork1() to properly deal with stack allocation failure. proc_linkup() is separated into proc_linkup() called from fork1(), and proc_linkup0(), that is used to set up the kernel process (was known as swapper). In collaboration with: Peter Holm Reviewed by: jhb
Diffstat (limited to 'sys/sparc64')
-rw-r--r--sys/sparc64/sparc64/machdep.c2
-rw-r--r--sys/sparc64/sparc64/pmap.c7
2 files changed, 7 insertions, 2 deletions
diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c
index 889d676..2e6d05e 100644
--- a/sys/sparc64/sparc64/machdep.c
+++ b/sys/sparc64/sparc64/machdep.c
@@ -399,7 +399,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec)
/*
* Initialize proc0 stuff (p_contested needs to be done early).
*/
- proc_linkup(&proc0, &thread0);
+ proc_linkup0(&proc0, &thread0);
proc0.p_md.md_sigtramp = NULL;
proc0.p_md.md_utrap = NULL;
thread0.td_kstack = kstack0;
diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c
index eb61582..1c71c5f 100644
--- a/sys/sparc64/sparc64/pmap.c
+++ b/sys/sparc64/sparc64/pmap.c
@@ -1006,7 +1006,7 @@ pmap_pinit0(pmap_t pm)
* Initialize a preallocated and zeroed pmap structure, such as one in a
* vmspace structure.
*/
-void
+int
pmap_pinit(pmap_t pm)
{
vm_page_t ma[TSB_PAGES];
@@ -1021,6 +1021,10 @@ pmap_pinit(pmap_t pm)
if (pm->pm_tsb == NULL) {
pm->pm_tsb = (struct tte *)kmem_alloc_nofault(kernel_map,
TSB_BSIZE);
+ if (pm->pm_tsb == NULL) {
+ PMAP_LOCK_DESTROY(pm);
+ return (0);
+ }
}
/*
@@ -1044,6 +1048,7 @@ pmap_pinit(pmap_t pm)
pm->pm_context[i] = -1;
pm->pm_active = 0;
bzero(&pm->pm_stats, sizeof(pm->pm_stats));
+ return (1);
}
/*
OpenPOWER on IntegriCloud