1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
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 #ifdef CONFIG_KALLSYMS
14 /* Include page_alloc wrapper before pageblock-flags.h. */
15 #include <wrapper/page_alloc.h>
17 #include <linux/pageblock-flags.h>
18 #include <linux/kallsyms.h>
19 #include <linux/mm_types.h>
20 #include <linux/module.h>
21 #include <wrapper/kallsyms.h>
22 #include <lttng/kernel-version.h>
24 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,14,0))
26 unsigned long (*get_pfnblock_flags_mask_sym
)(const struct page
*page
,
30 unsigned long wrapper_get_pfnblock_flags_mask(const struct page
*page
,
34 WARN_ON_ONCE(!get_pfnblock_flags_mask_sym
);
35 if (get_pfnblock_flags_mask_sym
) {
36 struct irq_ibt_state irq_ibt_state
;
39 irq_ibt_state
= wrapper_irq_ibt_save();
40 ret
= get_pfnblock_flags_mask_sym(page
, pfn
, mask
);
41 wrapper_irq_ibt_restore(irq_ibt_state
);
47 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0))
49 unsigned long (*get_pfnblock_flags_mask_sym
)(struct page
*page
,
53 unsigned long wrapper_get_pfnblock_flags_mask(struct page
*page
,
57 WARN_ON_ONCE(!get_pfnblock_flags_mask_sym
);
58 if (get_pfnblock_flags_mask_sym
) {
59 struct irq_ibt_state irq_ibt_state
;
62 irq_ibt_state
= wrapper_irq_ibt_save();
63 ret
= get_pfnblock_flags_mask_sym(page
, pfn
, mask
);
64 wrapper_irq_ibt_restore(irq_ibt_state
);
70 #else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0)) */
72 unsigned long (*get_pfnblock_flags_mask_sym
)(struct page
*page
,
74 unsigned long end_bitidx
,
77 unsigned long wrapper_get_pfnblock_flags_mask(struct page
*page
,
79 unsigned long end_bitidx
,
82 WARN_ON_ONCE(!get_pfnblock_flags_mask_sym
);
83 if (get_pfnblock_flags_mask_sym
) {
84 struct irq_ibt_state irq_ibt_state
;
87 irq_ibt_state
= wrapper_irq_ibt_save();
88 ret
= get_pfnblock_flags_mask_sym(page
, pfn
, end_bitidx
, mask
);
89 wrapper_irq_ibt_restore(irq_ibt_state
);
95 #endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0)) */
97 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask
);
99 int wrapper_get_pfnblock_flags_mask_init(void)
101 get_pfnblock_flags_mask_sym
=
102 (void *) kallsyms_lookup_funcptr("get_pfnblock_flags_mask");
103 if (!get_pfnblock_flags_mask_sym
)
107 EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask_init
);
111 #include <linux/pageblock-flags.h>