Index: kernel/arch/sparc64/include/arch/mm/frame.h
===================================================================
--- kernel/arch/sparc64/include/arch/mm/frame.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/sparc64/include/arch/mm/frame.h	(revision ee7f78a5c14921259ade650857bc3495b642f4f1)
@@ -46,4 +46,16 @@
 #endif
 
+#ifndef __ASM__
+
+#include <typedefs.h>
+
+extern uintptr_t end_of_identity;
+
+extern void frame_low_arch_init(void);
+extern void frame_high_arch_init(void);
+#define physmem_print()
+
+#endif
+
 #endif
 
Index: kernel/arch/sparc64/include/arch/mm/sun4u/frame.h
===================================================================
--- kernel/arch/sparc64/include/arch/mm/sun4u/frame.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/sparc64/include/arch/mm/sun4u/frame.h	(revision ee7f78a5c14921259ade650857bc3495b642f4f1)
@@ -72,10 +72,4 @@
 typedef union frame_address frame_address_t;
 
-extern uintptr_t end_of_identity;
-
-extern void frame_low_arch_init(void);
-extern void frame_high_arch_init(void);
-#define physmem_print()
-
 #endif
 
Index: kernel/arch/sparc64/include/arch/mm/sun4v/frame.h
===================================================================
--- kernel/arch/sparc64/include/arch/mm/sun4v/frame.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/sparc64/include/arch/mm/sun4v/frame.h	(revision ee7f78a5c14921259ade650857bc3495b642f4f1)
@@ -42,14 +42,4 @@
 #define FRAME_SIZE		(1 << FRAME_WIDTH)
 
-#ifndef __ASM__
-
-#include <typedefs.h>
-
-extern void frame_low_arch_init(void);
-extern void frame_high_arch_init(void);
-#define physmem_print()
-
-#endif
-
 #endif
 
Index: kernel/arch/sparc64/include/arch/trap/sun4v/mmu.h
===================================================================
--- kernel/arch/sparc64/include/arch/trap/sun4v/mmu.h	(revision e4d96e9386cdf86237fbc59dfe286c09d4a45432)
+++ kernel/arch/sparc64/include/arch/trap/sun4v/mmu.h	(revision ee7f78a5c14921259ade650857bc3495b642f4f1)
@@ -102,4 +102,11 @@
 	nop
 
+	/* exclude pages beyond the end of memory from the identity mapping */
+	sethi %hi(end_of_identity), %g4
+	ldx [%g4 + %lo(end_of_identity)], %g4
+	cmp %g1, %g4
+	bgeu %xcc, 0f
+	nop
+
 	/*
 	 * Installing the identity does not fit into 32 instructions, call
