VirtualBox

Changeset 91291 in vbox


Ignore:
Timestamp:
Sep 16, 2021 10:04:16 PM (3 years ago)
Author:
vboxsync
Message:

VMM/CPUM,++: Moved the nested SVM I/O permission bitmap allocation into CPUMCTX. bugref:10093

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.mac

    r91289 r91291  
    265265
    266266    alignb 4096
    267     .hwvirt.svm.Vmcb                   resb          4096
    268     .hwvirt.svm.abMsrBitmap            resb          8192
     267    .hwvirt.svm.Vmcb                    resb        4096
     268    .hwvirt.svm.abMsrBitmap             resb        8192
     269    .hwvirt.svm.abIoBitmap              resb        12288
    269270    .hwvirt.svm.uMsrHSavePa            resq          1
    270271    .hwvirt.svm.GCPhysVmcb             resq          1
     
    275276    .hwvirt.svm.cPauseFilterThreshold  resw          1
    276277    .hwvirt.svm.fInterceptEvents       resb          1
    277     alignb 8
    278     .hwvirt.svm.pvIoBitmapR0           RTR0PTR_RES   1
    279     alignb 8
    280     .hwvirt.svm.pvIoBitmapR3           RTR3PTR_RES   1
     278    ;.unnamed_padding.1 resb 0
    281279    alignb 8
    282280    .hwvirt.enmHwvirt                  resd          1
  • trunk/include/VBox/vmm/cpumctx.h

    r91289 r91291  
    508508                 * This one is just used for caching the bitmap from guest physical memory. */
    509509                uint8_t                 abMsrBitmap[0x2000];
    510 
    511                 /** 0x300 - MSR holding physical address of the Guest's Host-state. */
     510                /** 0x7000 - The IOPM (IO Permission bitmap).
     511                 *
     512                 * This need not be physically contiguous pages because we re-use the ring-0
     513                 * allocated IOPM while executing the nested-guest using hardware-assisted SVM
     514                 * because it's identical (we trap all IO accesses).
     515                 *
     516                 * This one is just used for caching the IOPM from guest physical memory in
     517                 * case the guest hypervisor allows direct access to some IO ports. */
     518                uint8_t                 abIoBitmap[0x3000];
     519
     520                /** 0xa000 - MSR holding physical address of the Guest's Host-state. */
    512521                uint64_t                uMsrHSavePa;
    513                 /** 0x308 - Guest physical address of the nested-guest VMCB. */
     522                /** 0xa008 - Guest physical address of the nested-guest VMCB. */
    514523                RTGCPHYS                GCPhysVmcb;
    515                 /** 0x320 - Guest's host-state save area. */
     524                /** 0xa010 - Guest's host-state save area. */
    516525                SVMHOSTSTATE            HostState;
    517                 /** 0x3d8 - Guest TSC time-stamp of when the previous PAUSE instr. was executed. */
     526                /** 0xa0c8 - Guest TSC time-stamp of when the previous PAUSE instr. was
     527                 *  executed. */
    518528                uint64_t                uPrevPauseTick;
    519                 /** 0x3e0 - Pause filter count. */
     529                /** 0xa0d0 - Pause filter count. */
    520530                uint16_t                cPauseFilter;
    521                 /** 0x3e2 - Pause filter threshold. */
     531                /** 0xa0d2 - Pause filter threshold. */
    522532                uint16_t                cPauseFilterThreshold;
    523                 /** 0x3e4 - Whether the injected event is subject to event intercepts. */
     533                /** 0xa0d4 - Whether the injected event is subject to event intercepts. */
    524534                bool                    fInterceptEvents;
    525                 /** 0x3e5 - Padding. */
     535                /** 0xa0d5 - Padding. */
    526536                bool                    afPadding[3];
    527                 /** 0x3f8 - IO permission bitmap - R0 ptr. */
    528                 R0PTRTYPE(void *)       pvIoBitmapR0;
    529                 /** 0x400 - IO permission bitmap - R3 ptr. */
    530                 R3PTRTYPE(void *)       pvIoBitmapR3;
    531537            } svm;
    532538
     
    631637#endif
    632638        /** 0x530 - Pad to 64 byte boundary. */
    633         uint8_t                 abPadding0[8];
     639        uint8_t                 abPadding0[8+16];
    634640    } hwvirt;
    635641} CPUMCTX;
     
    839845AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.Vmcb,                  4096);
    840846AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.abMsrBitmap,           4096);
    841 AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pvIoBitmapR0,          8);
     847AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.abIoBitmap,            4096);
    842848AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pVmcsR0,               8);
    843849AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pShadowVmcsR0,         8);
  • trunk/include/VBox/vmm/vm.h

    r91289 r91291  
    305305        CPUMCTX             GstCtx;
    306306#endif
    307         uint8_t             padding[49152];      /* multiple of 4096 */
     307        uint8_t             padding[61440];      /* multiple of 4096 */
    308308    } cpum;
    309309
  • trunk/include/VBox/vmm/vm.mac

    r91289 r91291  
    9191    .pgm                    resb 4096+28672
    9292    alignb 4096
    93     .cpum                   resb 49152
     93    .cpum                   resb 61440
    9494%define VMCPU.cpum.GstCtx   VMCPU.cpum
    9595    alignb 4096
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImplSvmInstr.cpp.h

    r91289 r91291  
    563563         * Copy the IO permission bitmap into the cache.
    564564         */
    565         Assert(pVCpu->cpum.GstCtx.hwvirt.svm.CTX_SUFF(pvIoBitmap));
    566         rc = PGMPhysSimpleReadGCPhys(pVM, pVCpu->cpum.GstCtx.hwvirt.svm.CTX_SUFF(pvIoBitmap), GCPhysIOBitmap,
    567                                      SVM_IOPM_PAGES * X86_PAGE_4K_SIZE);
     565        AssertCompile(sizeof(pVCpu->cpum.GstCtx.hwvirt.svm.abIoBitmap) == SVM_IOPM_PAGES * X86_PAGE_4K_SIZE);
     566        rc = PGMPhysSimpleReadGCPhys(pVM, pVCpu->cpum.GstCtx.hwvirt.svm.abIoBitmap, GCPhysIOBitmap,
     567                                     sizeof(pVCpu->cpum.GstCtx.hwvirt.svm.abIoBitmap));
    568568        if (RT_FAILURE(rc))
    569569        {
     
    989989
    990990    SVMIOIOEXITINFO IoExitInfo;
    991     void *pvIoBitmap = pVCpu->cpum.GstCtx.hwvirt.svm.CTX_SUFF(pvIoBitmap);
    992     bool const fIntercept = CPUMIsSvmIoInterceptSet(pvIoBitmap, u16Port, enmIoType, cbReg, cAddrSizeBits, iEffSeg, fRep,
    993                                                     fStrIo, &IoExitInfo);
     991    bool const fIntercept = CPUMIsSvmIoInterceptSet(pVCpu->cpum.GstCtx.hwvirt.svm.abMsrBitmap, u16Port, enmIoType, cbReg,
     992                                                    cAddrSizeBits, iEffSeg, fRep, fStrIo, &IoExitInfo);
    994993    if (fIntercept)
    995994    {
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r91289 r91291  
    49624962            if (CPUMIsGuestSvmCtrlInterceptSet(pVCpu, pCtx, SVM_CTRL_INTERCEPT_IOIO_PROT))
    49634963            {
    4964                 void *pvIoBitmap = pVCpu->cpum.GstCtx.hwvirt.svm.CTX_SUFF(pvIoBitmap);
    49654964                SVMIOIOEXITINFO IoExitInfo;
    49664965                IoExitInfo.u = pVmcbNstGst->ctrl.u64ExitInfo1;
    4967                 bool const fIntercept = hmR0SvmIsIoInterceptSet(pvIoBitmap, &IoExitInfo);
     4966                bool const fIntercept = hmR0SvmIsIoInterceptSet(pVCpu->cpum.GstCtx.hwvirt.svm.abIoBitmap, &IoExitInfo);
    49684967                if (fIntercept)
    49694968                    NST_GST_VMEXIT_CALL_RET(pVCpu, uExitCode, uExitInfo1, uExitInfo2);
  • trunk/src/VBox/VMM/VMMR3/CPUM.cpp

    r91289 r91291  
    10181018{
    10191019    Assert(pVM->cpum.s.GuestFeatures.fSvm);
    1020     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    1021     {
    1022         PVMCPU pVCpu = pVM->apCpusR3[i];
    1023 
    1024         if (pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR3)
    1025         {
    1026             SUPR3PageFreeEx(pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR3, SVM_IOPM_PAGES);
    1027             pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR3 = NULL;
    1028         }
    1029     }
     1020    RT_NOREF(pVM);
    10301021}
    10311022
     
    10511042        AssertCompile(SVM_VMCB_PAGES * X86_PAGE_SIZE == sizeof(pVCpu->cpum.s.Guest.hwvirt.svm.Vmcb));
    10521043        AssertCompile(SVM_MSRPM_PAGES * X86_PAGE_SIZE == sizeof(pVCpu->cpum.s.Guest.hwvirt.svm.abMsrBitmap));
    1053 
    1054         /*
    1055          * Allocate the IOPM (IO Permission bitmap).
    1056          *
    1057          * This need not be physically contiguous pages because we re-use the ring-0
    1058          * allocated IOPM while executing the nested-guest using hardware-assisted SVM
    1059          * because it's identical (we trap all IO accesses).
    1060          *
    1061          * This one is just used for caching the IOPM from guest physical memory in
    1062          * case the guest hypervisor allows direct access to some IO ports.
    1063          */
    1064         Assert(!pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR3);
    1065         rc = SUPR3PageAllocEx(SVM_IOPM_PAGES, 0 /* fFlags */, &pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR3,
    1066                               &pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR0, NULL /* paPages */);
    1067         if (RT_FAILURE(rc))
    1068         {
    1069             Assert(!pVCpu->cpum.s.Guest.hwvirt.svm.pvIoBitmapR3);
    1070             LogRel(("CPUM%u: Failed to alloc %u pages for the nested-guest's IO permission bitmap\n", pVCpu->idCpu,
    1071                     SVM_IOPM_PAGES));
    1072             break;
    1073         }
     1044        AssertCompile(SVM_IOPM_PAGES * X86_PAGE_SIZE == sizeof(pVCpu->cpum.s.Guest.hwvirt.svm.abIoBitmap));
    10741045    }
    10751046
     
    26312602            SSMR3PutMem(pSSM,   &pGstCtx->hwvirt.svm.Vmcb,           sizeof(pGstCtx->hwvirt.svm.Vmcb));
    26322603            SSMR3PutMem(pSSM,   &pGstCtx->hwvirt.svm.abMsrBitmap[0], sizeof(pGstCtx->hwvirt.svm.abMsrBitmap));
    2633             SSMR3PutMem(pSSM,    pGstCtx->hwvirt.svm.pvIoBitmapR3,  SVM_IOPM_PAGES  << X86_PAGE_4K_SHIFT);
     2604            SSMR3PutMem(pSSM,   &pGstCtx->hwvirt.svm.abIoBitmap[0],  sizeof(pGstCtx->hwvirt.svm.abIoBitmap));
    26342605            SSMR3PutU32(pSSM,    pGstCtx->hwvirt.fLocalForcedActions);
    26352606            SSMR3PutBool(pSSM,   pGstCtx->hwvirt.fGif);
     
    29152886                        SSMR3GetStructEx(pSSM, &pGstCtx->hwvirt.svm.HostState, sizeof(pGstCtx->hwvirt.svm.HostState),
    29162887                                         0 /* fFlags */, g_aSvmHwvirtHostState, NULL /* pvUser */);
    2917                         SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.svm.Vmcb,          sizeof(pGstCtx->hwvirt.svm.Vmcb));
     2888                        SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.svm.Vmcb,           sizeof(pGstCtx->hwvirt.svm.Vmcb));
    29182889                        SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.svm.abMsrBitmap[0], sizeof(pGstCtx->hwvirt.svm.abMsrBitmap));
    2919                         SSMR3GetMem(pSSM,       pGstCtx->hwvirt.svm.pvIoBitmapR3,  SVM_IOPM_PAGES  << X86_PAGE_4K_SHIFT);
     2890                        SSMR3GetMem(pSSM,      &pGstCtx->hwvirt.svm.abIoBitmap[0],  sizeof(pGstCtx->hwvirt.svm.abIoBitmap));
    29202891                        SSMR3GetU32(pSSM,      &pGstCtx->hwvirt.fLocalForcedActions);
    29212892                        SSMR3GetBool(pSSM,     &pGstCtx->hwvirt.fGif);
     
    41344105        pHlp->pfnPrintf(pHlp, "  cPauseFilterThreshold      = %RU32\n",     pCtx->hwvirt.svm.cPauseFilterThreshold);
    41354106        pHlp->pfnPrintf(pHlp, "  fInterceptEvents           = %u\n",        pCtx->hwvirt.svm.fInterceptEvents);
    4136         pHlp->pfnPrintf(pHlp, "  pvIoBitmapR3               = %p\n",        pCtx->hwvirt.svm.pvIoBitmapR3);
    4137         pHlp->pfnPrintf(pHlp, "  pvIoBitmapR0               = %RKv\n",      pCtx->hwvirt.svm.pvIoBitmapR0);
    41384107    }
    41394108    else if (fVmx)
  • trunk/src/VBox/VMM/include/CPUMInternal.mac

    r91289 r91291  
    233233    .Guest.hwvirt.svm.Vmcb                  resb        4096
    234234    .Guest.hwvirt.svm.abMsrBitmap           resb        8192
     235    .Guest.hwvirt.svm.abIoBitmap            resb        12288
    235236    .Guest.hwvirt.svm.uMsrHSavePa            resq         1
    236237    .Guest.hwvirt.svm.GCPhysVmcb             resq         1
     
    241242    .Guest.hwvirt.svm.cPauseFilterThreshold  resw         1
    242243    .Guest.hwvirt.svm.fInterceptEvents       resb         1
    243     alignb 8
    244     .Guest.hwvirt.svm.pvIoBitmapR0           RTR0PTR_RES  1
    245     alignb 8
    246     .Guest.hwvirt.svm.pvIoBitmapR3           RTR3PTR_RES  1
    247244
    248245    ;.unnamed_padding.1 resb 0
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r91289 r91291  
    130130    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.Vmcb);
    131131    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.abMsrBitmap);
     132    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.abIoBitmap);
    132133    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.uMsrHSavePa);
    133134    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.GCPhysVmcb);
     
    137138    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.cPauseFilterThreshold);
    138139    GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.fInterceptEvents);
    139     GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.pvIoBitmapR0);
    140     GEN_CHECK_OFF(CPUMCTX, hwvirt.svm.pvIoBitmapR3);
    141140    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.GCPhysVmxon);
    142141    GEN_CHECK_OFF(CPUMCTX, hwvirt.vmx.GCPhysVmcs);
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r91290 r91291  
    251251    CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.svm.Vmcb, 4096);
    252252    CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.svm.abMsrBitmap, 4096);
     253    CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.svm.abIoBitmap, 4096);
    253254
    254255    PVM pVM = NULL; NOREF(pVM);
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