Lines Matching +full:10 +full:base +full:- +full:te

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2013-2014, Intel Corporation.
8 * http://software.intel.com/en-us/intel-isa-extensions
42 * width encoded in IP-related packets), and event configuration (bitmasks with
78 u32 c = caps[cd->leaf * PT_CPUID_REGS_NUM + cd->reg]; in intel_pt_validate_cap()
79 unsigned int shift = __ffs(cd->mask); in intel_pt_validate_cap()
81 return (c & cd->mask) >> shift; in intel_pt_validate_cap()
97 enum pt_capabilities cap = (long)ea->var; in pt_cap_show()
111 PMU_FORMAT_ATTR(tsc, "config:10" );
117 PMU_FORMAT_ATTR(mtc_period, "config:14-17" );
118 PMU_FORMAT_ATTR(cyc_thresh, "config:19-22" );
119 PMU_FORMAT_ATTR(psb_period, "config:24-27" );
151 switch (pmu_attr->id) { in pt_timing_attr_show()
162 return -EINVAL; in pt_timing_attr_show()
213 /* model-specific quirks */ in pt_pmu_hw_init()
228 * Intel SDM, 36.5 "Tracing post-VMXON" says that in pt_pmu_hw_init()
230 * post-VMXON. in pt_pmu_hw_init()
245 ret = -ENOMEM; in pt_pmu_hw_init()
259 de_attr->attr.attr.name = pt_caps[i].name; in pt_pmu_hw_init()
261 sysfs_attr_init(&de_attr->attr.attr); in pt_pmu_hw_init()
263 de_attr->attr.attr.mode = S_IRUGO; in pt_pmu_hw_init()
264 de_attr->attr.show = pt_cap_show; in pt_pmu_hw_init()
265 de_attr->var = (void *)i; in pt_pmu_hw_init()
267 attrs[i] = &de_attr->attr.attr; in pt_pmu_hw_init()
314 u64 config = event->attr.config; in pt_event_valid()
388 * Re-using bit 0 for this purpose is fine because it is never in pt_event_valid()
390 * the attr.config resulted in -EINVAL. in pt_event_valid()
419 u64 ctl = event->hw.aux_config; in pt_config_start()
422 if (READ_ONCE(pt->vmx_on)) in pt_config_start()
423 perf_aux_output_flag(&pt->handle, PERF_AUX_FLAG_PARTIAL); in pt_config_start()
427 WRITE_ONCE(event->hw.aux_config, ctl); in pt_config_start()
460 struct pt_filters *filters = event->hw.addr_filters; in pt_config_filters()
470 for (range = 0; range < filters->nr_filters; range++) { in pt_config_filters()
471 struct pt_filter *filter = &filters->filter[range]; in pt_config_filters()
483 if (pt->filters.filter[range].msr_a != filter->msr_a) { in pt_config_filters()
484 wrmsrl(pt_address_ranges[range].msr_a, filter->msr_a); in pt_config_filters()
485 pt->filters.filter[range].msr_a = filter->msr_a; in pt_config_filters()
488 if (pt->filters.filter[range].msr_b != filter->msr_b) { in pt_config_filters()
489 wrmsrl(pt_address_ranges[range].msr_b, filter->msr_b); in pt_config_filters()
490 pt->filters.filter[range].msr_b = filter->msr_b; in pt_config_filters()
493 rtit_ctl |= (u64)filter->config << pt_address_ranges[range].reg_off; in pt_config_filters()
502 struct pt_buffer *buf = perf_get_aux(&pt->handle); in pt_config()
506 if (!event->hw.aux_config) { in pt_config()
513 if (!buf->single) in pt_config()
523 if (event->attr.config & BIT(0)) { in pt_config()
524 reg |= event->attr.config & RTIT_CTL_BRANCH_EN; in pt_config()
529 if (!event->attr.exclude_kernel) in pt_config()
531 if (!event->attr.exclude_user) in pt_config()
534 reg |= (event->attr.config & PT_CONFIG_MASK); in pt_config()
536 event->hw.aux_config = reg; in pt_config()
543 u64 ctl = READ_ONCE(event->hw.aux_config); in pt_config_stop()
550 if (!READ_ONCE(pt->vmx_on)) in pt_config_stop()
553 WRITE_ONCE(event->hw.aux_config, ctl); in pt_config_stop()
567 * struct topa - ToPA metadata
583 * Keep ToPA table-related metadata on the same page as the actual table,
588 ((PAGE_SIZE - sizeof(struct topa)) / sizeof(struct topa_entry))
591 * struct topa_page - page-sized ToPA table with metadata at the top
605 static inline struct topa_page *topa_entry_to_page(struct topa_entry *te) in topa_entry_to_page() argument
607 return (struct topa_page *)((unsigned long)te & PAGE_MASK); in topa_entry_to_page()
615 /* make -1 stand for the last table entry */
617 ((i) == -1 \
618 ? &topa_to_page(t)->table[(t)->last] \
619 : &topa_to_page(t)->table[(i)])
620 #define TOPA_ENTRY_SIZE(t, i) (sizes(TOPA_ENTRY((t), (i))->size))
621 #define TOPA_ENTRY_PAGES(t, i) (1 << TOPA_ENTRY((t), (i))->size)
627 void *base; in pt_config_buffer() local
629 if (buf->single) { in pt_config_buffer()
630 base = buf->data_pages[0]; in pt_config_buffer()
631 mask = (buf->nr_pages * PAGE_SIZE - 1) >> 7; in pt_config_buffer()
633 base = topa_to_page(buf->cur)->table; in pt_config_buffer()
634 mask = (u64)buf->cur_idx; in pt_config_buffer()
637 reg = virt_to_phys(base); in pt_config_buffer()
638 if (pt->output_base != reg) { in pt_config_buffer()
639 pt->output_base = reg; in pt_config_buffer()
643 reg = 0x7f | (mask << 7) | ((u64)buf->output_off << 32); in pt_config_buffer()
644 if (pt->output_mask != reg) { in pt_config_buffer()
645 pt->output_mask = reg; in pt_config_buffer()
651 * topa_alloc() - allocate page-sized ToPA table
668 tp->topa.last = 0; in topa_alloc()
671 * In case of singe-entry ToPA, always put the self-referencing END in topa_alloc()
675 TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p) >> TOPA_SHIFT; in topa_alloc()
676 TOPA_ENTRY(&tp->topa, 1)->end = 1; in topa_alloc()
679 return &tp->topa; in topa_alloc()
683 * topa_free() - free a page-sized ToPA table
692 * topa_insert_table() - insert a ToPA table into a buffer
702 struct topa *last = buf->last; in topa_insert_table()
704 list_add_tail(&topa->list, &buf->tables); in topa_insert_table()
706 if (!buf->first) { in topa_insert_table()
707 buf->first = buf->last = buf->cur = topa; in topa_insert_table()
711 topa->offset = last->offset + last->size; in topa_insert_table()
712 buf->last = topa; in topa_insert_table()
717 BUG_ON(last->last != TENTS_PER_PAGE - 1); in topa_insert_table()
719 TOPA_ENTRY(last, -1)->base = topa_pfn(topa); in topa_insert_table()
720 TOPA_ENTRY(last, -1)->end = 1; in topa_insert_table()
724 * topa_table_full() - check if a ToPA table is filled up
729 /* single-entry ToPA is a special case */ in topa_table_full()
731 return !!topa->last; in topa_table_full()
733 return topa->last == TENTS_PER_PAGE - 1; in topa_table_full()
737 * topa_insert_pages() - create a list of ToPA tables
749 struct topa *topa = buf->last; in topa_insert_pages()
753 p = virt_to_page(buf->data_pages[buf->nr_pages]); in topa_insert_pages()
760 return -ENOMEM; in topa_insert_pages()
765 if (topa->z_count == topa->last - 1) { in topa_insert_pages()
766 if (order == TOPA_ENTRY(topa, topa->last - 1)->size) in topa_insert_pages()
767 topa->z_count++; in topa_insert_pages()
770 TOPA_ENTRY(topa, -1)->base = page_to_phys(p) >> TOPA_SHIFT; in topa_insert_pages()
771 TOPA_ENTRY(topa, -1)->size = order; in topa_insert_pages()
772 if (!buf->snapshot && in topa_insert_pages()
774 TOPA_ENTRY(topa, -1)->intr = 1; in topa_insert_pages()
775 TOPA_ENTRY(topa, -1)->stop = 1; in topa_insert_pages()
778 topa->last++; in topa_insert_pages()
779 topa->size += sizes(order); in topa_insert_pages()
781 buf->nr_pages += 1ul << order; in topa_insert_pages()
787 * pt_topa_dump() - print ToPA tables and their entries
794 list_for_each_entry(topa, &buf->tables, list) { in pt_topa_dump()
798 pr_debug("# table @%p, off %llx size %zx\n", tp->table, in pt_topa_dump()
799 topa->offset, topa->size); in pt_topa_dump()
802 &tp->table[i], in pt_topa_dump()
803 (unsigned long)tp->table[i].base << TOPA_SHIFT, in pt_topa_dump()
804 sizes(tp->table[i].size), in pt_topa_dump()
805 tp->table[i].end ? 'E' : ' ', in pt_topa_dump()
806 tp->table[i].intr ? 'I' : ' ', in pt_topa_dump()
807 tp->table[i].stop ? 'S' : ' ', in pt_topa_dump()
808 *(u64 *)&tp->table[i]); in pt_topa_dump()
810 tp->table[i].stop) || in pt_topa_dump()
811 tp->table[i].end) in pt_topa_dump()
813 if (!i && topa->z_count) in pt_topa_dump()
814 i += topa->z_count; in pt_topa_dump()
820 * pt_buffer_advance() - advance to the next output region
827 buf->output_off = 0; in pt_buffer_advance()
828 buf->cur_idx++; in pt_buffer_advance()
830 if (buf->cur_idx == buf->cur->last) { in pt_buffer_advance()
831 if (buf->cur == buf->last) in pt_buffer_advance()
832 buf->cur = buf->first; in pt_buffer_advance()
834 buf->cur = list_entry(buf->cur->list.next, struct topa, in pt_buffer_advance()
836 buf->cur_idx = 0; in pt_buffer_advance()
841 * pt_update_head() - calculate current offsets and sizes
842 * @pt: Per-cpu pt context.
848 struct pt_buffer *buf = perf_get_aux(&pt->handle); in pt_update_head()
849 u64 topa_idx, base, old; in pt_update_head() local
851 if (buf->single) { in pt_update_head()
852 local_set(&buf->data_size, buf->output_off); in pt_update_head()
857 base = buf->cur->offset + buf->output_off; in pt_update_head()
860 for (topa_idx = 0; topa_idx < buf->cur_idx; topa_idx++) in pt_update_head()
861 base += TOPA_ENTRY_SIZE(buf->cur, topa_idx); in pt_update_head()
863 if (buf->snapshot) { in pt_update_head()
864 local_set(&buf->data_size, base); in pt_update_head()
866 old = (local64_xchg(&buf->head, base) & in pt_update_head()
867 ((buf->nr_pages << PAGE_SHIFT) - 1)); in pt_update_head()
868 if (base < old) in pt_update_head()
869 base += buf->nr_pages << PAGE_SHIFT; in pt_update_head()
871 local_add(base - old, &buf->data_size); in pt_update_head()
876 * pt_buffer_region() - obtain current output region's address
881 return phys_to_virt((phys_addr_t)TOPA_ENTRY(buf->cur, buf->cur_idx)->base << TOPA_SHIFT); in pt_buffer_region()
885 * pt_buffer_region_size() - obtain current output region's size
890 return TOPA_ENTRY_SIZE(buf->cur, buf->cur_idx); in pt_buffer_region_size()
894 * pt_handle_status() - take care of possible status conditions
895 * @pt: Per-cpu pt context.
899 struct pt_buffer *buf = perf_get_aux(&pt->handle); in pt_handle_status()
915 * On systems that only do single-entry ToPA, hitting STOP in pt_handle_status()
919 if (!buf->single && in pt_handle_status()
921 buf->output_off == pt_buffer_region_size(buf))) { in pt_handle_status()
922 perf_aux_output_flag(&pt->handle, in pt_handle_status()
929 * Also on single-entry ToPA implementations, interrupt will come in pt_handle_status()
933 !buf->snapshot && in pt_handle_status()
934 pt_buffer_region_size(buf) - buf->output_off <= TOPA_PMI_MARGIN) { in pt_handle_status()
938 memset(head + buf->output_off, 0, in pt_handle_status()
939 pt_buffer_region_size(buf) - in pt_handle_status()
940 buf->output_off); in pt_handle_status()
951 * pt_read_offset() - translate registers into buffer pointers
961 if (!buf->single) { in pt_read_offset()
962 rdmsrl(MSR_IA32_RTIT_OUTPUT_BASE, pt->output_base); in pt_read_offset()
963 tp = phys_to_virt(pt->output_base); in pt_read_offset()
964 buf->cur = &tp->topa; in pt_read_offset()
967 rdmsrl(MSR_IA32_RTIT_OUTPUT_MASK, pt->output_mask); in pt_read_offset()
969 buf->output_off = pt->output_mask >> 32; in pt_read_offset()
971 if (!buf->single) in pt_read_offset()
972 buf->cur_idx = (pt->output_mask & 0xffffff80) >> 7; in pt_read_offset()
985 if (WARN_ON_ONCE(pg >= buf->nr_pages)) in pt_topa_entry_for_page()
992 list_for_each_entry(topa, &buf->tables, list) { in pt_topa_entry_for_page()
993 if (topa->offset + topa->size > (unsigned long)pg << PAGE_SHIFT) in pt_topa_entry_for_page()
1009 if (WARN_ON_ONCE(topa->last == -1)) in pt_topa_entry_for_page()
1013 cur_pg = PFN_DOWN(topa->offset); in pt_topa_entry_for_page()
1014 if (topa->z_count) { in pt_topa_entry_for_page()
1015 z_pg = TOPA_ENTRY_PAGES(topa, 0) * (topa->z_count + 1); in pt_topa_entry_for_page()
1016 start_idx = topa->z_count + 1; in pt_topa_entry_for_page()
1024 idx = (pg - cur_pg) / TOPA_ENTRY_PAGES(topa, 0); in pt_topa_entry_for_page()
1025 return &tp->table[idx]; in pt_topa_entry_for_page()
1031 for (idx = start_idx, cur_pg += z_pg; idx < topa->last; idx++) { in pt_topa_entry_for_page()
1033 return &tp->table[idx]; in pt_topa_entry_for_page()
1047 pt_topa_prev_entry(struct pt_buffer *buf, struct topa_entry *te) in pt_topa_prev_entry() argument
1049 unsigned long table = (unsigned long)te & ~(PAGE_SIZE - 1); in pt_topa_prev_entry()
1054 if (tp->table != te) in pt_topa_prev_entry()
1055 return --te; in pt_topa_prev_entry()
1057 topa = &tp->topa; in pt_topa_prev_entry()
1058 if (topa == buf->first) in pt_topa_prev_entry()
1059 topa = buf->last; in pt_topa_prev_entry()
1065 return &tp->table[topa->last - 1]; in pt_topa_prev_entry()
1069 * pt_buffer_reset_markers() - place interrupt and stop bits in the buffer
1075 * the buffer has filled up. Only needed and sensible for non-snapshot counters.
1085 unsigned long head = local64_read(&buf->head); in pt_buffer_reset_markers()
1088 if (buf->single) in pt_buffer_reset_markers()
1092 if (buf->output_off + handle->size + 1 < pt_buffer_region_size(buf)) { in pt_buffer_reset_markers()
1094 return -EINVAL; in pt_buffer_reset_markers()
1103 if (buf->stop_te) { in pt_buffer_reset_markers()
1104 buf->stop_te->stop = 0; in pt_buffer_reset_markers()
1105 buf->stop_te->intr = 0; in pt_buffer_reset_markers()
1108 if (buf->intr_te) in pt_buffer_reset_markers()
1109 buf->intr_te->intr = 0; in pt_buffer_reset_markers()
1112 npages = handle->size >> PAGE_SHIFT; in pt_buffer_reset_markers()
1115 if (!offset_in_page(head + handle->size + 1)) in pt_buffer_reset_markers()
1119 idx &= buf->nr_pages - 1; in pt_buffer_reset_markers()
1121 if (idx != buf->stop_pos) { in pt_buffer_reset_markers()
1122 buf->stop_pos = idx; in pt_buffer_reset_markers()
1123 buf->stop_te = pt_topa_entry_for_page(buf, idx); in pt_buffer_reset_markers()
1124 buf->stop_te = pt_topa_prev_entry(buf, buf->stop_te); in pt_buffer_reset_markers()
1127 wakeup = handle->wakeup >> PAGE_SHIFT; in pt_buffer_reset_markers()
1130 idx = (head >> PAGE_SHIFT) + npages - 1; in pt_buffer_reset_markers()
1134 idx &= buf->nr_pages - 1; in pt_buffer_reset_markers()
1135 if (idx != buf->intr_pos) { in pt_buffer_reset_markers()
1136 buf->intr_pos = idx; in pt_buffer_reset_markers()
1137 buf->intr_te = pt_topa_entry_for_page(buf, idx); in pt_buffer_reset_markers()
1138 buf->intr_te = pt_topa_prev_entry(buf, buf->intr_te); in pt_buffer_reset_markers()
1141 buf->stop_te->stop = 1; in pt_buffer_reset_markers()
1142 buf->stop_te->intr = 1; in pt_buffer_reset_markers()
1143 buf->intr_te->intr = 1; in pt_buffer_reset_markers()
1149 * pt_buffer_reset_offsets() - adjust buffer's write pointers from aux_head
1166 struct topa_entry *te; in pt_buffer_reset_offsets() local
1169 if (buf->snapshot) in pt_buffer_reset_offsets()
1170 head &= (buf->nr_pages << PAGE_SHIFT) - 1; in pt_buffer_reset_offsets()
1172 if (!buf->single) { in pt_buffer_reset_offsets()
1173 pg = (head >> PAGE_SHIFT) & (buf->nr_pages - 1); in pt_buffer_reset_offsets()
1174 te = pt_topa_entry_for_page(buf, pg); in pt_buffer_reset_offsets()
1176 cur_tp = topa_entry_to_page(te); in pt_buffer_reset_offsets()
1177 buf->cur = &cur_tp->topa; in pt_buffer_reset_offsets()
1178 buf->cur_idx = te - TOPA_ENTRY(buf->cur, 0); in pt_buffer_reset_offsets()
1179 buf->output_off = head & (pt_buffer_region_size(buf) - 1); in pt_buffer_reset_offsets()
1181 buf->output_off = head; in pt_buffer_reset_offsets()
1184 local64_set(&buf->head, head); in pt_buffer_reset_offsets()
1185 local_set(&buf->data_size, 0); in pt_buffer_reset_offsets()
1189 * pt_buffer_fini_topa() - deallocate ToPA structure of a buffer
1196 if (buf->single) in pt_buffer_fini_topa()
1199 list_for_each_entry_safe(topa, iter, &buf->tables, list) { in pt_buffer_fini_topa()
1209 * pt_buffer_init_topa() - initialize ToPA table for pt buffer
1225 return -ENOMEM; in pt_buffer_init_topa()
1229 while (buf->nr_pages < nr_pages) { in pt_buffer_init_topa()
1233 return -ENOMEM; in pt_buffer_init_topa()
1239 TOPA_ENTRY(buf->last, -1)->base = topa_pfn(buf->first); in pt_buffer_init_topa()
1240 TOPA_ENTRY(buf->last, -1)->end = 1; in pt_buffer_init_topa()
1249 struct page *p = virt_to_page(buf->data_pages[0]); in pt_buffer_try_single()
1250 int ret = -ENOTSUPP, order = 0; in pt_buffer_try_single()
1258 if (!buf->snapshot) in pt_buffer_try_single()
1272 * 4KB - refer errata TGL052, ADL037 and RPL017. Future processors might in pt_buffer_try_single()
1279 buf->single = true; in pt_buffer_try_single()
1280 buf->nr_pages = nr_pages; in pt_buffer_try_single()
1287 * pt_buffer_setup_aux() - set up topa tables for a PT buffer
1303 int node, ret, cpu = event->cpu; in pt_buffer_setup_aux()
1312 if (event->attr.aux_sample_size && !snapshot) in pt_buffer_setup_aux()
1315 if (cpu == -1) in pt_buffer_setup_aux()
1323 buf->snapshot = snapshot; in pt_buffer_setup_aux()
1324 buf->data_pages = pages; in pt_buffer_setup_aux()
1325 buf->stop_pos = -1; in pt_buffer_setup_aux()
1326 buf->intr_pos = -1; in pt_buffer_setup_aux()
1328 INIT_LIST_HEAD(&buf->tables); in pt_buffer_setup_aux()
1344 * pt_buffer_free_aux() - perf AUX deallocation path callback
1358 int node = event->cpu == -1 ? -1 : cpu_to_node(event->cpu); in pt_addr_filters_init()
1365 return -ENOMEM; in pt_addr_filters_init()
1367 if (event->parent) in pt_addr_filters_init()
1368 memcpy(filters, event->parent->hw.addr_filters, in pt_addr_filters_init()
1371 event->hw.addr_filters = filters; in pt_addr_filters_init()
1378 kfree(event->hw.addr_filters); in pt_addr_filters_fini()
1379 event->hw.addr_filters = NULL; in pt_addr_filters_fini()
1383 /* Clamp to a canonical address greater-than-or-equal-to the address given */
1388 -BIT_ULL(vaddr_bits - 1); in clamp_to_ge_canonical_addr()
1391 /* Clamp to a canonical address less-than-or-equal-to the address given */
1396 BIT_ULL(vaddr_bits - 1) - 1; in clamp_to_le_canonical_addr()
1413 if (!filter->size || in pt_event_addr_filters_validate()
1414 filter->action == PERF_ADDR_FILTER_ACTION_START) in pt_event_addr_filters_validate()
1415 return -EOPNOTSUPP; in pt_event_addr_filters_validate()
1418 return -EOPNOTSUPP; in pt_event_addr_filters_validate()
1428 struct perf_addr_filter_range *fr = event->addr_filter_ranges; in pt_event_addr_filters_sync()
1429 struct pt_filters *filters = event->hw.addr_filters; in pt_event_addr_filters_sync()
1436 list_for_each_entry(filter, &head->list, entry) { in pt_event_addr_filters_sync()
1437 if (filter->path.dentry && !fr[range].start) { in pt_event_addr_filters_sync()
1440 unsigned long n = fr[range].size - 1; in pt_event_addr_filters_sync()
1444 if (a > ULONG_MAX - n) in pt_event_addr_filters_sync()
1449 * Apply the offset. 64-bit addresses written to the in pt_event_addr_filters_sync()
1451 * non-canonical addresses. Since software cannot in pt_event_addr_filters_sync()
1452 * execute at non-canonical addresses, adjusting to in pt_event_addr_filters_sync()
1462 filters->filter[range].msr_a = msr_a; in pt_event_addr_filters_sync()
1463 filters->filter[range].msr_b = msr_b; in pt_event_addr_filters_sync()
1464 if (filter->action == PERF_ADDR_FILTER_ACTION_FILTER) in pt_event_addr_filters_sync()
1465 filters->filter[range].config = 1; in pt_event_addr_filters_sync()
1467 filters->filter[range].config = 2; in pt_event_addr_filters_sync()
1471 filters->nr_filters = range; in pt_event_addr_filters_sync()
1475 * intel_pt_interrupt() - PT PMI handler
1481 struct perf_event *event = pt->handle.event; in intel_pt_interrupt()
1486 * do anything (particularly, re-enable) for this event here. in intel_pt_interrupt()
1488 if (!READ_ONCE(pt->handle_nmi)) in intel_pt_interrupt()
1496 buf = perf_get_aux(&pt->handle); in intel_pt_interrupt()
1506 perf_aux_output_end(&pt->handle, local_xchg(&buf->data_size, 0)); in intel_pt_interrupt()
1508 if (!event->hw.state) { in intel_pt_interrupt()
1511 buf = perf_aux_output_begin(&pt->handle, event); in intel_pt_interrupt()
1513 event->hw.state = PERF_HES_STOPPED; in intel_pt_interrupt()
1517 pt_buffer_reset_offsets(buf, pt->handle.head); in intel_pt_interrupt()
1519 ret = pt_buffer_reset_markers(buf, &pt->handle); in intel_pt_interrupt()
1521 perf_aux_output_end(&pt->handle, 0); in intel_pt_interrupt()
1547 WRITE_ONCE(pt->vmx_on, on); in intel_pt_handle_vmx()
1553 event = pt->handle.event; in intel_pt_handle_vmx()
1555 perf_aux_output_flag(&pt->handle, in intel_pt_handle_vmx()
1560 wrmsrl(MSR_IA32_RTIT_CTL, event->hw.aux_config); in intel_pt_handle_vmx()
1572 struct hw_perf_event *hwc = &event->hw; in pt_event_start()
1576 buf = perf_aux_output_begin(&pt->handle, event); in pt_event_start()
1580 pt_buffer_reset_offsets(buf, pt->handle.head); in pt_event_start()
1581 if (!buf->snapshot) { in pt_event_start()
1582 if (pt_buffer_reset_markers(buf, &pt->handle)) in pt_event_start()
1586 WRITE_ONCE(pt->handle_nmi, 1); in pt_event_start()
1587 hwc->state = 0; in pt_event_start()
1595 perf_aux_output_end(&pt->handle, 0); in pt_event_start()
1597 hwc->state = PERF_HES_STOPPED; in pt_event_start()
1608 WRITE_ONCE(pt->handle_nmi, 0); in pt_event_stop()
1613 if (event->hw.state == PERF_HES_STOPPED) in pt_event_stop()
1616 event->hw.state = PERF_HES_STOPPED; in pt_event_stop()
1619 struct pt_buffer *buf = perf_get_aux(&pt->handle); in pt_event_stop()
1624 if (WARN_ON_ONCE(pt->handle.event != event)) in pt_event_stop()
1633 if (buf->snapshot) in pt_event_stop()
1634 pt->handle.head = in pt_event_stop()
1635 local_xchg(&buf->data_size, in pt_event_stop()
1636 buf->nr_pages << PAGE_SHIFT); in pt_event_stop()
1637 perf_aux_output_end(&pt->handle, local_xchg(&buf->data_size, 0)); in pt_event_stop()
1646 struct pt_buffer *buf = perf_get_aux(&pt->handle); in pt_event_snapshot_aux()
1657 if (WARN_ON_ONCE(!buf->snapshot)) in pt_event_snapshot_aux()
1668 to = local_read(&buf->data_size); in pt_event_snapshot_aux()
1670 from = buf->nr_pages << PAGE_SHIFT; in pt_event_snapshot_aux()
1671 from += to - size; in pt_event_snapshot_aux()
1673 ret = perf_output_copy_aux(&pt->handle, handle, from, to); in pt_event_snapshot_aux()
1679 if (READ_ONCE(pt->handle_nmi)) in pt_event_snapshot_aux()
1693 struct hw_perf_event *hwc = &event->hw; in pt_event_add()
1694 int ret = -EBUSY; in pt_event_add()
1696 if (pt->handle.event) in pt_event_add()
1701 ret = -EINVAL; in pt_event_add()
1702 if (hwc->state == PERF_HES_STOPPED) in pt_event_add()
1705 hwc->state = PERF_HES_STOPPED; in pt_event_add()
1726 if (event->attr.type != pt_pmu.pmu.type) in pt_event_init()
1727 return -ENOENT; in pt_event_init()
1730 return -EINVAL; in pt_event_init()
1733 return -EBUSY; in pt_event_init()
1737 return -ENOMEM; in pt_event_init()
1740 event->destroy = pt_event_destroy; in pt_event_init()
1749 if (pt->handle.event) in cpu_emergency_stop_pt()
1750 pt_event_stop(pt->handle.event, PERF_EF_UPDATE); in cpu_emergency_stop_pt()
1755 return event->pmu == &pt_pmu.pmu; in is_intel_pt_event()
1765 return -ENODEV; in pt_init()
1781 return -EBUSY; in pt_init()
1790 return -ENODEV; in pt_init()
1813 ret = perf_pmu_register(&pt_pmu.pmu, "intel_pt", -1); in pt_init()