@@ -429,6 +429,17 @@ mshv_vp_dispatch(struct mshv_vp *vp, u32 flags,
429429 status = hv_do_hypercall (HVCALL_DISPATCH_VP , input , output );
430430 vp -> run .flags .root_sched_dispatched = 0 ;
431431
432+ trace_mshv_hvcall_dispatch_vp (vp -> vp_partition -> pt_id ,
433+ vp -> vp_index , flags ,
434+ output -> dispatch_state ,
435+ output -> dispatch_event ,
436+ #if defined(CONFIG_X86_64 )
437+ vp -> vp_register_page -> interrupt_vectors .as_uint64 ,
438+ #else
439+ 0 ,
440+ #endif
441+ status );
442+
432443 * res = * output ;
433444 preempt_enable ();
434445
@@ -451,6 +462,9 @@ mshv_vp_clear_explicit_suspend(struct mshv_vp *vp)
451462 ret = mshv_set_vp_registers (vp -> vp_index , vp -> vp_partition -> pt_id ,
452463 1 , & explicit_suspend );
453464
465+ trace_mshv_vp_clear_explicit_suspend (vp -> vp_partition -> pt_id ,
466+ vp -> vp_index , ret );
467+
454468 if (ret )
455469 vp_err (vp , "Failed to unsuspend\n" );
456470
@@ -493,6 +507,12 @@ mshv_vp_wait_for_hv_kick(struct mshv_vp *vp)
493507 if (ret )
494508 return - EINTR ;
495509
510+ trace_mshv_vp_wait_for_hv_kick (vp -> vp_partition -> pt_id ,
511+ vp -> vp_index ,
512+ vp -> run .kicked_by_hv ,
513+ mshv_vp_dispatch_thread_blocked (vp ),
514+ mshv_vp_interrupt_pending (vp ));
515+
496516 vp -> run .flags .root_sched_blocked = 0 ;
497517 vp -> run .kicked_by_hv = 0 ;
498518
@@ -521,6 +541,12 @@ static long mshv_run_vp_with_root_scheduler(struct mshv_vp *vp)
521541
522542 if (__xfer_to_guest_mode_work_pending ()) {
523543 ret = xfer_to_guest_mode_handle_work ();
544+
545+ trace_mshv_xfer_to_guest_mode_work (vp -> vp_partition -> pt_id ,
546+ vp -> vp_index ,
547+ read_thread_flags (),
548+ ret );
549+
524550 if (ret )
525551 break ;
526552 }
@@ -681,13 +707,19 @@ static long mshv_vp_ioctl_run_vp(struct mshv_vp *vp, void __user *ret_msg)
681707{
682708 long rc ;
683709
710+ trace_mshv_run_vp_entry (vp -> vp_partition -> pt_id , vp -> vp_index );
711+
684712 do {
685713 if (hv_scheduler_type == HV_SCHEDULER_TYPE_ROOT )
686714 rc = mshv_run_vp_with_root_scheduler (vp );
687715 else
688716 rc = mshv_run_vp_with_hyp_scheduler (vp );
689717 } while (rc == 0 && mshv_vp_handle_intercept (vp ));
690718
719+ trace_mshv_run_vp_exit (vp -> vp_partition -> pt_id , vp -> vp_index ,
720+ vp -> vp_intercept_msg_page -> header .message_type ,
721+ rc );
722+
691723 if (rc )
692724 return rc ;
693725
@@ -949,6 +981,8 @@ mshv_vp_release(struct inode *inode, struct file *filp)
949981{
950982 struct mshv_vp * vp = filp -> private_data ;
951983
984+ trace_mshv_vp_release (vp -> vp_partition -> pt_id , vp -> vp_index );
985+
952986 /* Rest of VP cleanup happens in destroy_partition() */
953987 mshv_partition_put (vp -> vp_partition );
954988 return 0 ;
@@ -1121,7 +1155,7 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
11211155 partition -> pt_vp_count ++ ;
11221156 partition -> pt_vp_array [args .vp_index ] = vp ;
11231157
1124- return ret ;
1158+ goto out ;
11251159
11261160remove_debugfs_vp :
11271161 mshv_debugfs_vp_remove (vp );
@@ -1147,6 +1181,8 @@ mshv_partition_ioctl_create_vp(struct mshv_partition *partition,
11471181 intercept_msg_page , input_vtl_zero );
11481182destroy_vp :
11491183 hv_call_delete_vp (partition -> pt_id , args .vp_index );
1184+ out :
1185+ trace_mshv_create_vp (partition -> pt_id , args .vp_index , ret );
11501186 return ret ;
11511187}
11521188
@@ -1346,6 +1382,10 @@ mshv_map_user_memory(struct mshv_partition *partition,
13461382 break ;
13471383 }
13481384
1385+ trace_mshv_map_user_memory (partition -> pt_id , region -> start_uaddr ,
1386+ region -> start_gfn , region -> nr_pages ,
1387+ region -> hv_map_flags , ret );
1388+
13491389 if (ret )
13501390 goto errout ;
13511391
@@ -1641,6 +1681,9 @@ disable_vp_dispatch(struct mshv_vp *vp)
16411681 if (ret )
16421682 vp_err (vp , "failed to suspend\n" );
16431683
1684+ trace_mshv_disable_vp_dispatch (vp -> vp_partition -> pt_id ,
1685+ vp -> vp_index , ret );
1686+
16441687 return ret ;
16451688}
16461689
@@ -1689,6 +1732,8 @@ drain_vp_signals(struct mshv_vp *vp)
16891732 vp -> run .kicked_by_hv = 0 ;
16901733 vp_signal_count = atomic64_read (& vp -> run .vp_signaled_count );
16911734 }
1735+
1736+ trace_mshv_drain_vp_signals (vp -> vp_partition -> pt_id , vp -> vp_index );
16921737}
16931738
16941739static void drain_all_vps (const struct mshv_partition * partition )
@@ -1742,6 +1787,8 @@ static void destroy_partition(struct mshv_partition *partition)
17421787 return ;
17431788 }
17441789
1790+ trace_mshv_destroy_partition (partition -> pt_id );
1791+
17451792 if (partition -> pt_initialized ) {
17461793 /*
17471794 * We only need to drain signals for root scheduler. This should be
@@ -1848,6 +1895,8 @@ mshv_partition_release(struct inode *inode, struct file *filp)
18481895{
18491896 struct mshv_partition * partition = filp -> private_data ;
18501897
1898+ trace_mshv_partition_release (partition -> pt_id );
1899+
18511900 mshv_eventfd_release (partition );
18521901
18531902 cleanup_srcu_struct (& partition -> pt_irq_srcu );
@@ -1977,6 +2026,7 @@ mshv_ioctl_create_partition(void __user *user_arg, struct device *module_dev)
19772026 struct hv_partition_creation_properties creation_properties ;
19782027 union hv_partition_isolation_properties isolation_properties ;
19792028 struct mshv_partition * partition ;
2029+ u64 pt_id = -1 ;
19802030 long ret ;
19812031
19822032 ret = mshv_ioctl_process_pt_flags (user_arg , & creation_flags ,
@@ -2016,30 +2066,38 @@ mshv_ioctl_create_partition(void __user *user_arg, struct device *module_dev)
20162066 ret = hv_call_create_partition (creation_flags ,
20172067 creation_properties ,
20182068 isolation_properties ,
2019- & partition -> pt_id );
2069+ & pt_id );
20202070 if (ret )
20212071 goto cleanup_irq_srcu ;
20222072
2073+ partition -> pt_id = pt_id ;
2074+
20232075 ret = add_partition (partition );
20242076 if (ret )
20252077 goto delete_partition ;
20262078
20272079 ret = mshv_init_async_handler (partition );
2028- if (!ret ) {
2029- ret = FD_ADD (O_CLOEXEC , anon_inode_getfile ("mshv_partition" ,
2030- & mshv_partition_fops ,
2031- partition , O_RDWR ));
2032- if (ret >= 0 )
2033- return ret ;
2034- }
2080+ if (ret )
2081+ goto remove_partition ;
2082+
2083+ ret = FD_ADD (O_CLOEXEC , anon_inode_getfile ("mshv_partition" ,
2084+ & mshv_partition_fops ,
2085+ partition , O_RDWR ));
2086+ if (ret < 0 )
2087+ goto remove_partition ;
2088+
2089+ goto out ;
2090+
2091+ remove_partition :
20352092 remove_partition (partition );
20362093delete_partition :
20372094 hv_call_delete_partition (partition -> pt_id );
20382095cleanup_irq_srcu :
20392096 cleanup_srcu_struct (& partition -> pt_irq_srcu );
20402097free_partition :
20412098 kfree (partition );
2042-
2099+ out :
2100+ trace_mshv_create_partition (pt_id , ret );
20432101 return ret ;
20442102}
20452103
0 commit comments