| @@ -343,6 +343,14 @@ DEFINE_BASIC_FETCH_FUNCS(deref) · 342 unmodified lines |
| 343 | 343 | DEFINE_FETCH_deref(string) |
| 344 | 344 | DEFINE_FETCH_deref(string_size) |
| 345 | 345 | |
| 346 | +static __kprobes void update_deref_fetch_param(struct deref_fetch_param *data) |
| 347 | +{ |
| 348 | + if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) |
| 349 | + update_deref_fetch_param(data->orig.data); |
| 350 | + else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn)) |
| 351 | + update_symbol_cache(data->orig.data); |
| 352 | +} |
| 353 | + |
| 346 | 354 | static __kprobes void free_deref_fetch_param(struct deref_fetch_param *data) |
| 347 | 355 | { |
| 348 | 356 | if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) |
| @@ -376,6 +384,19 @@ DEFINE_BASIC_FETCH_FUNCS(bitfield) · 27 unmodified lines |
| 376 | 384 | #define fetch_bitfield_string NULL |
| 377 | 385 | #define fetch_bitfield_string_size NULL |
| 378 | 386 | |
| 387 | +static __kprobes void |
| 388 | +update_bitfield_fetch_param(struct bitfield_fetch_param *data) |
| 389 | +{ |
| 390 | + /* |
| 391 | + * Don't check the bitfield itself, because this must be the |
| 392 | + * last fetch function. |
| 393 | + */ |
| 394 | + if (CHECK_FETCH_FUNCS(deref, data->orig.fn)) |
| 395 | + update_deref_fetch_param(data->orig.data); |
| 396 | + else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn)) |
| 397 | + update_symbol_cache(data->orig.data); |
| 398 | +} |
| 399 | + |
| 379 | 400 | static __kprobes void |
| 380 | 401 | free_bitfield_fetch_param(struct bitfield_fetch_param *data) |
| 381 | 402 | { |
| @@ -389,6 +410,7 @@ free_bitfield_fetch_param(struct bitfield_fetch_param *data) · 7 unmodified lines |
| 389 | 410 | free_symbol_cache(data->orig.data); |
| 390 | 411 | kfree(data); |
| 391 | 412 | } |
| 413 | + |
| 392 | 414 | /* Default (unsigned long) fetch type */ |
| 393 | 415 | #define __DEFAULT_FETCH_TYPE(t) u##t |
| 394 | 416 | #define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t) |
| @@ -536,6 +558,7 @@ struct probe_arg { · 141 unmodified lines |
| 536 | 558 | /* Flags for trace_probe */ |
| 537 | 559 | #define TP_FLAG_TRACE 1 |
| 538 | 560 | #define TP_FLAG_PROFILE 2 |
| 561 | +#define TP_FLAG_REGISTERED 4 |
| 539 | 562 | |
| 540 | 563 | struct trace_probe { |
| 541 | 564 | struct list_head list; |
| @@ -555,16 +578,49 @@ struct trace_probe { · 13 unmodified lines |
| 555 | 578 | (sizeof(struct probe_arg) * (n))) |
| 556 | 579 | |
| 557 | 580 | |
| 558 | | −static __kprobes int probe_is_return(struct trace_probe *tp) |
| 581 | +static __kprobes int trace_probe_is_return(struct trace_probe *tp) |
| 559 | 582 | { |
| 560 | 583 | return tp->rp.handler != NULL; |
| 561 | 584 | } |
| 562 | 585 | |
| 563 | | −static __kprobes const char *probe_symbol(struct trace_probe *tp) |
| 586 | +static __kprobes const char *trace_probe_symbol(struct trace_probe *tp) |
| 564 | 587 | { |
| 565 | 588 | return tp->symbol ? tp->symbol : "unknown"; |
| 566 | 589 | } |
| 567 | 590 | |
| 591 | +static __kprobes unsigned long trace_probe_offset(struct trace_probe *tp) |
| 592 | +{ |
| 593 | + return tp->rp.kp.offset; |
| 594 | +} |
| 595 | + |
| 596 | +static __kprobes bool trace_probe_is_enabled(struct trace_probe *tp) |
| 597 | +{ |
| 598 | + return !!(tp->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE)); |
| 599 | +} |
| 600 | + |
| 601 | +static __kprobes bool trace_probe_is_registered(struct trace_probe *tp) |
| 602 | +{ |
| 603 | + return !!(tp->flags & TP_FLAG_REGISTERED); |
| 604 | +} |
| 605 | + |
| 606 | +static __kprobes bool trace_probe_has_gone(struct trace_probe *tp) |
| 607 | +{ |
| 608 | + return !!(kprobe_gone(&tp->rp.kp)); |
| 609 | +} |
| 610 | + |
| 611 | +static __kprobes bool trace_probe_within_module(struct trace_probe *tp, |
| 612 | + struct module *mod) |
| 613 | +{ |
| 614 | + int len = strlen(mod->name); |
| 615 | + const char *name = trace_probe_symbol(tp); |
| 616 | + return strncmp(mod->name, name, len) == 0 && name[len] == ':'; |
| 617 | +} |
| 618 | + |
| 619 | +static __kprobes bool trace_probe_is_on_module(struct trace_probe *tp) |
| 620 | +{ |
| 621 | + return !!strchr(trace_probe_symbol(tp), ':'); |
| 622 | +} |
| 623 | + |
| 568 | 624 | static int register_probe_event(struct trace_probe *tp); |
| 569 | 625 | static void unregister_probe_event(struct trace_probe *tp); |
| 570 | 626 | |
| @@ -646,6 +702,16 @@ error: · 75 unmodified lines |
| 646 | 702 | return ERR_PTR(ret); |
| 647 | 703 | } |
| 648 | 704 | |
| 705 | +static void update_probe_arg(struct probe_arg *arg) |
| 706 | +{ |
| 707 | + if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn)) |
| 708 | + update_bitfield_fetch_param(arg->fetch.data); |
| 709 | + else if (CHECK_FETCH_FUNCS(deref, arg->fetch.fn)) |
| 710 | + update_deref_fetch_param(arg->fetch.data); |
| 711 | + else if (CHECK_FETCH_FUNCS(symbol, arg->fetch.fn)) |
| 712 | + update_symbol_cache(arg->fetch.data); |
| 713 | +} |
| 714 | + |
| 649 | 715 | static void free_probe_arg(struct probe_arg *arg) |
| 650 | 716 | { |
| 651 | 717 | if (CHECK_FETCH_FUNCS(bitfield, arg->fetch.fn)) |
| @@ -671,7 +737,7 @@ static void free_trace_probe(struct trace_probe *tp) · 19 unmodified lines |
| 671 | 737 | kfree(tp); |
| 672 | 738 | } |
| 673 | 739 | |
| 674 | | −static struct trace_probe *find_probe_event(const char *event, |
| 740 | +static struct trace_probe *find_trace_probe(const char *event, |
| 675 | 741 | const char *group) |
| 676 | 742 | { |
| 677 | 743 | struct trace_probe *tp; |
| @@ -683,13 +749,96 @@ static struct trace_probe *find_probe_event(const char *event, · 5 unmodified lines |
| 683 | 749 | return NULL; |
| 684 | 750 | } |
| 685 | 751 | |
| 752 | +/* Enable trace_probe - @flag must be TP_FLAG_TRACE or TP_FLAG_PROFILE */ |
| 753 | +static int enable_trace_probe(struct trace_probe *tp, int flag) |
| 754 | +{ |
| 755 | + int ret = 0; |
| 756 | + |
| 757 | + tp->flags |= flag; |
| 758 | + if (trace_probe_is_enabled(tp) && trace_probe_is_registered(tp) && |
| 759 | + !trace_probe_has_gone(tp)) { |
| 760 | + if (trace_probe_is_return(tp)) |
| 761 | + ret = enable_kretprobe(&tp->rp); |
| 762 | + else |
| 763 | + ret = enable_kprobe(&tp->rp.kp); |
| 764 | + } |
| 765 | + |
| 766 | + return ret; |
| 767 | +} |
| 768 | + |
| 769 | +/* Disable trace_probe - @flag must be TP_FLAG_TRACE or TP_FLAG_PROFILE */ |
| 770 | +static void disable_trace_probe(struct trace_probe *tp, int flag) |
| 771 | +{ |
| 772 | + tp->flags &= ~flag; |
| 773 | + if (!trace_probe_is_enabled(tp) && trace_probe_is_registered(tp)) { |
| 774 | + if (trace_probe_is_return(tp)) |
| 775 | + disable_kretprobe(&tp->rp); |
| 776 | + else |
| 777 | + disable_kprobe(&tp->rp.kp); |
| 778 | + } |
| 779 | +} |
| 780 | + |
| 781 | +/* Internal register function - just handle k*probes and flags */ |
| 782 | +static int __register_trace_probe(struct trace_probe *tp) |
| 783 | +{ |
| 784 | + int i, ret; |
| 785 | + |
| 786 | + if (trace_probe_is_registered(tp)) |
| 787 | + return -EINVAL; |
| 788 | + |
| 789 | + for (i = 0; i < tp->nr_args; i++) |
| 790 | + update_probe_arg(&tp->args[i]); |
| 791 | + |
| 792 | + /* Set/clear disabled flag according to tp->flag */ |
| 793 | + if (trace_probe_is_enabled(tp)) |
| 794 | + tp->rp.kp.flags &= ~KPROBE_FLAG_DISABLED; |
| 795 | + else |
| 796 | + tp->rp.kp.flags |= KPROBE_FLAG_DISABLED; |
| 797 | + |
| 798 | + if (trace_probe_is_return(tp)) |
| 799 | + ret = register_kretprobe(&tp->rp); |
| 800 | + else |
| 801 | + ret = register_kprobe(&tp->rp.kp); |
| 802 | + |
| 803 | + if (ret == 0) |
| 804 | + tp->flags |= TP_FLAG_REGISTERED; |
| 805 | + else { |
| 806 | + pr_warning("Could not insert probe at %s+%lu: %d\n", |
| 807 | + trace_probe_symbol(tp), trace_probe_offset(tp), ret); |
| 808 | + if (ret == -ENOENT && trace_probe_is_on_module(tp)) { |
| 809 | + pr_warning("This probe might be able to register after" |
| 810 | + "target module is loaded. Continue.\n"); |
| 811 | + ret = 0; |
| 812 | + } else if (ret == -EILSEQ) { |
| 813 | + pr_warning("Probing address(0x%p) is not an " |
| 814 | + "instruction boundary.\n", |
| 815 | + tp->rp.kp.addr); |
| 816 | + ret = -EINVAL; |
| 817 | + } |
| 818 | + } |
| 819 | + |
| 820 | + return ret; |
| 821 | +} |
| 822 | + |
| 823 | +/* Internal unregister function - just handle k*probes and flags */ |
| 824 | +static void __unregister_trace_probe(struct trace_probe *tp) |
| 825 | +{ |
| 826 | + if (trace_probe_is_registered(tp)) { |
| 827 | + if (trace_probe_is_return(tp)) |
| 828 | + unregister_kretprobe(&tp->rp); |
| 829 | + else |
| 830 | + unregister_kprobe(&tp->rp.kp); |
| 831 | + tp->flags &= ~TP_FLAG_REGISTERED; |
| 832 | + /* Cleanup kprobe for reuse */ |
| 833 | + if (tp->rp.kp.symbol_name) |
| 834 | + tp->rp.kp.addr = NULL; |
| 835 | + } |
| 836 | +} |
| 837 | + |
| 686 | 838 | /* Unregister a trace_probe and probe_event: call with locking probe_lock */ |
| 687 | 839 | static void unregister_trace_probe(struct trace_probe *tp) |
| 688 | 840 | { |
| 689 | | − if (probe_is_return(tp)) |
| 690 | | − unregister_kretprobe(&tp->rp); |
| 691 | | − else |
| 692 | | − unregister_kprobe(&tp->rp.kp); |
| 841 | + __unregister_trace_probe(tp); |
| 693 | 842 | list_del(&tp->list); |
| 694 | 843 | unregister_probe_event(tp); |
| 695 | 844 | } |
| @@ -702,41 +851,65 @@ static int register_trace_probe(struct trace_probe *tp) · 6 unmodified lines |
| 702 | 851 | |
| 703 | 852 | mutex_lock(&probe_lock); |
| 704 | 853 | |
| 705 | | − /* register as an event */ |
| 706 | | − old_tp = find_probe_event(tp->call.name, tp->call.class->system); |
| 854 | + /* Delete old (same name) event if exist */ |
| 855 | + old_tp = find_trace_probe(tp->call.name, tp->call.class->system); |
| 707 | 856 | if (old_tp) { |
| 708 | | − /* delete old event */ |
| 709 | 857 | unregister_trace_probe(old_tp); |
| 710 | 858 | free_trace_probe(old_tp); |
| 711 | 859 | } |
| 860 | + |
| 861 | + /* Register new event */ |
| 712 | 862 | ret = register_probe_event(tp); |
| 713 | 863 | if (ret) { |
| 714 | 864 | pr_warning("Failed to register probe event(%d)\n", ret); |
| 715 | 865 | goto end; |
| 716 | 866 | } |
| 717 | 867 | |
| 718 | | − tp->rp.kp.flags |= KPROBE_FLAG_DISABLED; |
| 719 | | − if (probe_is_return(tp)) |
| 720 | | − ret = register_kretprobe(&tp->rp); |
| 721 | | − else |
| 722 | | − ret = register_kprobe(&tp->rp.kp); |
| 723 | | − |
| 724 | | − if (ret) { |
| 725 | | − pr_warning("Could not insert probe(%d)\n", ret); |
| 726 | | − if (ret == -EILSEQ) { |
| 727 | | − pr_warning("Probing address(0x%p) is not an " |
| 728 | | − "instruction boundary.\n", |
| 729 | | − tp->rp.kp.addr); |
| 730 | | − ret = -EINVAL; |
| 731 | | − } |
| 868 | + /* Register k*probe */ |
| 869 | + ret = __register_trace_probe(tp); |
| 870 | + if (ret < 0) |
| 732 | 871 | unregister_probe_event(tp); |
| 733 | | − } else |
| 872 | + else |
| 734 | 873 | list_add_tail(&tp->list, &probe_list); |
| 874 | + |
| 735 | 875 | end: |
| 736 | 876 | mutex_unlock(&probe_lock); |
| 737 | 877 | return ret; |
| 738 | 878 | } |
| 739 | 879 | |
| 880 | +/* Module notifier call back, checking event on the module */ |
| 881 | +static int trace_probe_module_callback(struct notifier_block *nb, |
| 882 | + unsigned long val, void *data) |
| 883 | +{ |
| 884 | + struct module *mod = data; |
| 885 | + struct trace_probe *tp; |
| 886 | + int ret; |
| 887 | + |
| 888 | + if (val != MODULE_STATE_COMING) |
| 889 | + return NOTIFY_DONE; |
| 890 | + |
| 891 | + /* Update probes on coming module */ |
| 892 | + mutex_lock(&probe_lock); |
| 893 | + list_for_each_entry(tp, &probe_list, list) { |
| 894 | + if (trace_probe_within_module(tp, mod)) { |
| 895 | + __unregister_trace_probe(tp); |
| 896 | + ret = __register_trace_probe(tp); |
| 897 | + if (ret) |
| 898 | + pr_warning("Failed to re-register probe %s on" |
| 899 | + "%s: %d\n", |
| 900 | + tp->call.name, mod->name, ret); |
| 901 | + } |
| 902 | + } |
| 903 | + mutex_unlock(&probe_lock); |
| 904 | + |
| 905 | + return NOTIFY_DONE; |
| 906 | +} |
| 907 | + |
| 908 | +static struct notifier_block trace_probe_module_nb = { |
| 909 | + .notifier_call = trace_probe_module_callback, |
| 910 | + .priority = 1 /* Invoked after kprobe module callback */ |
| 911 | +}; |
| 912 | + |
| 740 | 913 | /* Split symbol and offset. */ |
| 741 | 914 | static int split_symbol_offset(char *symbol, unsigned long *offset) |
| 742 | 915 | { |
| @@ -962,8 +1135,8 @@ static int create_trace_probe(int argc, char **argv) · 219 unmodified lines |
| 962 | 1135 | { |
| 963 | 1136 | /* |
| 964 | 1137 | * Argument syntax: |
| 965 | | − * - Add kprobe: p[:[GRP/]EVENT] KSYM[+OFFS]|KADDR [FETCHARGS] |
| 966 | | − * - Add kretprobe: r[:[GRP/]EVENT] KSYM[+0] [FETCHARGS] |
| 1138 | + * - Add kprobe: p[:[GRP/]EVENT] [MOD:]KSYM[+OFFS]|KADDR [FETCHARGS] |
| 1139 | + * - Add kretprobe: r[:[GRP/]EVENT] [MOD:]KSYM[+0] [FETCHARGS] |
| 967 | 1140 | * Fetch args: |
| 968 | 1141 | * $retval : fetch return value |
| 969 | 1142 | * $stack : fetch stack address |
| @@ -1025,7 +1198,7 @@ static int create_trace_probe(int argc, char **argv) · 55 unmodified lines |
| 1025 | 1198 | return -EINVAL; |
| 1026 | 1199 | } |
| 1027 | 1200 | mutex_lock(&probe_lock); |
| 1028 | | − tp = find_probe_event(event, group); |
| 1201 | + tp = find_trace_probe(event, group); |
| 1029 | 1202 | if (!tp) { |
| 1030 | 1203 | mutex_unlock(&probe_lock); |
| 1031 | 1204 | pr_info("Event %s/%s doesn't exist.\n", group, event); |
| @@ -1144,7 +1317,7 @@ error: · 112 unmodified lines |
| 1144 | 1317 | return ret; |
| 1145 | 1318 | } |
| 1146 | 1319 | |
| 1147 | | −static void cleanup_all_probes(void) |
| 1320 | +static void release_all_trace_probes(void) |
| 1148 | 1321 | { |
| 1149 | 1322 | struct trace_probe *tp; |
| 1150 | 1323 | |
| @@ -1158,7 +1331,6 @@ static void cleanup_all_probes(void) · 7 unmodified lines |
| 1158 | 1331 | mutex_unlock(&probe_lock); |
| 1159 | 1332 | } |
| 1160 | 1333 | |
| 1161 | | − |
| 1162 | 1334 | /* Probes listing interfaces */ |
| 1163 | 1335 | static void *probes_seq_start(struct seq_file *m, loff_t *pos) |
| 1164 | 1336 | { |
| @@ -1181,15 +1353,16 @@ static int probes_seq_show(struct seq_file *m, void *v) · 16 unmodified lines |
| 1181 | 1353 | struct trace_probe *tp = v; |
| 1182 | 1354 | int i; |
| 1183 | 1355 | |
| 1184 | | − seq_printf(m, "%c", probe_is_return(tp) ? 'r' : 'p'); |
| 1356 | + seq_printf(m, "%c", trace_probe_is_return(tp) ? 'r' : 'p'); |
| 1185 | 1357 | seq_printf(m, ":%s/%s", tp->call.class->system, tp->call.name); |
| 1186 | 1358 | |
| 1187 | 1359 | if (!tp->symbol) |
| 1188 | 1360 | seq_printf(m, " 0x%p", tp->rp.kp.addr); |
| 1189 | 1361 | else if (tp->rp.kp.offset) |
| 1190 | | − seq_printf(m, " %s+%u", probe_symbol(tp), tp->rp.kp.offset); |
| 1362 | + seq_printf(m, " %s+%u", trace_probe_symbol(tp), |
| 1363 | + tp->rp.kp.offset); |
| 1191 | 1364 | else |
| 1192 | | − seq_printf(m, " %s", probe_symbol(tp)); |
| 1365 | + seq_printf(m, " %s", trace_probe_symbol(tp)); |
| 1193 | 1366 | |
| 1194 | 1367 | for (i = 0; i < tp->nr_args; i++) |
| 1195 | 1368 | seq_printf(m, " %s=%s", tp->args[i].name, tp->args[i].comm); |
| @@ -1209,7 +1382,7 @@ static int probes_open(struct inode *inode, struct file *file) · 13 unmodified lines |
| 1209 | 1382 | { |
| 1210 | 1383 | if ((file->f_mode & FMODE_WRITE) && |
| 1211 | 1384 | (file->f_flags & O_TRUNC)) |
| 1212 | | − cleanup_all_probes(); |
| 1385 | + release_all_trace_probes(); |
| 1213 | 1386 | |
| 1214 | 1387 | return seq_open(file, &probes_seq_op); |
| 1215 | 1388 | } |
| @@ -1513,30 +1686,6 @@ partial: · 297 unmodified lines |
| 1513 | 1686 | return TRACE_TYPE_PARTIAL_LINE; |
| 1514 | 1687 | } |
| 1515 | 1688 | |
| 1516 | | −static int probe_event_enable(struct ftrace_event_call *call) |
| 1517 | | −{ |
| 1518 | | − struct trace_probe *tp = (struct trace_probe *)call->data; |
| 1519 | | − |
| 1520 | | − tp->flags |= TP_FLAG_TRACE; |
| 1521 | | − if (probe_is_return(tp)) |
| 1522 | | − return enable_kretprobe(&tp->rp); |
| 1523 | | − else |
| 1524 | | − return enable_kprobe(&tp->rp.kp); |
| 1525 | | −} |
| 1526 | | − |
| 1527 | | −static void probe_event_disable(struct ftrace_event_call *call) |
| 1528 | | −{ |
| 1529 | | − struct trace_probe *tp = (struct trace_probe *)call->data; |
| 1530 | | − |
| 1531 | | − tp->flags &= ~TP_FLAG_TRACE; |
| 1532 | | − if (!(tp->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE))) { |
| 1533 | | − if (probe_is_return(tp)) |
| 1534 | | − disable_kretprobe(&tp->rp); |
| 1535 | | − else |
| 1536 | | − disable_kprobe(&tp->rp.kp); |
| 1537 | | − } |
| 1538 | | −} |
| 1539 | | − |
| 1540 | 1689 | #undef DEFINE_FIELD |
| 1541 | 1690 | #define DEFINE_FIELD(type, item, name, is_signed) \ |
| 1542 | 1691 | do { \ |
| @@ -1598,7 +1747,7 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len) · 55 unmodified lines |
| 1598 | 1747 | |
| 1599 | 1748 | const char *fmt, *arg; |
| 1600 | 1749 | |
| 1601 | | − if (!probe_is_return(tp)) { |
| 1750 | + if (!trace_probe_is_return(tp)) { |
| 1602 | 1751 | fmt = "(%lx)"; |
| 1603 | 1752 | arg = "REC->" FIELD_STRING_IP; |
| 1604 | 1753 | } else { |
| @@ -1715,49 +1864,25 @@ static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri, · 110 unmodified lines |
| 1715 | 1864 | head = this_cpu_ptr(call->perf_events); |
| 1716 | 1865 | perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, regs, head); |
| 1717 | 1866 | } |
| 1718 | | − |
| 1719 | | −static int probe_perf_enable(struct ftrace_event_call *call) |
| 1720 | | −{ |
| 1721 | | − struct trace_probe *tp = (struct trace_probe *)call->data; |
| 1722 | | − |
| 1723 | | − tp->flags |= TP_FLAG_PROFILE; |
| 1724 | | − |
| 1725 | | − if (probe_is_return(tp)) |
| 1726 | | − return enable_kretprobe(&tp->rp); |
| 1727 | | − else |
| 1728 | | − return enable_kprobe(&tp->rp.kp); |
| 1729 | | −} |
| 1730 | | − |
| 1731 | | −static void probe_perf_disable(struct ftrace_event_call *call) |
| 1732 | | −{ |
| 1733 | | − struct trace_probe *tp = (struct trace_probe *)call->data; |
| 1734 | | − |
| 1735 | | − tp->flags &= ~TP_FLAG_PROFILE; |
| 1736 | | − |
| 1737 | | − if (!(tp->flags & TP_FLAG_TRACE)) { |
| 1738 | | − if (probe_is_return(tp)) |
| 1739 | | − disable_kretprobe(&tp->rp); |
| 1740 | | − else |
| 1741 | | − disable_kprobe(&tp->rp.kp); |
| 1742 | | − } |
| 1743 | | −} |
| 1744 | 1867 | #endif /* CONFIG_PERF_EVENTS */ |
| 1745 | 1868 | |
| 1746 | 1869 | static __kprobes |
| 1747 | 1870 | int kprobe_register(struct ftrace_event_call *event, enum trace_reg type) |
| 1748 | 1871 | { |
| 1872 | + struct trace_probe *tp = (struct trace_probe *)event->data; |
| 1873 | + |
| 1749 | 1874 | switch (type) { |
| 1750 | 1875 | case TRACE_REG_REGISTER: |
| 1751 | | − return probe_event_enable(event); |
| 1876 | + return enable_trace_probe(tp, TP_FLAG_TRACE); |
| 1752 | 1877 | case TRACE_REG_UNREGISTER: |
| 1753 | | − probe_event_disable(event); |
| 1878 | + disable_trace_probe(tp, TP_FLAG_TRACE); |
| 1754 | 1879 | return 0; |
| 1755 | 1880 | |
| 1756 | 1881 | #ifdef CONFIG_PERF_EVENTS |
| 1757 | 1882 | case TRACE_REG_PERF_REGISTER: |
| 1758 | | − return probe_perf_enable(event); |
| 1883 | + return enable_trace_probe(tp, TP_FLAG_PROFILE); |
| 1759 | 1884 | case TRACE_REG_PERF_UNREGISTER: |
| 1760 | | − probe_perf_disable(event); |
| 1885 | + disable_trace_probe(tp, TP_FLAG_PROFILE); |
| 1761 | 1886 | return 0; |
| 1762 | 1887 | #endif |
| 1763 | 1888 | } |
| @@ -1807,7 +1932,7 @@ static int register_probe_event(struct trace_probe *tp) · 43 unmodified lines |
| 1807 | 1932 | |
| 1808 | 1933 | /* Initialize ftrace_event_call */ |
| 1809 | 1934 | INIT_LIST_HEAD(&call->class->fields); |
| 1810 | | − if (probe_is_return(tp)) { |
| 1935 | + if (trace_probe_is_return(tp)) { |
| 1811 | 1936 | call->event.funcs = &kretprobe_funcs; |
| 1812 | 1937 | call->class->define_fields = kretprobe_event_define_fields; |
| 1813 | 1938 | } else { |
| @@ -1846,6 +1971,9 @@ static __init int init_kprobe_trace(void) · 32 unmodified lines |
| 1846 | 1971 | struct dentry *d_tracer; |
| 1847 | 1972 | struct dentry *entry; |
| 1848 | 1973 | |
| 1974 | + if (register_module_notifier(&trace_probe_module_nb)) |
| 1975 | + return -EINVAL; |
| 1976 | + |
| 1849 | 1977 | d_tracer = tracing_init_dentry(); |
| 1850 | 1978 | if (!d_tracer) |
| 1851 | 1979 | return 0; |
| @@ -1899,12 +2027,12 @@ static __init int kprobe_trace_self_tests_init(void) · 47 unmodified lines |
| 1899 | 2027 | warn++; |
| 1900 | 2028 | } else { |
| 1901 | 2029 | /* Enable trace point */ |
| 1902 | | − tp = find_probe_event("testprobe", KPROBE_EVENT_SYSTEM); |
| 2030 | + tp = find_trace_probe("testprobe", KPROBE_EVENT_SYSTEM); |
| 1903 | 2031 | if (WARN_ON_ONCE(tp == NULL)) { |
| 1904 | 2032 | pr_warning("error on getting new probe.\n"); |
| 1905 | 2033 | warn++; |
| 1906 | 2034 | } else |
| 1907 | | − probe_event_enable(&tp->call); |
| 2035 | + enable_trace_probe(tp, TP_FLAG_TRACE); |
| 1908 | 2036 | } |
| 1909 | 2037 | |
| 1910 | 2038 | ret = command_trace_probe("r:testprobe2 kprobe_trace_selftest_target " |
| @@ -1914,12 +2042,12 @@ static __init int kprobe_trace_self_tests_init(void) · 3 unmodified lines |
| 1914 | 2042 | warn++; |
| 1915 | 2043 | } else { |
| 1916 | 2044 | /* Enable trace point */ |
| 1917 | | − tp = find_probe_event("testprobe2", KPROBE_EVENT_SYSTEM); |
| 2045 | + tp = find_trace_probe("testprobe2", KPROBE_EVENT_SYSTEM); |
| 1918 | 2046 | if (WARN_ON_ONCE(tp == NULL)) { |
| 1919 | 2047 | pr_warning("error on getting new probe.\n"); |
| 1920 | 2048 | warn++; |
| 1921 | 2049 | } else |
| 1922 | | − probe_event_enable(&tp->call); |
| 2050 | + enable_trace_probe(tp, TP_FLAG_TRACE); |
| 1923 | 2051 | } |
| 1924 | 2052 | |
| 1925 | 2053 | if (warn) |
| @@ -1940,7 +2068,7 @@ static __init int kprobe_trace_self_tests_init(void) · 14 unmodified lines |
| 1940 | 2068 | } |
| 1941 | 2069 | |
| 1942 | 2070 | end: |
| 1943 | | − cleanup_all_probes(); |
| 2071 | + release_all_trace_probes(); |
| 1944 | 2072 | if (warn) |
| 1945 | 2073 | pr_cont("NG: Some tests are failed. Please check them.\n"); |
| 1946 | 2074 | else |