Provide visibility into GPA intercept operations for debugging and performance analysis of Microsoft Hypervisor guest memory management.
Signed-off-by: Stanislav Kinsburskii <[email protected]> --- drivers/hv/mshv_root_main.c | 6 ++++-- drivers/hv/mshv_trace.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c index bb9fe4985e95..d4aab09fba47 100644 --- a/drivers/hv/mshv_root_main.c +++ b/drivers/hv/mshv_root_main.c @@ -675,7 +675,7 @@ static bool mshv_handle_gpa_intercept(struct mshv_vp *vp) region = mshv_partition_region_by_gfn_get(p, gfn); if (!region) - return false; + goto out; if (access_type == HV_INTERCEPT_ACCESS_WRITE && !(region->hv_map_flags & HV_MAP_GPA_WRITABLE)) @@ -691,7 +691,9 @@ static bool mshv_handle_gpa_intercept(struct mshv_vp *vp) put_region: mshv_region_put(region); - +out: + trace_mshv_handle_gpa_intercept(p->pt_id, vp->vp_index, gfn, + access_type, ret); return ret; } diff --git a/drivers/hv/mshv_trace.h b/drivers/hv/mshv_trace.h index ba3b3f575983..6b8fa477fa3b 100644 --- a/drivers/hv/mshv_trace.h +++ b/drivers/hv/mshv_trace.h @@ -12,6 +12,7 @@ #define _MSHV_TRACE_H_ #include <linux/tracepoint.h> +#include <hyperv/hvhdk.h> #undef TRACE_INCLUDE_PATH #define TRACE_INCLUDE_PATH ../../drivers/hv @@ -509,6 +510,34 @@ TRACE_EVENT(mshv_vp_wait_for_hv_kick, ) ); +TRACE_EVENT(mshv_handle_gpa_intercept, + TP_PROTO(u64 partition_id, u32 vp_index, u64 gfn, u8 access_type, bool handled), + TP_ARGS(partition_id, vp_index, gfn, access_type, handled), + TP_STRUCT__entry( + __field(u64, partition_id) + __field(u32, vp_index) + __field(u64, gfn) + __field(u8, access_type) + __field(bool, handled) + ), + TP_fast_assign( + __entry->partition_id = partition_id; + __entry->vp_index = vp_index; + __entry->gfn = gfn; + __entry->access_type = access_type; + __entry->handled = handled; + ), + TP_printk("partition_id=%llu vp_index=%u gfn=0x%llx access_type=%c handled=%d", + __entry->partition_id, + __entry->vp_index, + __entry->gfn, + __entry->access_type == HV_INTERCEPT_ACCESS_READ ? 'R' : + (__entry->access_type == HV_INTERCEPT_ACCESS_WRITE ? 'W' : + (__entry->access_type == HV_INTERCEPT_ACCESS_READ ? 'X' : '?')), + __entry->handled + ) +); + #endif /* _MSHV_TRACE_H_ */ /* This part must be outside protection */

