Lines Matching refs:iter
665 static int get_ksymbol_arch(struct kallsym_iter *iter) in get_ksymbol_arch() argument
667 int ret = arch_get_kallsym(iter->pos - kallsyms_num_syms, in get_ksymbol_arch()
668 &iter->value, &iter->type, in get_ksymbol_arch()
669 iter->name); in get_ksymbol_arch()
672 iter->pos_arch_end = iter->pos; in get_ksymbol_arch()
679 static int get_ksymbol_mod(struct kallsym_iter *iter) in get_ksymbol_mod() argument
681 int ret = module_get_kallsym(iter->pos - iter->pos_arch_end, in get_ksymbol_mod()
682 &iter->value, &iter->type, in get_ksymbol_mod()
683 iter->name, iter->module_name, in get_ksymbol_mod()
684 &iter->exported); in get_ksymbol_mod()
686 iter->pos_mod_end = iter->pos; in get_ksymbol_mod()
698 static int get_ksymbol_ftrace_mod(struct kallsym_iter *iter) in get_ksymbol_ftrace_mod() argument
700 int ret = ftrace_mod_get_kallsym(iter->pos - iter->pos_mod_end, in get_ksymbol_ftrace_mod()
701 &iter->value, &iter->type, in get_ksymbol_ftrace_mod()
702 iter->name, iter->module_name, in get_ksymbol_ftrace_mod()
703 &iter->exported); in get_ksymbol_ftrace_mod()
705 iter->pos_ftrace_mod_end = iter->pos; in get_ksymbol_ftrace_mod()
712 static int get_ksymbol_bpf(struct kallsym_iter *iter) in get_ksymbol_bpf() argument
716 strlcpy(iter->module_name, "bpf", MODULE_NAME_LEN); in get_ksymbol_bpf()
717 iter->exported = 0; in get_ksymbol_bpf()
718 ret = bpf_get_kallsym(iter->pos - iter->pos_ftrace_mod_end, in get_ksymbol_bpf()
719 &iter->value, &iter->type, in get_ksymbol_bpf()
720 iter->name); in get_ksymbol_bpf()
722 iter->pos_bpf_end = iter->pos; in get_ksymbol_bpf()
734 static int get_ksymbol_kprobe(struct kallsym_iter *iter) in get_ksymbol_kprobe() argument
736 strlcpy(iter->module_name, "__builtin__kprobes", MODULE_NAME_LEN); in get_ksymbol_kprobe()
737 iter->exported = 0; in get_ksymbol_kprobe()
738 return kprobe_get_kallsym(iter->pos - iter->pos_bpf_end, in get_ksymbol_kprobe()
739 &iter->value, &iter->type, in get_ksymbol_kprobe()
740 iter->name) < 0 ? 0 : 1; in get_ksymbol_kprobe()
744 static unsigned long get_ksymbol_core(struct kallsym_iter *iter) in get_ksymbol_core() argument
746 unsigned off = iter->nameoff; in get_ksymbol_core()
748 iter->module_name[0] = '\0'; in get_ksymbol_core()
749 iter->value = kallsyms_sym_address(iter->pos); in get_ksymbol_core()
751 iter->type = kallsyms_get_symbol_type(off); in get_ksymbol_core()
753 off = kallsyms_expand_symbol(off, iter->name, ARRAY_SIZE(iter->name)); in get_ksymbol_core()
755 return off - iter->nameoff; in get_ksymbol_core()
758 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos) in reset_iter() argument
760 iter->name[0] = '\0'; in reset_iter()
761 iter->nameoff = get_symbol_offset(new_pos); in reset_iter()
762 iter->pos = new_pos; in reset_iter()
764 iter->pos_arch_end = 0; in reset_iter()
765 iter->pos_mod_end = 0; in reset_iter()
766 iter->pos_ftrace_mod_end = 0; in reset_iter()
767 iter->pos_bpf_end = 0; in reset_iter()
776 static int update_iter_mod(struct kallsym_iter *iter, loff_t pos) in update_iter_mod() argument
778 iter->pos = pos; in update_iter_mod()
780 if ((!iter->pos_arch_end || iter->pos_arch_end > pos) && in update_iter_mod()
781 get_ksymbol_arch(iter)) in update_iter_mod()
784 if ((!iter->pos_mod_end || iter->pos_mod_end > pos) && in update_iter_mod()
785 get_ksymbol_mod(iter)) in update_iter_mod()
788 if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) && in update_iter_mod()
789 get_ksymbol_ftrace_mod(iter)) in update_iter_mod()
792 if ((!iter->pos_bpf_end || iter->pos_bpf_end > pos) && in update_iter_mod()
793 get_ksymbol_bpf(iter)) in update_iter_mod()
796 return get_ksymbol_kprobe(iter); in update_iter_mod()
800 static int update_iter(struct kallsym_iter *iter, loff_t pos) in update_iter() argument
804 return update_iter_mod(iter, pos); in update_iter()
807 if (pos != iter->pos) in update_iter()
808 reset_iter(iter, pos); in update_iter()
810 iter->nameoff += get_ksymbol_core(iter); in update_iter()
811 iter->pos++; in update_iter()
839 struct kallsym_iter *iter = m->private; in s_show() local
842 if (!iter->name[0]) in s_show()
845 value = iter->show_value ? (void *)iter->value : NULL; in s_show()
847 if (iter->module_name[0]) { in s_show()
854 type = iter->exported ? toupper(iter->type) : in s_show()
855 tolower(iter->type); in s_show()
857 type, iter->name, iter->module_name); in s_show()
860 iter->type, iter->name); in s_show()
916 struct kallsym_iter *iter = priv_data; in bpf_iter_ksym_init() local
918 reset_iter(iter, 0); in bpf_iter_ksym_init()
923 iter->show_value = kallsyms_show_value(current_cred()); in bpf_iter_ksym_init()
1003 struct kallsym_iter *iter; in kallsyms_open() local
1004 iter = __seq_open_private(file, &kallsyms_op, sizeof(*iter)); in kallsyms_open()
1005 if (!iter) in kallsyms_open()
1007 reset_iter(iter, 0); in kallsyms_open()
1013 iter->show_value = kallsyms_show_value(file->f_cred); in kallsyms_open()