VirtualBox

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


Ignore:
Timestamp:
Jun 15, 2018 11:00:02 AM (6 years ago)
Author:
vboxsync
Message:

EM,HM: Replaced HM exit history with the EM one. VT-x now reads TSC on every exit even when VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT is set. VT-x needed an API for updating the PC as RIP and CS are fetched from the VMCB. bugref:9044

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

Legend:

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

    r72534 r72560  
    10401040    pVmcbCtrl->u64MSRPMPhysAddr = pVCpu->hm.s.svm.HCPhysMsrBitmap;
    10411041
    1042     /* Initialize the #VMEXIT history array with end-of-array markers (UINT16_MAX). */
    1043     Assert(!pVCpu->hm.s.idxExitHistoryFree);
    1044     HMCPU_EXIT_HISTORY_RESET(pVCpu);
    1045 
    10461042    /* Initially all VMCB clean bits MBZ indicating that everything should be loaded from the VMCB in memory. */
    10471043    Assert(pVmcbCtrl->u32VmcbCleanBits == 0);
     
    10611057        memcpy(pbMsrBitmapCur, pbMsrBitmap, SVM_MSRPM_PAGES << X86_PAGE_4K_SHIFT);
    10621058        pVmcbCtrlCur->u64MSRPMPhysAddr = pVCpuCur->hm.s.svm.HCPhysMsrBitmap;
    1063 
    1064         /* Initialize the #VMEXIT history array with end-of-array markers (UINT16_MAX). */
    1065         Assert(!pVCpuCur->hm.s.idxExitHistoryFree);
    1066         HMCPU_EXIT_HISTORY_RESET(pVCpuCur);
    10671059
    10681060        /* Initially all VMCB clean bits MBZ indicating that everything should be loaded from the VMCB in memory. */
     
    45844576
    45854577    pSvmTransient->u64ExitCode  = pVmcbCtrl->u64ExitCode;       /* Save the #VMEXIT reason. */
    4586     HMCPU_EXIT_HISTORY_ADD(pVCpu, pVmcbCtrl->u64ExitCode);      /* Update the #VMEXIT history array. */
    45874578    pVmcbCtrl->u32VmcbCleanBits       = HMSVM_VMCB_CLEAN_ALL;   /* Mark the VMCB-state cache as unmodified by VMM. */
    45884579    pSvmTransient->fVectoringDoublePF = false;                  /* Vectoring double page-fault needs to be determined later. */
     
    46114602        }
    46124603    }
     4604
     4605    EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_SVM, pSvmTransient->u64ExitCode & EMEXIT_F_TYPE_MASK),
     4606                     pMixedCtx->cs.u64Base + pMixedCtx->rip, uHostTsc);
    46134607}
    46144608
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r72533 r72560  
    28442844        Log4(("VMXR0SetupVM: pVCpu=%p idCpu=%RU32\n", pVCpu, pVCpu->idCpu));
    28452845
    2846        /* Initialize the VM-exit history array with end-of-array markers (UINT16_MAX). */
    2847         Assert(!pVCpu->hm.s.idxExitHistoryFree);
    2848         HMCPU_EXIT_HISTORY_RESET(pVCpu);
    2849 
    28502846        /* Set revision dword at the beginning of the VMCS structure. */
    28512847        *(uint32_t *)pVCpu->hm.s.vmx.pvVmcs = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(pVM->hm.s.vmx.Msrs.u64BasicInfo);
     
    36533649        Log4(("Load[%RU32]: VMX_VMCS_GUEST_RIP=%#RX64 fContextUseFlags=%#RX32\n", pVCpu->idCpu, pMixedCtx->rip,
    36543650              HMCPU_CF_VALUE(pVCpu)));
     3651
     3652        /* Update the exit history entry with the correct CS.BASE + RIP or just RIP. */
     3653        if (HMCPU_CF_IS_SET(pVCpu, HM_CHANGED_GUEST_SEGMENT_REGS))
     3654            EMR0HistoryUpdatePC(pVCpu, pMixedCtx->cs.u64Base + pMixedCtx->rip, true);
     3655        else
     3656            EMR0HistoryUpdatePC(pVCpu, pMixedCtx->rip, false);
    36553657    }
    36563658    return rc;
     
    45944596        Log4(("Load[%RU32]: CS=%#RX16 Base=%#RX64 Limit=%#RX32 Attr=%#RX32\n", pVCpu->idCpu, pMixedCtx->cs.Sel,
    45954597              pMixedCtx->cs.u64Base, pMixedCtx->cs.u32Limit, pMixedCtx->cs.Attr.u));
     4598
     4599        /* Update the exit history entry with the correct CS.BASE + RIP. */
     4600        if (HMCPU_CF_IS_PENDING(pVCpu, HM_CHANGED_GUEST_RIP))
     4601            EMR0HistoryUpdatePC(pVCpu, pMixedCtx->cs.u64Base + pMixedCtx->rip, true);
    45964602    }
    45974603
     
    92089214{
    92099215    NOREF(pVM);
     9216    uint64_t uHostTsc = ASMReadTSC();
    92109217
    92119218    Assert(!VMMRZCallRing3IsEnabled(pVCpu));
     
    92199226
    92209227    if (!(pVCpu->hm.s.vmx.u32ProcCtls & VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT))
    9221         TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVCpu->hm.s.vmx.u64TSCOffset);
     9228        TMCpuTickSetLastSeen(pVCpu, uHostTsc + pVCpu->hm.s.vmx.u64TSCOffset);
    92229229
    92239230    STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatInGC, &pVCpu->hm.s.StatExit1, x);
     
    92619268         *
    92629269         * See Intel spec. 26.7 "VM-Entry failures during or after loading guest state".
     9270         *
     9271         * Note! We don't have CS or RIP at this point.  Will probably address that later
     9272         *       by amending the history entry added here.
    92639273         */
    9264         HMCPU_EXIT_HISTORY_ADD(pVCpu, pVmxTransient->uExitReason);
     9274        EMHistoryAddExit(pVCpu, EMEXIT_MAKE_FLAGS_AND_TYPE(EMEXIT_F_KIND_SVM, pVmxTransient->uExitReason & EMEXIT_F_TYPE_MASK),
     9275                         UINT64_MAX, uHostTsc);
    92659276
    92669277        if (!pVmxTransient->fVMEntryFailed)
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