VirtualBox

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


Ignore:
Timestamp:
Jun 3, 2009 2:54:22 PM (16 years ago)
Author:
vboxsync
Message:

AMD-V: Host VMCB must also be per-VCPU

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r20142 r20234  
    346346        bool                        padding[1];
    347347
    348         /** R0 memory object for the host VM control block (VMCB). */
    349         RTR0MEMOBJ                  pMemObjVMCBHost;
    350         /** Physical address of the host VM control block (VMCB). */
    351         RTHCPHYS                    pVMCBHostPhys;
    352         /** Virtual address of the host VM control block (VMCB). */
    353         R0PTRTYPE(void *)           pVMCBHost;
    354 
    355348        /** R0 memory object for the IO bitmap (12kb). */
    356349        RTR0MEMOBJ                  pMemObjIOBitmap;
     
    544537    struct
    545538    {
     539        /** R0 memory object for the host VM control block (VMCB). */
     540        RTR0MEMOBJ                  pMemObjVMCBHost;
     541        /** Physical address of the host VM control block (VMCB). */
     542        RTHCPHYS                    pVMCBHostPhys;
     543        /** Virtual address of the host VM control block (VMCB). */
     544        R0PTRTYPE(void *)           pVMCBHost;
     545
    546546        /** R0 memory object for the VM control block (VMCB). */
    547547        RTR0MEMOBJ                  pMemObjVMCB;
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r20222 r20234  
    128128    int rc;
    129129
    130     pVM->hwaccm.s.svm.pMemObjVMCBHost = NIL_RTR0MEMOBJ;
    131130    pVM->hwaccm.s.svm.pMemObjIOBitmap = NIL_RTR0MEMOBJ;
    132131    pVM->hwaccm.s.svm.pMemObjMSRBitmap = NIL_RTR0MEMOBJ;
    133 
    134     /* Allocate one page for the host context */
    135     rc = RTR0MemObjAllocCont(&pVM->hwaccm.s.svm.pMemObjVMCBHost, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
    136     if (RT_FAILURE(rc))
    137         return rc;
    138 
    139     pVM->hwaccm.s.svm.pVMCBHost     = RTR0MemObjAddress(pVM->hwaccm.s.svm.pMemObjVMCBHost);
    140     pVM->hwaccm.s.svm.pVMCBHostPhys = RTR0MemObjGetPagePhysAddr(pVM->hwaccm.s.svm.pMemObjVMCBHost, 0);
    141     ASMMemZeroPage(pVM->hwaccm.s.svm.pVMCBHost);
    142132
    143133    /* Allocate 12 KB for the IO bitmap (doesn't seem to be a way to convince SVM not to use it) */
     
    195185    for (unsigned i=0;i<pVM->cCPUs;i++)
    196186    {
    197         pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB = NIL_RTR0MEMOBJ;
    198 
    199         /* Allocate one page for the VM control block (VMCB). */
    200         rc = RTR0MemObjAllocCont(&pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
     187        PVMCPU pVCpu = &pVM->aCpus[i];
     188
     189        pVCpu->hwaccm.s.svm.pMemObjVMCBHost = NIL_RTR0MEMOBJ;
     190        pVCpu->hwaccm.s.svm.pMemObjVMCB     = NIL_RTR0MEMOBJ;
     191
     192        /* Allocate one page for the host context */
     193        rc = RTR0MemObjAllocCont(&pVCpu->hwaccm.s.svm.pMemObjVMCBHost, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
    201194        if (RT_FAILURE(rc))
    202195            return rc;
    203196
    204         pVM->aCpus[i].hwaccm.s.svm.pVMCB     = RTR0MemObjAddress(pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB);
    205         pVM->aCpus[i].hwaccm.s.svm.pVMCBPhys = RTR0MemObjGetPagePhysAddr(pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB, 0);
    206         ASMMemZeroPage(pVM->aCpus[i].hwaccm.s.svm.pVMCB);
     197        pVCpu->hwaccm.s.svm.pVMCBHost     = RTR0MemObjAddress(pVCpu->hwaccm.s.svm.pMemObjVMCBHost);
     198        pVCpu->hwaccm.s.svm.pVMCBHostPhys = RTR0MemObjGetPagePhysAddr(pVCpu->hwaccm.s.svm.pMemObjVMCBHost, 0);
     199        ASMMemZeroPage(pVCpu->hwaccm.s.svm.pVMCBHost);
     200
     201        /* Allocate one page for the VM control block (VMCB). */
     202        rc = RTR0MemObjAllocCont(&pVCpu->hwaccm.s.svm.pMemObjVMCB, 1 << PAGE_SHIFT, true /* executable R0 mapping */);
     203        if (RT_FAILURE(rc))
     204            return rc;
     205
     206        pVCpu->hwaccm.s.svm.pVMCB     = RTR0MemObjAddress(pVCpu->hwaccm.s.svm.pMemObjVMCB);
     207        pVCpu->hwaccm.s.svm.pVMCBPhys = RTR0MemObjGetPagePhysAddr(pVCpu->hwaccm.s.svm.pMemObjVMCB, 0);
     208        ASMMemZeroPage(pVCpu->hwaccm.s.svm.pVMCB);
    207209    }
    208210
     
    220222    for (unsigned i=0;i<pVM->cCPUs;i++)
    221223    {
    222         if (pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB != NIL_RTR0MEMOBJ)
    223         {
    224             RTR0MemObjFree(pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB, false);
    225             pVM->aCpus[i].hwaccm.s.svm.pVMCB       = 0;
    226             pVM->aCpus[i].hwaccm.s.svm.pVMCBPhys   = 0;
    227             pVM->aCpus[i].hwaccm.s.svm.pMemObjVMCB = NIL_RTR0MEMOBJ;
    228         }
    229     }
    230     if (pVM->hwaccm.s.svm.pMemObjVMCBHost != NIL_RTR0MEMOBJ)
    231     {
    232         RTR0MemObjFree(pVM->hwaccm.s.svm.pMemObjVMCBHost, false);
    233         pVM->hwaccm.s.svm.pVMCBHost       = 0;
    234         pVM->hwaccm.s.svm.pVMCBHostPhys   = 0;
    235         pVM->hwaccm.s.svm.pMemObjVMCBHost = NIL_RTR0MEMOBJ;
     224        PVMCPU pVCpu = &pVM->aCpus[i];
     225
     226        if (pVCpu->hwaccm.s.svm.pMemObjVMCBHost != NIL_RTR0MEMOBJ)
     227        {
     228            RTR0MemObjFree(pVCpu->hwaccm.s.svm.pMemObjVMCBHost, false);
     229            pVCpu->hwaccm.s.svm.pVMCBHost       = 0;
     230            pVCpu->hwaccm.s.svm.pVMCBHostPhys   = 0;
     231            pVCpu->hwaccm.s.svm.pMemObjVMCBHost = NIL_RTR0MEMOBJ;
     232        }
     233
     234        if (pVCpu->hwaccm.s.svm.pMemObjVMCB != NIL_RTR0MEMOBJ)
     235        {
     236            RTR0MemObjFree(pVCpu->hwaccm.s.svm.pMemObjVMCB, false);
     237            pVCpu->hwaccm.s.svm.pVMCB       = 0;
     238            pVCpu->hwaccm.s.svm.pVMCBPhys   = 0;
     239            pVCpu->hwaccm.s.svm.pMemObjVMCB = NIL_RTR0MEMOBJ;
     240        }
    236241    }
    237242    if (pVM->hwaccm.s.svm.pMemObjIOBitmap != NIL_RTR0MEMOBJ)
     
    11101115#endif
    11111116    TMNotifyStartOfExecution(pVCpu);
    1112     pVCpu->hwaccm.s.svm.pfnVMRun(pVM->hwaccm.s.svm.pVMCBHostPhys, pVCpu->hwaccm.s.svm.pVMCBPhys, pCtx, pVM, pVCpu);
     1117    pVCpu->hwaccm.s.svm.pfnVMRun(pVCpu->hwaccm.s.svm.pVMCBHostPhys, pVCpu->hwaccm.s.svm.pVMCBPhys, pCtx, pVM, pVCpu);
    11131118    TMNotifyEndOfExecution(pVCpu);
    11141119    VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED);
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