#include "head_32.h"
 
+.macro compare_to_kernel_boundary scratch, addr
 #if CONFIG_TASK_SIZE <= 0x80000000 && CONFIG_PAGE_OFFSET >= 0x80000000
 /* By simply checking Address >= 0x80000000, we know if its a kernel address */
-#define SIMPLE_KERNEL_ADDRESS          1
+       not.    \scratch, \addr
+#else
+       rlwinm  \scratch, \addr, 16, 0xfff8
+       cmpli   cr0, \scratch, PAGE_OFFSET@h
 #endif
+.endm
 
 /*
  * We need an ITLB miss handler for kernel addresses if:
        mtspr   SPRN_MD_EPN, r10
 #ifdef ITLB_MISS_KERNEL
        mfcr    r11
-#if defined(SIMPLE_KERNEL_ADDRESS)
-       cmpi    cr0, r10, 0     /* Address >= 0x80000000 */
-#else
-       rlwinm  r10, r10, 16, 0xfff8
-       cmpli   cr0, r10, PAGE_OFFSET@h
-#endif
+       compare_to_kernel_boundary r10, r10
 #endif
        mfspr   r10, SPRN_M_TWB /* Get level 1 table */
 #ifdef ITLB_MISS_KERNEL
-#if defined(SIMPLE_KERNEL_ADDRESS)
-       bge+    3f
-#else
        blt+    3f
-#endif
        rlwinm  r10, r10, 0, 20, 31
        oris    r10, r10, (swapper_pg_dir - PAGE_OFFSET)@ha
 3:
         * kernel page tables.
         */
        mfspr   r10, SPRN_MD_EPN
-       rlwinm  r10, r10, 16, 0xfff8
-       cmpli   cr0, r10, PAGE_OFFSET@h
-
+       compare_to_kernel_boundary r10, r10
        mfspr   r10, SPRN_M_TWB /* Get level 1 table */
        blt+    3f
        rlwinm  r10, r10, 0, 20, 31