Index: arch/sparc64/src/proc/scheduler.c
===================================================================
--- arch/sparc64/src/proc/scheduler.c	(revision 97f1691963436356ca38316e0966ffeb57cd5639)
+++ arch/sparc64/src/proc/scheduler.c	(revision ddcf365696799cc8ff00f5ce2cce529e5b6742ab)
@@ -31,4 +31,5 @@
 #include <arch.h>
 #include <arch/mm/tlb.h>
+#include <arch/mm/page.h>
 #include <config.h>
 #include <align.h>
@@ -39,7 +40,7 @@
 	__address base;
 	
-	base = ALIGN_DOWN(config.base, 4*1024*1024);
+	base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
 
-	if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + 4*1024*1024) {
+	if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + (1<<KERNEL_PAGE_WIDTH)) {
 		/*
 		 * Kernel stack of this thread is not locked in DTLB.
@@ -48,5 +49,5 @@
 		 */
 		 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (__address) THREAD->kstack);
-		 dtlb_insert_mapping((__address) THREAD->kstack, (__address) THREAD->kstack, PAGESIZE_8K, true, true);
+		 dtlb_insert_mapping((__address) THREAD->kstack, KA2PA(THREAD->kstack), PAGESIZE_8K, true, true);
 	}	
 }
@@ -57,7 +58,7 @@
 	__address base;
 
-	base = ALIGN_DOWN(config.base, 4*1024*1024);
+	base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
 
-	if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + 4*1024*1024) {
+	if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + (1<<KERNEL_PAGE_WIDTH)) {
 		/*
 		 * Kernel stack of this thread is locked in DTLB.
