#include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/processor.h>
+#include <linux/trace_events.h>
 
 #include "x86.h"
 #include "svm.h"
 #include "cpuid.h"
+#include "trace.h"
 
 static u8 sev_enc_bit;
 static int sev_flush_asids(void);
        if (!svm->ghcb)
                return;
 
+       trace_kvm_vmgexit_exit(svm->vcpu.vcpu_id, svm->ghcb);
+
        sev_es_sync_to_ghcb(svm);
 
        kvm_vcpu_unmap(&svm->vcpu, &svm->ghcb_map, true);
        svm->ghcb = svm->ghcb_map.hva;
        ghcb = svm->ghcb_map.hva;
 
+       trace_kvm_vmgexit_enter(svm->vcpu.vcpu_id, ghcb);
+
        exit_code = ghcb_get_sw_exit_code(ghcb);
 
        ret = sev_es_validate_vmgexit(svm);
 
                  __entry->vcpu_id, __entry->vp_index, __entry->msr,
                  __entry->data)
 );
+
+/*
+ * Tracepoint for the start of VMGEXIT processing
+ */
+TRACE_EVENT(kvm_vmgexit_enter,
+       TP_PROTO(unsigned int vcpu_id, struct ghcb *ghcb),
+       TP_ARGS(vcpu_id, ghcb),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, vcpu_id)
+               __field(u64, exit_reason)
+               __field(u64, info1)
+               __field(u64, info2)
+       ),
+
+       TP_fast_assign(
+               __entry->vcpu_id     = vcpu_id;
+               __entry->exit_reason = ghcb->save.sw_exit_code;
+               __entry->info1       = ghcb->save.sw_exit_info_1;
+               __entry->info2       = ghcb->save.sw_exit_info_2;
+       ),
+
+       TP_printk("vcpu %u, exit_reason %llx, exit_info1 %llx, exit_info2 %llx",
+                 __entry->vcpu_id, __entry->exit_reason,
+                 __entry->info1, __entry->info2)
+);
+
+/*
+ * Tracepoint for the end of VMGEXIT processing
+ */
+TRACE_EVENT(kvm_vmgexit_exit,
+       TP_PROTO(unsigned int vcpu_id, struct ghcb *ghcb),
+       TP_ARGS(vcpu_id, ghcb),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, vcpu_id)
+               __field(u64, exit_reason)
+               __field(u64, info1)
+               __field(u64, info2)
+       ),
+
+       TP_fast_assign(
+               __entry->vcpu_id     = vcpu_id;
+               __entry->exit_reason = ghcb->save.sw_exit_code;
+               __entry->info1       = ghcb->save.sw_exit_info_1;
+               __entry->info2       = ghcb->save.sw_exit_info_2;
+       ),
+
+       TP_printk("vcpu %u, exit_reason %llx, exit_info1 %llx, exit_info2 %llx",
+                 __entry->vcpu_id, __entry->exit_reason,
+                 __entry->info1, __entry->info2)
+);
+
 #endif /* _TRACE_KVM_H */
 
 #undef TRACE_INCLUDE_PATH