From 3fbe5ead23cd44e65e5c76aee57e9efa81fd7ab3 Mon Sep 17 00:00:00 2001 From: ps Date: Wed, 11 Jun 2003 05:18:59 +0000 Subject: 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 , jeff Reviewed by: jeff, peter, scottl, lots of USENIX folks --- sys/kern/kern_malloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/kern/kern_malloc.c') 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; /* -- cgit v1.1