VirtualBox

Changeset 41147 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
May 3, 2012 8:15:27 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77764
Message:

SUPDrv,VMM: Tracepoints in raw-mode.

Location:
trunk/src/VBox/VMM
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/Makefile.kmk

    r41076 r41147  
    5353ifdef VBOX_WITH_PCI_PASSTHROUGH
    5454 VMM_COMMON_DEFS += VBOX_WITH_PCI_PASSTHROUGH
     55endif
     56ifdef VBOX_WITH_DTRACE_RC
     57 VMM_COMMON_DEFS += VBOX_WITH_DTRACE_RC
    5558endif
    5659# VMM_COMMON_DEFS += VBOX_WITH_NS_ACCOUNTING_STATS
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r40763 r41147  
    666666                {
    667667                    RTCCUINTREG uFlags = ASMIntDisableFlags();
    668                     VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC);
    669 
    670                     TMNotifyStartOfExecution(pVCpu);
    671                     rc = pVM->vmm.s.pfnHostToGuestR0(pVM);
    672                     pVCpu->vmm.s.iLastGZRc = rc;
    673                     TMNotifyEndOfExecution(pVCpu);
    674 
    675                     VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
     668
     669                    for (;;)
     670                    {
     671                        VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC);
     672                        TMNotifyStartOfExecution(pVCpu);
     673
     674                        rc = pVM->vmm.s.pfnHostToGuestR0(pVM);
     675                        pVCpu->vmm.s.iLastGZRc = rc;
     676
     677                        TMNotifyEndOfExecution(pVCpu);
     678                        VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
     679
     680                        if (rc != VINF_VMM_CALL_TRACER)
     681                            break;
     682                        SUPR0TracerUmodProbeFire(pVM->pSession, &pVCpu->vmm.s.TracerCtx);
     683                    }
    676684
    677685                    /* Re-enable VT-x if previously turned off. */
  • trunk/src/VBox/VMM/VMMR3/PDMLdr.cpp

    r39078 r41147  
    3232#include <VBox/err.h>
    3333#include <VBox/vmm/hwaccm.h>
     34#include <VBox/VBoxTpG.h>
    3435
    3536#include <VBox/log.h>
     
    168169
    169170/**
    170  * Applies relocations to GC modules.
     171 * Applies relocations to RC modules.
    171172 *
    172173 * This must be done very early in the relocation
    173  * process so that components can resolve GC symbols during relocation.
     174 * process so that components can resolve RC symbols during relocation.
    174175 *
    175176 * @param   pUVM        Pointer to the user mode VM structure.
     
    182183
    183184    /*
    184      * GC Modules.
     185     * RC Modules.
    185186     */
    186187    RTCritSectEnter(&pUVM->pdm.s.ListCritSect);
     
    431432
    432433/**
    433  * Loads a module into the guest context (i.e. into the Hypervisor memory region).
     434 * Loads a module into the raw-mode context (i.e. into the Hypervisor memory
     435 * region).
    434436 *
    435437 * @returns VBox status code.
     
    528530                        if (RT_SUCCESS(rc))
    529531                        {
     532#ifdef VBOX_WITH_DTRACE_RC
     533                            /*
     534                             * Register the tracer bits if present.
     535                             */
     536                            RTLDRADDR uValue;
     537                            rc = RTLdrGetSymbolEx(pModule->hLdrMod, pModule->pvBits, pModule->ImageBase,
     538                                                  "g_VTGObjHeader", &uValue);
     539                            if (RT_SUCCESS(rc))
     540                            {
     541                                PVTGOBJHDR pVtgHdr = (PVTGOBJHDR)MMHyperRCToCC(pVM, (RTRCPTR)uValue);
     542                                if (   pVtgHdr
     543                                    && !memcmp(pVtgHdr->szMagic, VTGOBJHDR_MAGIC, sizeof(pVtgHdr->szMagic)))
     544                                    rc = SUPR3TracerRegisterModule(~(uintptr_t)0, pModule->szName, pVtgHdr, uValue,
     545                                                                   SUP_TRACER_UMOD_FLAGS_SHARED);
     546                                else
     547                                    rc = pVtgHdr ? VERR_INVALID_MAGIC : VERR_INVALID_POINTER;
     548                                if (RT_FAILURE(rc))
     549                                    LogRel(("PDM: Failed to register tracepoints for '%s': %Rrc\n", pModule->szName, rc));
     550                            }
     551#endif
     552
    530553                            /*
    531554                             * Insert the module.
     
    542565                                pUVM->pdm.s.pModules = pModule; /* (pNext is zeroed by alloc) */
    543566                            Log(("PDM: RC Module at %RRv %s (%s)\n", (RTRCPTR)pModule->ImageBase, pszName, pszFilename));
     567
    544568                            RTCritSectLeave(&pUVM->pdm.s.ListCritSect);
    545569                            RTMemTmpFree(pszFile);
    546570                            RTMemTmpFree(paPages);
     571
    547572                            return VINF_SUCCESS;
    548573                        }
  • trunk/src/VBox/VMM/VMMRC/VMMRC.cpp

    r39078 r41147  
    210210
    211211/**
     212 * Calls the ring-0 host code.
     213 *
     214 * @param   pVM             The VM handle.
     215 */
     216DECLASM(void) vmmRCProbeFireHelper(PVM pVM)
     217{
     218    pVM->vmm.s.pfnGuestToHostRC(VINF_VMM_CALL_TRACER);
     219}
     220
     221
     222
     223/**
    212224 * Execute the trap testcase.
    213225 *
  • trunk/src/VBox/VMM/VMMRC/VMMRC.def

    r39357 r41147  
    6666    MMGCRamReadNoTrapHandler
    6767    VMMGetSvnRev
     68    VMMRCProbeFire
    6869    vmmGCLoggerFlush
    6970    vmmGCLoggerWrapper
  • trunk/src/VBox/VMM/VMMRC/VMMRCA.asm

    r37955 r41147  
    44;
    55
    6 ; Copyright (C) 2006-2007 Oracle Corporation
     6;
     7; Copyright (C) 2006-2012 Oracle Corporation
    78;
    89; This file is part of VirtualBox Open Source Edition (OSE), as
     
    2021%include "VBox/asmdefs.mac"
    2122%include "iprt/x86.mac"
     23%include "VBox/sup.mac"
     24%include "VBox/vmm/vm.mac"
     25%include "VMMInternal.mac"
    2226
    2327
     
    4852;* External Symbols                                                            *
    4953;*******************************************************************************
     54extern IMPNAME(g_VM)
    5055extern IMPNAME(g_Logger)
    5156extern IMPNAME(g_RelLogger)
    5257extern NAME(RTLogLogger)
     58extern NAME(vmmRCProbeFireHelper)
    5359
    5460
     
    214220ENDPROC vmmGCTestTrap0e
    215221
     222
     223
     224;;
     225; The raw-mode context equivalent of SUPTracerFireProbe. 
     226;
     227; See also SUPLibTracerA.asm.
     228;
     229EXPORTEDNAME VMMRCProbeFire
     230        push    ebp
     231        mov     ebp, esp
     232
     233        ;
     234        ; Save edx and eflags so we can use them.
     235        ;
     236        pushf
     237        push    edx
     238
     239        ;
     240        ; Get the address of the tracer context record after first checking
     241        ; that host calls hasn't been disabled.
     242        ;
     243        mov     edx, IMP(g_VM)
     244        add     edx, [ecx + VM.offVMCPU]
     245        cmp     dword [edx + VMMCPU.cCallRing3Disabled], 0
     246        jnz     .return
     247        add     edx, [VMCPU.vmm + VMMCPU.TracerCtx]
     248
     249        ;
     250        ; Save the X86 context.
     251        ;
     252        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.eax], eax
     253        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.ecx], ecx
     254        pop     eax
     255        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.edx], eax
     256        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.ebx], ebx
     257        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.esi], esi
     258        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.edi], edi
     259        pop     eax
     260        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.eflags], eax
     261        mov     eax, [ebp + 4]
     262        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.eip], eax
     263        mov     eax, [ebp]
     264        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.ebp], eax
     265        lea     eax, [ebp + 4*2]
     266        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.esp], eax
     267
     268        mov     ecx, [ebp + 4*2]
     269        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.uVtgProbeLoc], ecx
     270
     271        mov     eax, [ecx + 4]          ; VTGPROBELOC::idProbe.
     272        mov     [edx + SUPDRVTRACERUSRCTX32.idProbe], eax
     273        mov     dword [edx + SUPDRVTRACERUSRCTX32.cBits], 32
     274
     275        ; Copy the arguments off the stack.
     276%macro COPY_ONE_ARG 1
     277        mov     eax, [ebp + 8 + %1 * 4]
     278        mov     [edx + SUPDRVTRACERUSRCTX32.u.X86.aArgs + %1*4], eax
     279%endmacro
     280        COPY_ONE_ARG 0
     281        COPY_ONE_ARG 1
     282        COPY_ONE_ARG 2
     283        COPY_ONE_ARG 3
     284        COPY_ONE_ARG 4
     285        COPY_ONE_ARG 5
     286        COPY_ONE_ARG 6
     287        COPY_ONE_ARG 7
     288        COPY_ONE_ARG 8
     289        COPY_ONE_ARG 9
     290        COPY_ONE_ARG 10
     291        COPY_ONE_ARG 11
     292        COPY_ONE_ARG 12
     293        COPY_ONE_ARG 13
     294        COPY_ONE_ARG 14
     295        COPY_ONE_ARG 15
     296        COPY_ONE_ARG 16
     297        COPY_ONE_ARG 17
     298        COPY_ONE_ARG 18
     299        COPY_ONE_ARG 19
     300
     301        ;
     302        ; Call the helper (too lazy to do the VMM structure stuff).
     303        ;
     304        mov     ecx, IMP(g_VM)
     305        push    ecx
     306        call    NAME(vmmRCProbeFireHelper)
     307
     308.return:
     309        leave
     310        ret
     311ENDPROC      VMMRCProbeFire
     312
  • trunk/src/VBox/VMM/include/VMMInternal.h

    r39303 r41147  
    2020
    2121#include <VBox/cdefs.h>
     22#include <VBox/sup.h>
    2223#include <VBox/vmm/stam.h>
    2324#include <VBox/log.h>
     
    425426     *  attempts at recursive rendezvous. */
    426427    bool volatile               fInRendezvous;
    427     bool                        afPadding[HC_ARCH_BITS == 32 ? 7 : 3];
     428    bool                        afPadding[HC_ARCH_BITS == 32 ? 3 : 7];
    428429    /** @} */
     430
     431    /** @name Raw-mode context tracting data.
     432     * @{ */
     433    SUPDRVTRACERUSRCTX          TracerCtx;
     434    /** @} */
     435
     436    /** Alignment padding, making sure u64CallRing3Arg is nicly aligned. */
     437    uint32_t                    u32Padding1;
    429438
    430439    /** @name Call Ring-3
     
    439448    /** The argument to the operation. */
    440449    uint64_t                    u64CallRing3Arg;
    441     /** The Ring-0 jmp buffer. */
     450    /** The Ring-0 jmp buffer.
     451     * @remarks The size of this type isn't stable in assembly, so don't put
     452     *          anything that needs to be accessed from assembly after it. */
    442453    VMMR0JMPBUF                 CallRing3JmpBufR0;
    443454    /** @} */
    444455
    445456} VMMCPU;
     457AssertCompileMemberAlignment(VMMCPU, TracerCtx, 8);
    446458/** Pointer to VMMCPU. */
    447459typedef VMMCPU *PVMMCPU;
  • trunk/src/VBox/VMM/include/VMMInternal.mac

    r35333 r41147  
    1717
    1818%include "VBox/asmdefs.mac"
     19%include "VBox/sup.mac"
    1920
    2021;
     
    9596endstruc
    9697
     98
     99struc VMMCPU
     100                               
     101        .offVMCPU               resd 1
     102        .iLastGZRc              resd 1
     103        .pbEMTStackR3           RTR3PTR_RES 1
     104        .pbEMTStackRC           RTRCPTR_RES 1
     105        .pbEMTStackBottomRC     RTRCPTR_RES 1
     106%ifdef LOG_ENABLED
     107        .pR0LoggerR3            RTR3PTR_RES 1
     108        .pR0LoggerR0            RTR0PTR_RES 1
     109%endif
     110
     111        .fInRendezvous          resb 1
     112%if HC_ARCH_BITS == 32
     113        .afPadding              resb 7
     114%else
     115        .afPadding              resb 3
     116%endif
     117
     118        alignb 8
     119        .TracerCtx              resb SUPDRVTRACERUSRCTX64_size
     120
     121
     122        .cCallRing3Disabled     resd 1
     123        .enmCallRing3Operation  resd 1
     124        .rcCallRing3            resd 1
     125        .u64CallRing3Arg        resq 1
     126        ; .CallRing3JmpBufR0    resb no-can-do
     127
     128endstruc
     129
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette