]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kallsyms: Make kallsyms_on_each_symbol generally available
authorJiri Olsa <jolsa@kernel.org>
Tue, 10 May 2022 12:26:12 +0000 (14:26 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Dec 2023 17:36:45 +0000 (18:36 +0100)
[ Upstream commit d721def7392a7348ffb9f3583b264239cbd3702c ]

Making kallsyms_on_each_symbol generally available, so it can be
used outside CONFIG_LIVEPATCH option in following changes.

Rather than adding another ifdef option let's make the function
generally available (when CONFIG_KALLSYMS option is defined).

Cc: Christoph Hellwig <hch@lst.de>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20220510122616.2652285-2-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/kallsyms.h
kernel/kallsyms.c

index a1d6fc82d7f0649884f7a098870dd7fdb07f09a1..eae9f423bd648624ff84a0902bfe728c8405a630 100644 (file)
@@ -74,11 +74,11 @@ static inline void *dereference_symbol_descriptor(void *ptr)
        return ptr;
 }
 
+#ifdef CONFIG_KALLSYMS
 int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
                                      unsigned long),
                            void *data);
 
-#ifdef CONFIG_KALLSYMS
 /* Lookup the address for a symbol. Returns 0 if not found. */
 unsigned long kallsyms_lookup_name(const char *name);
 
@@ -172,6 +172,11 @@ static inline bool kallsyms_show_value(const struct cred *cred)
        return false;
 }
 
+static inline int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
+                                         unsigned long), void *data)
+{
+       return -EOPNOTSUPP;
+}
 #endif /*CONFIG_KALLSYMS*/
 
 static inline void print_ip_sym(const char *loglvl, unsigned long ip)
index 0ba87982d017fc4acc1b58e6ed798fa769b00887..e0d9f77cf2d4b1408de94c6f6e09a3fe647b76ed 100644 (file)
@@ -204,7 +204,6 @@ unsigned long kallsyms_lookup_name(const char *name)
        return module_kallsyms_lookup_name(name);
 }
 
-#ifdef CONFIG_LIVEPATCH
 /*
  * Iterate over all symbols in vmlinux.  For symbols from modules use
  * module_kallsyms_on_each_symbol instead.
@@ -226,7 +225,6 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
        }
        return 0;
 }
-#endif /* CONFIG_LIVEPATCH */
 
 static unsigned long get_symbol_pos(unsigned long addr,
                                    unsigned long *symbolsize,