1 #include <linux/mmdebug.h>
2 #include <linux/module.h>
11 unsigned long __phys_addr(unsigned long x
)
13 if (x
>= __START_KERNEL_map
) {
14 x
-= __START_KERNEL_map
;
15 VIRTUAL_BUG_ON(x
>= KERNEL_IMAGE_SIZE
);
18 VIRTUAL_BUG_ON(x
< PAGE_OFFSET
);
20 VIRTUAL_BUG_ON(!phys_addr_valid(x
));
24 EXPORT_SYMBOL(__phys_addr
);
26 bool __virt_addr_valid(unsigned long x
)
28 if (x
>= __START_KERNEL_map
) {
29 x
-= __START_KERNEL_map
;
30 if (x
>= KERNEL_IMAGE_SIZE
)
37 if (!phys_addr_valid(x
))
41 return pfn_valid(x
>> PAGE_SHIFT
);
43 EXPORT_SYMBOL(__virt_addr_valid
);
47 #ifdef CONFIG_DEBUG_VIRTUAL
48 unsigned long __phys_addr(unsigned long x
)
50 /* VMALLOC_* aren't constants */
51 VIRTUAL_BUG_ON(x
< PAGE_OFFSET
);
52 VIRTUAL_BUG_ON(__vmalloc_start_set
&& is_vmalloc_addr((void *) x
));
53 return x
- PAGE_OFFSET
;
55 EXPORT_SYMBOL(__phys_addr
);
58 bool __virt_addr_valid(unsigned long x
)
62 if (__vmalloc_start_set
&& is_vmalloc_addr((void *) x
))
64 if (x
>= FIXADDR_START
)
66 return pfn_valid((x
- PAGE_OFFSET
) >> PAGE_SHIFT
);
68 EXPORT_SYMBOL(__virt_addr_valid
);
70 #endif /* CONFIG_X86_64 */