Index: trunk/src/VBox/VMM/Makefile.kmk
===================================================================
--- trunk/src/VBox/VMM/Makefile.kmk	(revision 41117)
+++ trunk/src/VBox/VMM/Makefile.kmk	(revision 41147)
@@ -53,4 +53,7 @@
 ifdef VBOX_WITH_PCI_PASSTHROUGH
  VMM_COMMON_DEFS += VBOX_WITH_PCI_PASSTHROUGH
+endif
+ifdef VBOX_WITH_DTRACE_RC
+ VMM_COMMON_DEFS += VBOX_WITH_DTRACE_RC
 endif
 # VMM_COMMON_DEFS += VBOX_WITH_NS_ACCOUNTING_STATS
Index: trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 41117)
+++ trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 41147)
@@ -666,12 +666,20 @@
                 {
                     RTCCUINTREG uFlags = ASMIntDisableFlags();
-                    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC);
-
-                    TMNotifyStartOfExecution(pVCpu);
-                    rc = pVM->vmm.s.pfnHostToGuestR0(pVM);
-                    pVCpu->vmm.s.iLastGZRc = rc;
-                    TMNotifyEndOfExecution(pVCpu);
-
-                    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
+
+                    for (;;)
+                    {
+                        VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC);
+                        TMNotifyStartOfExecution(pVCpu);
+
+                        rc = pVM->vmm.s.pfnHostToGuestR0(pVM);
+                        pVCpu->vmm.s.iLastGZRc = rc;
+
+                        TMNotifyEndOfExecution(pVCpu);
+                        VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
+
+                        if (rc != VINF_VMM_CALL_TRACER)
+                            break;
+                        SUPR0TracerUmodProbeFire(pVM->pSession, &pVCpu->vmm.s.TracerCtx);
+                    }
 
                     /* Re-enable VT-x if previously turned off. */
Index: trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp	(revision 41117)
+++ trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp	(revision 41147)
@@ -32,4 +32,5 @@
 #include <VBox/err.h>
 #include <VBox/vmm/hwaccm.h>
+#include <VBox/VBoxTpG.h>
 
 #include <VBox/log.h>
@@ -168,8 +169,8 @@
 
 /**
- * Applies relocations to GC modules.
+ * Applies relocations to RC modules.
  *
  * This must be done very early in the relocation
- * process so that components can resolve GC symbols during relocation.
+ * process so that components can resolve RC symbols during relocation.
  *
  * @param   pUVM        Pointer to the user mode VM structure.
@@ -182,5 +183,5 @@
 
     /*
-     * GC Modules.
+     * RC Modules.
      */
     RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
@@ -431,5 +432,6 @@
 
 /**
- * Loads a module into the guest context (i.e. into the Hypervisor memory region).
+ * Loads a module into the raw-mode context (i.e. into the Hypervisor memory 
+ * region). 
  *
  * @returns VBox status code.
@@ -528,4 +530,25 @@
                         if (RT_SUCCESS(rc))
                         {
+#ifdef VBOX_WITH_DTRACE_RC
+                            /*
+                             * Register the tracer bits if present.
+                             */
+                            RTLDRADDR uValue;
+                            rc = RTLdrGetSymbolEx(pModule->hLdrMod, pModule->pvBits, pModule->ImageBase, 
+                                                  "g_VTGObjHeader", &uValue);
+                            if (RT_SUCCESS(rc))
+                            {
+                                PVTGOBJHDR pVtgHdr = (PVTGOBJHDR)MMHyperRCToCC(pVM, (RTRCPTR)uValue);
+                                if (   pVtgHdr 
+                                    && !memcmp(pVtgHdr->szMagic, VTGOBJHDR_MAGIC, sizeof(pVtgHdr->szMagic)))
+                                    rc = SUPR3TracerRegisterModule(~(uintptr_t)0, pModule->szName, pVtgHdr, uValue, 
+                                                                   SUP_TRACER_UMOD_FLAGS_SHARED);
+                                else
+                                    rc = pVtgHdr ? VERR_INVALID_MAGIC : VERR_INVALID_POINTER;
+                                if (RT_FAILURE(rc))
+                                    LogRel(("PDM: Failed to register tracepoints for '%s': %Rrc\n", pModule->szName, rc));
+                            }
+#endif
+
                             /*
                              * Insert the module.
@@ -542,7 +565,9 @@
                                 pUVM->pdm.s.pModules = pModule; /* (pNext is zeroed by alloc) */
                             Log(("PDM: RC Module at %RRv %s (%s)\n", (RTRCPTR)pModule->ImageBase, pszName, pszFilename));
+
                             RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
                             RTMemTmpFree(pszFile);
                             RTMemTmpFree(paPages);
+
                             return VINF_SUCCESS;
                         }
Index: trunk/src/VBox/VMM/VMMRC/VMMRC.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMRC/VMMRC.cpp	(revision 41117)
+++ trunk/src/VBox/VMM/VMMRC/VMMRC.cpp	(revision 41147)
@@ -210,4 +210,16 @@
 
 /**
+ * Calls the ring-0 host code.
+ *
+ * @param   pVM             The VM handle.
+ */
+DECLASM(void) vmmRCProbeFireHelper(PVM pVM)
+{
+    pVM->vmm.s.pfnGuestToHostRC(VINF_VMM_CALL_TRACER);
+}
+
+
+
+/**
  * Execute the trap testcase.
  *
Index: trunk/src/VBox/VMM/VMMRC/VMMRC.def
===================================================================
--- trunk/src/VBox/VMM/VMMRC/VMMRC.def	(revision 41117)
+++ trunk/src/VBox/VMM/VMMRC/VMMRC.def	(revision 41147)
@@ -66,4 +66,5 @@
     MMGCRamReadNoTrapHandler
     VMMGetSvnRev
+    VMMRCProbeFire
     vmmGCLoggerFlush
     vmmGCLoggerWrapper
Index: trunk/src/VBox/VMM/VMMRC/VMMRCA.asm
===================================================================
--- trunk/src/VBox/VMM/VMMRC/VMMRCA.asm	(revision 41117)
+++ trunk/src/VBox/VMM/VMMRC/VMMRCA.asm	(revision 41147)
@@ -4,5 +4,6 @@
 ;
 
-; Copyright (C) 2006-2007 Oracle Corporation
+;
+; Copyright (C) 2006-2012 Oracle Corporation
 ;
 ; This file is part of VirtualBox Open Source Edition (OSE), as
@@ -20,4 +21,7 @@
 %include "VBox/asmdefs.mac"
 %include "iprt/x86.mac"
+%include "VBox/sup.mac"
+%include "VBox/vmm/vm.mac"
+%include "VMMInternal.mac"
 
 
@@ -48,7 +52,9 @@
 ;* External Symbols                                                            *
 ;*******************************************************************************
+extern IMPNAME(g_VM)
 extern IMPNAME(g_Logger)
 extern IMPNAME(g_RelLogger)
 extern NAME(RTLogLogger)
+extern NAME(vmmRCProbeFireHelper)
 
 
@@ -214,2 +220,93 @@
 ENDPROC vmmGCTestTrap0e
 
+
+
+;;
+; The raw-mode context equivalent of SUPTracerFireProbe.  
+;
+; See also SUPLibTracerA.asm.
+;
+EXPORTEDNAME VMMRCProbeFire
+        push    ebp
+        mov     ebp, esp
+
+        ;
+        ; Save edx and eflags so we can use them.
+        ;
+        pushf
+        push    edx
+
+        ;
+        ; Get the address of the tracer context record after first checking 
+        ; that host calls hasn't been disabled.
+        ;
+        mov     edx, IMP(g_VM)
+        add     edx, [ecx + VM.offVMCPU]
+        cmp     dword [edx + VMMCPU.cCallRing3Disabled], 0
+        jnz     .return
+        add     edx, [VMCPU.vmm + VMMCPU.TracerCtx]
+
+        ;
+        ; Save the X86 context.
+        ;
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.eax], eax
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.ecx], ecx
+        pop     eax
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.edx], eax
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.ebx], ebx
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.esi], esi
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.edi], edi
+        pop     eax
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.eflags], eax
+        mov     eax, [ebp + 4]
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.eip], eax
+        mov     eax, [ebp]
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.ebp], eax
+        lea     eax, [ebp + 4*2]
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.esp], eax
+
+        mov     ecx, [ebp + 4*2]
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.uVtgProbeLoc], ecx
+
+        mov     eax, [ecx + 4]          ; VTGPROBELOC::idProbe.
+        mov     [edx + SUPDRVTRACERUSRCTX32.idProbe], eax
+        mov     dword [edx + SUPDRVTRACERUSRCTX32.cBits], 32
+
+        ; Copy the arguments off the stack.
+%macro COPY_ONE_ARG 1
+        mov     eax, [ebp + 8 + %1 * 4]
+        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.aArgs + %1*4], eax
+%endmacro
+        COPY_ONE_ARG 0
+        COPY_ONE_ARG 1
+        COPY_ONE_ARG 2
+        COPY_ONE_ARG 3
+        COPY_ONE_ARG 4
+        COPY_ONE_ARG 5
+        COPY_ONE_ARG 6
+        COPY_ONE_ARG 7
+        COPY_ONE_ARG 8
+        COPY_ONE_ARG 9
+        COPY_ONE_ARG 10
+        COPY_ONE_ARG 11
+        COPY_ONE_ARG 12
+        COPY_ONE_ARG 13
+        COPY_ONE_ARG 14
+        COPY_ONE_ARG 15
+        COPY_ONE_ARG 16
+        COPY_ONE_ARG 17
+        COPY_ONE_ARG 18
+        COPY_ONE_ARG 19
+
+        ;
+        ; Call the helper (too lazy to do the VMM structure stuff).
+        ;
+        mov     ecx, IMP(g_VM)
+        push    ecx
+        call    NAME(vmmRCProbeFireHelper)
+
+.return:
+        leave
+        ret
+ENDPROC      VMMRCProbeFire
+
Index: trunk/src/VBox/VMM/include/VMMInternal.h
===================================================================
--- trunk/src/VBox/VMM/include/VMMInternal.h	(revision 41117)
+++ trunk/src/VBox/VMM/include/VMMInternal.h	(revision 41147)
@@ -20,4 +20,5 @@
 
 #include <VBox/cdefs.h>
+#include <VBox/sup.h>
 #include <VBox/vmm/stam.h>
 #include <VBox/log.h>
@@ -425,6 +426,14 @@
      *  attempts at recursive rendezvous. */
     bool volatile               fInRendezvous;
-    bool                        afPadding[HC_ARCH_BITS == 32 ? 7 : 3];
+    bool                        afPadding[HC_ARCH_BITS == 32 ? 3 : 7];
     /** @} */
+
+    /** @name Raw-mode context tracting data.
+     * @{ */
+    SUPDRVTRACERUSRCTX          TracerCtx;
+    /** @} */
+
+    /** Alignment padding, making sure u64CallRing3Arg is nicly aligned. */
+    uint32_t                    u32Padding1;
 
     /** @name Call Ring-3
@@ -439,9 +448,12 @@
     /** The argument to the operation. */
     uint64_t                    u64CallRing3Arg;
-    /** The Ring-0 jmp buffer. */
+    /** The Ring-0 jmp buffer.
+     * @remarks The size of this type isn't stable in assembly, so don't put 
+     *          anything that needs to be accessed from assembly after it. */
     VMMR0JMPBUF                 CallRing3JmpBufR0;
     /** @} */
 
 } VMMCPU;
+AssertCompileMemberAlignment(VMMCPU, TracerCtx, 8);
 /** Pointer to VMMCPU. */
 typedef VMMCPU *PVMMCPU;
Index: trunk/src/VBox/VMM/include/VMMInternal.mac
===================================================================
--- trunk/src/VBox/VMM/include/VMMInternal.mac	(revision 41117)
+++ trunk/src/VBox/VMM/include/VMMInternal.mac	(revision 41147)
@@ -17,4 +17,5 @@
 
 %include "VBox/asmdefs.mac"
+%include "VBox/sup.mac"
 
 ;
@@ -95,2 +96,34 @@
 endstruc
 
+
+struc VMMCPU
+                                
+        .offVMCPU               resd 1
+        .iLastGZRc              resd 1
+        .pbEMTStackR3           RTR3PTR_RES 1
+        .pbEMTStackRC           RTRCPTR_RES 1
+        .pbEMTStackBottomRC     RTRCPTR_RES 1
+%ifdef LOG_ENABLED
+        .pR0LoggerR3            RTR3PTR_RES 1
+        .pR0LoggerR0            RTR0PTR_RES 1
+%endif
+
+        .fInRendezvous          resb 1
+%if HC_ARCH_BITS == 32
+        .afPadding              resb 7
+%else
+        .afPadding              resb 3
+%endif
+
+        alignb 8
+        .TracerCtx              resb SUPDRVTRACERUSRCTX64_size
+
+
+        .cCallRing3Disabled     resd 1
+        .enmCallRing3Operation  resd 1
+        .rcCallRing3            resd 1
+        .u64CallRing3Arg        resq 1
+        ; .CallRing3JmpBufR0    resb no-can-do
+
+endstruc
+
