summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2003-06-11 05:18:59 +0000
committerps <ps@FreeBSD.org>2003-06-11 05:18:59 +0000
commit3fbe5ead23cd44e65e5c76aee57e9efa81fd7ab3 (patch)
treef6a4b667a02d99449067e8acd2533ec32773921f /sys/kern/kern_malloc.c
parentbe2119ccd61ba022f450ea438c051574fec4e5cf (diff)
downloadFreeBSD-src-3fbe5ead23cd44e65e5c76aee57e9efa81fd7ab3.zip
FreeBSD-src-3fbe5ead23cd44e65e5c76aee57e9efa81fd7ab3.tar.gz
Don't overflow when calculating vm_kmem_size. This fixes kmem_map
too small panics on PAE machines which have odd > 4GB sizes (4.5 gig would render a 20MB of KVA for kmem_map instead of 200MB). Submitted by: John Cagle <john.cagle@hp.com>, jeff Reviewed by: jeff, peter, scottl, lots of USENIX folks
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 4b84659..2d8daa3 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -420,11 +420,11 @@ kmeminit(dummy)
* so make sure that there is enough space.
*/
vm_kmem_size = VM_KMEM_SIZE;
- mem_size = cnt.v_page_count * PAGE_SIZE;
+ mem_size = cnt.v_page_count;
#if defined(VM_KMEM_SIZE_SCALE)
- if ((mem_size / VM_KMEM_SIZE_SCALE) > vm_kmem_size)
- vm_kmem_size = mem_size / VM_KMEM_SIZE_SCALE;
+ if ((mem_size / VM_KMEM_SIZE_SCALE) > (vm_kmem_size / PAGE_SIZE))
+ vm_kmem_size = (mem_size / VM_KMEM_SIZE_SCALE) * PAGE_SIZE;
#endif
#if defined(VM_KMEM_SIZE_MAX)
@@ -441,7 +441,7 @@ kmeminit(dummy)
* to something sane. Be careful to not overflow the 32bit
* ints while doing the check.
*/
- if ((vm_kmem_size / 2) > (cnt.v_page_count * PAGE_SIZE))
+ if (((vm_kmem_size / 2) / PAGE_SIZE) > cnt.v_page_count)
vm_kmem_size = 2 * cnt.v_page_count * PAGE_SIZE;
/*
OpenPOWER on IntegriCloud