Skip to content

Commit cfc4268

Browse files
Stanislav Kinsburskiiliuw
authored andcommitted
mshv: Add tracepoint for GPA intercept handling
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>
1 parent 404cd6b commit cfc4268

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

drivers/hv/mshv_root_main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ static bool mshv_handle_gpa_intercept(struct mshv_vp *vp)
674674

675675
region = mshv_partition_region_by_gfn_get(p, gfn);
676676
if (!region)
677-
return false;
677+
goto out;
678678

679679
if (access_type == HV_INTERCEPT_ACCESS_WRITE &&
680680
!(region->hv_map_flags & HV_MAP_GPA_WRITABLE))
@@ -690,7 +690,9 @@ static bool mshv_handle_gpa_intercept(struct mshv_vp *vp)
690690

691691
put_region:
692692
mshv_region_put(region);
693-
693+
out:
694+
trace_mshv_handle_gpa_intercept(p->pt_id, vp->vp_index, gfn,
695+
access_type, ret);
694696
return ret;
695697
}
696698

drivers/hv/mshv_trace.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define _MSHV_TRACE_H_
1313

1414
#include <linux/tracepoint.h>
15+
#include <hyperv/hvhdk.h>
1516

1617
#undef TRACE_INCLUDE_PATH
1718
#define TRACE_INCLUDE_PATH ../../drivers/hv
@@ -509,6 +510,34 @@ TRACE_EVENT(mshv_vp_wait_for_hv_kick,
509510
)
510511
);
511512

513+
TRACE_EVENT(mshv_handle_gpa_intercept,
514+
TP_PROTO(u64 partition_id, u32 vp_index, u64 gfn, u8 access_type, bool handled),
515+
TP_ARGS(partition_id, vp_index, gfn, access_type, handled),
516+
TP_STRUCT__entry(
517+
__field(u64, partition_id)
518+
__field(u32, vp_index)
519+
__field(u64, gfn)
520+
__field(u8, access_type)
521+
__field(bool, handled)
522+
),
523+
TP_fast_assign(
524+
__entry->partition_id = partition_id;
525+
__entry->vp_index = vp_index;
526+
__entry->gfn = gfn;
527+
__entry->access_type = access_type == HV_INTERCEPT_ACCESS_READ ? 'R' :
528+
(access_type == HV_INTERCEPT_ACCESS_WRITE ? 'W' :
529+
(access_type == HV_INTERCEPT_ACCESS_EXECUTE ? 'X' : '?'));
530+
__entry->handled = handled;
531+
),
532+
TP_printk("partition_id=%llu vp_index=%u gfn=0x%llx access_type=%c handled=%d",
533+
__entry->partition_id,
534+
__entry->vp_index,
535+
__entry->gfn,
536+
__entry->access_type,
537+
__entry->handled
538+
)
539+
);
540+
512541
#endif /* _MSHV_TRACE_H_ */
513542

514543
/* This part must be outside protection */

0 commit comments

Comments
 (0)