kallsyms: Make kallsyms_on_each_symbol generally available

[ 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>
Stable-dep-of: b022f0c7e404 ("tracing/kprobes: Return EADDRNOTAVAIL when
func matches several symbols")
Signed-off-by: Sherry Yang <sherry.yang@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jiri Olsa 2024-10-08 15:29:45 -07:00 committed by Ksawlii
parent 098bb6f404
commit 9dc3580302
2 changed files with 6 additions and 3 deletions

View file

@ -71,11 +71,11 @@ static inline void *dereference_symbol_descriptor(void *ptr)
return ptr; return ptr;
} }
#ifdef CONFIG_KALLSYMS
int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
unsigned long), unsigned long),
void *data); void *data);
#ifdef CONFIG_KALLSYMS
/* Lookup the address for a symbol. Returns 0 if not found. */ /* Lookup the address for a symbol. Returns 0 if not found. */
unsigned long kallsyms_lookup_name(const char *name); unsigned long kallsyms_lookup_name(const char *name);
@ -155,6 +155,11 @@ static inline bool kallsyms_show_value(const struct cred *cred)
return false; 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*/ #endif /*CONFIG_KALLSYMS*/
static inline void print_ip_sym(const char *loglvl, unsigned long ip) static inline void print_ip_sym(const char *loglvl, unsigned long ip)

View file

@ -265,7 +265,6 @@ unsigned long kallsyms_lookup_name(const char *name)
return module_kallsyms_lookup_name(name); return module_kallsyms_lookup_name(name);
} }
#ifdef CONFIG_LIVEPATCH
/* /*
* Iterate over all symbols in vmlinux. For symbols from modules use * Iterate over all symbols in vmlinux. For symbols from modules use
* module_kallsyms_on_each_symbol instead. * module_kallsyms_on_each_symbol instead.
@ -287,7 +286,6 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *,
} }
return 0; return 0;
} }
#endif /* CONFIG_LIVEPATCH */
static unsigned long get_symbol_pos(unsigned long addr, static unsigned long get_symbol_pos(unsigned long addr,
unsigned long *symbolsize, unsigned long *symbolsize,