Lines Matching +full:magic +full:- +full:packet
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright(C) 2015-2018 Linaro Limited.
12 #include <linux/coresight-pmu.h>
22 #include "cs-etm.h"
23 #include "cs-etm-decoder/cs-etm-decoder.h"
37 #include "thread-stack.h"
40 #include "util/synthetic-events.h"
61 * Per-thread ignores the trace channel ID and instead assumes that
96 struct cs_etm_packet *packet; member
151 #define SINK_UNSET ((u32) -1)
163 static int cs_etm__get_magic(struct cs_etm_queue *etmq, u8 trace_chan_id, u64 *magic) in cs_etm__get_magic() argument
168 inode = intlist__find(etmq->traceid_list, trace_chan_id); in cs_etm__get_magic()
170 return -EINVAL; in cs_etm__get_magic()
172 metadata = inode->priv; in cs_etm__get_magic()
173 *magic = metadata[CS_ETM_MAGIC]; in cs_etm__get_magic()
182 inode = intlist__find(etmq->traceid_list, trace_chan_id); in cs_etm__get_cpu()
184 return -EINVAL; in cs_etm__get_cpu()
186 metadata = inode->priv; in cs_etm__get_cpu()
204 * The result is cached in etm->pid_fmt so this function only needs to be called
231 return etmq->etm->pid_fmt; in cs_etm__get_pid_fmt()
238 struct int_node *inode = intlist__findnew(etmq->traceid_list, trace_chan_id); in cs_etm__insert_trace_id_node()
242 return -ENOMEM; in cs_etm__insert_trace_id_node()
244 /* Disallow re-mapping a different traceID to metadata pair. */ in cs_etm__insert_trace_id_node()
245 if (inode->priv) { in cs_etm__insert_trace_id_node()
246 u64 *curr_cpu_data = inode->priv; in cs_etm__insert_trace_id_node()
253 * are expected (but not supported) in per-thread mode, in cs_etm__insert_trace_id_node()
256 if (etmq->etm->per_thread_decoding) in cs_etm__insert_trace_id_node()
257 pr_err("CS_ETM: overlapping Trace IDs aren't currently supported in per-thread mode\n"); in cs_etm__insert_trace_id_node()
259 pr_err("CS_ETM: map mismatch between HW_ID packet CPU and Trace ID\n"); in cs_etm__insert_trace_id_node()
261 return -EINVAL; in cs_etm__insert_trace_id_node()
270 pr_err("CS_ETM: mismatch between CPU trace ID and HW_ID packet ID\n"); in cs_etm__insert_trace_id_node()
271 return -EINVAL; in cs_etm__insert_trace_id_node()
274 /* Skip re-adding the same mappings if everything matched */ in cs_etm__insert_trace_id_node()
279 inode->priv = cpu_metadata; in cs_etm__insert_trace_id_node()
286 if (etm->per_thread_decoding) in cs_etm__get_queue()
287 return etm->queues.queue_array[0].priv; in cs_etm__get_queue()
289 return etm->queues.queue_array[cpu].priv; in cs_etm__get_queue()
302 if (etmq->format == UNFORMATTED) in cs_etm__map_trace_id_v0()
310 for (unsigned int i = 0; i < etm->queues.nr_queues; ++i) { in cs_etm__map_trace_id_v0()
313 etmq = etm->queues.queue_array[i].priv; in cs_etm__map_trace_id_v0()
332 return -EINVAL; in cs_etm__process_trace_id_v0()
339 * if we are picking up the association from the packet, need to plug in cs_etm__process_trace_id_v0()
355 * Check sink id hasn't changed in per-cpu mode. In per-thread mode, in cs_etm__process_trace_id_v0_1()
359 if (!etmq->etm->per_thread_decoding && etmq->sink_id != SINK_UNSET && in cs_etm__process_trace_id_v0_1()
360 etmq->sink_id != sink_id) { in cs_etm__process_trace_id_v0_1()
362 return -EINVAL; in cs_etm__process_trace_id_v0_1()
365 etmq->sink_id = sink_id; in cs_etm__process_trace_id_v0_1()
368 for (unsigned int i = 0; i < etm->queues.nr_queues; ++i) { in cs_etm__process_trace_id_v0_1()
369 struct cs_etm_queue *other_etmq = etm->queues.queue_array[i].priv; in cs_etm__process_trace_id_v0_1()
372 if (other_etmq->sink_id != etmq->sink_id) in cs_etm__process_trace_id_v0_1()
376 if (other_etmq->traceid_list == etmq->traceid_list) in cs_etm__process_trace_id_v0_1()
380 if (!intlist__empty(etmq->traceid_list)) { in cs_etm__process_trace_id_v0_1()
382 return -EINVAL; in cs_etm__process_trace_id_v0_1()
385 etmq->own_traceid_list = NULL; in cs_etm__process_trace_id_v0_1()
386 intlist__delete(etmq->traceid_list); in cs_etm__process_trace_id_v0_1()
387 etmq->traceid_list = other_etmq->traceid_list; in cs_etm__process_trace_id_v0_1()
418 return -EINVAL; in cs_etm__metadata_get_trace_id()
424 * update metadata trace ID from the value found in the AUX_HW_INFO packet.
440 return -EINVAL; in cs_etm__metadata_set_trace_id()
453 for (i = 0; i < etm->num_cpu; i++) { in get_cpu_data_idx()
454 if (etm->metadata[i][CS_ETM_CPU] == (u64)cpu) { in get_cpu_data_idx()
459 return -1; in get_cpu_data_idx()
470 return (idx != -1) ? etm->metadata[idx] : NULL; in get_cpu_data()
490 hw_id = event->aux_output_hw_id.hw_id; in cs_etm__process_aux_output_hw_id()
497 return -EINVAL; in cs_etm__process_aux_output_hw_id()
501 etm = container_of(session->auxtrace, struct cs_etm_auxtrace, auxtrace); in cs_etm__process_aux_output_hw_id()
502 if (!etm || !etm->metadata) in cs_etm__process_aux_output_hw_id()
503 return -EINVAL; in cs_etm__process_aux_output_hw_id()
506 evsel = evlist__event2evsel(session->evlist, event); in cs_etm__process_aux_output_hw_id()
508 return -EINVAL; in cs_etm__process_aux_output_hw_id()
514 if (cpu == -1) { in cs_etm__process_aux_output_hw_id()
515 /* no CPU in the sample - possibly recorded with an old version of perf */ in cs_etm__process_aux_output_hw_id()
517 err = -EINVAL; in cs_etm__process_aux_output_hw_id()
536 * When a timestamp packet is encountered the backend code in cs_etm__etmq_set_traceid_queue_timestamp()
542 etmq->pending_timestamp_chan_id = trace_chan_id; in cs_etm__etmq_set_traceid_queue_timestamp()
550 if (!etmq->pending_timestamp_chan_id) in cs_etm__etmq_get_timestamp()
554 *trace_chan_id = etmq->pending_timestamp_chan_id; in cs_etm__etmq_get_timestamp()
557 etmq->pending_timestamp_chan_id); in cs_etm__etmq_get_timestamp()
562 etmq->pending_timestamp_chan_id = 0; in cs_etm__etmq_get_timestamp()
565 return packet_queue->cs_timestamp; in cs_etm__etmq_get_timestamp()
572 queue->head = 0; in cs_etm__clear_packet_queue()
573 queue->tail = 0; in cs_etm__clear_packet_queue()
574 queue->packet_count = 0; in cs_etm__clear_packet_queue()
576 queue->packet_buffer[i].isa = CS_ETM_ISA_UNKNOWN; in cs_etm__clear_packet_queue()
577 queue->packet_buffer[i].start_addr = CS_ETM_INVAL_ADDR; in cs_etm__clear_packet_queue()
578 queue->packet_buffer[i].end_addr = CS_ETM_INVAL_ADDR; in cs_etm__clear_packet_queue()
579 queue->packet_buffer[i].instr_count = 0; in cs_etm__clear_packet_queue()
580 queue->packet_buffer[i].last_instr_taken_branch = false; in cs_etm__clear_packet_queue()
581 queue->packet_buffer[i].last_instr_size = 0; in cs_etm__clear_packet_queue()
582 queue->packet_buffer[i].last_instr_type = 0; in cs_etm__clear_packet_queue()
583 queue->packet_buffer[i].last_instr_subtype = 0; in cs_etm__clear_packet_queue()
584 queue->packet_buffer[i].last_instr_cond = 0; in cs_etm__clear_packet_queue()
585 queue->packet_buffer[i].flags = 0; in cs_etm__clear_packet_queue()
586 queue->packet_buffer[i].exception_number = UINT32_MAX; in cs_etm__clear_packet_queue()
587 queue->packet_buffer[i].trace_chan_id = UINT8_MAX; in cs_etm__clear_packet_queue()
588 queue->packet_buffer[i].cpu = INT_MIN; in cs_etm__clear_packet_queue()
597 struct intlist *traceid_queues_list = etmq->traceid_queues_list; in cs_etm__clear_all_packet_queues()
600 idx = (int)(intptr_t)inode->priv; in cs_etm__clear_all_packet_queues()
601 tidq = etmq->traceid_queues[idx]; in cs_etm__clear_all_packet_queues()
602 cs_etm__clear_packet_queue(&tidq->packet_queue); in cs_etm__clear_all_packet_queues()
610 int rc = -ENOMEM; in cs_etm__init_traceid_queue()
612 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__init_traceid_queue()
614 cs_etm__clear_packet_queue(&tidq->packet_queue); in cs_etm__init_traceid_queue()
616 queue = &etmq->etm->queues.queue_array[etmq->queue_nr]; in cs_etm__init_traceid_queue()
617 tidq->trace_chan_id = trace_chan_id; in cs_etm__init_traceid_queue()
618 tidq->el = tidq->prev_packet_el = ocsd_EL_unknown; in cs_etm__init_traceid_queue()
619 tidq->thread = machine__findnew_thread(&etm->session->machines.host, -1, in cs_etm__init_traceid_queue()
620 queue->tid); in cs_etm__init_traceid_queue()
621 tidq->prev_packet_thread = machine__idle_thread(&etm->session->machines.host); in cs_etm__init_traceid_queue()
623 tidq->packet = zalloc(sizeof(struct cs_etm_packet)); in cs_etm__init_traceid_queue()
624 if (!tidq->packet) in cs_etm__init_traceid_queue()
627 tidq->prev_packet = zalloc(sizeof(struct cs_etm_packet)); in cs_etm__init_traceid_queue()
628 if (!tidq->prev_packet) in cs_etm__init_traceid_queue()
631 if (etm->synth_opts.last_branch) { in cs_etm__init_traceid_queue()
634 sz += etm->synth_opts.last_branch_sz * in cs_etm__init_traceid_queue()
636 tidq->last_branch = zalloc(sz); in cs_etm__init_traceid_queue()
637 if (!tidq->last_branch) in cs_etm__init_traceid_queue()
639 tidq->last_branch_rb = zalloc(sz); in cs_etm__init_traceid_queue()
640 if (!tidq->last_branch_rb) in cs_etm__init_traceid_queue()
644 tidq->event_buf = malloc(PERF_SAMPLE_MAX_SIZE); in cs_etm__init_traceid_queue()
645 if (!tidq->event_buf) in cs_etm__init_traceid_queue()
651 zfree(&tidq->last_branch_rb); in cs_etm__init_traceid_queue()
652 zfree(&tidq->last_branch); in cs_etm__init_traceid_queue()
653 zfree(&tidq->prev_packet); in cs_etm__init_traceid_queue()
654 zfree(&tidq->packet); in cs_etm__init_traceid_queue()
666 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__etmq_get_traceid_queue()
668 if (etm->per_thread_decoding) in cs_etm__etmq_get_traceid_queue()
671 traceid_queues_list = etmq->traceid_queues_list; in cs_etm__etmq_get_traceid_queue()
679 idx = (int)(intptr_t)inode->priv; in cs_etm__etmq_get_traceid_queue()
680 return etmq->traceid_queues[idx]; in cs_etm__etmq_get_traceid_queue()
698 inode->priv = (void *)(intptr_t)idx; in cs_etm__etmq_get_traceid_queue()
704 traceid_queues = etmq->traceid_queues; in cs_etm__etmq_get_traceid_queue()
717 etmq->traceid_queues = traceid_queues; in cs_etm__etmq_get_traceid_queue()
719 return etmq->traceid_queues[idx]; in cs_etm__etmq_get_traceid_queue()
739 return &tidq->packet_queue; in cs_etm__etmq_get_packet_queue()
749 if (etm->synth_opts.branches || etm->synth_opts.last_branch || in cs_etm__packet_swap()
750 etm->synth_opts.instructions) { in cs_etm__packet_swap()
752 * Swap PACKET with PREV_PACKET: PACKET becomes PREV_PACKET for in cs_etm__packet_swap()
753 * the next incoming packet. in cs_etm__packet_swap()
757 * packet is used for the 'from' IP for branch samples, so the in cs_etm__packet_swap()
760 * tracking the thread for the previous packet the branch sample in cs_etm__packet_swap()
763 tmp = tidq->packet; in cs_etm__packet_swap()
764 tidq->packet = tidq->prev_packet; in cs_etm__packet_swap()
765 tidq->prev_packet = tmp; in cs_etm__packet_swap()
766 tidq->prev_packet_el = tidq->el; in cs_etm__packet_swap()
767 thread__put(tidq->prev_packet_thread); in cs_etm__packet_swap()
768 tidq->prev_packet_thread = thread__get(tidq->thread); in cs_etm__packet_swap()
780 snprintf(queue_nr, sizeof(queue_nr), "Qnr:%d; ", etmq->queue_nr); in cs_etm__packet_dump()
784 if (len && (pkt_string[len-1] == '\n')) in cs_etm__packet_dump()
795 t_params->protocol = cs_etm__get_v7_protocol_version(etmidr); in cs_etm__set_trace_param_etmv3()
796 t_params->etmv3.reg_ctrl = metadata[CS_ETM_ETMCR]; in cs_etm__set_trace_param_etmv3()
797 t_params->etmv3.reg_trc_id = metadata[CS_ETM_ETMTRACEIDR]; in cs_etm__set_trace_param_etmv3()
803 t_params->protocol = CS_ETM_PROTO_ETMV4i; in cs_etm__set_trace_param_etmv4()
804 t_params->etmv4.reg_idr0 = metadata[CS_ETMV4_TRCIDR0]; in cs_etm__set_trace_param_etmv4()
805 t_params->etmv4.reg_idr1 = metadata[CS_ETMV4_TRCIDR1]; in cs_etm__set_trace_param_etmv4()
806 t_params->etmv4.reg_idr2 = metadata[CS_ETMV4_TRCIDR2]; in cs_etm__set_trace_param_etmv4()
807 t_params->etmv4.reg_idr8 = metadata[CS_ETMV4_TRCIDR8]; in cs_etm__set_trace_param_etmv4()
808 t_params->etmv4.reg_configr = metadata[CS_ETMV4_TRCCONFIGR]; in cs_etm__set_trace_param_etmv4()
809 t_params->etmv4.reg_traceidr = metadata[CS_ETMV4_TRCTRACEIDR]; in cs_etm__set_trace_param_etmv4()
815 t_params->protocol = CS_ETM_PROTO_ETE; in cs_etm__set_trace_param_ete()
816 t_params->ete.reg_idr0 = metadata[CS_ETE_TRCIDR0]; in cs_etm__set_trace_param_ete()
817 t_params->ete.reg_idr1 = metadata[CS_ETE_TRCIDR1]; in cs_etm__set_trace_param_ete()
818 t_params->ete.reg_idr2 = metadata[CS_ETE_TRCIDR2]; in cs_etm__set_trace_param_ete()
819 t_params->ete.reg_idr8 = metadata[CS_ETE_TRCIDR8]; in cs_etm__set_trace_param_ete()
820 t_params->ete.reg_configr = metadata[CS_ETE_TRCCONFIGR]; in cs_etm__set_trace_param_ete()
821 t_params->ete.reg_traceidr = metadata[CS_ETE_TRCTRACEIDR]; in cs_etm__set_trace_param_ete()
822 t_params->ete.reg_devarch = metadata[CS_ETE_TRCDEVARCH]; in cs_etm__set_trace_param_ete()
830 intlist__for_each_entry(inode, etmq->traceid_list) { in cs_etm__init_trace_params()
831 u64 *metadata = inode->priv; in cs_etm__init_trace_params()
847 return -EINVAL; in cs_etm__init_trace_params()
858 int ret = -EINVAL; in cs_etm__init_decoder_params()
863 d_params->packet_printer = cs_etm__packet_dump; in cs_etm__init_decoder_params()
864 d_params->operation = mode; in cs_etm__init_decoder_params()
865 d_params->data = etmq; in cs_etm__init_decoder_params()
866 d_params->formatted = etmq->format == FORMATTED; in cs_etm__init_decoder_params()
867 d_params->fsyncs = false; in cs_etm__init_decoder_params()
868 d_params->hsyncs = false; in cs_etm__init_decoder_params()
869 d_params->frame_aligned = true; in cs_etm__init_decoder_params()
886 cs_etm_decoder__get_name(etmq->decoder), buffer->size); in cs_etm__dump_event()
892 etmq->decoder, buffer->offset, in cs_etm__dump_event()
893 &((u8 *)buffer->data)[buffer_used], in cs_etm__dump_event()
894 buffer->size - buffer_used, &consumed); in cs_etm__dump_event()
899 } while (buffer_used < buffer->size); in cs_etm__dump_event()
901 cs_etm_decoder__reset(etmq->decoder); in cs_etm__dump_event()
907 struct cs_etm_auxtrace *etm = container_of(session->auxtrace, in cs_etm__flush_events()
913 if (!tool->ordered_events) in cs_etm__flush_events()
914 return -EINVAL; in cs_etm__flush_events()
916 if (etm->timeless_decoding) { in cs_etm__flush_events()
918 * Pass tid = -1 to process all queues. But likely they will have in cs_etm__flush_events()
921 return cs_etm__process_timeless_queues(etm, -1); in cs_etm__flush_events()
933 struct intlist *traceid_queues_list = etmq->traceid_queues_list; in cs_etm__free_traceid_queues()
936 priv = (uintptr_t)inode->priv; in cs_etm__free_traceid_queues()
940 tidq = etmq->traceid_queues[idx]; in cs_etm__free_traceid_queues()
941 thread__zput(tidq->thread); in cs_etm__free_traceid_queues()
942 thread__zput(tidq->prev_packet_thread); in cs_etm__free_traceid_queues()
943 zfree(&tidq->event_buf); in cs_etm__free_traceid_queues()
944 zfree(&tidq->last_branch); in cs_etm__free_traceid_queues()
945 zfree(&tidq->last_branch_rb); in cs_etm__free_traceid_queues()
946 zfree(&tidq->prev_packet); in cs_etm__free_traceid_queues()
947 zfree(&tidq->packet); in cs_etm__free_traceid_queues()
959 etmq->traceid_queues_list = NULL; in cs_etm__free_traceid_queues()
962 zfree(&etmq->traceid_queues); in cs_etm__free_traceid_queues()
973 cs_etm_decoder__free(etmq->decoder); in cs_etm__free_queue()
976 if (etmq->own_traceid_list) { in cs_etm__free_queue()
978 intlist__for_each_entry_safe(inode, tmp, etmq->own_traceid_list) in cs_etm__free_queue()
979 intlist__remove(etmq->own_traceid_list, inode); in cs_etm__free_queue()
982 intlist__delete(etmq->own_traceid_list); in cs_etm__free_queue()
991 struct cs_etm_auxtrace *aux = container_of(session->auxtrace, in cs_etm__free_events()
994 struct auxtrace_queues *queues = &aux->queues; in cs_etm__free_events()
996 for (i = 0; i < queues->nr_queues; i++) { in cs_etm__free_events()
997 cs_etm__free_queue(queues->queue_array[i].priv); in cs_etm__free_events()
998 queues->queue_array[i].priv = NULL; in cs_etm__free_events()
1007 struct cs_etm_auxtrace *aux = container_of(session->auxtrace, in cs_etm__free()
1011 session->auxtrace = NULL; in cs_etm__free()
1013 for (i = 0; i < aux->num_cpu; i++) in cs_etm__free()
1014 zfree(&aux->metadata[i]); in cs_etm__free()
1016 zfree(&aux->metadata); in cs_etm__free()
1023 struct cs_etm_auxtrace *aux = container_of(session->auxtrace, in cs_etm__evsel_is_auxtrace()
1027 return evsel->core.attr.type == aux->pmu_type; in cs_etm__evsel_is_auxtrace()
1040 return &etmq->etm->session->machines.host; in cs_etm__get_machine()
1052 return machines__find_guest(&etmq->etm->session->machines, in cs_etm__get_machine()
1059 return &etmq->etm->session->machines.host; in cs_etm__get_machine()
1118 assert(tidq->el == ocsd_EL1 || tidq->el == ocsd_EL0); in cs_etm__mem_access()
1120 assert(tidq->el == ocsd_EL2); in cs_etm__mem_access()
1122 assert(tidq->el == ocsd_EL3); in cs_etm__mem_access()
1125 cpumode = cs_etm__cpu_mode(etmq, address, tidq->el); in cs_etm__mem_access()
1127 if (!thread__find_map(tidq->thread, cpumode, address, &al)) in cs_etm__mem_access()
1134 if (dso__data(dso)->status == DSO_DATA_STATUS_ERROR && in cs_etm__mem_access()
1142 len = dso__data_read_offset(dso, maps__machine(thread__maps(tidq->thread)), in cs_etm__mem_access()
1147 …" Enable CONFIG_PROC_KCORE or use option '-k /path/to/vmlinux' for kernel symbols.\n"… in cs_etm__mem_access()
1168 etmq->traceid_queues_list = intlist__new(NULL); in cs_etm__alloc_queue()
1169 if (!etmq->traceid_queues_list) in cs_etm__alloc_queue()
1173 * Create an RB tree for traceID-metadata tuple. Since the conversion in cs_etm__alloc_queue()
1174 * has to be made for each packet that gets decoded, optimizing access in cs_etm__alloc_queue()
1177 etmq->traceid_list = etmq->own_traceid_list = intlist__new(NULL); in cs_etm__alloc_queue()
1178 if (!etmq->traceid_list) in cs_etm__alloc_queue()
1184 intlist__delete(etmq->traceid_queues_list); in cs_etm__alloc_queue()
1194 struct cs_etm_queue *etmq = queue->priv; in cs_etm__setup_queue()
1202 return -ENOMEM; in cs_etm__setup_queue()
1204 queue->priv = etmq; in cs_etm__setup_queue()
1205 etmq->etm = etm; in cs_etm__setup_queue()
1206 etmq->queue_nr = queue_nr; in cs_etm__setup_queue()
1207 queue->cpu = queue_nr; /* Placeholder, may be reset to -1 in per-thread mode */ in cs_etm__setup_queue()
1208 etmq->offset = 0; in cs_etm__setup_queue()
1209 etmq->sink_id = SINK_UNSET; in cs_etm__setup_queue()
1224 * We are under a CPU-wide trace scenario. As such we need to know in cs_etm__queue_first_cs_timestamp()
1242 * encountering a CS timestamp, a full packet queue or the end of in cs_etm__queue_first_cs_timestamp()
1260 * We didn't find a timestamp so empty all the traceid packet in cs_etm__queue_first_cs_timestamp()
1261 * queues before looking for another timestamp packet, either in cs_etm__queue_first_cs_timestamp()
1276 * Note that packets decoded above are still in the traceID's packet in cs_etm__queue_first_cs_timestamp()
1280 ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, cs_timestamp); in cs_etm__queue_first_cs_timestamp()
1289 struct branch_stack *bs_src = tidq->last_branch_rb; in cs_etm__copy_last_branch_rb()
1290 struct branch_stack *bs_dst = tidq->last_branch; in cs_etm__copy_last_branch_rb()
1294 * Set the number of records before early exit: ->nr is used to in cs_etm__copy_last_branch_rb()
1295 * determine how many branches to copy from ->entries. in cs_etm__copy_last_branch_rb()
1297 bs_dst->nr = bs_src->nr; in cs_etm__copy_last_branch_rb()
1302 if (!bs_src->nr) in cs_etm__copy_last_branch_rb()
1306 * As bs_src->entries is a circular buffer, we need to copy from it in in cs_etm__copy_last_branch_rb()
1308 * branch ->last_branch_pos until the end of bs_src->entries buffer. in cs_etm__copy_last_branch_rb()
1310 nr = etmq->etm->synth_opts.last_branch_sz - tidq->last_branch_pos; in cs_etm__copy_last_branch_rb()
1311 memcpy(&bs_dst->entries[0], in cs_etm__copy_last_branch_rb()
1312 &bs_src->entries[tidq->last_branch_pos], in cs_etm__copy_last_branch_rb()
1317 * of the bs_src->entries buffer and until the ->last_branch_pos element in cs_etm__copy_last_branch_rb()
1322 if (bs_src->nr >= etmq->etm->synth_opts.last_branch_sz) { in cs_etm__copy_last_branch_rb()
1323 memcpy(&bs_dst->entries[nr], in cs_etm__copy_last_branch_rb()
1324 &bs_src->entries[0], in cs_etm__copy_last_branch_rb()
1325 sizeof(struct branch_entry) * tidq->last_branch_pos); in cs_etm__copy_last_branch_rb()
1332 tidq->last_branch_pos = 0; in cs_etm__reset_last_branch_rb()
1333 tidq->last_branch_rb->nr = 0; in cs_etm__reset_last_branch_rb()
1345 * 16-bit word of the instruction: 0b11101, 0b11110 and 0b11111 in cs_etm__t32_instr_size()
1346 * denote a 32-bit instruction. in cs_etm__t32_instr_size()
1351 static inline u64 cs_etm__first_executed_instr(struct cs_etm_packet *packet) in cs_etm__first_executed_instr() argument
1357 if (packet->sample_type == CS_ETM_DISCONTINUITY || in cs_etm__first_executed_instr()
1358 packet->sample_type == CS_ETM_EXCEPTION) in cs_etm__first_executed_instr()
1361 return packet->start_addr; in cs_etm__first_executed_instr()
1365 u64 cs_etm__last_executed_instr(const struct cs_etm_packet *packet) in cs_etm__last_executed_instr() argument
1367 /* Returns 0 for the CS_ETM_DISCONTINUITY packet */ in cs_etm__last_executed_instr()
1368 if (packet->sample_type == CS_ETM_DISCONTINUITY) in cs_etm__last_executed_instr()
1371 return packet->end_addr - packet->last_instr_size; in cs_etm__last_executed_instr()
1376 const struct cs_etm_packet *packet, in cs_etm__instr_addr() argument
1379 if (packet->isa == CS_ETM_ISA_T32) { in cs_etm__instr_addr()
1380 u64 addr = packet->start_addr; in cs_etm__instr_addr()
1385 offset--; in cs_etm__instr_addr()
1391 return packet->start_addr + offset * 4; in cs_etm__instr_addr()
1397 struct branch_stack *bs = tidq->last_branch_rb; in cs_etm__update_last_branch_rb()
1406 if (!tidq->last_branch_pos) in cs_etm__update_last_branch_rb()
1407 tidq->last_branch_pos = etmq->etm->synth_opts.last_branch_sz; in cs_etm__update_last_branch_rb()
1409 tidq->last_branch_pos -= 1; in cs_etm__update_last_branch_rb()
1411 be = &bs->entries[tidq->last_branch_pos]; in cs_etm__update_last_branch_rb()
1412 be->from = cs_etm__last_executed_instr(tidq->prev_packet); in cs_etm__update_last_branch_rb()
1413 be->to = cs_etm__first_executed_instr(tidq->packet); in cs_etm__update_last_branch_rb()
1415 be->flags.mispred = 0; in cs_etm__update_last_branch_rb()
1416 be->flags.predicted = 1; in cs_etm__update_last_branch_rb()
1419 * Increment bs->nr until reaching the number of last branches asked by in cs_etm__update_last_branch_rb()
1422 if (bs->nr < etmq->etm->synth_opts.last_branch_sz) in cs_etm__update_last_branch_rb()
1423 bs->nr += 1; in cs_etm__update_last_branch_rb()
1429 event->header.size = perf_event__sample_event_size(sample, type, 0); in cs_etm__inject_event()
1437 struct auxtrace_buffer *aux_buffer = etmq->buffer; in cs_etm__get_trace()
1441 queue = &etmq->etm->queues.queue_array[etmq->queue_nr]; in cs_etm__get_trace()
1449 etmq->buf_len = 0; in cs_etm__get_trace()
1453 etmq->buffer = aux_buffer; in cs_etm__get_trace()
1456 if (!aux_buffer->data) { in cs_etm__get_trace()
1458 int fd = perf_data__fd(etmq->etm->session->data); in cs_etm__get_trace()
1460 aux_buffer->data = auxtrace_buffer__get_data(aux_buffer, fd); in cs_etm__get_trace()
1461 if (!aux_buffer->data) in cs_etm__get_trace()
1462 return -ENOMEM; in cs_etm__get_trace()
1469 etmq->buf_used = 0; in cs_etm__get_trace()
1470 etmq->buf_len = aux_buffer->size; in cs_etm__get_trace()
1471 etmq->buf = aux_buffer->data; in cs_etm__get_trace()
1473 return etmq->buf_len; in cs_etm__get_trace()
1482 if (tid != -1) { in cs_etm__set_thread()
1483 thread__zput(tidq->thread); in cs_etm__set_thread()
1484 tidq->thread = machine__find_thread(machine, -1, tid); in cs_etm__set_thread()
1488 if (!tidq->thread) in cs_etm__set_thread()
1489 tidq->thread = machine__idle_thread(machine); in cs_etm__set_thread()
1491 tidq->el = el; in cs_etm__set_thread()
1501 return -EINVAL; in cs_etm__etmq_set_tid_el()
1509 return !!etmq->etm->timeless_decoding; in cs_etm__etmq_is_timeless()
1514 const struct cs_etm_packet *packet, in cs_etm__copy_insn() argument
1519 * packet, so directly bail out with 'insn_len' = 0. in cs_etm__copy_insn()
1521 if (packet->sample_type == CS_ETM_DISCONTINUITY) { in cs_etm__copy_insn()
1522 sample->insn_len = 0; in cs_etm__copy_insn()
1527 * T32 instruction size might be 32-bit or 16-bit, decide by calling in cs_etm__copy_insn()
1530 if (packet->isa == CS_ETM_ISA_T32) in cs_etm__copy_insn()
1531 sample->insn_len = cs_etm__t32_instr_size(etmq, trace_chan_id, in cs_etm__copy_insn()
1532 sample->ip); in cs_etm__copy_insn()
1533 /* Otherwise, A64 and A32 instruction size are always 32-bit. */ in cs_etm__copy_insn()
1535 sample->insn_len = 4; in cs_etm__copy_insn()
1537 cs_etm__mem_access(etmq, trace_chan_id, sample->ip, sample->insn_len, in cs_etm__copy_insn()
1538 (void *)sample->insn, 0); in cs_etm__copy_insn()
1543 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__convert_sample_time()
1545 if (etm->has_virtual_ts) in cs_etm__convert_sample_time()
1546 return tsc_to_perf_time(cs_timestamp, &etm->tc); in cs_etm__convert_sample_time()
1554 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__resolve_sample_time()
1555 struct cs_etm_packet_queue *packet_queue = &tidq->packet_queue; in cs_etm__resolve_sample_time()
1557 if (!etm->timeless_decoding && etm->has_virtual_ts) in cs_etm__resolve_sample_time()
1558 return packet_queue->cs_timestamp; in cs_etm__resolve_sample_time()
1560 return etm->latest_kernel_timestamp; in cs_etm__resolve_sample_time()
1568 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__synth_instruction_sample()
1569 union perf_event *event = tidq->event_buf; in cs_etm__synth_instruction_sample()
1573 event->sample.header.type = PERF_RECORD_SAMPLE; in cs_etm__synth_instruction_sample()
1574 event->sample.header.misc = cs_etm__cpu_mode(etmq, addr, tidq->el); in cs_etm__synth_instruction_sample()
1575 event->sample.header.size = sizeof(struct perf_event_header); in cs_etm__synth_instruction_sample()
1581 sample.pid = thread__pid(tidq->thread); in cs_etm__synth_instruction_sample()
1582 sample.tid = thread__tid(tidq->thread); in cs_etm__synth_instruction_sample()
1583 sample.id = etmq->etm->instructions_id; in cs_etm__synth_instruction_sample()
1584 sample.stream_id = etmq->etm->instructions_id; in cs_etm__synth_instruction_sample()
1586 sample.cpu = tidq->packet->cpu; in cs_etm__synth_instruction_sample()
1587 sample.flags = tidq->prev_packet->flags; in cs_etm__synth_instruction_sample()
1588 sample.cpumode = event->sample.header.misc; in cs_etm__synth_instruction_sample()
1590 cs_etm__copy_insn(etmq, tidq->trace_chan_id, tidq->packet, &sample); in cs_etm__synth_instruction_sample()
1592 if (etm->synth_opts.last_branch) in cs_etm__synth_instruction_sample()
1593 sample.branch_stack = tidq->last_branch; in cs_etm__synth_instruction_sample()
1595 if (etm->synth_opts.inject) { in cs_etm__synth_instruction_sample()
1597 etm->instructions_sample_type); in cs_etm__synth_instruction_sample()
1602 ret = perf_session__deliver_synth_event(etm->session, event, &sample); in cs_etm__synth_instruction_sample()
1614 * The cs etm packet encodes an instruction range between a branch target
1621 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__synth_branch_sample()
1623 union perf_event *event = tidq->event_buf; in cs_etm__synth_branch_sample()
1631 ip = cs_etm__last_executed_instr(tidq->prev_packet); in cs_etm__synth_branch_sample()
1633 event->sample.header.type = PERF_RECORD_SAMPLE; in cs_etm__synth_branch_sample()
1634 event->sample.header.misc = cs_etm__cpu_mode(etmq, ip, in cs_etm__synth_branch_sample()
1635 tidq->prev_packet_el); in cs_etm__synth_branch_sample()
1636 event->sample.header.size = sizeof(struct perf_event_header); in cs_etm__synth_branch_sample()
1642 sample.pid = thread__pid(tidq->prev_packet_thread); in cs_etm__synth_branch_sample()
1643 sample.tid = thread__tid(tidq->prev_packet_thread); in cs_etm__synth_branch_sample()
1644 sample.addr = cs_etm__first_executed_instr(tidq->packet); in cs_etm__synth_branch_sample()
1645 sample.id = etmq->etm->branches_id; in cs_etm__synth_branch_sample()
1646 sample.stream_id = etmq->etm->branches_id; in cs_etm__synth_branch_sample()
1648 sample.cpu = tidq->packet->cpu; in cs_etm__synth_branch_sample()
1649 sample.flags = tidq->prev_packet->flags; in cs_etm__synth_branch_sample()
1650 sample.cpumode = event->sample.header.misc; in cs_etm__synth_branch_sample()
1652 cs_etm__copy_insn(etmq, tidq->trace_chan_id, tidq->prev_packet, in cs_etm__synth_branch_sample()
1658 if (etm->synth_opts.last_branch) { in cs_etm__synth_branch_sample()
1661 .hw_idx = -1ULL, in cs_etm__synth_branch_sample()
1670 if (etm->synth_opts.inject) { in cs_etm__synth_branch_sample()
1672 etm->branches_sample_type); in cs_etm__synth_branch_sample()
1677 ret = perf_session__deliver_synth_event(etm->session, event, &sample); in cs_etm__synth_branch_sample()
1690 struct evlist *evlist = session->evlist; in cs_etm__synth_events()
1698 if (evsel->core.attr.type == etm->pmu_type) { in cs_etm__synth_events()
1712 attr.sample_type = evsel->core.attr.sample_type & PERF_SAMPLE_MASK; in cs_etm__synth_events()
1715 if (etm->timeless_decoding) in cs_etm__synth_events()
1720 attr.exclude_user = evsel->core.attr.exclude_user; in cs_etm__synth_events()
1721 attr.exclude_kernel = evsel->core.attr.exclude_kernel; in cs_etm__synth_events()
1722 attr.exclude_hv = evsel->core.attr.exclude_hv; in cs_etm__synth_events()
1723 attr.exclude_host = evsel->core.attr.exclude_host; in cs_etm__synth_events()
1724 attr.exclude_guest = evsel->core.attr.exclude_guest; in cs_etm__synth_events()
1725 attr.sample_id_all = evsel->core.attr.sample_id_all; in cs_etm__synth_events()
1726 attr.read_format = evsel->core.attr.read_format; in cs_etm__synth_events()
1729 id = evsel->core.id[0] + 1000000000; in cs_etm__synth_events()
1734 if (etm->synth_opts.branches) { in cs_etm__synth_events()
1741 etm->branches_sample_type = attr.sample_type; in cs_etm__synth_events()
1742 etm->branches_id = id; in cs_etm__synth_events()
1747 if (etm->synth_opts.last_branch) { in cs_etm__synth_events()
1757 if (etm->synth_opts.instructions) { in cs_etm__synth_events()
1759 attr.sample_period = etm->synth_opts.period; in cs_etm__synth_events()
1760 etm->instructions_sample_period = attr.sample_period; in cs_etm__synth_events()
1764 etm->instructions_sample_type = attr.sample_type; in cs_etm__synth_events()
1765 etm->instructions_id = id; in cs_etm__synth_events()
1775 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__sample()
1777 u8 trace_chan_id = tidq->trace_chan_id; in cs_etm__sample()
1780 /* Get instructions remainder from previous packet */ in cs_etm__sample()
1781 instrs_prev = tidq->period_instructions; in cs_etm__sample()
1783 tidq->period_instructions += tidq->packet->instr_count; in cs_etm__sample()
1789 if (etm->synth_opts.last_branch && in cs_etm__sample()
1790 tidq->prev_packet->sample_type == CS_ETM_RANGE && in cs_etm__sample()
1791 tidq->prev_packet->last_instr_taken_branch) in cs_etm__sample()
1794 if (etm->synth_opts.instructions && in cs_etm__sample()
1795 tidq->period_instructions >= etm->instructions_sample_period) { in cs_etm__sample()
1809 * -------------------------------------------------- in cs_etm__sample()
1816 * \---------------- -----------------/ in cs_etm__sample()
1818 * tidq->packet->instr_count in cs_etm__sample()
1821 * every etm->instructions_sample_period instructions - as in cs_etm__sample()
1823 * last sample before the current etm packet, n+1 to n+3 in cs_etm__sample()
1824 * samples are generated from the current etm packet. in cs_etm__sample()
1826 * tidq->packet->instr_count represents the number of in cs_etm__sample()
1827 * instructions in the current etm packet. in cs_etm__sample()
1831 * previous etm packet. This will always be less than in cs_etm__sample()
1832 * etm->instructions_sample_period. in cs_etm__sample()
1835 * instructions, one is the tail of the old packet and another in cs_etm__sample()
1836 * is the head of the new coming packet, to generate in cs_etm__sample()
1839 * instructions will be used by later packet and it is assigned in cs_etm__sample()
1840 * to tidq->period_instructions for next round calculation. in cs_etm__sample()
1844 * Get the initial offset into the current packet instructions; in cs_etm__sample()
1846 * etm->instructions_sample_period. in cs_etm__sample()
1848 u64 offset = etm->instructions_sample_period - instrs_prev; in cs_etm__sample()
1852 if (etm->synth_opts.last_branch) in cs_etm__sample()
1855 while (tidq->period_instructions >= in cs_etm__sample()
1856 etm->instructions_sample_period) { in cs_etm__sample()
1858 * Calculate the address of the sampled instruction (-1 in cs_etm__sample()
1864 tidq->packet, offset - 1); in cs_etm__sample()
1867 etm->instructions_sample_period); in cs_etm__sample()
1871 offset += etm->instructions_sample_period; in cs_etm__sample()
1872 tidq->period_instructions -= in cs_etm__sample()
1873 etm->instructions_sample_period; in cs_etm__sample()
1877 if (etm->synth_opts.branches) { in cs_etm__sample()
1880 /* Generate sample for tracing on packet */ in cs_etm__sample()
1881 if (tidq->prev_packet->sample_type == CS_ETM_DISCONTINUITY) in cs_etm__sample()
1884 /* Generate sample for branch taken packet */ in cs_etm__sample()
1885 if (tidq->prev_packet->sample_type == CS_ETM_RANGE && in cs_etm__sample()
1886 tidq->prev_packet->last_instr_taken_branch) in cs_etm__sample()
1904 * When the exception packet is inserted, whether the last instruction in cs_etm__exception()
1905 * in previous range packet is taken branch or not, we need to force in cs_etm__exception()
1906 * to set 'prev_packet->last_instr_taken_branch' to true. This ensures in cs_etm__exception()
1910 * The exception packet includes the dummy address values, so don't in cs_etm__exception()
1911 * swap PACKET with PREV_PACKET. This keeps PREV_PACKET to be useful in cs_etm__exception()
1914 if (tidq->prev_packet->sample_type == CS_ETM_RANGE) in cs_etm__exception()
1915 tidq->prev_packet->last_instr_taken_branch = true; in cs_etm__exception()
1924 struct cs_etm_auxtrace *etm = etmq->etm; in cs_etm__flush()
1926 /* Handle start tracing packet */ in cs_etm__flush()
1927 if (tidq->prev_packet->sample_type == CS_ETM_EMPTY) in cs_etm__flush()
1930 if (etmq->etm->synth_opts.last_branch && in cs_etm__flush()
1931 etmq->etm->synth_opts.instructions && in cs_etm__flush()
1932 tidq->prev_packet->sample_type == CS_ETM_RANGE) { in cs_etm__flush()
1945 addr = cs_etm__last_executed_instr(tidq->prev_packet); in cs_etm__flush()
1949 tidq->period_instructions); in cs_etm__flush()
1953 tidq->period_instructions = 0; in cs_etm__flush()
1957 if (etm->synth_opts.branches && in cs_etm__flush()
1958 tidq->prev_packet->sample_type == CS_ETM_RANGE) { in cs_etm__flush()
1968 if (etm->synth_opts.last_branch) in cs_etm__flush()
1980 * It has no new packet coming and 'etmq->packet' contains the stale in cs_etm__end_block()
1981 * packet which was set at the previous time with packets swapping; in cs_etm__end_block()
1982 * so skip to generate branch sample to avoid stale packet. in cs_etm__end_block()
1988 if (etmq->etm->synth_opts.last_branch && in cs_etm__end_block()
1989 etmq->etm->synth_opts.instructions && in cs_etm__end_block()
1990 tidq->prev_packet->sample_type == CS_ETM_RANGE) { in cs_etm__end_block()
2000 addr = cs_etm__last_executed_instr(tidq->prev_packet); in cs_etm__end_block()
2004 tidq->period_instructions); in cs_etm__end_block()
2008 tidq->period_instructions = 0; in cs_etm__end_block()
2024 if (!etmq->buf_len) { in cs_etm__get_data_block()
2030 * are contiguous, reset the decoder to force re-sync. in cs_etm__get_data_block()
2032 ret = cs_etm_decoder__reset(etmq->decoder); in cs_etm__get_data_block()
2037 return etmq->buf_len; in cs_etm__get_data_block()
2041 struct cs_etm_packet *packet, in cs_etm__is_svc_instr() argument
2049 switch (packet->isa) { in cs_etm__is_svc_instr()
2055 * +-----------------+--------+ in cs_etm__is_svc_instr()
2057 * +-----------------+--------+ in cs_etm__is_svc_instr()
2063 addr = end_addr - 2; in cs_etm__is_svc_instr()
2075 * +---------+---------+-------------------------+ in cs_etm__is_svc_instr()
2077 * +---------+---------+-------------------------+ in cs_etm__is_svc_instr()
2079 addr = end_addr - 4; in cs_etm__is_svc_instr()
2092 * +-----------------------+---------+-----------+ in cs_etm__is_svc_instr()
2094 * +-----------------------+---------+-----------+ in cs_etm__is_svc_instr()
2096 addr = end_addr - 4; in cs_etm__is_svc_instr()
2112 struct cs_etm_traceid_queue *tidq, u64 magic) in cs_etm__is_syscall() argument
2114 u8 trace_chan_id = tidq->trace_chan_id; in cs_etm__is_syscall()
2115 struct cs_etm_packet *packet = tidq->packet; in cs_etm__is_syscall() local
2116 struct cs_etm_packet *prev_packet = tidq->prev_packet; in cs_etm__is_syscall()
2118 if (magic == __perf_cs_etmv3_magic) in cs_etm__is_syscall()
2119 if (packet->exception_number == CS_ETMV3_EXC_SVC) in cs_etm__is_syscall()
2125 * packet address. in cs_etm__is_syscall()
2127 if (magic == __perf_cs_etmv4_magic) { in cs_etm__is_syscall()
2128 if (packet->exception_number == CS_ETMV4_EXC_CALL && in cs_etm__is_syscall()
2130 prev_packet->end_addr)) in cs_etm__is_syscall()
2138 u64 magic) in cs_etm__is_async_exception() argument
2140 struct cs_etm_packet *packet = tidq->packet; in cs_etm__is_async_exception() local
2142 if (magic == __perf_cs_etmv3_magic) in cs_etm__is_async_exception()
2143 if (packet->exception_number == CS_ETMV3_EXC_DEBUG_HALT || in cs_etm__is_async_exception()
2144 packet->exception_number == CS_ETMV3_EXC_ASYNC_DATA_ABORT || in cs_etm__is_async_exception()
2145 packet->exception_number == CS_ETMV3_EXC_PE_RESET || in cs_etm__is_async_exception()
2146 packet->exception_number == CS_ETMV3_EXC_IRQ || in cs_etm__is_async_exception()
2147 packet->exception_number == CS_ETMV3_EXC_FIQ) in cs_etm__is_async_exception()
2150 if (magic == __perf_cs_etmv4_magic) in cs_etm__is_async_exception()
2151 if (packet->exception_number == CS_ETMV4_EXC_RESET || in cs_etm__is_async_exception()
2152 packet->exception_number == CS_ETMV4_EXC_DEBUG_HALT || in cs_etm__is_async_exception()
2153 packet->exception_number == CS_ETMV4_EXC_SYSTEM_ERROR || in cs_etm__is_async_exception()
2154 packet->exception_number == CS_ETMV4_EXC_INST_DEBUG || in cs_etm__is_async_exception()
2155 packet->exception_number == CS_ETMV4_EXC_DATA_DEBUG || in cs_etm__is_async_exception()
2156 packet->exception_number == CS_ETMV4_EXC_IRQ || in cs_etm__is_async_exception()
2157 packet->exception_number == CS_ETMV4_EXC_FIQ) in cs_etm__is_async_exception()
2165 u64 magic) in cs_etm__is_sync_exception() argument
2167 u8 trace_chan_id = tidq->trace_chan_id; in cs_etm__is_sync_exception()
2168 struct cs_etm_packet *packet = tidq->packet; in cs_etm__is_sync_exception() local
2169 struct cs_etm_packet *prev_packet = tidq->prev_packet; in cs_etm__is_sync_exception()
2171 if (magic == __perf_cs_etmv3_magic) in cs_etm__is_sync_exception()
2172 if (packet->exception_number == CS_ETMV3_EXC_SMC || in cs_etm__is_sync_exception()
2173 packet->exception_number == CS_ETMV3_EXC_HYP || in cs_etm__is_sync_exception()
2174 packet->exception_number == CS_ETMV3_EXC_JAZELLE_THUMBEE || in cs_etm__is_sync_exception()
2175 packet->exception_number == CS_ETMV3_EXC_UNDEFINED_INSTR || in cs_etm__is_sync_exception()
2176 packet->exception_number == CS_ETMV3_EXC_PREFETCH_ABORT || in cs_etm__is_sync_exception()
2177 packet->exception_number == CS_ETMV3_EXC_DATA_FAULT || in cs_etm__is_sync_exception()
2178 packet->exception_number == CS_ETMV3_EXC_GENERIC) in cs_etm__is_sync_exception()
2181 if (magic == __perf_cs_etmv4_magic) { in cs_etm__is_sync_exception()
2182 if (packet->exception_number == CS_ETMV4_EXC_TRAP || in cs_etm__is_sync_exception()
2183 packet->exception_number == CS_ETMV4_EXC_ALIGNMENT || in cs_etm__is_sync_exception()
2184 packet->exception_number == CS_ETMV4_EXC_INST_FAULT || in cs_etm__is_sync_exception()
2185 packet->exception_number == CS_ETMV4_EXC_DATA_FAULT) in cs_etm__is_sync_exception()
2192 if (packet->exception_number == CS_ETMV4_EXC_CALL && in cs_etm__is_sync_exception()
2194 prev_packet->end_addr)) in cs_etm__is_sync_exception()
2204 if (packet->exception_number > CS_ETMV4_EXC_FIQ && in cs_etm__is_sync_exception()
2205 packet->exception_number <= CS_ETMV4_EXC_END) in cs_etm__is_sync_exception()
2215 struct cs_etm_packet *packet = tidq->packet; in cs_etm__set_sample_flags() local
2216 struct cs_etm_packet *prev_packet = tidq->prev_packet; in cs_etm__set_sample_flags()
2217 u8 trace_chan_id = tidq->trace_chan_id; in cs_etm__set_sample_flags()
2218 u64 magic; in cs_etm__set_sample_flags() local
2221 switch (packet->sample_type) { in cs_etm__set_sample_flags()
2228 if (packet->last_instr_type == OCSD_INSTR_BR && in cs_etm__set_sample_flags()
2229 packet->last_instr_subtype == OCSD_S_INSTR_NONE) { in cs_etm__set_sample_flags()
2230 packet->flags = PERF_IP_FLAG_BRANCH; in cs_etm__set_sample_flags()
2232 if (packet->last_instr_cond) in cs_etm__set_sample_flags()
2233 packet->flags |= PERF_IP_FLAG_CONDITIONAL; in cs_etm__set_sample_flags()
2240 if (packet->last_instr_type == OCSD_INSTR_BR && in cs_etm__set_sample_flags()
2241 packet->last_instr_subtype == OCSD_S_INSTR_BR_LINK) in cs_etm__set_sample_flags()
2242 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2249 if (packet->last_instr_type == OCSD_INSTR_BR_INDIRECT && in cs_etm__set_sample_flags()
2250 packet->last_instr_subtype == OCSD_S_INSTR_BR_LINK) in cs_etm__set_sample_flags()
2251 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2259 if (packet->last_instr_type == OCSD_INSTR_BR_INDIRECT && in cs_etm__set_sample_flags()
2260 packet->last_instr_subtype == OCSD_S_INSTR_V7_IMPLIED_RET) in cs_etm__set_sample_flags()
2261 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2269 if (packet->last_instr_type == OCSD_INSTR_BR_INDIRECT && in cs_etm__set_sample_flags()
2270 packet->last_instr_subtype == OCSD_S_INSTR_NONE) in cs_etm__set_sample_flags()
2271 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2275 if (packet->last_instr_type == OCSD_INSTR_BR_INDIRECT && in cs_etm__set_sample_flags()
2276 packet->last_instr_subtype == OCSD_S_INSTR_V8_RET) in cs_etm__set_sample_flags()
2277 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2285 if (prev_packet->sample_type == CS_ETM_DISCONTINUITY) in cs_etm__set_sample_flags()
2286 prev_packet->flags |= PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2290 * If the previous packet is an exception return packet in cs_etm__set_sample_flags()
2292 * it needs to calibrate the previous packet sample flags in cs_etm__set_sample_flags()
2295 if (prev_packet->flags == (PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2299 packet, packet->start_addr)) in cs_etm__set_sample_flags()
2300 prev_packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2306 * The trace is discontinuous, if the previous packet is in cs_etm__set_sample_flags()
2307 * instruction packet, set flag PERF_IP_FLAG_TRACE_END in cs_etm__set_sample_flags()
2308 * for previous packet. in cs_etm__set_sample_flags()
2310 if (prev_packet->sample_type == CS_ETM_RANGE) in cs_etm__set_sample_flags()
2311 prev_packet->flags |= PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2315 ret = cs_etm__get_magic(etmq, packet->trace_chan_id, &magic); in cs_etm__set_sample_flags()
2320 if (cs_etm__is_syscall(etmq, tidq, magic)) in cs_etm__set_sample_flags()
2321 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2328 else if (cs_etm__is_async_exception(tidq, magic)) in cs_etm__set_sample_flags()
2329 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2337 else if (cs_etm__is_sync_exception(etmq, tidq, magic)) in cs_etm__set_sample_flags()
2338 packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2343 * When the exception packet is inserted, since exception in cs_etm__set_sample_flags()
2344 * packet is not used standalone for generating samples in cs_etm__set_sample_flags()
2346 * packet; so set previous range packet flags to tell perf in cs_etm__set_sample_flags()
2349 if (prev_packet->sample_type == CS_ETM_RANGE) in cs_etm__set_sample_flags()
2350 prev_packet->flags = packet->flags; in cs_etm__set_sample_flags()
2354 * When the exception return packet is inserted, since in cs_etm__set_sample_flags()
2355 * exception return packet is not used standalone for in cs_etm__set_sample_flags()
2357 * instruction range packet; so set previous range packet in cs_etm__set_sample_flags()
2361 * other exception types; unfortunately the packet doesn't in cs_etm__set_sample_flags()
2363 * the exception type purely based on exception return packet. in cs_etm__set_sample_flags()
2364 * If we record the exception number from exception packet and in cs_etm__set_sample_flags()
2365 * reuse it for exception return packet, this is not reliable in cs_etm__set_sample_flags()
2368 * used for exception return packet for these two cases. in cs_etm__set_sample_flags()
2370 * For exception return packet, we only need to distinguish the in cs_etm__set_sample_flags()
2371 * packet is for system call or for other types. Thus the in cs_etm__set_sample_flags()
2372 * decision can be deferred when receive the next packet which in cs_etm__set_sample_flags()
2378 if (prev_packet->sample_type == CS_ETM_RANGE) in cs_etm__set_sample_flags()
2379 prev_packet->flags = PERF_IP_FLAG_BRANCH | in cs_etm__set_sample_flags()
2397 * Packets are decoded and added to the decoder's packet queue in cs_etm__decode_data_block()
2398 * until the decoder packet processing callback has requested that in cs_etm__decode_data_block()
2400 * operations that stop processing are a timestamp packet or a full in cs_etm__decode_data_block()
2403 ret = cs_etm_decoder__process_data_block(etmq->decoder, in cs_etm__decode_data_block()
2404 etmq->offset, in cs_etm__decode_data_block()
2405 &etmq->buf[etmq->buf_used], in cs_etm__decode_data_block()
2406 etmq->buf_len, in cs_etm__decode_data_block()
2411 etmq->offset += processed; in cs_etm__decode_data_block()
2412 etmq->buf_used += processed; in cs_etm__decode_data_block()
2413 etmq->buf_len -= processed; in cs_etm__decode_data_block()
2425 packet_queue = &tidq->packet_queue; in cs_etm__process_traceid_queue()
2427 /* Process each packet in this chunk */ in cs_etm__process_traceid_queue()
2430 tidq->packet); in cs_etm__process_traceid_queue()
2439 * Since packet addresses are swapped in packet in cs_etm__process_traceid_queue()
2449 switch (tidq->packet->sample_type) { in cs_etm__process_traceid_queue()
2452 * If the packet contains an instruction in cs_etm__process_traceid_queue()
2461 * If the exception packet is coming, in cs_etm__process_traceid_queue()
2463 * range packet to be handled properly. in cs_etm__process_traceid_queue()
2476 * Should not receive empty packet, in cs_etm__process_traceid_queue()
2479 pr_err("CS ETM Trace: empty packet\n"); in cs_etm__process_traceid_queue()
2480 return -EINVAL; in cs_etm__process_traceid_queue()
2494 struct intlist *traceid_queues_list = etmq->traceid_queues_list; in cs_etm__clear_all_traceid_queues()
2497 idx = (int)(intptr_t)inode->priv; in cs_etm__clear_all_traceid_queues()
2498 tidq = etmq->traceid_queues[idx]; in cs_etm__clear_all_traceid_queues()
2512 return -EINVAL; in cs_etm__run_per_thread_timeless_decoder()
2527 * Process each packet in this chunk, nothing to do if in cs_etm__run_per_thread_timeless_decoder()
2533 } while (etmq->buf_len); in cs_etm__run_per_thread_timeless_decoder()
2564 * buffer. But here in per-cpu mode we need to iterate in cs_etm__run_per_cpu_timeless_decoder()
2568 etmq->traceid_queues_list) { in cs_etm__run_per_cpu_timeless_decoder()
2569 idx = (int)(intptr_t)inode->priv; in cs_etm__run_per_cpu_timeless_decoder()
2570 tidq = etmq->traceid_queues[idx]; in cs_etm__run_per_cpu_timeless_decoder()
2573 } while (etmq->buf_len); in cs_etm__run_per_cpu_timeless_decoder()
2575 intlist__for_each_entry(inode, etmq->traceid_queues_list) { in cs_etm__run_per_cpu_timeless_decoder()
2576 idx = (int)(intptr_t)inode->priv; in cs_etm__run_per_cpu_timeless_decoder()
2577 tidq = etmq->traceid_queues[idx]; in cs_etm__run_per_cpu_timeless_decoder()
2592 struct auxtrace_queues *queues = &etm->queues; in cs_etm__process_timeless_queues()
2594 for (i = 0; i < queues->nr_queues; i++) { in cs_etm__process_timeless_queues()
2595 struct auxtrace_queue *queue = &etm->queues.queue_array[i]; in cs_etm__process_timeless_queues()
2596 struct cs_etm_queue *etmq = queue->priv; in cs_etm__process_timeless_queues()
2602 if (etm->per_thread_decoding) { in cs_etm__process_timeless_queues()
2609 if (tid == -1 || thread__tid(tidq->thread) == tid) in cs_etm__process_timeless_queues()
2629 * Pre-populate the heap with one entry from each queue so that we can in cs_etm__process_timestamped_queues()
2632 for (i = 0; i < etm->queues.nr_queues; i++) { in cs_etm__process_timestamped_queues()
2633 etmq = etm->queues.queue_array[i].priv; in cs_etm__process_timestamped_queues()
2643 if (!etm->heap.heap_cnt) in cs_etm__process_timestamped_queues()
2647 cs_queue_nr = etm->heap.heap_array[0].queue_nr; in cs_etm__process_timestamped_queues()
2650 queue = &etm->queues.queue_array[queue_nr]; in cs_etm__process_timestamped_queues()
2651 etmq = queue->priv; in cs_etm__process_timestamped_queues()
2657 auxtrace_heap__pop(&etm->heap); in cs_etm__process_timestamped_queues()
2666 ret = -EINVAL; in cs_etm__process_timestamped_queues()
2724 ret = auxtrace_heap__add(&etm->heap, cs_queue_nr, cs_timestamp); in cs_etm__process_timestamped_queues()
2727 for (i = 0; i < etm->queues.nr_queues; i++) { in cs_etm__process_timestamped_queues()
2730 etmq = etm->queues.queue_array[i].priv; in cs_etm__process_timestamped_queues()
2734 intlist__for_each_entry(inode, etmq->traceid_queues_list) { in cs_etm__process_timestamped_queues()
2735 int idx = (int)(intptr_t)inode->priv; in cs_etm__process_timestamped_queues()
2738 tidq = etmq->traceid_queues[idx]; in cs_etm__process_timestamped_queues()
2753 if (etm->timeless_decoding) in cs_etm__process_itrace_start()
2762 th = machine__findnew_thread(&etm->session->machines.host, in cs_etm__process_itrace_start()
2763 event->itrace_start.pid, in cs_etm__process_itrace_start()
2764 event->itrace_start.tid); in cs_etm__process_itrace_start()
2766 return -ENOMEM; in cs_etm__process_itrace_start()
2777 bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT; in cs_etm__process_switch_cpu_wide()
2780 * Context switch in per-thread mode are irrelevant since perf in cs_etm__process_switch_cpu_wide()
2783 if (etm->timeless_decoding) in cs_etm__process_switch_cpu_wide()
2800 th = machine__findnew_thread(&etm->session->machines.host, in cs_etm__process_switch_cpu_wide()
2801 event->context_switch.next_prev_pid, in cs_etm__process_switch_cpu_wide()
2802 event->context_switch.next_prev_tid); in cs_etm__process_switch_cpu_wide()
2804 return -ENOMEM; in cs_etm__process_switch_cpu_wide()
2816 struct cs_etm_auxtrace *etm = container_of(session->auxtrace, in cs_etm__process_event()
2823 if (!tool->ordered_events) { in cs_etm__process_event()
2825 return -EINVAL; in cs_etm__process_event()
2828 switch (event->header.type) { in cs_etm__process_event()
2831 * Don't need to wait for cs_etm__flush_events() in per-thread mode to in cs_etm__process_event()
2838 if (etm->per_thread_decoding && etm->timeless_decoding) in cs_etm__process_event()
2840 event->fork.tid); in cs_etm__process_event()
2855 if (sample->time && (sample->time != (u64)-1)) in cs_etm__process_event()
2856 etm->latest_kernel_timestamp = sample->time; in cs_etm__process_event()
2876 for (i = 0; i < etm->queues.nr_queues; ++i) in dump_queued_data()
2877 list_for_each_entry(buf, &etm->queues.queue_array[i].head, list) in dump_queued_data()
2878 if (buf->reference == event->reference) in dump_queued_data()
2879 cs_etm__dump_event(etm->queues.queue_array[i].priv, buf); in dump_queued_data()
2886 struct cs_etm_auxtrace *etm = container_of(session->auxtrace, in cs_etm__process_auxtrace_event()
2889 if (!etm->data_queued) { in cs_etm__process_auxtrace_event()
2892 int fd = perf_data__fd(session->data); in cs_etm__process_auxtrace_event()
2893 bool is_pipe = perf_data__is_pipe(session->data); in cs_etm__process_auxtrace_event()
2895 int idx = event->auxtrace.idx; in cs_etm__process_auxtrace_event()
2901 if (data_offset == -1) in cs_etm__process_auxtrace_event()
2902 return -errno; in cs_etm__process_auxtrace_event()
2905 err = auxtrace_queues__add_event(&etm->queues, session, in cs_etm__process_auxtrace_event()
2912 cs_etm__dump_event(etm->queues.queue_array[idx].priv, buffer); in cs_etm__process_auxtrace_event()
2916 dump_queued_data(etm, &event->auxtrace); in cs_etm__process_auxtrace_event()
2924 struct evlist *evlist = etm->session->evlist; in cs_etm__setup_timeless_decoding()
2926 /* Override timeless mode with user input from --itrace=Z */ in cs_etm__setup_timeless_decoding()
2927 if (etm->synth_opts.timeless_decoding) { in cs_etm__setup_timeless_decoding()
2928 etm->timeless_decoding = true; in cs_etm__setup_timeless_decoding()
2936 if (cs_etm__evsel_is_auxtrace(etm->session, evsel)) { in cs_etm__setup_timeless_decoding()
2937 etm->timeless_decoding = in cs_etm__setup_timeless_decoding()
2938 !(evsel->core.attr.config & BIT(ETM_OPT_TS)); in cs_etm__setup_timeless_decoding()
2943 return -EINVAL; in cs_etm__setup_timeless_decoding()
2979 for (k = CS_ETM_COMMON_BLK_MAX_V1 - 1; k < nr_in_params; k++) in cs_etm__create_meta_blk()
2984 /* read version 1 info block - input and output nr_params may differ */ in cs_etm__create_meta_blk()
2989 /* if input has more params than output - skip excess */ in cs_etm__create_meta_blk()
2998 metadata[CS_ETM_NR_TRC_PARAMS] = nr_out_params - nr_cmn_params; in cs_etm__create_meta_blk()
3028 struct cs_etm_auxtrace *etm = container_of(session->auxtrace, in cs_etm__queue_aux_fragment()
3040 auxtrace_event = &auxtrace_event_union->auxtrace; in cs_etm__queue_aux_fragment()
3041 if (auxtrace_event->header.type != PERF_RECORD_AUXTRACE) in cs_etm__queue_aux_fragment()
3042 return -EINVAL; in cs_etm__queue_aux_fragment()
3044 if (auxtrace_event->header.size < sizeof(struct perf_record_auxtrace) || in cs_etm__queue_aux_fragment()
3045 auxtrace_event->header.size != sz) { in cs_etm__queue_aux_fragment()
3046 return -EINVAL; in cs_etm__queue_aux_fragment()
3050 * In per-thread mode, auxtrace CPU is set to -1, but TID will be set instead. See in cs_etm__queue_aux_fragment()
3053 * So now compare only TIDs if auxtrace CPU is -1, and CPUs if auxtrace CPU is not -1. in cs_etm__queue_aux_fragment()
3056 if (auxtrace_event->cpu == (__u32) -1) { in cs_etm__queue_aux_fragment()
3057 etm->per_thread_decoding = true; in cs_etm__queue_aux_fragment()
3058 if (auxtrace_event->tid != sample->tid) in cs_etm__queue_aux_fragment()
3060 } else if (auxtrace_event->cpu != sample->cpu) { in cs_etm__queue_aux_fragment()
3061 if (etm->per_thread_decoding) { in cs_etm__queue_aux_fragment()
3063 * Found a per-cpu buffer after a per-thread one was in cs_etm__queue_aux_fragment()
3066 pr_err("CS ETM: Inconsistent per-thread/per-cpu mode.\n"); in cs_etm__queue_aux_fragment()
3067 return -EINVAL; in cs_etm__queue_aux_fragment()
3072 if (aux_event->flags & PERF_AUX_FLAG_OVERWRITE) { in cs_etm__queue_aux_fragment()
3078 aux_size = min(aux_event->aux_size, auxtrace_event->size); in cs_etm__queue_aux_fragment()
3084 aux_offset = aux_event->aux_offset - aux_size; in cs_etm__queue_aux_fragment()
3086 aux_size = aux_event->aux_size; in cs_etm__queue_aux_fragment()
3087 aux_offset = aux_event->aux_offset; in cs_etm__queue_aux_fragment()
3090 if (aux_offset >= auxtrace_event->offset && in cs_etm__queue_aux_fragment()
3091 aux_offset + aux_size <= auxtrace_event->offset + auxtrace_event->size) { in cs_etm__queue_aux_fragment()
3092 struct cs_etm_queue *etmq = etm->queues.queue_array[auxtrace_event->idx].priv; in cs_etm__queue_aux_fragment()
3101 file_offset += aux_offset - auxtrace_event->offset + auxtrace_event->header.size; in cs_etm__queue_aux_fragment()
3104 " tid: %d cpu: %d\n", aux_size, aux_offset, sample->tid, sample->cpu); in cs_etm__queue_aux_fragment()
3105 err = auxtrace_queues__add_event(&etm->queues, session, &auxtrace_fragment, in cs_etm__queue_aux_fragment()
3110 format = (aux_event->flags & PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW) ? in cs_etm__queue_aux_fragment()
3112 if (etmq->format != UNSET && format != etmq->format) { in cs_etm__queue_aux_fragment()
3114 return -EINVAL; in cs_etm__queue_aux_fragment()
3116 etmq->format = format; in cs_etm__queue_aux_fragment()
3128 if (event->header.type == PERF_RECORD_AUX_OUTPUT_HW_ID) { in cs_etm__process_aux_hw_id_cb()
3146 if (event->header.type != PERF_RECORD_AUX) in cs_etm__queue_aux_records_cb()
3149 if (event->header.size < sizeof(struct perf_record_aux)) in cs_etm__queue_aux_records_cb()
3150 return -EINVAL; in cs_etm__queue_aux_records_cb()
3153 if (!event->aux.aux_size) in cs_etm__queue_aux_records_cb()
3160 evsel = evlist__event2evsel(session->evlist, event); in cs_etm__queue_aux_records_cb()
3162 return -EINVAL; in cs_etm__queue_aux_records_cb()
3171 list_for_each_entry(auxtrace_index, &session->auxtrace_index, list) { in cs_etm__queue_aux_records_cb()
3172 for (i = 0; i < auxtrace_index->nr; i++) { in cs_etm__queue_aux_records_cb()
3173 ent = &auxtrace_index->entries[i]; in cs_etm__queue_aux_records_cb()
3174 ret = cs_etm__queue_aux_fragment(session, ent->file_offset, in cs_etm__queue_aux_records_cb()
3175 ent->sz, &event->aux, &sample); in cs_etm__queue_aux_records_cb()
3190 " tid: %d cpu: %d\n", event->aux.aux_offset, sample.tid, sample.cpu); in cs_etm__queue_aux_records_cb()
3199 struct auxtrace_index *index = list_first_entry_or_null(&session->auxtrace_index, in cs_etm__queue_aux_records()
3201 if (index && index->nr > 0) in cs_etm__queue_aux_records()
3202 return perf_session__peek_events(session, session->header.data_offset, in cs_etm__queue_aux_records()
3203 session->header.data_size, in cs_etm__queue_aux_records()
3209 * queueing them in cs_etm__process_auxtrace_event() if etm->data_queued is still in cs_etm__queue_aux_records()
3218 (CS_##type##_##param - CS_ETM_COMMON_BLK_MAX_V1))
3239 /* Unknown / unsupported magic number. */ in cs_etm__has_virtual_ts()
3267 /* unknown magic number */ in cs_etm__map_trace_ids_metadata()
3268 return -EINVAL; in cs_etm__map_trace_ids_metadata()
3285 int decoders = intlist__nr_entries(etmq->traceid_list); in cs_etm__create_queue_decoders()
3294 if (etmq->format == UNFORMATTED) in cs_etm__create_queue_decoders()
3312 etmq->decoder = cs_etm_decoder__new(decoders, &d_params, in cs_etm__create_queue_decoders()
3315 if (!etmq->decoder) in cs_etm__create_queue_decoders()
3322 if (cs_etm_decoder__add_mem_access_cb(etmq->decoder, in cs_etm__create_queue_decoders()
3323 0x0L, ((u64) -1L), in cs_etm__create_queue_decoders()
3331 cs_etm_decoder__free(etmq->decoder); in cs_etm__create_queue_decoders()
3334 return -EINVAL; in cs_etm__create_queue_decoders()
3339 struct auxtrace_queues *queues = &etm->queues; in cs_etm__create_decoders()
3341 for (unsigned int i = 0; i < queues->nr_queues; i++) { in cs_etm__create_decoders()
3342 bool empty = list_empty(&queues->queue_array[i].head); in cs_etm__create_decoders()
3343 struct cs_etm_queue *etmq = queues->queue_array[i].priv; in cs_etm__create_decoders()
3348 * etmq->format is unknown for empty queues. in cs_etm__create_decoders()
3350 assert(empty || etmq->format != UNSET); in cs_etm__create_decoders()
3364 struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info; in cs_etm__process_auxtrace_info_full()
3366 struct perf_record_time_conv *tc = &session->time_conv; in cs_etm__process_auxtrace_info_full()
3368 int total_size = auxtrace_info->header.size; in cs_etm__process_auxtrace_info_full()
3378 ptr = (u64 *) auxtrace_info->priv; in cs_etm__process_auxtrace_info_full()
3382 return -ENOMEM; in cs_etm__process_auxtrace_info_full()
3405 metadata[j] = cs_etm__create_meta_blk(ptr, &i, CS_ETE_PRIV_MAX, -1); in cs_etm__process_auxtrace_info_full()
3407 …ui__error("CS ETM Trace: Unrecognised magic number %#"PRIx64". File could be from a newer version … in cs_etm__process_auxtrace_info_full()
3409 err = -EINVAL; in cs_etm__process_auxtrace_info_full()
3414 err = -ENOMEM; in cs_etm__process_auxtrace_info_full()
3429 priv_size = total_size - event_header_size - INFO_HEADER_SIZE; in cs_etm__process_auxtrace_info_full()
3431 err = -EINVAL; in cs_etm__process_auxtrace_info_full()
3438 err = -ENOMEM; in cs_etm__process_auxtrace_info_full()
3447 etm->pid_fmt = cs_etm__init_pid_fmt(metadata[0]); in cs_etm__process_auxtrace_info_full()
3449 err = auxtrace_queues__init_nr(&etm->queues, max_cpu + 1); in cs_etm__process_auxtrace_info_full()
3453 for (unsigned int j = 0; j < etm->queues.nr_queues; ++j) { in cs_etm__process_auxtrace_info_full()
3454 err = cs_etm__setup_queue(etm, &etm->queues.queue_array[j], j); in cs_etm__process_auxtrace_info_full()
3459 if (session->itrace_synth_opts->set) { in cs_etm__process_auxtrace_info_full()
3460 etm->synth_opts = *session->itrace_synth_opts; in cs_etm__process_auxtrace_info_full()
3462 itrace_synth_opts__set_default(&etm->synth_opts, in cs_etm__process_auxtrace_info_full()
3463 session->itrace_synth_opts->default_no_sample); in cs_etm__process_auxtrace_info_full()
3464 etm->synth_opts.callchain = false; in cs_etm__process_auxtrace_info_full()
3467 etm->session = session; in cs_etm__process_auxtrace_info_full()
3469 etm->num_cpu = num_cpu; in cs_etm__process_auxtrace_info_full()
3470 etm->pmu_type = (unsigned int) ((ptr[CS_PMU_TYPE_CPUS] >> 32) & 0xffffffff); in cs_etm__process_auxtrace_info_full()
3471 etm->snapshot_mode = (ptr[CS_ETM_SNAPSHOT] != 0); in cs_etm__process_auxtrace_info_full()
3472 etm->metadata = metadata; in cs_etm__process_auxtrace_info_full()
3473 etm->auxtrace_type = auxtrace_info->type; in cs_etm__process_auxtrace_info_full()
3475 if (etm->synth_opts.use_timestamp) in cs_etm__process_auxtrace_info_full()
3485 etm->has_virtual_ts = true; in cs_etm__process_auxtrace_info_full()
3488 etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu); in cs_etm__process_auxtrace_info_full()
3490 if (!etm->has_virtual_ts) in cs_etm__process_auxtrace_info_full()
3497 etm->auxtrace.process_event = cs_etm__process_event; in cs_etm__process_auxtrace_info_full()
3498 etm->auxtrace.process_auxtrace_event = cs_etm__process_auxtrace_event; in cs_etm__process_auxtrace_info_full()
3499 etm->auxtrace.flush_events = cs_etm__flush_events; in cs_etm__process_auxtrace_info_full()
3500 etm->auxtrace.free_events = cs_etm__free_events; in cs_etm__process_auxtrace_info_full()
3501 etm->auxtrace.free = cs_etm__free; in cs_etm__process_auxtrace_info_full()
3502 etm->auxtrace.evsel_is_auxtrace = cs_etm__evsel_is_auxtrace; in cs_etm__process_auxtrace_info_full()
3503 session->auxtrace = &etm->auxtrace; in cs_etm__process_auxtrace_info_full()
3509 etm->tc.time_shift = tc->time_shift; in cs_etm__process_auxtrace_info_full()
3510 etm->tc.time_mult = tc->time_mult; in cs_etm__process_auxtrace_info_full()
3511 etm->tc.time_zero = tc->time_zero; in cs_etm__process_auxtrace_info_full()
3513 etm->tc.time_cycles = tc->time_cycles; in cs_etm__process_auxtrace_info_full()
3514 etm->tc.time_mask = tc->time_mask; in cs_etm__process_auxtrace_info_full()
3515 etm->tc.cap_user_time_zero = tc->cap_user_time_zero; in cs_etm__process_auxtrace_info_full()
3516 etm->tc.cap_user_time_short = tc->cap_user_time_short; in cs_etm__process_auxtrace_info_full()
3542 * If no AUX_HW_ID packets are present - which means a file recorded on an old kernel in cs_etm__process_auxtrace_info_full()
3549 err = perf_session__peek_events(session, session->header.data_offset, in cs_etm__process_auxtrace_info_full()
3550 session->header.data_size, in cs_etm__process_auxtrace_info_full()
3566 etm->data_queued = etm->queues.populated; in cs_etm__process_auxtrace_info_full()
3570 auxtrace_queues__free(&etm->queues); in cs_etm__process_auxtrace_info_full()
3571 session->auxtrace = NULL; in cs_etm__process_auxtrace_info_full()