Index: kernel/arch/sparc64/src/cpu/cpu.c
===================================================================
--- kernel/arch/sparc64/src/cpu/cpu.c	(revision a9ac978f3aba8259d5f8270ee59a08a41d15d94c)
+++ kernel/arch/sparc64/src/cpu/cpu.c	(revision f5e39a320e357d44b5a00aee5a89c13acba9c80d)
@@ -41,4 +41,7 @@
 #include <arch/types.h>
 #include <arch/drivers/tick.h>
+#include <arch/mm/page.h>
+#include <arch/mm/tlb.h>
+#include <macros.h>
 
 /** Perform sparc64 specific initialization of the processor structure for the current processor. */
@@ -53,4 +56,7 @@
 	CPU->arch.mid = upa_config.mid;
 	
+	/*
+	 * Detect processor frequency.
+	 */
 	node = ofw_tree_find_child_by_device_type(ofw_tree_lookup("/"), "cpu");
 	while (node) {
@@ -71,4 +77,20 @@
 	CPU->arch.clock_frequency = clock_frequency;
 	tick_init();
+	
+	/*
+	 * Lock CPU stack in DTLB.
+	 */
+	uintptr_t base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
+		 
+	if (!overlaps((uintptr_t) CPU->stack, PAGE_SIZE, base, (1<<KERNEL_PAGE_WIDTH))) {
+		/*
+		 * Kernel stack of this processor is not locked in DTLB.
+		 * First, demap any already existing mappings.
+		 * Second, create a locked mapping for it.
+		 */
+		dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) CPU->stack);
+		dtlb_insert_mapping((uintptr_t) CPU->stack, KA2PA(CPU->stack), PAGESIZE_8K, true, true);
+	}
+
 }
 
