summaryrefslogtreecommitdiff
path: root/sys/arch/mips64
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-05-09 19:45:20 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-05-09 19:45:20 +0000
commit755d6e186c2b1a9652026a47039992a821d7e013 (patch)
tree0249299131cb0a4cdf1fd5af5a766a087a546758 /sys/arch/mips64
parentff43252f553c0fe3579033f6fa874248b7aafe53 (diff)
Do not panic when running the MP kernel on a single-processor system; found
the hard way by tobiasu@
Diffstat (limited to 'sys/arch/mips64')
-rw-r--r--sys/arch/mips64/mips64/cpu.c14
-rw-r--r--sys/arch/mips64/mips64/mem.c11
2 files changed, 14 insertions, 11 deletions
diff --git a/sys/arch/mips64/mips64/cpu.c b/sys/arch/mips64/mips64/cpu.c
index fd9b14d1cd4..ee6322991c6 100644
--- a/sys/arch/mips64/mips64/cpu.c
+++ b/sys/arch/mips64/mips64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.49 2012/10/03 11:18:23 miod Exp $ */
+/* $OpenBSD: cpu.c,v 1.50 2013/05/09 19:45:19 miod Exp $ */
/*
* Copyright (c) 1997-2004 Opsycon AB (www.opsycon.se)
@@ -86,11 +86,13 @@ cpuattach(struct device *parent, struct device *dev, void *aux)
#ifdef MULTIPROCESSOR
ci->ci_flags |= CPUF_RUNNING | CPUF_PRESENT | CPUF_PRIMARY;
cpuset_add(&cpus_running, ci);
- cpu_info_secondaries = (struct cpu_info *)
- alloc_contiguous_pages(sizeof(struct cpu_info) *
- (ncpusfound - 1));
- if (cpu_info_secondaries == NULL)
- panic("unable to allocate cpu_info");
+ if (ncpusfound > 1) {
+ cpu_info_secondaries = (struct cpu_info *)
+ alloc_contiguous_pages(sizeof(struct cpu_info) *
+ (ncpusfound - 1));
+ if (cpu_info_secondaries == NULL)
+ panic("unable to allocate cpu_info");
+ }
#endif
}
#ifdef MULTIPROCESSOR
diff --git a/sys/arch/mips64/mips64/mem.c b/sys/arch/mips64/mips64/mem.c
index 3de987bc7c8..885f392c626 100644
--- a/sys/arch/mips64/mips64/mem.c
+++ b/sys/arch/mips64/mips64/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.17 2011/05/01 07:01:37 miod Exp $ */
+/* $OpenBSD: mem.c,v 1.18 2013/05/09 19:45:19 miod Exp $ */
/* $NetBSD: mem.c,v 1.6 1995/04/10 11:55:03 mycroft Exp $ */
/*
@@ -97,7 +97,8 @@ mmrw(dev_t dev, struct uio *uio, int flags)
{
struct iovec *iov;
boolean_t allowed;
- int error = 0, c;
+ int error = 0;
+ size_t c;
vaddr_t v;
while (uio->uio_resid > 0 && error == 0) {
@@ -115,7 +116,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
case 0:
v = uio->uio_offset;
c = iov->iov_len;
- if (v + c > ptoa((psize_t)physmem))
+ if (v + c < v || v + c > ptoa((psize_t)physmem))
return (EFAULT);
v = (vaddr_t)PHYS_TO_XKPHYS(v, CCA_NONCOHERENT);
error = uiomove((caddr_t)v, c, uio);
@@ -124,7 +125,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
/* minor device 1 is kernel memory */
case 1:
v = uio->uio_offset;
- c = min(iov->iov_len, MAXPHYS);
+ c = ulmin(iov->iov_len, MAXPHYS);
/* Allow access to RAM through XKPHYS... */
if (IS_XKPHYS(v))
@@ -167,7 +168,7 @@ mmrw(dev_t dev, struct uio *uio, int flags)
if (zeropage == NULL)
zeropage = malloc(PAGE_SIZE, M_TEMP,
M_WAITOK | M_ZERO);
- c = min(iov->iov_len, PAGE_SIZE);
+ c = ulmin(iov->iov_len, PAGE_SIZE);
error = uiomove(zeropage, c, uio);
continue;