summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authordv <dv@cvs.openbsd.org>2021-06-07 13:55:55 +0000
committerdv <dv@cvs.openbsd.org>2021-06-07 13:55:55 +0000
commitbc4e51e1f64d077b963a337a94dc49023a6a77b4 (patch)
treefb88b1bf2260b348f3663b6931a47fb5421619a6 /sys/arch
parent9318de16db8d6e6cf53005339612262300ba7229 (diff)
vmm(4): add dt tracepoints for guest entry/exit
To aid in development and debugging, this adds a tracepoint prior to vm entry and after vm exit. It captures the vcpu and run params plus the exit code, but dt(4)/btrace(8) will need some future work to leverage those args. The location of the tracepoint might change in the future, but for now this solves my issues trying to use printf's to debug vmcs state corruption. ok mpi@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/vmm.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index 8ef4a14f85f..a3c7e42510c 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.284 2021/05/18 00:05:20 dv Exp $ */
+/* $OpenBSD: vmm.c,v 1.285 2021/06/07 13:55:54 dv Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -28,6 +28,7 @@
#include <sys/rwlock.h>
#include <sys/pledge.h>
#include <sys/memrange.h>
+#include <sys/tracepoint.h>
#include <uvm/uvm_extern.h>
@@ -4704,6 +4705,8 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
invvpid(IA32_VMX_INVVPID_SINGLE_CTX_GLB, &vid);
}
+ TRACEPOINT(vmm, guest_enter, vcpu, vrp);
+
/* Start / resume the VCPU */
#ifdef VMM_DEBUG
KERNEL_ASSERT_LOCKED();
@@ -4756,6 +4759,8 @@ vcpu_run_vmx(struct vcpu *vcpu, struct vm_run_params *vrp)
}
}
+ TRACEPOINT(vmm, guest_exit, vcpu, vrp, exit_reason);
+
if (ret || exitinfo != VMX_EXIT_INFO_COMPLETE ||
exit_reason != VMX_EXIT_EXTINT) {
KERNEL_LOCK();
@@ -7059,6 +7064,8 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
vcpu->vc_event = 0;
}
+ TRACEPOINT(vmm, guest_enter, vcpu, vrp);
+
/* Start / resume the VCPU */
#ifdef VMM_DEBUG
KERNEL_ASSERT_LOCKED();
@@ -7103,6 +7110,8 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp)
vcpu->vc_gueststate.vg_exit_reason = exit_reason;
}
+ TRACEPOINT(vmm, guest_exit, vcpu, vrp, exit_reason);
+
/* If we exited successfully ... */
if (ret == 0) {
vcpu->vc_gueststate.vg_rflags = vmcb->v_rflags;