Index: uspace/libc/generic/as.c
===================================================================
--- uspace/libc/generic/as.c	(revision 5a8b2a2e58c0aff599e30b00eed3a773ff644968)
+++ uspace/libc/generic/as.c	(revision b82a13cbddc002cae6929e88cac7339a21b58789)
@@ -38,4 +38,5 @@
 #include <align.h>
 #include <types.h>
+#include <bitops.h>
 
 /**
@@ -54,10 +55,12 @@
 void *as_area_create(void *address, size_t size, int flags)
 {
-	return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address, (sysarg_t) size, (sysarg_t) flags);
+	return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t ) address,
+		(sysarg_t) size, (sysarg_t) flags);
 }
 
 /** Resize address space area.
  *
- * @param address Virtual address pointing into already existing address space area.
+ * @param address Virtual address pointing into already existing address space
+ * 	area.
  * @param size New requested size of the area.
  * @param flags Currently unused.
@@ -67,10 +70,12 @@
 int as_area_resize(void *address, size_t size, int flags)
 {
-	return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t) size, (sysarg_t) flags);
+	return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t ) address, (sysarg_t)
+		size, (sysarg_t) flags);
 }
 
 /** Destroy address space area.
  *
- * @param address Virtual address pointing into the address space area being destroyed.
+ * @param address Virtual address pointing into the address space area being
+ * 	destroyed.
  *
  * @return Zero on success or a code from @ref errno.h on failure.
@@ -134,15 +139,27 @@
 	/* Return pointer to area not managed by sbrk */
 	return ((void *) &_heap + maxheapsize);
-
 }
 
 /** Return pointer to some unmapped area, where fits new as_area
  *
+ * @param sz Requested size of the allocation.
+ * @param color Requested virtual color of the allocation.
+ *
+ * @return Pointer to the beginning 
+ *
  * TODO: make some first_fit/... algorithm, we are now just incrementing
  *       the pointer to last area
  */
-void * as_get_mappable_page(size_t sz)
+#include <stdio.h>
+void *as_get_mappable_page(size_t sz, int color)
 {
 	void *res;
+	uint64_t asz;
+	int i;
+	
+	if (!sz)
+		return NULL;	
+
+	asz = 1 << (fnzb64(sz - 1) + 1);
 
 	/* Set heapsize to some meaningful value */
@@ -150,10 +167,23 @@
 		set_maxheapsize(MAX_HEAP_SIZE);
 	
-	if (!last_allocated)
-		last_allocated = (void *) ALIGN_UP((void *) &_heap + maxheapsize, PAGE_SIZE);
-	
-	sz = ALIGN_UP(sz, PAGE_SIZE);
+	/*
+	 * Make sure we allocate from naturally aligned address and a page of
+	 * appropriate color.
+	 */
+	i = 0;
+	do {
+		if (!last_allocated) {
+			last_allocated = (void *) ALIGN_UP((void *) &_heap +
+				maxheapsize, asz);
+		} else {
+			last_allocated = (void *) ALIGN_UP(((uintptr_t)
+				last_allocated) + (int) (i > 0), asz);
+		}
+	} while ((asz < (1 << (PAGE_COLOR_BITS + PAGE_WIDTH))) &&
+		(PAGE_COLOR((uintptr_t) last_allocated) != color) &&
+		(++i < (1 << PAGE_COLOR_BITS)));
+
 	res = last_allocated;
-	last_allocated += sz;
+	last_allocated += ALIGN_UP(sz, PAGE_SIZE);
 
 	return res;
Index: uspace/libc/generic/mman.c
===================================================================
--- uspace/libc/generic/mman.c	(revision 5a8b2a2e58c0aff599e30b00eed3a773ff644968)
+++ uspace/libc/generic/mman.c	(revision b82a13cbddc002cae6929e88cac7339a21b58789)
@@ -40,5 +40,5 @@
 {
 	if (!start)
-		start = as_get_mappable_page(length);
+		start = as_get_mappable_page(length, 0);
 	
 //	if (! ((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE)))
Index: uspace/libc/generic/time.c
===================================================================
--- uspace/libc/generic/time.c	(revision 5a8b2a2e58c0aff599e30b00eed3a773ff644968)
+++ uspace/libc/generic/time.c	(revision b82a13cbddc002cae6929e88cac7339a21b58789)
@@ -41,4 +41,5 @@
 #include <atomic.h>
 #include <futex.h>
+#include <sysinfo.h>
 #include <ipc/services.h>
 
@@ -72,7 +73,10 @@
 
 	if (!ktime) {
-		mapping = as_get_mappable_page(PAGE_SIZE);
+		mapping = as_get_mappable_page(PAGE_SIZE, (int)
+			sysinfo_value("clock.fcolor"));
 		/* Get the mapping of kernel clock */
-		res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t) mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights, NULL);
+		res = ipc_call_sync_3(PHONE_NS, IPC_M_AS_AREA_RECV, (sysarg_t)
+			mapping, PAGE_SIZE, SERVICE_MEM_REALTIME, NULL, &rights,
+			NULL);
 		if (res) {
 			printf("Failed to initialize timeofday memarea\n");
