Index: kernel/arch/amd64/include/mm/page.h
===================================================================
--- kernel/arch/amd64/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/amd64/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -52,4 +52,6 @@
 #define PAGE_WIDTH	FRAME_WIDTH
 #define PAGE_SIZE	FRAME_SIZE
+
+#define PAGE_COLOR_BITS	0			/* dummy */
 
 #ifdef KERNEL
Index: kernel/arch/ia32/include/mm/page.h
===================================================================
--- kernel/arch/ia32/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/ia32/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -40,4 +40,6 @@
 #define PAGE_WIDTH	FRAME_WIDTH
 #define PAGE_SIZE	FRAME_SIZE
+
+#define PAGE_COLOR_BITS	0			/* dummy */
 
 #ifdef KERNEL
Index: kernel/arch/ia32xen/include/mm/page.h
===================================================================
--- kernel/arch/ia32xen/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/ia32xen/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -41,4 +41,6 @@
 #define PAGE_SIZE	FRAME_SIZE
 
+#define PAGE_COLOR_BITS	0			/* dummy */
+
 #ifdef KERNEL
 
Index: kernel/arch/ia64/include/mm/page.h
===================================================================
--- kernel/arch/ia64/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/ia64/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -42,9 +42,10 @@
 #define PAGE_WIDTH	FRAME_WIDTH
 
+#define PAGE_COLOR_BITS	0			/* dummy */
 
 #ifdef KERNEL
 
 /** Bit width of the TLB-locked portion of kernel address space. */
-#define KERNEL_PAGE_WIDTH	28	/* 256M */
+#define KERNEL_PAGE_WIDTH		28	/* 256M */
 
 #define PPN_SHIFT			12
@@ -65,5 +66,5 @@
 #define PA2KA(x)	((uintptr_t) (x+(VRN_KERNEL<<VRN_SHIFT)))
 
-#define VHPT_WIDTH 			20         	/* 1M */
+#define VHPT_WIDTH 			20	/* 1M */
 #define VHPT_SIZE 			(1 << VHPT_WIDTH)
 
Index: kernel/arch/mips32/include/mm/page.h
===================================================================
--- kernel/arch/mips32/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/mips32/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -40,4 +40,6 @@
 #define PAGE_WIDTH	FRAME_WIDTH
 #define PAGE_SIZE	FRAME_SIZE
+
+#define PAGE_COLOR_BITS	0			/* dummy */
 
 #ifndef __ASM__
Index: kernel/arch/ppc32/include/mm/page.h
===================================================================
--- kernel/arch/ppc32/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/ppc32/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -40,4 +40,6 @@
 #define PAGE_WIDTH	FRAME_WIDTH
 #define PAGE_SIZE	FRAME_SIZE
+
+#define PAGE_COLOR_BITS	0			/* dummy */
 
 #ifdef KERNEL
Index: kernel/arch/ppc64/include/mm/page.h
===================================================================
--- kernel/arch/ppc64/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/ppc64/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -40,4 +40,6 @@
 #define PAGE_WIDTH	FRAME_WIDTH
 #define PAGE_SIZE	FRAME_SIZE
+
+#define PAGE_COLOR_BITS	0			/* dummy */
 
 #ifdef KERNEL
Index: kernel/arch/sparc64/include/mm/page.h
===================================================================
--- kernel/arch/sparc64/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/arch/sparc64/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -41,4 +41,6 @@
 #define PAGE_SIZE	FRAME_SIZE
 
+#define PAGE_COLOR_BITS	1			/**< 14 - 13; 2^14 == 16K == alias boundary. */
+
 #ifdef KERNEL
 
Index: kernel/genarch/src/mm/asid_fifo.c
===================================================================
--- kernel/genarch/src/mm/asid_fifo.c	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/genarch/src/mm/asid_fifo.c	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -64,7 +64,7 @@
 	int i;
 
-	#if (!FIFO_STATIC)
+#if (!FIFO_STATIC)
 	fifo_create(free_asids);
-	#endif
+#endif
 		
 	for (i = 0; i < ASIDS_ALLOCABLE; i++) {
Index: kernel/generic/include/mm/page.h
===================================================================
--- kernel/generic/include/mm/page.h	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/generic/include/mm/page.h	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -67,4 +67,10 @@
 #define PAGE_GLOBAL		(1<<PAGE_GLOBAL_SHIFT)
 
+
+/**
+ * Macro for computing page color.
+ */
+#define PAGE_COLOR(va)		(((va) >> PAGE_WIDTH) & ((1 << PAGE_COLOR_BITS) - 1))
+
 /** Page fault access type. */
 enum pf_access {
Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 7bf7ef77b559bde9e785ddbc26c19e06dd0ff54c)
+++ kernel/generic/src/mm/as.c	(revision d0485c6a1e50e0398bb04d70d1e1ed89ea3db22a)
@@ -551,10 +551,11 @@
  * @param dst_flags_mask Destination address space area flags mask.
  *
- * @return Zero on success or ENOENT if there is no such task or
- *	   if there is no such address space area,
- *	   EPERM if there was a problem in accepting the area or
- *	   ENOMEM if there was a problem in allocating destination
- *	   address space area. ENOTSUP is returned if an attempt
- *	   to share non-anonymous address space area is detected.
+ * @return Zero on success or ENOENT if there is no such task or if there is no
+ * such address space area, EPERM if there was a problem in accepting the area
+ * or ENOMEM if there was a problem in allocating destination address space
+ * area. ENOTSUP is returned if the address space area backend does not support
+ * sharing. It can be also returned if the architecture uses virtually indexed
+ * caches and the source and destination areas start at pages with different
+ * page colors.
  */
 int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
@@ -581,4 +582,18 @@
 	}
 	
+#if 0	/* disable the check for now */
+#ifdef CONFIG_VIRT_IDX_CACHE
+	if (PAGE_COLOR(src_area->base) != PAGE_COLOR(dst_base)) {
+		/*
+		 * Refuse to create illegal address alias.
+		 */
+		mutex_unlock(&src_area->lock);
+		mutex_unlock(&src_as->lock);
+		interrupts_restore(ipl);
+		return ENOTSUP;
+	}
+#endif /* CONFIG_VIRT_IDX_CACHE */
+#endif
+
 	if (!src_area->backend || !src_area->backend->share) {
 		/*
