]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mshv: Add tracepoint for GPA intercept handling
authorStanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Tue, 24 Mar 2026 23:59:59 +0000 (23:59 +0000)
committerWei Liu <wei.liu@kernel.org>
Wed, 22 Apr 2026 06:23:25 +0000 (06:23 +0000)
Provide visibility into GPA intercept operations for debugging and
performance analysis of Microsoft Hypervisor guest memory management.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
Reviewed-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
drivers/hv/mshv_root_main.c
drivers/hv/mshv_trace.h

index 735b2d39e06a84f570d81bb98f0ed0c37c7d38c8..bd1359eb58dd46d31d1ef3e5aed3e2382689fe73 100644 (file)
@@ -674,7 +674,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))
@@ -690,7 +690,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;
 }
 
index ba3b3f575983f3fc9587a5c120f99dca8be9c449..e7280c47e579aa43c093214d463004cb37b925c7 100644 (file)
@@ -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 == HV_INTERCEPT_ACCESS_READ ? 'R' :
+                                          (access_type == HV_INTERCEPT_ACCESS_WRITE ? 'W' :
+                                           (access_type == HV_INTERCEPT_ACCESS_EXECUTE ? 'X' : '?'));
+                   __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,
+                   __entry->handled
+           )
+);
+
 #endif /* _MSHV_TRACE_H_ */
 
 /* This part must be outside protection */