#include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/sched/debug.h>
 #include <linux/sched/signal.h>
               field, regs->cp0_epc, field, regs->regs[31]);
 }
 
-/*
- * Check, whether MC's (virtual) DMA address caused the bus error.
- * See "Virtual DMA Specification", Draft 1.5, Feb 13 1992, SGI
- */
-
-static int addr_is_ram(unsigned long addr, unsigned sz)
-{
-       int i;
-
-       for (i = 0; i < boot_mem_map.nr_map; i++) {
-               unsigned long a = boot_mem_map.map[i].addr;
-               if (a <= addr && addr+sz <= a+boot_mem_map.map[i].size)
-                       return 1;
-       }
-       return 0;
-}
-
 static int check_microtlb(u32 hi, u32 lo, unsigned long vaddr)
 {
        /* This is likely rather similar to correct code ;-) */
                        /* PTEIndex is VPN-low (bits [22:14]/[20:12] ?) */
                        unsigned long pte = (lo >> 6) << 12; /* PTEBase */
                        pte += 8*((vaddr >> pgsz) & 0x1ff);
-                       if (addr_is_ram(pte, 8)) {
+                       if (page_is_ram(PFN_DOWN(pte))) {
                                /*
                                 * Note: Since DMA hardware does look up
                                 * translation on its own, this PTE *must*