~ubuntu-branches/ubuntu/precise/virtualbox/precise-updates

« back to all changes in this revision

Viewing changes to src/VBox/VMM/VMMR0/HWVMXR0.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-10-17 23:23:09 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20111017232309-kzm6841lzk61ranj
Tags: 4.1.4-dfsg-1
* New upstream release.
  - Fixes missing icons when using pt_BR locale. (Closes: #507188)
  - Fixes guest additions download url. (Closes: #637349; LP: #840668)
* Refresh patches.
* Drop the vboxmouse x11 driver. The mouse integration is now completely
  handled by the kernel module.
* Restrict dh_pycentral to the virtualbox binary package.
* Merge changes from the Ubuntu package but use them only when built
  on Ubuntu:
  - Add an Apport hook.
  - Add vboxguest modalias to the package control field.
* Pass KBUILD_VERBOSE=2 to kmk.
* Add 36-fix-text-mode.patch to fix text mode when using the vboxvideo driver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: HWVMXR0.cpp 37955 2011-07-14 12:23:02Z vboxsync $ */
 
1
/* $Id: HWVMXR0.cpp $ */
2
2
/** @file
3
3
 * HWACCM VMX - Host Context Ring 0.
4
4
 */
1234
1234
}
1235
1235
 
1236
1236
/**
1237
 
 * Prefetch the 4 PDPT pointers (PAE and nested paging only)
1238
 
 *
1239
 
 * @returns VINF_SUCCESS or fatal error.
1240
 
 * @param   pVM         The VM to operate on.
1241
 
 * @param   pVCpu       The VMCPU to operate on.
1242
 
 * @param   pCtx        Guest context
1243
 
 */
1244
 
static int vmxR0PrefetchPAEPdptrs(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
1245
 
{
1246
 
    if (CPUMIsGuestInPAEModeEx(pCtx))
1247
 
    {
1248
 
        for (unsigned i=0;i<4;i++)
1249
 
        {
1250
 
            X86PDPE Pdpe;
1251
 
            int rc = PGMGstQueryPaePDPtr(pVCpu, i, &Pdpe);
1252
 
            AssertRCReturn(rc, rc);
1253
 
 
1254
 
            rc = VMXWriteVMCS64(VMX_VMCS_GUEST_PDPTR0_FULL + i*2, Pdpe.u);
1255
 
            AssertRC(rc);
1256
 
        }
1257
 
    }
1258
 
    return VINF_SUCCESS;
1259
 
}
 
1237
 * Loads the 4 PDPEs into the guest state when nested paging is used and the
 
1238
 * guest operates in PAE mode.
 
1239
 *
 
1240
 * @returns VINF_SUCCESS or fatal error.
 
1241
 * @param   pVCpu       The VMCPU to operate on.
 
1242
 * @param   pCtx        Guest context
 
1243
 */
 
1244
static int hmR0VmxLoadPaePdpes(PVMCPU pVCpu, PCPUMCTX pCtx)
 
1245
{
 
1246
    if (CPUMIsGuestInPAEModeEx(pCtx))
 
1247
    {
 
1248
        X86PDPE aPdpes[4];
 
1249
        int rc = PGMGstGetPaePdpes(pVCpu, &aPdpes[0]);
 
1250
        AssertRCReturn(rc, rc);
 
1251
 
 
1252
        rc = VMXWriteVMCS64(VMX_VMCS_GUEST_PDPTR0_FULL, aPdpes[0].u); AssertRCReturn(rc, rc);
 
1253
        rc = VMXWriteVMCS64(VMX_VMCS_GUEST_PDPTR1_FULL, aPdpes[1].u); AssertRCReturn(rc, rc);
 
1254
        rc = VMXWriteVMCS64(VMX_VMCS_GUEST_PDPTR2_FULL, aPdpes[2].u); AssertRCReturn(rc, rc);
 
1255
        rc = VMXWriteVMCS64(VMX_VMCS_GUEST_PDPTR3_FULL, aPdpes[3].u); AssertRCReturn(rc, rc);
 
1256
    }
 
1257
    return VINF_SUCCESS;
 
1258
}
 
1259
 
 
1260
/**
 
1261
 * Saves the 4 PDPEs into the guest state when nested paging is used and the
 
1262
 * guest operates in PAE mode.
 
1263
 *
 
1264
 * @returns VINF_SUCCESS or fatal error.
 
1265
 * @param   pVCpu       The VMCPU to operate on.
 
1266
 * @param   pCtx        Guest context
 
1267
 *
 
1268
 * @remarks Tell PGM about CR3 changes before calling this helper.
 
1269
 */
 
1270
static int hmR0VmxSavePaePdpes(PVMCPU pVCpu, PCPUMCTX pCtx)
 
1271
{
 
1272
    if (CPUMIsGuestInPAEModeEx(pCtx))
 
1273
    {
 
1274
        int rc;
 
1275
        X86PDPE aPdpes[4];
 
1276
        rc = VMXReadVMCS64(VMX_VMCS_GUEST_PDPTR0_FULL, &aPdpes[0].u); AssertRCReturn(rc, rc);
 
1277
        rc = VMXReadVMCS64(VMX_VMCS_GUEST_PDPTR1_FULL, &aPdpes[1].u); AssertRCReturn(rc, rc);
 
1278
        rc = VMXReadVMCS64(VMX_VMCS_GUEST_PDPTR2_FULL, &aPdpes[2].u); AssertRCReturn(rc, rc);
 
1279
        rc = VMXReadVMCS64(VMX_VMCS_GUEST_PDPTR3_FULL, &aPdpes[3].u); AssertRCReturn(rc, rc);
 
1280
 
 
1281
        rc = PGMGstUpdatePaePdpes(pVCpu, &aPdpes[0]);
 
1282
        AssertRCReturn(rc, rc);
 
1283
    }
 
1284
    return VINF_SUCCESS;
 
1285
}
 
1286
 
1260
1287
 
1261
1288
/**
1262
1289
 * Update the exception bitmap according to the current CPU state
1751
1778
            {
1752
1779
                /* Save the real guest CR3 in VMX_VMCS_GUEST_CR3 */
1753
1780
                val = pCtx->cr3;
1754
 
                /* Prefetch the four PDPT entries in PAE mode. */
1755
 
                rc = vmxR0PrefetchPAEPdptrs(pVM, pVCpu, pCtx);
 
1781
                rc = hmR0VmxLoadPaePdpes(pVCpu, pCtx);
1756
1782
                AssertRCReturn(rc, rc);
1757
1783
            }
1758
1784
        }
2026
2052
            CPUMSetGuestCR3(pVCpu, val);
2027
2053
            PGMUpdateCR3(pVCpu, val);
2028
2054
        }
2029
 
        /* Prefetch the four PDPT entries in PAE mode. */
2030
 
        rc = vmxR0PrefetchPAEPdptrs(pVM, pVCpu, pCtx);
 
2055
        rc = hmR0VmxSavePaePdpes(pVCpu, pCtx);
2031
2056
        AssertRCReturn(rc, rc);
2032
2057
    }
2033
2058
 
2159
2184
        /* Force a TLB flush on VM entry. */
2160
2185
        pVCpu->hwaccm.s.fForceTLBFlush = true;
2161
2186
    }
2162
 
    else
2163
 
        Assert(!pCpu->fFlushTLB);
 
2187
    /* Disabled because this has triggered every time I have suspended my
 
2188
     * laptop with a VM running for the past three months or more.  */
 
2189
    // else
 
2190
    //     Assert(!pCpu->fFlushTLB);
2164
2191
 
2165
2192
    /* Check for tlb shootdown flushes. */
2166
2193
    if (VMCPU_FF_TESTANDCLEAR(pVCpu, VMCPU_FF_TLB_FLUSH))
3855
3882
                {
3856
3883
                    Log2(("IOMInterpretOUTSEx %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, uPort, cbSize));
3857
3884
                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringWrite);
3858
 
                    rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, cbSize);
 
3885
                    rc = IOMInterpretOUTSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, pDis->addrmode, cbSize);
3859
3886
                }
3860
3887
                else
3861
3888
                {
3862
3889
                    Log2(("IOMInterpretINSEx  %RGv %x size=%d\n", (RTGCPTR)pCtx->rip, uPort, cbSize));
3863
3890
                    STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitIOStringRead);
3864
 
                    rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, cbSize);
 
3891
                    rc = IOMInterpretINSEx(pVM, CPUMCTX2CORE(pCtx), uPort, pDis->prefix, pDis->addrmode, cbSize);
3865
3892
                }
3866
3893
            }
3867
3894
            else