Florian Fainelli | e4dace3 | 2017-09-08 16:15:31 -0700 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/module.h> |
| 3 | #include <linux/export.h> |
| 4 | #include <linux/mm.h> |
| 5 | #include <linux/vmalloc.h> |
| 6 | #include <linux/slab.h> |
| 7 | #include <linux/sizes.h> |
| 8 | |
| 9 | #include <asm/page.h> |
| 10 | #ifdef CONFIG_MIPS |
| 11 | #include <asm/bootinfo.h> |
| 12 | #endif |
| 13 | |
| 14 | struct foo { |
| 15 | unsigned int bar; |
| 16 | }; |
| 17 | |
Colin Ian King | b15f5f1 | 2018-08-21 21:57:07 -0700 | [diff] [blame] | 18 | static struct foo *foo; |
Florian Fainelli | e4dace3 | 2017-09-08 16:15:31 -0700 | [diff] [blame] | 19 | |
| 20 | static int __init test_debug_virtual_init(void) |
| 21 | { |
| 22 | phys_addr_t pa; |
| 23 | void *va; |
| 24 | |
| 25 | va = (void *)VMALLOC_START; |
| 26 | pa = virt_to_phys(va); |
| 27 | |
| 28 | pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va); |
| 29 | |
| 30 | foo = kzalloc(sizeof(*foo), GFP_KERNEL); |
| 31 | if (!foo) |
| 32 | return -ENOMEM; |
| 33 | |
| 34 | pa = virt_to_phys(foo); |
| 35 | va = foo; |
| 36 | pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | module_init(test_debug_virtual_init); |
| 41 | |
| 42 | static void __exit test_debug_virtual_exit(void) |
| 43 | { |
| 44 | kfree(foo); |
| 45 | } |
| 46 | module_exit(test_debug_virtual_exit); |
| 47 | |
| 48 | MODULE_LICENSE("GPL"); |
| 49 | MODULE_DESCRIPTION("Test module for CONFIG_DEBUG_VIRTUAL"); |