mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 08:58:07 +00:00
10fdf838e5
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>
50 lines
940 B
C
50 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");
|