@@ -9504,6 +9504,31 @@ static int instance_mkdir(const char *name)
9504
9504
return ret ;
9505
9505
}
9506
9506
9507
+ static u64 map_pages (u64 start , u64 size )
9508
+ {
9509
+ struct page * * pages ;
9510
+ phys_addr_t page_start ;
9511
+ unsigned int page_count ;
9512
+ unsigned int i ;
9513
+ void * vaddr ;
9514
+
9515
+ page_count = DIV_ROUND_UP (size , PAGE_SIZE );
9516
+
9517
+ page_start = start ;
9518
+ pages = kmalloc_array (page_count , sizeof (struct page * ), GFP_KERNEL );
9519
+ if (!pages )
9520
+ return 0 ;
9521
+
9522
+ for (i = 0 ; i < page_count ; i ++ ) {
9523
+ phys_addr_t addr = page_start + i * PAGE_SIZE ;
9524
+ pages [i ] = pfn_to_page (addr >> PAGE_SHIFT );
9525
+ }
9526
+ vaddr = vmap (pages , page_count , VM_MAP , PAGE_KERNEL );
9527
+ kfree (pages );
9528
+
9529
+ return (u64 )(unsigned long )vaddr ;
9530
+ }
9531
+
9507
9532
/**
9508
9533
* trace_array_get_by_name - Create/Lookup a trace array, given its name.
9509
9534
* @name: The name of the trace array to be looked up/created.
@@ -10350,6 +10375,7 @@ __init static void enable_instances(void)
10350
10375
{
10351
10376
struct trace_array * tr ;
10352
10377
char * curr_str ;
10378
+ char * name ;
10353
10379
char * str ;
10354
10380
char * tok ;
10355
10381
@@ -10358,19 +10384,56 @@ __init static void enable_instances(void)
10358
10384
str = boot_instance_info ;
10359
10385
10360
10386
while ((curr_str = strsep (& str , "\t" ))) {
10387
+ unsigned long start = 0 ;
10388
+ unsigned long size = 0 ;
10389
+ unsigned long addr = 0 ;
10361
10390
10362
10391
tok = strsep (& curr_str , "," );
10392
+ name = strsep (& tok , "@" );
10393
+ if (tok ) {
10394
+ start = memparse (tok , & tok );
10395
+ if (!start ) {
10396
+ pr_warn ("Tracing: Invalid boot instance address for %s\n" ,
10397
+ name );
10398
+ continue ;
10399
+ }
10400
+ }
10363
10401
10364
- if (IS_ENABLED (CONFIG_TRACER_MAX_TRACE ))
10365
- do_allocate_snapshot (tok );
10402
+ if (start ) {
10403
+ if (* tok != ':' ) {
10404
+ pr_warn ("Tracing: No size specified for instance %s\n" , name );
10405
+ continue ;
10406
+ }
10407
+ tok ++ ;
10408
+ size = memparse (tok , & tok );
10409
+ if (!size ) {
10410
+ pr_warn ("Tracing: Invalid boot instance size for %s\n" ,
10411
+ name );
10412
+ continue ;
10413
+ }
10414
+ addr = map_pages (start , size );
10415
+ if (addr ) {
10416
+ pr_info ("Tracing: mapped boot instance %s at physical memory 0x%lx of size 0x%lx\n" ,
10417
+ name , start , size );
10418
+ } else {
10419
+ pr_warn ("Tracing: Failed to map boot instance %s\n" , name );
10420
+ continue ;
10421
+ }
10422
+ } else {
10423
+ /* Only non mapped buffers have snapshot buffers */
10424
+ if (IS_ENABLED (CONFIG_TRACER_MAX_TRACE ))
10425
+ do_allocate_snapshot (name );
10426
+ }
10366
10427
10367
- tr = trace_array_get_by_name ( tok , NULL );
10428
+ tr = trace_array_create_systems ( name , NULL , addr , size );
10368
10429
if (!tr ) {
10369
- pr_warn ("Failed to create instance buffer %s\n" , curr_str );
10430
+ pr_warn ("Tracing: Failed to create instance buffer %s\n" , curr_str );
10370
10431
continue ;
10371
10432
}
10372
- /* Allow user space to delete it */
10373
- trace_array_put (tr );
10433
+
10434
+ /* Only allow non mapped buffers to be deleted */
10435
+ if (!start )
10436
+ trace_array_put (tr );
10374
10437
10375
10438
while ((tok = strsep (& curr_str , "," ))) {
10376
10439
early_enable_events (tr , tok , true);
0 commit comments