1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
4 * wrapper around get_pfnblock_flags_mask and Ubuntu
5 * get_pageblock_flags_mask. Using KALLSYMS to get their address when
6 * available, else we need to have a kernel that exports this function
9 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 #include <lttng-kernel-version.h>
14 #if (defined(CONFIG_KALLSYMS) \
15 && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2) \
16 || LTTNG_KERNEL_RANGE(3,14,36, 3,15,0) \
17 || LTTNG_KERNEL_RANGE(3,18,10, 3,19,0) \
18 || LTTNG_DEBIAN_KERNEL_RANGE(3,16,7,9,0,0, 3,17,0,0,0,0) \
19 || LTTNG_UBUNTU_KERNEL_RANGE(3,16,7,34, 3,17,0,0)))
21 #include <linux/kallsyms.h>
22 #include <linux/mm_types.h>
23 #include <linux/module.h>
24 #include <wrapper/kallsyms.h>
25 #include <wrapper/page_alloc.h>
28 unsigned long (*get_pfnblock_flags_mask_sym
)(struct page
*page
,
30 unsigned long end_bitidx
,
33 unsigned long wrapper_get_pfnblock_flags_mask(struct page
*page
,
35 unsigned long end_bitidx
,
38 WARN_ON_ONCE(!get_pfnblock_flags_mask_sym
);
39 if (get_pfnblock_flags_mask_sym
) {
40 return get_pfnblock_flags_mask_sym(page
, pfn
, end_bitidx
, mask
);
45 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask
);
47 int wrapper_get_pfnblock_flags_mask_init(void)
49 get_pfnblock_flags_mask_sym
=
50 (void *) kallsyms_lookup_funcptr("get_pfnblock_flags_mask");
51 if (!get_pfnblock_flags_mask_sym
)
55 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask_init
);
58 * Canary function to check for 'get_pfnblock_flags_mask()' at compile time.
60 * From 'include/linux/pageblock-flags.h':
62 * unsigned long get_pfnblock_flags_mask(struct page *page,
64 * unsigned long end_bitidx,
65 * unsigned long mask);
67 __attribute__((unused
)) static
68 unsigned long __canary__get_pfnblock_flags_mask(struct page
*page
,
70 unsigned long end_bitidx
,
73 return get_pfnblock_flags_mask(page
, pfn
, end_bitidx
, mask
);
78 #include <linux/pageblock-flags.h>
82 #if (defined(CONFIG_KALLSYMS) \
83 && LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,50, 3,14,0,0))
85 #include <linux/kallsyms.h>
86 #include <linux/mm_types.h>
87 #include <linux/module.h>
88 #include <wrapper/kallsyms.h>
89 #include <wrapper/page_alloc.h>
92 unsigned long (*get_pageblock_flags_mask_sym
)(struct page
*page
,
93 unsigned long end_bitidx
,
96 unsigned long wrapper_get_pageblock_flags_mask(struct page
*page
,
97 unsigned long end_bitidx
,
100 WARN_ON_ONCE(!get_pageblock_flags_mask_sym
);
101 if (get_pageblock_flags_mask_sym
) {
102 return get_pageblock_flags_mask_sym(page
, end_bitidx
, mask
);
107 EXPORT_SYMBOL_GPL(wrapper_get_pageblock_flags_mask
);
109 int wrapper_get_pageblock_flags_mask_init(void)
111 get_pageblock_flags_mask_sym
=
112 (void *) kallsyms_lookup_funcptr("get_pageblock_flags_mask");
113 if (!get_pageblock_flags_mask_sym
)
117 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask_init
);
121 #include <linux/pageblock-flags.h>