diff options
author | Petr Mladek <pmladek@suse.com> | 2018-01-22 10:40:32 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2018-01-22 10:40:32 +0100 |
commit | 3ccdc5190f8df12dfafff9264e406c5496401da5 (patch) | |
tree | ca4afea86b2ae2625125658b2e0af2e043e84017 /include/linux/kallsyms.h | |
parent | 6fd78a1a99c9580da49ee8f951fdce9846256375 (diff) | |
parent | 1df7338ac96558d5ae4c1a9dd5d1cb60fcd1bdb2 (diff) | |
download | linux-stable-3ccdc5190f8df12dfafff9264e406c5496401da5.tar.gz linux-stable-3ccdc5190f8df12dfafff9264e406c5496401da5.tar.bz2 linux-stable-3ccdc5190f8df12dfafff9264e406c5496401da5.zip |
Merge branch 'for-4.16-deprecate-printk-pf' into for-4.16
Diffstat (limited to 'include/linux/kallsyms.h')
-rw-r--r-- | include/linux/kallsyms.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 708f337d780b..e4f2e5a65f14 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -9,6 +9,10 @@ #include <linux/errno.h> #include <linux/kernel.h> #include <linux/stddef.h> +#include <linux/mm.h> +#include <linux/module.h> + +#include <asm/sections.h> #define KSYM_NAME_LEN 128 #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ @@ -22,6 +26,56 @@ struct module; +static inline int is_kernel_inittext(unsigned long addr) +{ + if (addr >= (unsigned long)_sinittext + && addr <= (unsigned long)_einittext) + return 1; + return 0; +} + +static inline int is_kernel_text(unsigned long addr) +{ + if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) || + arch_is_kernel_text(addr)) + return 1; + return in_gate_area_no_mm(addr); +} + +static inline int is_kernel(unsigned long addr) +{ + if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end) + return 1; + return in_gate_area_no_mm(addr); +} + +static inline int is_ksym_addr(unsigned long addr) +{ + if (IS_ENABLED(CONFIG_KALLSYMS_ALL)) + return is_kernel(addr); + + return is_kernel_text(addr) || is_kernel_inittext(addr); +} + +static inline void *dereference_symbol_descriptor(void *ptr) +{ +#ifdef HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR + struct module *mod; + + ptr = dereference_kernel_function_descriptor(ptr); + if (is_ksym_addr((unsigned long)ptr)) + return ptr; + + preempt_disable(); + mod = __module_address((unsigned long)ptr); + preempt_enable(); + + if (mod) + ptr = dereference_module_function_descriptor(mod, ptr); +#endif + return ptr; +} + #ifdef CONFIG_KALLSYMS /* Lookup the address for a symbol. Returns 0 if not found. */ unsigned long kallsyms_lookup_name(const char *name); |