VirtualBox

Ignore:
Timestamp:
Aug 6, 2015 11:34:04 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101982
Message:

SUPDrv,VMMR0: Added SUPR0BadContext for reporting AC=0 and (on darwin with VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV defined) refuse further I/O control calls. That way we'll sit up and pay attention, hopefully. VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV is currently enabled for all non-release builds (odd build numbers), and we check EFLAGS.AC at the end of each ioctrl call.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPDrv-darwin.cpp

    r57220 r57229  
    7979#endif
    8080
    81 /* Temporary debugging. */
     81/* The following macros are duplicated in the-darwin-kernel.h. */
     82#define IPRT_DARWIN_SAVE_EFL_AC()           RTCCUINTREG const fSavedEfl = ASMGetFlags();
     83#define IPRT_DARWIN_RESTORE_EFL_AC()        ASMSetFlags(fSavedEfl)
     84#define IPRT_DARWIN_RESTORE_EFL_ONLY_AC()   ASMChangeFlags(~X86_EFL_AC, fSavedEfl & X86_EFL_AC)
     85
     86
     87/* Temporary debugging - very temporary... */
    8288#define VBOX_PROC_SELFNAME_LEN  (20)
    83 #define VBOX_RETRIEVE_CUR_PROC_NAME(_name)    char _name[VBOX_PROC_SELFNAME_LEN]; \
    84                                               proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN)
     89#define VBOX_RETRIEVE_CUR_PROC_NAME(_name)  char _name[VBOX_PROC_SELFNAME_LEN]; \
     90                                            proc_selfname(pszProcName, VBOX_PROC_SELFNAME_LEN)
    8591
    8692
     
    586592    PSUPDRVSESSION      pSession;
    587593
     594#ifdef VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV
     595    /*
     596     * Refuse all I/O control calls if we've ever detected EFLAGS.AC being cleared.
     597     *
     598     * This isn't a problem, as there is absolutely nothing in the kernel context that
     599     * depend on user context triggering cleanups.  That would be pretty wild, right?
     600     */
     601    if (RT_UNLIKELY(g_DevExt.cBadContextCalls > 0))
     602    {
     603        SUPR0Printf("VBoxDrvDarwinIOCtl: EFLAGS.AC=0 detected %u times, refusing all I/O controls!\n", g_DevExt.cBadContextCalls);
     604        return EDEVERR;
     605    }
     606#endif
     607
    588608    /*
    589609     * Find the session.
     
    651671#if defined(VBOX_STRICT) || defined(VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV)
    652672    if (RT_UNLIKELY(!(ASMGetFlags() & X86_EFL_AC)))
    653         SUPR0Printf("VBoxDrvDarwinIOCtlSMAP: someone cleared AC handling iCmd=%#lx\n", iCmd);
     673        supdrvBadContext(&g_DevExt, "SUPDrv-darwin.cpp",  __LINE__, "VBoxDrvDarwinIOCtlSMAP");
    654674#endif
    655675    ASMSetFlags(fSavedEfl);
     
    14351455RTDECL(int) SUPR0Printf(const char *pszFormat, ...)
    14361456{
     1457    IPRT_DARWIN_SAVE_EFL_AC();
    14371458    va_list     va;
    14381459    char        szMsg[512];
     
    14441465
    14451466    printf("%s", szMsg);
     1467
     1468    IPRT_DARWIN_RESTORE_EFL_AC();
    14461469    return 0;
    14471470}
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