VirtualBox

Changeset 39154 in vbox


Ignore:
Timestamp:
Oct 31, 2011 3:36:29 PM (13 years ago)
Author:
vboxsync
Message:

IOM: Added flags for dropping into the vbox debugger on complicated MMIO accesses. DBGF: some namespace cleanups.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbg.h

    r35696 r39154  
    4141
    4242RT_C_DECLS_BEGIN
     43
     44#ifdef IN_RING3 /* The debugger stuff is ring-3 only. */
    4345
    4446/** @def VBOX_WITH_DEBUGGER
     
    10691071DECLEXPORT(int) DBGCPlugInEntry(DBGCPLUGINOP enmOperation, PVM pVM, uintptr_t uArg);
    10701072
     1073#endif /* IN_RING3 */
     1074
    10711075/** @} */
    10721076
  • trunk/include/VBox/vmm/dbgf.h

    r38838 r39154  
    5454
    5555
     56#ifdef IN_RING3
     57
    5658/**
    5759 * Mixed address.
     
    124126VMMR3DECL(PDBGFADDRESS) DBGFR3AddrSub(PDBGFADDRESS pAddress, RTGCUINTPTR uSubtrahend);
    125127
     128#endif /* IN_RING3 */
    126129
    127130
     
    265268typedef const DBGFEVENT *PCDBGFEVENT;
    266269
     270#ifdef IN_RING3 /* The event API only works in ring-3. */
    267271
    268272/** @def DBGFSTOP
     
    272276 * @param   pVM     VM Handle.
    273277 */
    274 #ifdef VBOX_STRICT
    275 # define DBGFSTOP(pVM)  DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, __FILE__, __LINE__, __PRETTY_FUNCTION__, NULL)
    276 #else
    277 # define DBGFSTOP(pVM)  VINF_SUCCESS
    278 #endif
     278# ifdef VBOX_STRICT
     279#  define DBGFSTOP(pVM)  DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, __FILE__, __LINE__, __PRETTY_FUNCTION__, NULL)
     280# else
     281#  define DBGFSTOP(pVM)  VINF_SUCCESS
     282# endif
    279283
    280284VMMR3DECL(int)  DBGFR3Init(PVM pVM);
     
    296300VMMR3DECL(int)  DBGFR3Step(PVM pVM, VMCPUID idCpu);
    297301VMMR3DECL(int)  DBGFR3PrgStep(PVMCPU pVCpu);
     302
     303#endif /* IN_RING3 */
     304
    298305
    299306
     
    377384typedef const DBGFBP *PCDBGFBP;
    378385
    379 
     386#ifdef IN_RING3 /* The breakpoint management API is only available in ring-3. */
    380387VMMR3DECL(int)  DBGFR3BpSet(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable, uint32_t *piBp);
    381388VMMR3DECL(int)  DBGFR3BpSetReg(PVM pVM, PCDBGFADDRESS pAddress, uint64_t iHitTrigger, uint64_t iHitDisable,
     
    399406
    400407VMMR3DECL(int)          DBGFR3BpEnum(PVM pVM, PFNDBGFBPENUM pfnCallback, void *pvUser);
     408#endif /* IN_RING3 */
     409
    401410VMMDECL(RTGCUINTREG)    DBGFBpGetDR7(PVM pVM);
    402411VMMDECL(RTGCUINTREG)    DBGFBpGetDR0(PVM pVM);
     
    407416
    408417
    409 
     418#ifdef IN_RING3 /* The CPU mode API only works in ring-3. */
    410419VMMR3DECL(CPUMMODE)     DBGFR3CpuGetMode(PVM pVM, VMCPUID idCpu);
    411 
    412 
    413 
     420#endif
     421
     422
     423
     424#ifdef IN_RING3 /* The info callbacks API only works in ring-3. */
    414425
    415426/**
     
    551562VMMR3DECL(PCDBGFINFOHLP)    DBGFR3InfoLogRelHlp(void);
    552563
    553 
    554 
     564#endif /* IN_RING3 */
     565
     566
     567#ifdef IN_RING3 /* The log contrl API only works in ring-3. */
    555568VMMR3DECL(int) DBGFR3LogModifyGroups(PVM pVM, const char *pszGroupSettings);
    556569VMMR3DECL(int) DBGFR3LogModifyFlags(PVM pVM, const char *pszFlagSettings);
    557570VMMR3DECL(int) DBGFR3LogModifyDestinations(PVM pVM, const char *pszDestSettings);
    558 
    559 
     571#endif /* IN_RING3 */
     572
     573#ifdef IN_RING3 /* The debug information management APIs only works in ring-3. */
    560574
    561575/** Max length (including '\\0') of a symbol name. */
     
    621635/** The last special one. */
    622636#define DBGF_AS_LAST                DBGF_AS_GLOBAL
     637#endif
    623638/** The number of special address space handles. */
    624639#define DBGF_AS_COUNT               (6U)
     640#ifdef IN_RING3
    625641/** Converts an alias handle to an array index. */
    626642#define DBGF_AS_ALIAS_2_INDEX(hAlias) \
     
    663679VMMR3DECL(void)         DBGFR3LineFree(PDBGFLINE pLine);
    664680
     681#endif /* IN_RING3 */
     682
     683#ifdef IN_RING3 /* The stack API only works in ring-3. */
    665684
    666685/**
     
    795814/** Set if the content of the frame is filled in by DBGFR3StackWalk() and can be used
    796815 * to construct the next frame. */
    797 #define DBGFSTACKFRAME_FLAGS_ALL_VALID RT_BIT(0)
     816# define DBGFSTACKFRAME_FLAGS_ALL_VALID RT_BIT(0)
    798817/** This is the last stack frame we can read.
    799818 * This flag is not set if the walk stop because of max dept or recursion. */
    800 #define DBGFSTACKFRAME_FLAGS_LAST       RT_BIT(1)
     819# define DBGFSTACKFRAME_FLAGS_LAST      RT_BIT(1)
    801820/** This is the last record because we detected a loop. */
    802 #define DBGFSTACKFRAME_FLAGS_LOOP       RT_BIT(2)
     821# define DBGFSTACKFRAME_FLAGS_LOOP      RT_BIT(2)
    803822/** This is the last record because we reached the maximum depth. */
    804 #define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
     823# define DBGFSTACKFRAME_FLAGS_MAX_DEPTH RT_BIT(3)
    805824/** 16-bit frame. */
    806 #define DBGFSTACKFRAME_FLAGS_16BIT      RT_BIT(4)
     825# define DBGFSTACKFRAME_FLAGS_16BIT     RT_BIT(4)
    807826/** 32-bit frame. */
    808 #define DBGFSTACKFRAME_FLAGS_32BIT      RT_BIT(5)
     827# define DBGFSTACKFRAME_FLAGS_32BIT     RT_BIT(5)
    809828/** 64-bit frame. */
    810 #define DBGFSTACKFRAME_FLAGS_64BIT      RT_BIT(6)
     829# define DBGFSTACKFRAME_FLAGS_64BIT     RT_BIT(6)
    811830/** @} */
    812831
     
    835854VMMR3DECL(void)             DBGFR3StackWalkEnd(PCDBGFSTACKFRAME pFirstFrame);
    836855
    837 
    838 
     856#endif /* IN_RING3 */
     857
     858
     859#ifdef IN_RING3 /* The disassembly API only works in ring-3. */
    839860
    840861/** Flags to pass to DBGFR3DisasInstrEx().
     
    900921 * @thread Any EMT.
    901922 */
    902 #ifdef LOG_ENABLED
    903 # define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) \
     923# ifdef LOG_ENABLED
     924#  define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) \
    904925    do { \
    905926        if (LogIsEnabled()) \
    906927            DBGFR3DisasInstrLogInternal(pVCpu, Sel, GCPtr); \
    907928    } while (0)
    908 #else
    909 # define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) do { } while (0)
     929# else
     930#  define DBGFR3DisasInstrLog(pVCpu, Sel, GCPtr) do { } while (0)
     931# endif
    910932#endif
    911933
    912934
     935#ifdef IN_RING3
    913936VMMR3DECL(int) DBGFR3MemScan(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, RTGCUINTPTR uAlign,
    914937                             const void *pvNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress);
     
    916939VMMR3DECL(int) DBGFR3MemReadString(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, char *pszBuf, size_t cbBuf);
    917940VMMR3DECL(int) DBGFR3MemWrite(PVM pVM, VMCPUID idCpu, PCDBGFADDRESS pAddress, void const *pvBuf, size_t cbRead);
     941#endif
    918942
    919943
  • trunk/include/VBox/vmm/iom.h

    r39111 r39154  
    120120#define IOMMMIO_FLAGS_WRITE_MODE                        UINT32_C(0x00000070)
    121121
     122/** Whether to do a DBGSTOP on complicated reads.
     123 * What this includes depends on the read mode, but generally all misaligned
     124 * reads as well as word and byte reads and maybe qword reads. */
     125#define IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_READ       UINT32_C(0x00000100)
     126/** Whether to do a DBGSTOP on complicated writes.
     127 * This depends on the write mode, but generally all writes where we have to
     128 * supply bytes (zero them or read them). */
     129#define IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE      UINT32_C(0x00000200)
     130
    122131/** Mask of valid flags. */
    123 #define IOMMMIO_FLAGS_VALID_MASK                        UINT32_C(0x00000073)
     132#define IOMMMIO_FLAGS_VALID_MASK                        UINT32_C(0x00000373)
    124133/** @} */
    125134
  • trunk/src/VBox/Devices/USB/DevOHCI.cpp

    r39151 r39154  
    351351    /** A flag indicating that the bulk list may have in-flight URBs. */
    352352    bool                fBulkNeedsCleaning;
     353
     354    /** Whether RC/R0 is enabled. */
     355    bool                fRZEnabled;
    353356
    354357    uint32_t            Alignment3;     /**< Align size on a 8 byte boundary. */
     
    47904793 * @param   cb          The size of the read.
    47914794 */
    4792 PDMBOTHCBDECL(int) ohciRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
     4795PDMBOTHCBDECL(int) ohciMmioRead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
    47934796{
    47944797    POHCI pOhci = PDMINS_2_DATA(pDevIns, POHCI);
     
    48294832 * @param   cb          The size of the data being written.
    48304833 */
    4831 PDMBOTHCBDECL(int) ohciWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
     4834PDMBOTHCBDECL(int) ohciMmioWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
    48324835{
    48334836    POHCI pOhci = PDMINS_2_DATA(pDevIns, POHCI);
     
    48384841    if (cb != sizeof(uint32_t))
    48394842    {
    4840         Log2(("ohciWrite: Bad write size!!! GCPhysAddr=%RGp cb=%d\n", GCPhysAddr, cb));
     4843        Log2(("ohciMmioWrite: Bad write size!!! GCPhysAddr=%RGp cb=%d\n", GCPhysAddr, cb));
    48414844        return VINF_SUCCESS;
    48424845    }
    48434846    if (GCPhysAddr & 0x3)
    48444847    {
    4845         Log2(("ohciWrite: Unaligned write!!! GCPhysAddr=%RGp cb=%d\n", GCPhysAddr, cb));
     4848        Log2(("ohciMmioWrite: Unaligned write!!! GCPhysAddr=%RGp cb=%d\n", GCPhysAddr, cb));
    48464849        return VINF_SUCCESS;
    48474850    }
     
    48744877    POHCI pOhci = (POHCI)pPciDev;
    48754878    int rc = PDMDevHlpMMIORegister(pOhci->CTX_SUFF(pDevIns), GCPhysAddress, cb, NULL /*pvUser*/,
    4876                                    IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_PASSTHRU,
    4877                                    ohciWrite, ohciRead, "USB OHCI");
     4879                                   IOMMMIO_FLAGS_READ_DWORD | IOMMMIO_FLAGS_WRITE_DWORD_ZEROED
     4880                                   | IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE,
     4881                                   ohciMmioWrite, ohciMmioRead, "USB OHCI");
    48784882    if (RT_FAILURE(rc))
    48794883        return rc;
    48804884
    4881 # if 1 /* this enabled / disabled GC/R0 stuff */
    4882     rc = PDMDevHlpMMIORegisterRC(pOhci->CTX_SUFF(pDevIns), GCPhysAddress, cb, NIL_RTRCPTR /*pvUser*/, "ohciWrite", "ohciRead");
    4883     if (RT_FAILURE(rc))
    4884         return rc;
    4885 
    4886     rc = PDMDevHlpMMIORegisterR0(pOhci->CTX_SUFF(pDevIns), GCPhysAddress, cb, NIL_RTR0PTR /*pvUser*/, "ohciWrite", "ohciRead");
    4887     if (RT_FAILURE(rc))
    4888         return rc;
    4889 # endif
     4885    if (pOhci->fRZEnabled)
     4886    {
     4887        rc = PDMDevHlpMMIORegisterRC(pOhci->CTX_SUFF(pDevIns), GCPhysAddress, cb,
     4888                                     NIL_RTRCPTR /*pvUser*/, "ohciMmioWrite", "ohciMmioRead");
     4889        if (RT_FAILURE(rc))
     4890            return rc;
     4891
     4892        rc = PDMDevHlpMMIORegisterR0(pOhci->CTX_SUFF(pDevIns), GCPhysAddress, cb,
     4893                                     NIL_RTR0PTR /*pvUser*/, "ohciMmioWrite", "ohciMmioRead");
     4894        if (RT_FAILURE(rc))
     4895            return rc;
     4896    }
    48904897
    48914898    pOhci->MMIOBase = GCPhysAddress;
     
    53665373static DECLCALLBACK(int) ohciR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    53675374{
    5368     POHCI   pOhci = PDMINS_2_DATA(pDevIns, POHCI);
    5369     int     rc;
     5375    POHCI pOhci = PDMINS_2_DATA(pDevIns, POHCI);
    53705376    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    5371 
    5372     /*
    5373      * Read configuration. No configuration keys are currently supported.
    5374      */
    5375     if (!CFGMR3AreValuesValid(pCfg, "\0"))
    5376         return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    5377                                 N_("Configuration error: Unknown config key"));
    53785377
    53795378    /*
     
    54095408    pOhci->RootHub.ILeds.pfnQueryStatusLed       = ohciRhQueryStatusLed;
    54105409
     5410
     5411    /*
     5412     * Read configuration. No configuration keys are currently supported.
     5413     */
     5414    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "RZEnabled", "");
     5415    int rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pOhci->fRZEnabled, true);
     5416    AssertLogRelRCReturn(rc, rc);
     5417
     5418
    54115419    /*
    54125420     * Register PCI device and I/O region.
     
    54235431    aMsiReg.iMsiNextOffset = 0x0;
    54245432    rc = PDMDevHlpPCIRegisterMsi(pDevIns, &aMsiReg);
    5425     if (RT_FAILURE (rc))
     5433    if (RT_FAILURE(rc))
    54265434    {
    54275435        PCIDevSetCapabilityList(&pOhci->PciDev, 0x0);
  • trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp

    r39112 r39154  
    8585 *          VINF_IOM_HC_MMIO_READ may be returned.
    8686 *
     87 * @param   pVM                 The VM handle.
    8788 * @param   pRange              The range to write to.
    8889 * @param   GCPhys              The physical address to start writing.
     
    9091 * @param   cbValue             The size of the value to write.
    9192 */
    92 static VBOXSTRICTRC iomMMIODoComplicatedWrite(PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void const *pvValue, unsigned cbValue)
     93static VBOXSTRICTRC iomMMIODoComplicatedWrite(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void const *pvValue, unsigned cbValue)
    9394{
    9495    AssertReturn(   (pRange->fFlags & IOMMMIO_FLAGS_WRITE_MODE) != IOMMMIO_FLAGS_WRITE_PASSTHRU
     
    100101
    101102    /*
     103     * Do debug stop if requested.
     104     */
     105    int rc = VINF_SUCCESS; NOREF(pVM);
     106#ifdef VBOX_STRICT
     107    if (pRange->fFlags & IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE)
     108# ifdef IN_RING3
     109        rc = DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, RT_SRC_POS,
     110                            "Complicated write %#x byte at %RGp to %s\n", cbValue, GCPhys, R3STRING(pRange->pszDesc));
     111# else
     112        return VINF_IOM_HC_MMIO_WRITE;
     113# endif
     114#endif
     115
     116
     117    /*
    102118     * Split and conquer.
    103119     */
    104     int rc = VINF_SUCCESS;
    105120    for (;;)
    106121    {
     
    251266                                                    GCPhysFault, (void *)pvData, cb); /** @todo fix const!! */
    252267        else
    253             rc = iomMMIODoComplicatedWrite(pRange, GCPhysFault, pvData, cb);
     268            rc = iomMMIODoComplicatedWrite(pVM, pRange, GCPhysFault, pvData, cb);
    254269    }
    255270    else
     
    271286 *          VINF_IOM_HC_MMIO_WRITE may be returned.
    272287 *
     288 * @param   pVM                 The VM handle.
    273289 * @param   pRange              The range to read from.
    274290 * @param   GCPhys              The physical address to start reading.
     
    276292 * @param   cbValue             The size of the value to read.
    277293 */
    278 static VBOXSTRICTRC iomMMIODoComplicatedRead(PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void *pvValue, unsigned cbValue)
     294static VBOXSTRICTRC iomMMIODoComplicatedRead(PVM pVM, PIOMMMIORANGE pRange, RTGCPHYS GCPhys, void *pvValue, unsigned cbValue)
    279295{
    280296    AssertReturn(   (pRange->fFlags & IOMMMIO_FLAGS_READ_MODE) == IOMMMIO_FLAGS_READ_DWORD
     
    285301
    286302    /*
     303     * Do debug stop if requested.
     304     */
     305    int rc = VINF_SUCCESS; NOREF(pVM);
     306#ifdef VBOX_STRICT
     307    if (pRange->fFlags & IOMMMIO_FLAGS_DBGSTOP_ON_COMPLICATED_WRITE)
     308# ifdef IN_RING3
     309        rc = DBGFR3EventSrc(pVM, DBGFEVENT_DEV_STOP, RT_SRC_POS,
     310                            "Complicated read %#x byte at %RGp to %s\n", cbValue, GCPhys, R3STRING(pRange->pszDesc));
     311# else
     312        return VINF_IOM_HC_MMIO_READ;
     313# endif
     314#endif
     315
     316    /*
    287317     * Split and conquer.
    288318     */
    289     int rc = VINF_SUCCESS;
    290319    for (;;)
    291320    {
     
    439468            rc = pRange->CTX_SUFF(pfnReadCallback)(pRange->CTX_SUFF(pDevIns), pRange->CTX_SUFF(pvUser), GCPhys, pvValue, cbValue);
    440469        else
    441             rc = iomMMIODoComplicatedRead(pRange, GCPhys, pvValue, cbValue);
     470            rc = iomMMIODoComplicatedRead(pVM, pRange, GCPhys, pvValue, cbValue);
    442471    }
    443472    else
     
    18041833                                                   pu32Value, (unsigned)cbValue);
    18051834        else
    1806             rc = iomMMIODoComplicatedRead(pRange, GCPhys, pu32Value, (unsigned)cbValue);
     1835            rc = iomMMIODoComplicatedRead(pVM, pRange, GCPhys, pu32Value, (unsigned)cbValue);
    18071836        STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfRead), a);
    18081837        switch (VBOXSTRICTRC_VAL(rc))
     
    19331962                                                    GCPhys, &u32Value, (unsigned)cbValue);
    19341963        else
    1935             rc = iomMMIODoComplicatedWrite(pRange, GCPhys, &u32Value, (unsigned)cbValue);
     1964            rc = iomMMIODoComplicatedWrite(pVM, pRange, GCPhys, &u32Value, (unsigned)cbValue);
    19361965        STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfWrite), a);
    19371966#ifndef IN_RING3
  • trunk/src/VBox/VMM/include/DBGFInternal.h

    r37410 r39154  
    104104typedef struct DBGFINFO *PDBGFINFO;
    105105
     106#ifdef IN_RING3
    106107/**
    107108 * Info structure.
     
    160161    char            szName[1];
    161162} DBGFINFO;
     163#endif /* IN_RING3 */
    162164
    163165
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r39078 r39154  
    39913991int             pgmGstLazyMapPml4(PVMCPU pVCpu, PX86PML4 *ppPml4);
    39923992
    3993 # if defined(VBOX_STRICT) && HC_ARCH_BITS == 64
     3993# if defined(VBOX_STRICT) && HC_ARCH_BITS == 64 && defined(IN_RING3)
    39943994DECLCALLBACK(int)  pgmR3CmdCheckDuplicatePages(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs);
    39953995DECLCALLBACK(int)  pgmR3CmdShowSharedModules(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs);
Note: See TracChangeset for help on using the changeset viewer.

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