Index: kernel/arch/sparc64/src/mm/tlb.c
===================================================================
--- kernel/arch/sparc64/src/mm/tlb.c	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ kernel/arch/sparc64/src/mm/tlb.c	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -104,5 +104,5 @@
 	data.p = true;
 	data.w = true;
-	data.g = true;
+	data.g = false;
 
 	dtlb_data_in_write(data.value);
Index: kernel/arch/sparc64/src/start.S
===================================================================
--- kernel/arch/sparc64/src/start.S	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ kernel/arch/sparc64/src/start.S	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -126,5 +126,22 @@
 	
 	! write DTLB data and install the kernel mapping
-	SET_TLB_DATA(g1, g2, TTE_G)
+	SET_TLB_DATA(g1, g2, 0)			! use non-global mapping
+	stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG		
+	membar #Sync
+
+	/*
+	 * Because we cannot use global mappings (because we want to
+	 * have separate 64-bit address spaces for both the kernel
+	 * and the userspace), we prepare the identity mapping also in
+	 * context 1. This step is required by the
+	 * code installing the ITLB mapping.
+	 */
+	! write DTLB tag of context 1 (i.e. MEM_CONTEXT_TEMP)
+	SET_TLB_TAG(g1, MEM_CONTEXT_TEMP)
+	stxa %g1, [VA_DMMU_TAG_ACCESS] %asi			
+	membar #Sync
+
+	! write DTLB data and install the kernel mapping in context 1
+	SET_TLB_DATA(g1, g2, 0)			! use non-global mapping
 	stxa %g1, [%g0] ASI_DTLB_DATA_IN_REG		
 	membar #Sync
Index: kernel/generic/include/mm/as.h
===================================================================
--- kernel/generic/include/mm/as.h	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ kernel/generic/include/mm/as.h	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -62,6 +62,4 @@
 #define USER_ADDRESS_SPACE_START	USER_ADDRESS_SPACE_START_ARCH
 #define USER_ADDRESS_SPACE_END		USER_ADDRESS_SPACE_END_ARCH
-
-#define IS_KA(addr)	((addr)>=KERNEL_ADDRESS_SPACE_START && (addr)<=KERNEL_ADDRESS_SPACE_END)
 
 #define USTACK_ADDRESS	USTACK_ADDRESS_ARCH
Index: uspace/libc/arch/sparc64/include/syscall.h
===================================================================
--- uspace/libc/arch/sparc64/include/syscall.h	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ uspace/libc/arch/sparc64/include/syscall.h	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -51,4 +51,5 @@
 		: "=r" (a1)
 		: "r" (a1), "r" (a2), "r" (a3), "r" (a4), "i" (id)
+		: "memory"
 	);
 	
Index: uspace/libc/generic/as.c
===================================================================
--- uspace/libc/generic/as.c	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ uspace/libc/generic/as.c	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -37,4 +37,10 @@
 #include <unistd.h>
 #include <align.h>
+#include <types.h>
+
+/**
+ * Either 4*256M on 32-bit architecures or 16*256M on 64-bit architectures.
+ */
+#define MAX_HEAP_SIZE	(sizeof(uintptr_t)<<28)
 
 /** Create address space area.
@@ -142,5 +148,5 @@
 	/* Set heapsize to some meaningful value */
 	if (maxheapsize == -1)
-		set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH >> 1, PAGE_SIZE));
+		set_maxheapsize(MAX_HEAP_SIZE);
 	
 	if (!last_allocated)
Index: uspace/libc/generic/psthread.c
===================================================================
--- uspace/libc/generic/psthread.c	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ uspace/libc/generic/psthread.c	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -62,5 +62,5 @@
 static int threads_in_manager;
 
-/** Setup PSthread information into TCB structure */
+/** Setup psthread information into TCB structure */
 psthread_data_t * psthread_setup()
 {
@@ -90,5 +90,5 @@
 }
 
-/** Function that is called on entry to new uspace thread */
+/** Function that is called on entry to new pseudo thread */
 void psthread_main(void)
 {
@@ -210,6 +210,5 @@
 }
 
-/**
- * Create a userspace thread
+/** Create a userspace pseudo thread.
  *
  * @param func Pseudo thread function.
Index: uspace/libc/include/as.h
===================================================================
--- uspace/libc/include/as.h	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ uspace/libc/include/as.h	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -41,6 +41,4 @@
 #include <kernel/mm/as.h>
 
-#define USER_ADDRESS_SPACE_SIZE_ARCH (USER_ADDRESS_SPACE_END_ARCH-USER_ADDRESS_SPACE_START_ARCH+1)
-
 extern void *as_area_create(void *address, size_t size, int flags);
 extern int as_area_resize(void *address, size_t size, int flags);
Index: uspace/libc/include/stdio.h
===================================================================
--- uspace/libc/include/stdio.h	(revision 2def78824559e9a326693314a605af8e1e7e690a)
+++ uspace/libc/include/stdio.h	(revision d681c173694bd83b842b2932968cec935ec1f26f)
@@ -41,5 +41,15 @@
 #define EOF (-1)
 
+#include <string.h>
 #include <io/stream.h>
+
+#define DEBUG(fmt, ...) \
+{ \
+	char buf[256]; \
+	int n; \
+	n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \
+	if (n > 0) \
+		(void) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, strlen(buf)); \
+}
 
 extern int getchar(void);
