VirtualBox

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


Ignore:
Timestamp:
Mar 7, 2024 9:36:08 AM (12 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
162088
Message:

VMM/PGM: Nested VMX: bugref:10607 Fixed getting shadow page when the guest paging mode (SLAT) is EPT.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllShw.h

    r99748 r103720  
    448448
    449449# elif PGM_SHW_TYPE == PGM_TYPE_EPT
    450     /*
    451      * We're currently ASSUMING that the SLAT mode here is always "direct".
    452      * If a guest (e.g., nested Hyper-V) turns out to require this
    453      * (probably while modifying shadow non-MMIO2 pages) then handle this
    454      * by calling (NestedGetPage). Asserting for now.
    455      */
    456     Assert(pVCpu->pgm.s.enmGuestSlatMode == PGMSLAT_DIRECT);
    457     PEPTPD          pPDDst;
    458     int rc = pgmShwGetEPTPDPtr(pVCpu, GCPtr, NULL, &pPDDst);
    459     if (rc == VINF_SUCCESS) /** @todo this function isn't expected to return informational status codes. Check callers / fix. */
    460     { /* likely */ }
     450    EPTPDE Pde;
     451    const unsigned iPd = ((GCPtr >> SHW_PD_SHIFT) & SHW_PD_MASK);
     452
     453    if (pVCpu->pgm.s.enmGuestSlatMode == PGMSLAT_DIRECT)
     454    {
     455        PEPTPD pPDDst;
     456        int rc = pgmShwGetEPTPDPtr(pVCpu, GCPtr, NULL, &pPDDst);
     457        if (rc == VINF_SUCCESS) /** @todo this function isn't expected to return informational status codes. Check callers / fix. */
     458        { /* likely */ }
     459        else
     460        {
     461            AssertRC(rc);
     462            return rc;
     463        }
     464        Assert(pPDDst);
     465        Pde = pPDDst->a[iPd];
     466    }
    461467    else
    462468    {
    463         AssertRC(rc);
    464         return rc;
    465     }
    466     Assert(pPDDst);
    467 
    468     const unsigned  iPd = ((GCPtr >> SHW_PD_SHIFT) & SHW_PD_MASK);
    469     EPTPDE Pde = pPDDst->a[iPd];
     469#  ifdef VBOX_WITH_NESTED_HWVIRT_VMX_EPT
     470        Assert(pVCpu->pgm.s.enmGuestSlatMode == PGMSLAT_EPT);
     471        Assert(!(GCPtr & GUEST_PAGE_OFFSET_MASK));
     472        PGMPTWALK      Walk;
     473        PGMPTWALKGST   GstWalkAll;
     474        RTGCPHYS const GCPhysNestedPage = GCPtr;
     475        int rc = pgmGstSlatWalk(pVCpu, GCPhysNestedPage, false /*fIsLinearAddrValid*/, 0 /*GCPtrNestedFault*/, &Walk,
     476                                &GstWalkAll);
     477        if (RT_SUCCESS(rc))
     478        {
     479#   ifdef DEBUG_ramshankar
     480            /* Paranoia. */
     481            Assert(GstWalkAll.enmType == PGMPTWALKGSTTYPE_EPT);
     482            Assert(Walk.fSucceeded);
     483            Assert(Walk.fEffective & (PGM_PTATTRS_EPT_R_MASK | PGM_PTATTRS_EPT_W_MASK | PGM_PTATTRS_EPT_X_SUPER_MASK));
     484            Assert(Walk.fIsSlat);
     485            Assert(RT_BOOL(Walk.fEffective & PGM_PTATTRS_R_MASK)  ==  RT_BOOL(Walk.fEffective & PGM_PTATTRS_EPT_R_MASK));
     486            Assert(RT_BOOL(Walk.fEffective & PGM_PTATTRS_W_MASK)  ==  RT_BOOL(Walk.fEffective & PGM_PTATTRS_EPT_W_MASK));
     487            Assert(RT_BOOL(Walk.fEffective & PGM_PTATTRS_NX_MASK) == !RT_BOOL(Walk.fEffective & PGM_PTATTRS_EPT_X_SUPER_MASK));
     488#   endif
     489            PGM_A20_ASSERT_MASKED(pVCpu, Walk.GCPhys);
     490
     491            /* Update the nested-guest physical address with the translated guest-physical address. */
     492            GCPtr = Walk.GCPhys;
     493
     494            /* Get the PD. */
     495            PSHWPD pEptPd;
     496            rc = pgmShwGetNestedEPTPDPtr(pVCpu, GCPhysNestedPage, NULL /*ppPdpt*/, &pEptPd, &GstWalkAll);
     497            AssertRCReturn(rc, rc);
     498            Assert(pEptPd);
     499
     500            Assert(iPd < EPT_PG_ENTRIES);
     501            Pde = pEptPd->a[iPd];
     502        }
     503        else
     504        {
     505            Log(("Failed to translate nested-guest physical address %#RGp rc=%Rrc\n", GCPhysNestedPage, rc));
     506            return rc;
     507        }
     508
     509#  else  /* !VBOX_WITH_NESTED_HWVIRT_VMX_EPT */
     510        AssertFailed();
     511        return VERR_PGM_SHW_NONE_IPE;
     512#  endif /* !VBOX_WITH_NESTED_HWVIRT_VMX_EPT */
     513    }
    470514
    471515# elif PGM_SHW_TYPE == PGM_TYPE_32BIT || PGM_SHW_TYPE == PGM_TYPE_NESTED_32BIT
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