VirtualBox

Changeset 21999 in vbox


Ignore:
Timestamp:
Aug 5, 2009 2:12:58 PM (15 years ago)
Author:
vboxsync
Message:

Deadlock prevention

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/HWACCM.cpp

    r21989 r21999  
    14641464 * @returns VBox status code.
    14651465 * @param   pVM         The VM to operate on.
     1466 * @param   idCpu       VCPU to execute hwaccmR3RemovePatches on
    14661467 * @param   pPatchMem   Patch memory range
    14671468 * @param   cbPatchMem  Size of the memory range
    14681469 */
    1469 VMMR3DECL(int)  HWACMMR3EnablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem)
    1470 {
    1471     Log(("HWACMMR3EnablePatching %RGv size %x\n", pPatchMem, cbPatchMem));
    1472 
    1473     /* Current TPR patching only applies to AMD cpus.
    1474      * May need to be extended to Intel CPUs without the APIC TPR hardware optimization.
    1475      */
    1476     if (CPUMGetCPUVendor(pVM) != CPUMCPUVENDOR_AMD)
    1477         return VERR_NOT_SUPPORTED;
    1478 
    1479     int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONE_BY_ONE, hwaccmR3RemovePatches, (void *)VMMGetCpuId(pVM));
     1470int hwaccmR3EnablePatching(PVM pVM, VMCPUID idCpu, RTRCPTR pPatchMem, unsigned cbPatchMem)
     1471{
     1472    int rc = VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONE_BY_ONE, hwaccmR3RemovePatches, (void *)idCpu);
    14801473    AssertRC(rc);
    14811474
     
    14841477    pVM->hwaccm.s.cbGuestPatchMem     = cbPatchMem;
    14851478    return VINF_SUCCESS;
     1479}
     1480
     1481/**
     1482 * Enable patching in a VT-x/AMD-V guest
     1483 *
     1484 * @returns VBox status code.
     1485 * @param   pVM         The VM to operate on.
     1486 * @param   pPatchMem   Patch memory range
     1487 * @param   cbPatchMem  Size of the memory range
     1488 */
     1489VMMR3DECL(int)  HWACMMR3EnablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem)
     1490{
     1491    Log(("HWACMMR3EnablePatching %RGv size %x\n", pPatchMem, cbPatchMem));
     1492
     1493    /* Current TPR patching only applies to AMD cpus.
     1494     * Needs to be extended to Intel CPUs without the APIC TPR hardware optimization.
     1495     */
     1496    if (CPUMGetCPUVendor(pVM) != CPUMCPUVENDOR_AMD)
     1497        return VERR_NOT_SUPPORTED;
     1498
     1499    if (pVM->cCPUs > 1)
     1500    {
     1501        /* We own the IOM lock here and could cause a deadlock by waiting for a VCPU that is blocking on the IOM lock. */
     1502        PVMREQ pReq;
     1503        int rc = VMR3ReqCallU(pVM->pUVM, VMCPUID_ANY_QUEUE, &pReq, 0, VMREQFLAGS_NO_WAIT,
     1504                              (PFNRT)hwaccmR3EnablePatching, 4, pVM, VMMGetCpuId(pVM), (RTRCPTR)pPatchMem, cbPatchMem);
     1505        AssertRC(rc);
     1506        return rc;
     1507    }
     1508    else
     1509        return hwaccmR3EnablePatching(pVM, VMMGetCpuId(pVM), (RTRCPTR)pPatchMem, cbPatchMem);
    14861510}
    14871511
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