@@ -2510,134 +2510,6 @@ static bool cs_etm__is_timeless_decoding(struct cs_etm_auxtrace *etm)
2510
2510
return timeless_decoding ;
2511
2511
}
2512
2512
2513
- static const char * const cs_etm_global_header_fmts [] = {
2514
- [CS_HEADER_VERSION ] = " Header version %llx\n" ,
2515
- [CS_PMU_TYPE_CPUS ] = " PMU type/num cpus %llx\n" ,
2516
- [CS_ETM_SNAPSHOT ] = " Snapshot %llx\n" ,
2517
- };
2518
-
2519
- static const char * const cs_etm_priv_fmts [] = {
2520
- [CS_ETM_MAGIC ] = " Magic number %llx\n" ,
2521
- [CS_ETM_CPU ] = " CPU %lld\n" ,
2522
- [CS_ETM_NR_TRC_PARAMS ] = " NR_TRC_PARAMS %llx\n" ,
2523
- [CS_ETM_ETMCR ] = " ETMCR %llx\n" ,
2524
- [CS_ETM_ETMTRACEIDR ] = " ETMTRACEIDR %llx\n" ,
2525
- [CS_ETM_ETMCCER ] = " ETMCCER %llx\n" ,
2526
- [CS_ETM_ETMIDR ] = " ETMIDR %llx\n" ,
2527
- };
2528
-
2529
- static const char * const cs_etmv4_priv_fmts [] = {
2530
- [CS_ETM_MAGIC ] = " Magic number %llx\n" ,
2531
- [CS_ETM_CPU ] = " CPU %lld\n" ,
2532
- [CS_ETM_NR_TRC_PARAMS ] = " NR_TRC_PARAMS %llx\n" ,
2533
- [CS_ETMV4_TRCCONFIGR ] = " TRCCONFIGR %llx\n" ,
2534
- [CS_ETMV4_TRCTRACEIDR ] = " TRCTRACEIDR %llx\n" ,
2535
- [CS_ETMV4_TRCIDR0 ] = " TRCIDR0 %llx\n" ,
2536
- [CS_ETMV4_TRCIDR1 ] = " TRCIDR1 %llx\n" ,
2537
- [CS_ETMV4_TRCIDR2 ] = " TRCIDR2 %llx\n" ,
2538
- [CS_ETMV4_TRCIDR8 ] = " TRCIDR8 %llx\n" ,
2539
- [CS_ETMV4_TRCAUTHSTATUS ] = " TRCAUTHSTATUS %llx\n" ,
2540
- [CS_ETE_TRCDEVARCH ] = " TRCDEVARCH %llx\n"
2541
- };
2542
-
2543
- static const char * const param_unk_fmt =
2544
- " Unknown parameter [%d] %" PRIx64 "\n" ;
2545
- static const char * const magic_unk_fmt =
2546
- " Magic number Unknown %" PRIx64 "\n" ;
2547
-
2548
- static int cs_etm__print_cpu_metadata_v0 (u64 * val , int * offset )
2549
- {
2550
- int i = * offset , j , nr_params = 0 , fmt_offset ;
2551
- u64 magic ;
2552
-
2553
- /* check magic value */
2554
- magic = val [i + CS_ETM_MAGIC ];
2555
- if ((magic != __perf_cs_etmv3_magic ) &&
2556
- (magic != __perf_cs_etmv4_magic )) {
2557
- /* failure - note bad magic value */
2558
- fprintf (stdout , magic_unk_fmt , magic );
2559
- return - EINVAL ;
2560
- }
2561
-
2562
- /* print common header block */
2563
- fprintf (stdout , cs_etm_priv_fmts [CS_ETM_MAGIC ], val [i ++ ]);
2564
- fprintf (stdout , cs_etm_priv_fmts [CS_ETM_CPU ], val [i ++ ]);
2565
-
2566
- if (magic == __perf_cs_etmv3_magic ) {
2567
- nr_params = CS_ETM_NR_TRC_PARAMS_V0 ;
2568
- fmt_offset = CS_ETM_ETMCR ;
2569
- /* after common block, offset format index past NR_PARAMS */
2570
- for (j = fmt_offset ; j < nr_params + fmt_offset ; j ++ , i ++ )
2571
- fprintf (stdout , cs_etm_priv_fmts [j ], val [i ]);
2572
- } else if (magic == __perf_cs_etmv4_magic ) {
2573
- nr_params = CS_ETMV4_NR_TRC_PARAMS_V0 ;
2574
- fmt_offset = CS_ETMV4_TRCCONFIGR ;
2575
- /* after common block, offset format index past NR_PARAMS */
2576
- for (j = fmt_offset ; j < nr_params + fmt_offset ; j ++ , i ++ )
2577
- fprintf (stdout , cs_etmv4_priv_fmts [j ], val [i ]);
2578
- }
2579
- * offset = i ;
2580
- return 0 ;
2581
- }
2582
-
2583
- static int cs_etm__print_cpu_metadata_v1 (u64 * val , int * offset )
2584
- {
2585
- int i = * offset , j , total_params = 0 ;
2586
- u64 magic ;
2587
-
2588
- magic = val [i + CS_ETM_MAGIC ];
2589
- /* total params to print is NR_PARAMS + common block size for v1 */
2590
- total_params = val [i + CS_ETM_NR_TRC_PARAMS ] + CS_ETM_COMMON_BLK_MAX_V1 ;
2591
-
2592
- if (magic == __perf_cs_etmv3_magic ) {
2593
- for (j = 0 ; j < total_params ; j ++ , i ++ ) {
2594
- /* if newer record - could be excess params */
2595
- if (j >= CS_ETM_PRIV_MAX )
2596
- fprintf (stdout , param_unk_fmt , j , val [i ]);
2597
- else
2598
- fprintf (stdout , cs_etm_priv_fmts [j ], val [i ]);
2599
- }
2600
- } else if (magic == __perf_cs_etmv4_magic || magic == __perf_cs_ete_magic ) {
2601
- /*
2602
- * ETE and ETMv4 can be printed in the same block because the number of parameters
2603
- * is saved and they share the list of parameter names. ETE is also only supported
2604
- * in V1 files.
2605
- */
2606
- for (j = 0 ; j < total_params ; j ++ , i ++ ) {
2607
- /* if newer record - could be excess params */
2608
- if (j >= CS_ETE_PRIV_MAX )
2609
- fprintf (stdout , param_unk_fmt , j , val [i ]);
2610
- else
2611
- fprintf (stdout , cs_etmv4_priv_fmts [j ], val [i ]);
2612
- }
2613
- } else {
2614
- /* failure - note bad magic value and error out */
2615
- fprintf (stdout , magic_unk_fmt , magic );
2616
- return - EINVAL ;
2617
- }
2618
- * offset = i ;
2619
- return 0 ;
2620
- }
2621
-
2622
- static void cs_etm__print_auxtrace_info (u64 * val , int num )
2623
- {
2624
- int i , cpu = 0 , version , err ;
2625
-
2626
- version = val [0 ];
2627
-
2628
- for (i = 0 ; i < CS_HEADER_VERSION_MAX ; i ++ )
2629
- fprintf (stdout , cs_etm_global_header_fmts [i ], val [i ]);
2630
-
2631
- for (i = CS_HEADER_VERSION_MAX ; cpu < num ; cpu ++ ) {
2632
- if (version == 0 )
2633
- err = cs_etm__print_cpu_metadata_v0 (val , & i );
2634
- else if (version == 1 )
2635
- err = cs_etm__print_cpu_metadata_v1 (val , & i );
2636
- if (err )
2637
- return ;
2638
- }
2639
- }
2640
-
2641
2513
/*
2642
2514
* Read a single cpu parameter block from the auxtrace_info priv block.
2643
2515
*
@@ -2874,52 +2746,20 @@ static int cs_etm__queue_aux_records(struct perf_session *session)
2874
2746
return 0 ;
2875
2747
}
2876
2748
2877
- int cs_etm__process_auxtrace_info (union perf_event * event ,
2878
- struct perf_session * session )
2749
+ int cs_etm__process_auxtrace_info_full (union perf_event * event ,
2750
+ struct perf_session * session )
2879
2751
{
2880
2752
struct perf_record_auxtrace_info * auxtrace_info = & event -> auxtrace_info ;
2881
2753
struct cs_etm_auxtrace * etm = NULL ;
2882
2754
struct int_node * inode ;
2883
- unsigned int pmu_type ;
2884
2755
int event_header_size = sizeof (struct perf_event_header );
2885
- int info_header_size ;
2886
2756
int total_size = auxtrace_info -> header .size ;
2887
2757
int priv_size = 0 ;
2888
2758
int num_cpu , trcidr_idx ;
2889
2759
int err = 0 ;
2890
2760
int i , j ;
2891
2761
u64 * ptr = NULL ;
2892
2762
u64 * * metadata = NULL ;
2893
- u64 hdr_version ;
2894
-
2895
- /*
2896
- * sizeof(auxtrace_info_event::type) +
2897
- * sizeof(auxtrace_info_event::reserved) == 8
2898
- */
2899
- info_header_size = 8 ;
2900
-
2901
- if (total_size < (event_header_size + info_header_size ))
2902
- return - EINVAL ;
2903
-
2904
- priv_size = total_size - event_header_size - info_header_size ;
2905
-
2906
- /* First the global part */
2907
- ptr = (u64 * ) auxtrace_info -> priv ;
2908
-
2909
- /* Look for version of the header */
2910
- hdr_version = ptr [0 ];
2911
- if (hdr_version > CS_HEADER_CURRENT_VERSION ) {
2912
- pr_err ("\nCS ETM Trace: Unknown Header Version = %#" PRIx64 , hdr_version );
2913
- pr_err (", version supported <= %x\n" , CS_HEADER_CURRENT_VERSION );
2914
- return - EINVAL ;
2915
- }
2916
-
2917
- num_cpu = ptr [CS_PMU_TYPE_CPUS ] & 0xffffffff ;
2918
- pmu_type = (unsigned int ) ((ptr [CS_PMU_TYPE_CPUS ] >> 32 ) &
2919
- 0xffffffff );
2920
-
2921
- if (dump_trace )
2922
- cs_etm__print_auxtrace_info (ptr , num_cpu );
2923
2763
2924
2764
/*
2925
2765
* Create an RB tree for traceID-metadata tuple. Since the conversion
@@ -2930,6 +2770,9 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
2930
2770
if (!traceid_list )
2931
2771
return - ENOMEM ;
2932
2772
2773
+ /* First the global part */
2774
+ ptr = (u64 * ) auxtrace_info -> priv ;
2775
+ num_cpu = ptr [CS_PMU_TYPE_CPUS ] & 0xffffffff ;
2933
2776
metadata = zalloc (sizeof (* metadata ) * num_cpu );
2934
2777
if (!metadata ) {
2935
2778
err = - ENOMEM ;
@@ -3008,6 +2851,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
3008
2851
* The following tests if the correct number of double words was
3009
2852
* present in the auxtrace info section.
3010
2853
*/
2854
+ priv_size = total_size - event_header_size - INFO_HEADER_SIZE ;
3011
2855
if (i * 8 != priv_size ) {
3012
2856
err = - EINVAL ;
3013
2857
goto err_free_metadata ;
@@ -3036,7 +2880,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
3036
2880
etm -> machine = & session -> machines .host ;
3037
2881
3038
2882
etm -> num_cpu = num_cpu ;
3039
- etm -> pmu_type = pmu_type ;
2883
+ etm -> pmu_type = ( unsigned int ) (( ptr [ CS_PMU_TYPE_CPUS ] >> 32 ) & 0xffffffff ) ;
3040
2884
etm -> snapshot_mode = (ptr [CS_ETM_SNAPSHOT ] != 0 );
3041
2885
etm -> metadata = metadata ;
3042
2886
etm -> auxtrace_type = auxtrace_info -> type ;
0 commit comments