2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 20:23:57 +08:00
linux-next/lib/test_debug_virtual.c
Christophe Leroy 10fdf838e5 lib: fix build failure in CONFIG_DEBUG_VIRTUAL test
On several arches, virt_to_phys() is in io.h

Build fails without it:

  CC      lib/test_debug_virtual.o
lib/test_debug_virtual.c: In function 'test_debug_virtual_init':
lib/test_debug_virtual.c:26:7: error: implicit declaration of function 'virt_to_phys' [-Werror=implicit-function-declaration]
  pa = virt_to_phys(va);
       ^

Fixes: e4dace3615 ("lib: add test module for CONFIG_DEBUG_VIRTUAL")
CC: stable@vger.kernel.org
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-12-17 22:12:30 +11:00

51 lines
940 B
C

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/export.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/slab.h>
#include <linux/sizes.h>
#include <linux/io.h>
#include <asm/page.h>
#ifdef CONFIG_MIPS
#include <asm/bootinfo.h>
#endif
struct foo {
unsigned int bar;
};
static struct foo *foo;
static int __init test_debug_virtual_init(void)
{
phys_addr_t pa;
void *va;
va = (void *)VMALLOC_START;
pa = virt_to_phys(va);
pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va);
foo = kzalloc(sizeof(*foo), GFP_KERNEL);
if (!foo)
return -ENOMEM;
pa = virt_to_phys(foo);
va = foo;
pr_info("PA: %pa for VA: 0x%lx\n", &pa, (unsigned long)va);
return 0;
}
module_init(test_debug_virtual_init);
static void __exit test_debug_virtual_exit(void)
{
kfree(foo);
}
module_exit(test_debug_virtual_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Test module for CONFIG_DEBUG_VIRTUAL");