shithub: riscv

Download patch

ref: 0a101736b885578f673bc08b7fd040e977ede331
parent: d304dc8119a737c65eca8717e1f436a1e0edf880
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Aug 7 17:11:11 EDT 2014

pc, pc64: make pc kaddr() check reject -KZERO address (thanks aiju)

--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -947,7 +947,7 @@
 void*
 kaddr(ulong pa)
 {
-	if(pa > (ulong)-KZERO)
+	if(pa >= (ulong)-KZERO)
 		panic("kaddr: pa=%#.8lux", pa);
 	return (void*)(pa+KZERO);
 }
--- a/sys/src/9/pc64/mmu.c
+++ b/sys/src/9/pc64/mmu.c
@@ -143,7 +143,7 @@
 void*
 kaddr(uintptr pa)
 {
-	if(pa > (uintptr)-KZERO)
+	if(pa >= (uintptr)-KZERO)
 		panic("kaddr: pa=%#p pc=%#p", pa, getcallerpc(&pa));
 	return (void*)(pa+KZERO);
 }
--- a/sys/src/9/port/xalloc.c
+++ b/sys/src/9/port/xalloc.c
@@ -72,7 +72,7 @@
 		/* first give to kernel */
 		if(n > 0){
 			m->kbase = (uintptr)KADDR(m->base);
-			m->klimit = (uintptr)KADDR(m->base+size);
+			m->klimit = (uintptr)KADDR(m->base+size-1)+1;
 			xhole(m->base, size);
 			kpages -= n;
 		}