#define PHYS_OFFSET PLAT_PHYS_OFFSET
#define PHYS_PFN_OFFSET ((unsigned long)(PHYS_OFFSET >> PAGE_SHIFT))
+#ifdef CONFIG_AMLOGIC_MODIFY
+extern unsigned long phys_check(phys_addr_t x);
+extern unsigned long virt_check(unsigned long x);
+extern int scheduler_running;
+#endif
static inline phys_addr_t __virt_to_phys(unsigned long x)
{
+#ifdef CONFIG_AMLOGIC_MODIFY
+ return virt_check(x);
+#else
return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET;
+#endif
}
static inline unsigned long __phys_to_virt(phys_addr_t x)
{
+#ifdef CONFIG_AMLOGIC_MODIFY
+ return phys_check(x);
+#else
return x - PHYS_OFFSET + PAGE_OFFSET;
+#endif
}
#endif
empty_zero_page = virt_to_page(zero_page);
__flush_dcache_page(NULL, empty_zero_page);
}
+
+#ifdef CONFIG_AMLOGIC_MODIFY
+unsigned long notrace phys_check(phys_addr_t x)
+{
+ unsigned long addr;
+ struct page *page;
+
+ addr = x - PHYS_OFFSET + PAGE_OFFSET;
+ if (scheduler_running) {
+ page = phys_to_page(x);
+
+ /*
+ * if physical address is not in linear mapping range,
+ * then this will cause BUG
+ */
+ if (is_vmalloc_or_module_addr((const void *)addr) ||
+ PageHighMem(page)) {
+ pr_err("BAD USING of phys_to_virt, addr:%x, page:%lx\n",
+ x, page_to_pfn(page));
+ dump_stack();
+ }
+ }
+ return addr;
+}
+EXPORT_SYMBOL(phys_check);
+
+unsigned long notrace virt_check(unsigned long x)
+{
+ if (scheduler_running && (x >= VMALLOC_START || x <= PAGE_OFFSET)) {
+ pr_err("bad input of virt:%lx\n", x);
+ dump_stack();
+ }
+ return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET;
+}
+EXPORT_SYMBOL(virt_check);
+#endif