Re: [PATCH V2 03/13] kprobes: Add symbols for kprobe insn pages

From: Adrian Hunter
Date: Fri Feb 28 2020 - 09:03:02 EST


On 26/02/20 5:21 pm, Jiri Olsa wrote:
> On Wed, Feb 12, 2020 at 02:49:39PM +0200, Adrian Hunter wrote:
>> Symbols are needed for tools to describe instruction addresses. Pages
>> allocated for kprobe's purposes need symbols to be created for them.
>> Add such symbols to be visible via /proc/kallsyms.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>
>
> SNIP
>
>> @@ -272,6 +273,8 @@ static inline bool is_kprobe_##__name##_slot(unsigned long addr) \
>> { \
>> return __is_insn_slot_addr(&kprobe_##__name##_slots, addr); \
>> }
>> +#define KPROBE_INSN_PAGE_SYM "kprobe_insn_page"
>> +#define KPROBE_OPTINSN_PAGE_SYM "kprobe_optinsn_page"
>> #else /* __ARCH_WANT_KPROBES_INSN_SLOT */
>> #define DEFINE_INSN_CACHE_OPS(__name) \
>> static inline bool is_kprobe_##__name##_slot(unsigned long addr) \
>> @@ -373,6 +376,13 @@ void dump_kprobe(struct kprobe *kp);
>> void *alloc_insn_page(void);
>> void free_insn_page(void *page);
>>
>> +int kprobe_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
>> + char *sym);
>> +int kprobe_cache_get_kallsym(struct kprobe_insn_cache *c, unsigned int *symnum,
>> + unsigned long *value, char *type, char *sym);
>> +
>> +int arch_kprobe_get_kallsym(unsigned int *symnum, unsigned long *value,
>> + char *type, char *sym);
>> #else /* !CONFIG_KPROBES: */
>>
>> static inline int kprobes_built_in(void)
>> @@ -435,6 +445,24 @@ static inline bool within_kprobe_blacklist(unsigned long addr)
>> {
>> return true;
>> }
>> +static inline int kprobe_get_kallsym(unsigned int symnum, unsigned long *value,
>> + char *type, char *sym)
>> +{
>> + return 0;
>> +}
>> +static inline int kprobe_cache_get_kallsym(struct kprobe_insn_cache *c,
>> + unsigned int *symnum,
>> + unsigned long *value, char *type,
>> + char *sym)
>> +{
>> + return 0;
>> +}
>> +static inline int arch_kprobe_get_kallsym(unsigned int *symnum,
>> + unsigned long *value, char *type,
>> + char *sym)
>> +{
>> + return 0;
>> +}
>
> there's another arch_kprobe_get_kallsym marked as __weak,
> is above function superfluous?

Yes, it is removed in V3.