VirtualBox

Changeset 57109 in vbox


Ignore:
Timestamp:
Jul 28, 2015 11:50:17 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101837
Message:

VMM: Check AC during ring-0 module and VM init when the host has SMAP enabled.

Location:
trunk
Files:
5 edited

Legend:

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

    r57055 r57109  
    11731173/** HM returned in the wrong state. */
    11741174#define VERR_VMM_WRONG_HM_VMCPU_STATE       (-2716)
     1175/** SMAP enabled, but the AC flag was found to be clear - check the kernel
     1176 * log for details. */
     1177#define VERR_VMM_SMAP_BUT_AC_CLEAR          (-2717)
    11751178/** @} */
    11761179
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r56706 r57109  
    12361236    }
    12371237
    1238     pVM->hm.s.uHostKernelFeatures = SUPR0GetKernelFeatures();
     1238    pVM->hm.s.fHostKernelFeatures = SUPR0GetKernelFeatures();
    12391239
    12401240    /*
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r56837 r57109  
    31113111            pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_SEL_TR;
    31123112            /* If the host has made GDT read-only, we would need to temporarily toggle CR0.WP before writing the GDT. */
    3113             if (pVM->hm.s.uHostKernelFeatures & SUPKERNELFEATURES_GDT_READ_ONLY)
     3113            if (pVM->hm.s.fHostKernelFeatures & SUPKERNELFEATURES_GDT_READ_ONLY)
    31143114                pVCpu->hm.s.vmx.fRestoreHostFlags |= VMX_RESTORE_HOST_GDT_READ_ONLY;
    31153115            pVCpu->hm.s.vmx.RestoreHost.uHostSelTR = uSelTR;
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r56766 r57109  
    6363
    6464/*******************************************************************************
     65*   Defined Constants And Macros                                               *
     66*******************************************************************************/
     67/** SMAP check setup. */
     68#define VMM_CHECK_SMAP_SETUP() uint32_t const fKernelFeatures = SUPR0GetKernelFeatures()
     69/** Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it
     70 * will be logged and @a a_BadExpr is executed. */
     71#define VMM_CHECK_SMAP_CHECK(a_BadExpr) \
     72    do { \
     73        if (fKernelFeatures & SUPKERNELFEATURES_SMAP) \
     74        { \
     75            RTCCUINTREG uEFlags = ASMGetFlags(); \
     76            if (RT_LIKELY(uEFlags & X86_EFL_AC)) \
     77            { /* likely */ } \
     78            else \
     79            { \
     80                SUPR0Printf("%s, line %d: EFLAGS.AC is clear! (%#x)\n", __FUNCTION__, __LINE__, (uint32_t)uEFlags); \
     81                a_BadExpr; \
     82            } \
     83        } \
     84    } while (0)
     85/** Checks that the AC flag is set if SMAP is enabled.  If AC is not set, it
     86 * will be logged, written to the VMs assertion text buffer, and @a a_BadExpr is
     87 * executed. */
     88#define VMM_CHECK_SMAP_CHECK2(a_pVM, a_BadExpr) \
     89    VMM_CHECK_SMAP_CHECK( \
     90        RTStrPrintf(pVM->vmm.s.szRing0AssertMsg1, sizeof(pVM->vmm.s.szRing0AssertMsg1), \
     91                    "%s, line %d: EFLAGS.AC is clear! (%#x)\n", __FUNCTION__, __LINE__, (uint32_t)uEFlags); \
     92        a_BadExpr)
     93
     94
     95/*******************************************************************************
    6596*   Internal Functions                                                         *
    6697*******************************************************************************/
     
    106137DECLEXPORT(int) ModuleInit(void *hMod)
    107138{
     139    VMM_CHECK_SMAP_SETUP();
     140    VMM_CHECK_SMAP_CHECK(RT_NOTHING);
     141
    108142#ifdef VBOX_WITH_DTRACE_R0
    109143    /*
     
    133167    if (RT_SUCCESS(rc))
    134168    {
     169        VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    135170        rc = GVMMR0Init();
    136171        if (RT_SUCCESS(rc))
    137172        {
     173            VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    138174            rc = GMMR0Init();
    139175            if (RT_SUCCESS(rc))
    140176            {
     177                VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    141178                rc = HMR0Init();
    142179                if (RT_SUCCESS(rc))
    143180                {
     181                    VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    144182                    rc = PGMRegisterStringFormatTypes();
    145183                    if (RT_SUCCESS(rc))
    146184                    {
     185                        VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    147186#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    148187                        rc = PGMR0DynMapInit();
     
    150189                        if (RT_SUCCESS(rc))
    151190                        {
     191                            VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    152192                            rc = IntNetR0Init();
    153193                            if (RT_SUCCESS(rc))
    154194                            {
    155195#ifdef VBOX_WITH_PCI_PASSTHROUGH
     196                                VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    156197                                rc = PciRawR0Init();
    157198#endif
    158199                                if (RT_SUCCESS(rc))
    159200                                {
     201                                    VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    160202                                    rc = CPUMR0ModuleInit();
    161203                                    if (RT_SUCCESS(rc))
    162204                                    {
    163205#ifdef VBOX_WITH_TRIPLE_FAULT_HACK
     206                                        VMM_CHECK_SMAP_CHECK(RT_NOTHING);
    164207                                        rc = vmmR0TripleFaultHackInit();
    165208                                        if (RT_SUCCESS(rc))
    166209#endif
    167210                                        {
    168                                             LogFlow(("ModuleInit: returns success.\n"));
    169                                             return VINF_SUCCESS;
     211                                            VMM_CHECK_SMAP_CHECK(rc = VERR_VMM_SMAP_BUT_AC_CLEAR);
     212                                            if (RT_SUCCESS(rc))
     213                                            {
     214                                                LogFlow(("ModuleInit: returns success.\n"));
     215                                                return VINF_SUCCESS;
     216                                            }
    170217                                        }
    171218
     
    281328static int vmmR0InitVM(PVM pVM, uint32_t uSvnRev, uint32_t uBuildType)
    282329{
     330    VMM_CHECK_SMAP_SETUP();
     331    VMM_CHECK_SMAP_CHECK(return VERR_VMM_SMAP_BUT_AC_CLEAR);
     332
    283333    /*
    284334     * Match the SVN revisions and build type.
     
    356406     * Initialize the per VM data for GVMM and GMM.
    357407     */
     408    VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    358409    int rc = GVMMR0InitVM(pVM);
    359410//    if (RT_SUCCESS(rc))
     
    364415         * Init HM, CPUM and PGM (Darwin only).
    365416         */
     417        VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    366418        rc = HMR0InitVM(pVM);
     419        if (RT_SUCCESS(rc))
     420            VMM_CHECK_SMAP_CHECK2(pVM, rc = VERR_VMM_RING0_ASSERTION); /* CPUR0InitVM will otherwise panic the host */
    367421        if (RT_SUCCESS(rc))
    368422        {
     
    370424            if (RT_SUCCESS(rc))
    371425            {
     426                VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    372427#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    373428                rc = PGMR0DynMapInitVM(pVM);
     
    375430                if (RT_SUCCESS(rc))
    376431                {
     432                    VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    377433#ifdef VBOX_WITH_PCI_PASSTHROUGH
    378434                    rc = PciRawR0InitVM(pVM);
     
    380436                    if (RT_SUCCESS(rc))
    381437                    {
     438                        VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
    382439                        rc = GIMR0InitVM(pVM);
    383440                        if (RT_SUCCESS(rc))
    384441                        {
    385                             GVMMR0DoneInitVM(pVM);
    386                             return rc;
     442                            VMM_CHECK_SMAP_CHECK2(pVM, rc = VERR_VMM_RING0_ASSERTION);
     443                            if (RT_SUCCESS(rc))
     444                            {
     445                                GVMMR0DoneInitVM(pVM);
     446                                VMM_CHECK_SMAP_CHECK2(pVM, RT_NOTHING);
     447                                return rc;
     448                            }
     449
     450                            /* bail out*/
     451                            GIMR0TermVM(pVM);
    387452                        }
    388 
    389                         /* bail out*/
    390453#ifdef VBOX_WITH_PCI_PASSTHROUGH
    391454                        PciRawR0TermVM(pVM);
     
    397460        }
    398461    }
    399 
    400462
    401463    RTLogSetDefaultInstanceThread(NULL, (uintptr_t)pVM->pSession);
  • trunk/src/VBox/VMM/include/HMInternal.h

    r56716 r57109  
    369369
    370370    /** Host kernel flags that HM might need to know (SUPKERNELFEATURES_XXX). */
    371     uint32_t                    uHostKernelFeatures;
     371    uint32_t                    fHostKernelFeatures;
    372372
    373373    /** Maximum ASID allowed. */
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