VirtualBox

Changeset 21709 in vbox


Ignore:
Timestamp:
Jul 17, 2009 4:07:35 PM (16 years ago)
Author:
vboxsync
Message:

Use LSTAR for TPR caching.

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

Legend:

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

    r21708 r21709  
    13821382
    13831383    /* Clear all patch information. */
    1384     pVM->hwaccm.s.pGuestPatchMem      = 0;
    1385     pVM->hwaccm.s.pFreeGuestPatchMem  = 0;
    1386     pVM->hwaccm.s.cbGuestPatchMem     = 0;
    1387     pVM->hwaccm.s.svm.cPatches        = 0;
    1388     pVM->hwaccm.s.svm.PatchTree       = 0;
     1384    pVM->hwaccm.s.pGuestPatchMem         = 0;
     1385    pVM->hwaccm.s.pFreeGuestPatchMem     = 0;
     1386    pVM->hwaccm.s.cbGuestPatchMem        = 0;
     1387    pVM->hwaccm.s.svm.cPatches           = 0;
     1388    pVM->hwaccm.s.svm.PatchTree          = 0;
     1389    pVM->hwaccm.s.svm.fTPRPatchingActive = false;
    13891390    ASMMemZero32(pVM->hwaccm.s.svm.aPatches, sizeof(pVM->hwaccm.s.svm.aPatches));
    13901391}
     
    14431444    pVM->hwaccm.s.svm.PatchTree       = 0;
    14441445    pVM->hwaccm.s.pFreeGuestPatchMem  = pVM->hwaccm.s.pGuestPatchMem;
     1446    pVM->hwaccm.s.svm.fTPRPatchingActive = false;
    14451447    return VINF_SUCCESS;
    14461448}
     
    14941496    pVM->hwaccm.s.pFreeGuestPatchMem  = 0;
    14951497    pVM->hwaccm.s.cbGuestPatchMem     = 0;
     1498    pVM->hwaccm.s.svm.fTPRPatchingActive = false;
    14961499    return VINF_SUCCESS;
    14971500}
     
    18831886
    18841887                pVM->hwaccm.s.svm.cPatches++;
     1888                pVM->hwaccm.s.svm.fTPRPatchingActive = true;
    18851889                return VINF_SUCCESS;
    18861890            }
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r21652 r21709  
    406406        /** Set if erratum 170 affects the AMD cpu. */
    407407        bool                        fAlwaysFlushTLB;
    408         /** Explicit alignment padding to make 32-bit gcc align u64RegisterMask
    409          *  naturally. */
    410         bool                        padding[1];
     408        /** Set when TPR patching is active. */
     409        bool                        fTPRPatchingActive;
    411410
    412411        /** R0 memory object for the IO bitmap (12kb). */
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r21696 r21709  
    10761076        int rc = PDMApicGetTPR(pVCpu, &u8LastTPR, &fPending);
    10771077        AssertRC(rc);
    1078         pVMCB->ctrl.IntCtrl.n.u8VTPR = (u8LastTPR >> 4); /* cr8 bits 3-0 correspond to bits 7-4 of the task priority mmio register. */
    1079 
    1080         if (fPending)
    1081         {
    1082             /* A TPR change could activate a pending interrupt, so catch cr8 writes. */
    1083             pVMCB->ctrl.u16InterceptWrCRx |= RT_BIT(8);
     1078
     1079        if (pVM->hwaccm.s.svm.fTPRPatchingActive)
     1080        {
     1081            /* Our patch code uses LSTAR for TPR caching. */
     1082            pCtx->msrLSTAR = u8LastTPR;
    10841083        }
    10851084        else
    1086             /* No interrupts are pending, so we don't need to be explicitely notified.
    1087              * There are enough world switches for detecting pending interrupts.
    1088              */
    1089             pVMCB->ctrl.u16InterceptWrCRx &= ~RT_BIT(8);
    1090 
     1085        {
     1086            pVMCB->ctrl.IntCtrl.n.u8VTPR = (u8LastTPR >> 4); /* cr8 bits 3-0 correspond to bits 7-4 of the task priority mmio register. */
     1087
     1088            if (fPending)
     1089            {
     1090                /* A TPR change could activate a pending interrupt, so catch cr8 writes. */
     1091                pVMCB->ctrl.u16InterceptWrCRx |= RT_BIT(8);
     1092            }
     1093            else
     1094                /* No interrupts are pending, so we don't need to be explicitely notified.
     1095                * There are enough world switches for detecting pending interrupts.
     1096                */
     1097                pVMCB->ctrl.u16InterceptWrCRx &= ~RT_BIT(8);
     1098        }
    10911099        fSyncTPR = !fPending;
    10921100    }
     
    14731481    /* Sync back the TPR if it was changed. */
    14741482    if (    fSyncTPR
    1475         &&  (u8LastTPR >> 4) != pVMCB->ctrl.IntCtrl.n.u8VTPR)
    1476     {
    1477         rc = PDMApicSetTPR(pVCpu, pVMCB->ctrl.IntCtrl.n.u8VTPR << 4);   /* cr8 bits 3-0 correspond to bits 7-4 of the task priority mmio register. */
     1483        &&  pVM->hwaccm.s.svm.fTPRPatchingActive
     1484        &&  (pCtx->msrLSTAR & 0xff) != u8LastTPR)
     1485    {
     1486        /* Our patch code uses LSTAR for TPR caching. */
     1487        rc = PDMApicSetTPR(pVCpu, pCtx->msrLSTAR & 0xff);
    14781488        AssertRC(rc);
     1489    }
     1490    else
     1491    {
     1492        if (    fSyncTPR
     1493            &&  (u8LastTPR >> 4) != pVMCB->ctrl.IntCtrl.n.u8VTPR)
     1494        {
     1495            rc = PDMApicSetTPR(pVCpu, pVMCB->ctrl.IntCtrl.n.u8VTPR << 4);   /* cr8 bits 3-0 correspond to bits 7-4 of the task priority mmio register. */
     1496            AssertRC(rc);
     1497        }
    14791498    }
    14801499
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