]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/hv_support_kext.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / kern / hv_support_kext.c
index ca9054202bfd90b91cdb21480e5507d77f4fcac9..39ef71694d6ed86a8ab71f2833d0ddeab08008dd 100644 (file)
@@ -33,6 +33,7 @@
 #include <libkern/OSAtomic.h>
 #include <vm/vm_pageout.h>
 #include <mach/sdt.h>
+#include <sys/kdebug.h>
 
 #if defined(__x86_64__) && CONFIG_VMX
 #include <i386/vmx/vmx_cpu.h>
@@ -52,6 +53,8 @@ hv_callbacks_t hv_callbacks = {
        .thread_destroy = NULL, /* thread is being destroyed */
        .task_destroy = NULL,   /* task is being destroyed */
        .volatile_state = NULL, /* thread state is becoming volatile */
+       .resume = NULL,         /* system is being resumed */
+       .memory_pressure = NULL,/* (unused) */
 };
 
 /* trap tables for hv_*_trap syscalls */
@@ -192,7 +195,8 @@ hv_release_callbacks(void)
                .suspend = NULL,
                .thread_destroy = NULL,
                .task_destroy = NULL,
-               .volatile_state = NULL
+               .volatile_state = NULL,
+               .resume = NULL,
        };
 
        hv_callbacks_enabled = 0;
@@ -208,6 +212,15 @@ hv_suspend(void)
        }
 }
 
+/* system resume notification */
+void
+hv_resume(void)
+{
+       if (hv_callbacks_enabled && hv_callbacks.resume) {
+               hv_callbacks.resume();
+       }
+}
+
 /* dispatch hv_task_trap/hv_thread_trap syscalls to trap handlers,
  *  fail for invalid index or absence of trap handlers, trap handler is
  *  responsible for validating targets */
@@ -244,10 +257,30 @@ void
 hv_trace_guest_enter(uint32_t vcpu_id, uint64_t *vcpu_regs)
 {
        DTRACE_HV2(guest__enter, uint32_t, vcpu_id, uint64_t *, vcpu_regs);
+
+       KDBG(MACHDBG_CODE(DBG_MACH_HV, HV_GUEST_ENTER) | DBG_FUNC_START, vcpu_id);
 }
 
 void
-hv_trace_guest_exit(uint32_t vcpu_id, uint64_t *vcpu_regs)
+hv_trace_guest_exit(uint32_t vcpu_id, uint64_t *vcpu_regs, uint32_t reason)
 {
+       KDBG(MACHDBG_CODE(DBG_MACH_HV, HV_GUEST_ENTER) | DBG_FUNC_END, vcpu_id,
+           reason);
+
        DTRACE_HV2(guest__exit, uint32_t, vcpu_id, uint64_t *, vcpu_regs);
 }
+
+void
+hv_trace_guest_error(uint32_t vcpu_id, uint64_t *vcpu_regs, uint32_t failure,
+    uint32_t error)
+{
+       /*
+        * An error indicates that the guest enter failed so there will be no
+        * guest exit. Close the guest enter interval.
+        */
+       KDBG(MACHDBG_CODE(DBG_MACH_HV, HV_GUEST_ENTER) | DBG_FUNC_END, vcpu_id,
+           -1, failure, error);
+       KDBG(MACHDBG_CODE(DBG_MACH_HV, HV_GUEST_ERROR), vcpu_id, failure, error);
+
+       DTRACE_HV3(guest__error, uint32_t, vcpu_id, uint64_t *, vcpu_regs, uint32_t, failure);
+}