VirtualBox

Changeset 91304 in vbox for trunk/src


Ignore:
Timestamp:
Sep 17, 2021 8:43:17 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146964
Message:

VMM/CPUM,++: Moved the nested VT-X MSR permission bitmap allocations into CPUMCTX. bugref:10093

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

Legend:

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

    r91301 r91304  
    67546754        /* Read the MSR bitmap. */
    67556755        RTGCPHYS const GCPhysMsrBitmap = pVmcs->u64AddrMsrBitmap.u;
    6756         Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap));
    6757         int rc = PGMPhysSimpleReadGCPhys(pVCpu->CTX_SUFF(pVM), pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap),
    6758                                          GCPhysMsrBitmap, VMX_V_MSR_BITMAP_SIZE);
     6756        int rc = PGMPhysSimpleReadGCPhys(pVCpu->CTX_SUFF(pVM), &pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap[0],
     6757                                         GCPhysMsrBitmap, sizeof(pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap));
    67596758        if (RT_SUCCESS(rc))
    67606759        { /* likely */ }
     
    74477446    if (pVmcs->u32ProcCtls & VMX_PROC_CTLS_USE_MSR_BITMAPS)
    74487447    {
    7449         Assert(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap));
    7450         uint32_t const fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), idMsr);
     7448        uint32_t const fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap, idMsr);
    74517449        if (uExitReason == VMX_EXIT_RDMSR)
    74527450            return RT_BOOL(fMsrpm & VMXMSRPM_EXIT_RD);
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r91297 r91304  
    21272127 *
    21282128 * @returns @c true if the MSR is intercepted, @c false otherwise.
    2129  * @param   pvMsrBitmap     The MSR bitmap.
     2129 * @param   pbMsrBitmap     The MSR bitmap.
    21302130 * @param   offMsr          The MSR byte offset.
    21312131 * @param   iBit            The bit offset from the byte offset.
    21322132 */
    2133 DECLINLINE(bool) hmR0VmxIsMsrBitSet(const void *pvMsrBitmap, uint16_t offMsr, int32_t iBit)
    2134 {
    2135     uint8_t const * const pbMsrBitmap = (uint8_t const * const)pvMsrBitmap;
    2136     Assert(pbMsrBitmap);
     2133DECLINLINE(bool) hmR0VmxIsMsrBitSet(uint8_t const *pbMsrBitmap, uint16_t offMsr, int32_t iBit)
     2134{
    21372135    Assert(offMsr + (iBit >> 3) <= X86_PAGE_4K_SIZE);
    21382136    return ASMBitTest(pbMsrBitmap + offMsr, iBit);
     
    22042202#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    22052203        bool const fClear = !fIsNstGstVmcs ? true
    2206                           : !hmR0VmxIsMsrBitSet(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), offMsrRead, iBit);
     2204                          : !hmR0VmxIsMsrBitSet(pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap, offMsrRead, iBit);
    22072205#else
    22082206        RT_NOREF2(pVCpu, fIsNstGstVmcs);
     
    22242222#ifdef VBOX_WITH_NESTED_HWVIRT_VMX
    22252223        bool const fClear = !fIsNstGstVmcs ? true
    2226                           : !hmR0VmxIsMsrBitSet(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), offMsrWrite, iBit);
     2224                          : !hmR0VmxIsMsrBitSet(pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap, offMsrWrite, iBit);
    22272225#else
    22282226        RT_NOREF2(pVCpu, fIsNstGstVmcs);
     
    28402838                     * allow passthrough too.
    28412839                     */
    2842                     void const *pvMsrBitmapNstGst = pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap);
     2840                    void const *pvMsrBitmapNstGst = pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap;
    28432841                    Assert(pvMsrBitmapNstGst);
    28442842                    uint32_t const fMsrpmNstGst = CPUMGetVmxMsrPermission(pvMsrBitmapNstGst, pGuestMsrLoad->u32Msr);
     
    1042210420    if (pVmcsNstGst->u32ProcCtls & VMX_PROC_CTLS_USE_MSR_BITMAPS)
    1042310421    {
    10424         uint64_t const *pu64MsrBitmapNstGst = (uint64_t const *)pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap);
     10422        uint64_t const *pu64MsrBitmapNstGst = (uint64_t const *)&pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap[0];
    1042510423        uint64_t const *pu64MsrBitmapGst    = (uint64_t const *)pVmcsInfoGst->pvMsrBitmap;
    1042610424        Assert(pu64MsrBitmapNstGst);
     
    1732517323    uint32_t fMsrpm;
    1732617324    if (CPUMIsGuestVmxProcCtlsSet(&pVCpu->cpum.GstCtx, VMX_PROC_CTLS_USE_MSR_BITMAPS))
    17327         fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), pVCpu->cpum.GstCtx.ecx);
     17325        fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap, pVCpu->cpum.GstCtx.ecx);
    1732817326    else
    1732917327        fMsrpm = VMXMSRPM_EXIT_RD;
     
    1734717345    uint32_t fMsrpm;
    1734817346    if (CPUMIsGuestVmxProcCtlsSet(&pVCpu->cpum.GstCtx, VMX_PROC_CTLS_USE_MSR_BITMAPS))
    17349         fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.CTX_SUFF(pvMsrBitmap), pVCpu->cpum.GstCtx.ecx);
     17347        fMsrpm = CPUMGetVmxMsrPermission(pVCpu->cpum.GstCtx.hwvirt.vmx.abMsrBitmap, pVCpu->cpum.GstCtx.ecx);
    1735017348    else
    1735117349        fMsrpm = VMXMSRPM_EXIT_WR;
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r91301 r91304  
    10671067            pCtx->hwvirt.vmx.pvVirtApicPageR3 = NULL;
    10681068        }
    1069         if (pCtx->hwvirt.vmx.pvMsrBitmapR3)
    1070         {
    1071             SUPR3ContFree(pCtx->hwvirt.vmx.pvMsrBitmapR3, VMX_V_MSR_BITMAP_PAGES);
    1072             pCtx->hwvirt.vmx.pvMsrBitmapR3 = NULL;
    1073         }
    10741069        if (pCtx->hwvirt.vmx.pvIoBitmapR3)
    10751070        {
     
    11181113        AssertCompile(sizeof(pCtx->hwvirt.vmx.aExitMsrLoadArea) == VMX_V_AUTOMSR_AREA_PAGES * X86_PAGE_SIZE);
    11191114        AssertCompile(sizeof(pCtx->hwvirt.vmx.aExitMsrLoadArea) == VMX_V_AUTOMSR_AREA_SIZE);
     1115        AssertCompile(sizeof(pCtx->hwvirt.vmx.abMsrBitmap) == VMX_V_MSR_BITMAP_PAGES * X86_PAGE_SIZE);
     1116        AssertCompile(sizeof(pCtx->hwvirt.vmx.abMsrBitmap) == VMX_V_MSR_BITMAP_SIZE);
    11201117
    11211118        /*
     
    11351132
    11361133        /*
    1137          * Allocate the MSR bitmap.
    1138          */
    1139         pCtx->hwvirt.vmx.pvMsrBitmapR3 = SUPR3ContAlloc(VMX_V_MSR_BITMAP_PAGES, &pCtx->hwvirt.vmx.pvMsrBitmapR0, NULL);
    1140         if (pCtx->hwvirt.vmx.pvMsrBitmapR3)
    1141         { /* likely */ }
    1142         else
    1143         {
    1144             LogRel(("CPUM%u: Failed to alloc %u pages for the nested-guest's MSR bitmap\n", pVCpu->idCpu,
    1145                     VMX_V_MSR_BITMAP_PAGES));
    1146             break;
    1147         }
    1148 
    1149         /*
    11501134         * Allocate the I/O bitmaps (A and B).
    11511135         */
     
    11641148         * Zero out all allocated pages (should compress well for saved-state).
    11651149         */
     1150        /** @todo this is and always was unnecessary - they are already zeroed. */
    11661151        RT_ZERO(pCtx->hwvirt.vmx.Vmcs);
    11671152        RT_ZERO(pCtx->hwvirt.vmx.ShadowVmcs);
     
    11711156        RT_ZERO(pCtx->hwvirt.vmx.aExitMsrStoreArea);
    11721157        RT_ZERO(pCtx->hwvirt.vmx.aExitMsrLoadArea);
    1173         memset(pCtx->hwvirt.vmx.CTX_SUFF(pvMsrBitmap),         0, VMX_V_MSR_BITMAP_SIZE);
     1158        RT_ZERO(pCtx->hwvirt.vmx.abMsrBitmap);
    11741159        memset(pCtx->hwvirt.vmx.CTX_SUFF(pvIoBitmap),          0, VMX_V_IO_BITMAP_A_SIZE + VMX_V_IO_BITMAP_B_SIZE);
    11751160        memset(pCtx->hwvirt.vmx.CTX_SUFF(pvVirtApicPage),      0, VMX_V_VIRT_APIC_SIZE);
     
    24852470            SSMR3PutMem(pSSM,     &pGstCtx->hwvirt.vmx.aExitMsrStoreArea[0], sizeof(pGstCtx->hwvirt.vmx.aExitMsrStoreArea));
    24862471            SSMR3PutMem(pSSM,     &pGstCtx->hwvirt.vmx.aExitMsrLoadArea[0],  sizeof(pGstCtx->hwvirt.vmx.aExitMsrLoadArea));
    2487             SSMR3PutMem(pSSM,      pGstCtx->hwvirt.vmx.pvMsrBitmapR3, VMX_V_MSR_BITMAP_SIZE);
     2472            SSMR3PutMem(pSSM,     &pGstCtx->hwvirt.vmx.abMsrBitmap[0],       sizeof(pGstCtx->hwvirt.vmx.abMsrBitmap));
    24882473            SSMR3PutMem(pSSM,      pGstCtx->hwvirt.vmx.pvIoBitmapR3, VMX_V_IO_BITMAP_A_SIZE + VMX_V_IO_BITMAP_B_SIZE);
    24892474            SSMR3PutU64(pSSM,      pGstCtx->hwvirt.vmx.uFirstPauseLoopTick);
     
    27752760                        SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.vmx.aExitMsrStoreArea[0], sizeof(pGstCtx->hwvirt.vmx.aExitMsrStoreArea));
    27762761                        SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.vmx.aExitMsrLoadArea[0],  sizeof(pGstCtx->hwvirt.vmx.aExitMsrLoadArea));
    2777                         SSMR3GetMem(pSSM,       pGstCtx->hwvirt.vmx.pvMsrBitmapR3, VMX_V_MSR_BITMAP_SIZE);
     2762                        SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.vmx.abMsrBitmap[0],       sizeof(pGstCtx->hwvirt.vmx.abMsrBitmap));
    27782763                        SSMR3GetMem(pSSM,       pGstCtx->hwvirt.vmx.pvIoBitmapR3, VMX_V_IO_BITMAP_A_SIZE + VMX_V_IO_BITMAP_B_SIZE);
    27792764                        SSMR3GetU64(pSSM,      &pGstCtx->hwvirt.vmx.uFirstPauseLoopTick);
  • trunk/src/VBox/VMM/include/CPUMInternal.mac

    r91301 r91304  
    255255    .Guest.hwvirt.vmx.aExitMsrStoreArea     resb        0x2000
    256256    .Guest.hwvirt.vmx.aExitMsrLoadArea      resb        0x2000
     257    .Guest.hwvirt.vmx.abMsrBitmap           resb        0x1000
    257258    alignb 8
    258259    .Guest.hwvirt.vmx.GCPhysVmxon           resq        1
     
    269270    .Guest.hwvirt.vmx.pvVirtApicPageR0      resq        1
    270271    .Guest.hwvirt.vmx.pvVirtApicPageR3      resq        1
    271     .Guest.hwvirt.vmx.pvMsrBitmapR0         resq        1
    272     .Guest.hwvirt.vmx.pvMsrBitmapR3         resq        1
    273272    .Guest.hwvirt.vmx.pvIoBitmapR0          resq        1
    274273    .Guest.hwvirt.vmx.pvIoBitmapR3          resq        1
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r91301 r91304  
    150150    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvVirtApicPageR0);
    151151    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvVirtApicPageR3);
    152     GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvMsrBitmapR0);
    153     GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvMsrBitmapR3);
    154152    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvIoBitmapR0);
    155153    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.pvIoBitmapR3);
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r91301 r91304  
    259259    CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.aExitMsrStoreArea, 4096);
    260260    CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.aExitMsrLoadArea, 4096);
     261    CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.abMsrBitmap, 4096);
    261262
    262263    PVM pVM = NULL; NOREF(pVM);
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