VirtualBox

Changeset 87558 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Feb 3, 2021 11:21:28 AM (4 years ago)
Author:
vboxsync
Message:

VMM/HMVMX: Moved/copy last branch stuff from HM::vmxUse to HMR0PERVM::vmx. bugref:9217

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r87557 r87558  
    875875 * @remarks Must only be called when LBR is enabled.
    876876 */
    877 DECL_FORCE_INLINE(bool) hmR0VmxIsLbrBranchFromMsr(PCVM pVM, uint32_t idMsr, uint32_t *pidxMsr)
    878 {
    879     Assert(pVM->hm.s.vmx.fLbr);
    880     Assert(pVM->hm.s.vmx.idLbrFromIpMsrFirst);
    881     uint32_t const cLbrStack = pVM->hm.s.vmx.idLbrFromIpMsrLast - pVM->hm.s.vmx.idLbrFromIpMsrFirst + 1;
    882     uint32_t const idxMsr    = idMsr - pVM->hm.s.vmx.idLbrFromIpMsrFirst;
     877DECL_FORCE_INLINE(bool) hmR0VmxIsLbrBranchFromMsr(PCVMCC pVM, uint32_t idMsr, uint32_t *pidxMsr)
     878{
     879    Assert(pVM->hmr0.s.vmx.fLbr);
     880    Assert(pVM->hmr0.s.vmx.idLbrFromIpMsrFirst);
     881    uint32_t const cLbrStack = pVM->hmr0.s.vmx.idLbrFromIpMsrLast - pVM->hmr0.s.vmx.idLbrFromIpMsrFirst + 1;
     882    uint32_t const idxMsr    = idMsr - pVM->hmr0.s.vmx.idLbrFromIpMsrFirst;
    883883    if (idxMsr < cLbrStack)
    884884    {
     
    903903 *          are supported by the CPU (see hmR0VmxSetupLbrMsrRange).
    904904 */
    905 DECL_FORCE_INLINE(bool) hmR0VmxIsLbrBranchToMsr(PCVM pVM, uint32_t idMsr, uint32_t *pidxMsr)
    906 {
    907     Assert(pVM->hm.s.vmx.fLbr);
    908     if (pVM->hm.s.vmx.idLbrToIpMsrFirst)
    909     {
    910         uint32_t const cLbrStack = pVM->hm.s.vmx.idLbrToIpMsrLast - pVM->hm.s.vmx.idLbrToIpMsrFirst + 1;
    911         uint32_t const idxMsr    = idMsr - pVM->hm.s.vmx.idLbrToIpMsrFirst;
     905DECL_FORCE_INLINE(bool) hmR0VmxIsLbrBranchToMsr(PCVMCC pVM, uint32_t idMsr, uint32_t *pidxMsr)
     906{
     907    Assert(pVM->hmr0.s.vmx.fLbr);
     908    if (pVM->hmr0.s.vmx.idLbrToIpMsrFirst)
     909    {
     910        uint32_t const cLbrStack = pVM->hmr0.s.vmx.idLbrToIpMsrLast - pVM->hmr0.s.vmx.idLbrToIpMsrFirst + 1;
     911        uint32_t const idxMsr    = idMsr - pVM->hmr0.s.vmx.idLbrToIpMsrFirst;
    912912        if (idxMsr < cLbrStack)
    913913        {
     
    27962796            {
    27972797                /* Verify LBR MSRs (used only for debugging) are intercepted. We don't passthru these MSRs to the guest yet. */
    2798                 PCVM pVM = pVCpu->CTX_SUFF(pVM);
    2799                 if (   pVM->hm.s.vmx.fLbr
     2798                PCVMCC pVM = pVCpu->CTX_SUFF(pVM);
     2799                if (   pVM->hmr0.s.vmx.fLbr
    28002800                    && (   hmR0VmxIsLbrBranchFromMsr(pVM, pGuestMsrLoad->u32Msr, NULL /* pidxMsr */)
    28012801                        || hmR0VmxIsLbrBranchToMsr(pVM, pGuestMsrLoad->u32Msr, NULL /* pidxMsr */)
    2802                         || pGuestMsrLoad->u32Msr == pVM->hm.s.vmx.idLbrTosMsr))
     2802                        || pGuestMsrLoad->u32Msr == pVM->hmr0.s.vmx.idLbrTosMsr))
    28032803                {
    28042804                    AssertMsgReturnVoid((fMsrpm & VMXMSRPM_MASK) == VMXMSRPM_EXIT_RD_WR,
     
    33963396static int hmR0VmxSetupLbrMsrRange(PVMCC pVM)
    33973397{
    3398     Assert(pVM->hm.s.vmx.fLbr);
     3398    Assert(pVM->hmr0.s.vmx.fLbr);
    33993399    uint32_t idLbrFromIpMsrFirst;
    34003400    uint32_t idLbrFromIpMsrLast;
     
    34813481     * Update the LBR info. to the VM struct. for use later.
    34823482     */
    3483     pVM->hm.s.vmx.idLbrTosMsr         = idLbrTosMsr;
    3484     pVM->hm.s.vmx.idLbrFromIpMsrFirst = idLbrFromIpMsrFirst;
    3485     pVM->hm.s.vmx.idLbrFromIpMsrLast  = idLbrFromIpMsrLast;
    3486 
    3487     pVM->hm.s.vmx.idLbrToIpMsrFirst   = idLbrToIpMsrFirst;
    3488     pVM->hm.s.vmx.idLbrToIpMsrLast    = idLbrToIpMsrLast;
     3483    pVM->hmr0.s.vmx.idLbrTosMsr = idLbrTosMsr;
     3484
     3485    pVM->hm.s.vmx.idLbrFromIpMsrFirstForRing3 = pVM->hmr0.s.vmx.idLbrFromIpMsrFirst = idLbrFromIpMsrFirst;
     3486    pVM->hm.s.vmx.idLbrFromIpMsrLastForRing3  = pVM->hmr0.s.vmx.idLbrFromIpMsrLast  = idLbrFromIpMsrLast;
     3487
     3488    pVM->hm.s.vmx.idLbrToIpMsrFirstForRing3   = pVM->hmr0.s.vmx.idLbrToIpMsrFirst   = idLbrToIpMsrFirst;
     3489    pVM->hm.s.vmx.idLbrToIpMsrLastForRing3    = pVM->hmr0.s.vmx.idLbrToIpMsrLast    = idLbrToIpMsrLast;
    34893490    return VINF_SUCCESS;
    34903491}
     
    40734074        pVmcsInfo->u64Cr4Mask = u64Cr4Mask;
    40744075
    4075         if (pVCpu->CTX_SUFF(pVM)->hm.s.vmx.fLbr)
     4076        if (pVCpu->CTX_SUFF(pVM)->hmr0.s.vmx.fLbr)
    40764077        {
    40774078            rc = VMXWriteVmcsNw(VMX_VMCS64_GUEST_DEBUGCTL_FULL, MSR_IA32_DEBUGCTL_LBR);
     
    45494550
    45504551    /* Determine LBR capabilities. */
    4551     if (pVM->hm.s.vmx.fLbr)
     4552    pVM->hmr0.s.vmx.fLbr = pVM->hm.s.vmx.fLbrCfg;
     4553    if (pVM->hmr0.s.vmx.fLbr)
    45524554    {
    45534555        rc = hmR0VmxSetupLbrMsrRange(pVM);
     
    68346836
    68356837        /* Last Branch Record. */
    6836         if (pVM->hm.s.vmx.fLbr)
     6838        if (pVM->hmr0.s.vmx.fLbr)
    68376839        {
    68386840            PVMXVMCSINFOSHARED const pVmcsInfoShared = pVmxTransient->pVmcsInfo->pShared;
    6839             uint32_t const idFromIpMsrStart = pVM->hm.s.vmx.idLbrFromIpMsrFirst;
    6840             uint32_t const idToIpMsrStart   = pVM->hm.s.vmx.idLbrToIpMsrFirst;
    6841             uint32_t const cLbrStack        = pVM->hm.s.vmx.idLbrFromIpMsrLast - pVM->hm.s.vmx.idLbrFromIpMsrFirst + 1;
     6841            uint32_t const idFromIpMsrStart = pVM->hmr0.s.vmx.idLbrFromIpMsrFirst;
     6842            uint32_t const idToIpMsrStart   = pVM->hmr0.s.vmx.idLbrToIpMsrFirst;
     6843            uint32_t const cLbrStack        = pVM->hmr0.s.vmx.idLbrFromIpMsrLast - pVM->hmr0.s.vmx.idLbrFromIpMsrFirst + 1;
    68426844            Assert(cLbrStack <= 32);
    68436845            for (uint32_t i = 0; i < cLbrStack; i++)
     
    68596861
    68606862            /* Add LBR top-of-stack MSR (which contains the index to the most recent record). */
    6861             int rc = hmR0VmxAddAutoLoadStoreMsr(pVCpu, pVmxTransient, pVM->hm.s.vmx.idLbrTosMsr,
     6863            int rc = hmR0VmxAddAutoLoadStoreMsr(pVCpu, pVmxTransient, pVM->hmr0.s.vmx.idLbrTosMsr,
    68626864                                                pVmcsInfoShared->u64LbrTosMsr, false /* fSetReadWrite */,
    68636865                                                false /* fUpdateHostMsr */);
     
    77847786                        {
    77857787                            uint32_t idxLbrMsr;
    7786                             if (pVM->hm.s.vmx.fLbr)
     7788                            if (pVM->hmr0.s.vmx.fLbr)
    77877789                            {
    77887790                                if (hmR0VmxIsLbrBranchFromMsr(pVM, idMsr, &idxLbrMsr))
     
    77987800                                    break;
    77997801                                }
    7800                                 if (idMsr == pVM->hm.s.vmx.idLbrTosMsr)
     7802                                if (idMsr == pVM->hmr0.s.vmx.idLbrTosMsr)
    78017803                                {
    78027804                                    pVmcsInfoShared->u64LbrTosMsr = pMsrs[i].u64Value;
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