VirtualBox

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


Ignore:
Timestamp:
Jul 5, 2012 12:10:53 PM (12 years ago)
Author:
vboxsync
Message:

VMM: RDTSCP support on Intel. Segregated some common CPU features from the AMD superset into Extended features as they're now available on Intel too.

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

Legend:

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

    r41965 r42024  
    186186        {
    187187            uint32_t fExtFeaturesEDX = ASMCpuId_EDX(0x80000001);
    188             if (fExtFeaturesEDX & X86_CPUID_AMD_FEATURE_EDX_SEP)
     188            if (fExtFeaturesEDX & X86_CPUID_EXT_FEATURE_EDX_SYSCALL)
    189189            {
    190190#ifdef RT_ARCH_X86
    191191# ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
    192                 if (fExtFeaturesEDX & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE)
     192                if (fExtFeaturesEDX & X86_CPUID_EXT_FEATURE_EDX_LONG_MODE)
    193193# else
    194194                if (!ASMIsIntelCpu())
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r41965 r42024  
    22192219    {
    22202220        Log2(("SVM: Rdtscp\n"));
    2221         STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitRdtsc);
     2221        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitRdtscp);
    22222222        rc = EMInterpretRdtscp(pVM, pVCpu, pCtx);
    22232223        if (rc == VINF_SUCCESS)
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r41965 r42024  
    568568            if (pVM->hwaccm.s.vmx.fUnrestrictedGuest)
    569569                val |= VMX_VMCS_CTRL_PROC_EXEC2_REAL_MODE;
     570
     571            if (pVM->hwaccm.s.vmx.msr.vmx_proc_ctls2.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC2_RDTSCP)
     572                val |= VMX_VMCS_CTRL_PROC_EXEC2_RDTSCP;
    570573
    571574            /* Mask away the bits that the CPU doesn't support */
     
    13161319         * Check if EFER MSR present.
    13171320         */
    1318         if (ASMCpuId_EDX(0x80000001) & (X86_CPUID_AMD_FEATURE_EDX_NX|X86_CPUID_AMD_FEATURE_EDX_LONG_MODE))
    1319         {
    1320             if (ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_SEP)
     1321        if (ASMCpuId_EDX(0x80000001) & (X86_CPUID_EXT_FEATURE_EDX_NX | X86_CPUID_EXT_FEATURE_EDX_LONG_MODE))
     1322        {
     1323            if (ASMCpuId_EDX(0x80000001) & X86_CPUID_EXT_FEATURE_EDX_SYSCALL)
    13211324            {
    13221325                pMsr->u32IndexMSR = MSR_K6_STAR;
    13231326                pMsr->u32Reserved = 0;
    1324                 pMsr->u64Value    = ASMRdMsr(MSR_K6_STAR);                   /* legacy syscall eip, cs & ss */
     1327                pMsr->u64Value    = ASMRdMsr(MSR_K6_STAR);          /* legacy syscall eip, cs & ss */
    13251328                pMsr++; idxMsr++;
    13261329            }
     
    20982101    CPUMGetGuestCpuId(pVCpu, 0x80000001, &ulTemp, &ulTemp, &ulTemp, &ulEdx);
    20992102    /* EFER MSR present? */
    2100     if (ulEdx & (X86_CPUID_AMD_FEATURE_EDX_NX|X86_CPUID_AMD_FEATURE_EDX_LONG_MODE))
     2103    if (ulEdx & (X86_CPUID_EXT_FEATURE_EDX_NX | X86_CPUID_EXT_FEATURE_EDX_LONG_MODE))
    21012104    {
    21022105        pMsr->u32IndexMSR = MSR_K6_EFER;
     
    21052108        /* VT-x will complain if only MSR_K6_EFER_LME is set. */
    21062109        if (!CPUMIsGuestInLongModeEx(pCtx))
    2107             pMsr->u64Value &= ~(MSR_K6_EFER_LMA|MSR_K6_EFER_LME);
     2110            pMsr->u64Value &= ~(MSR_K6_EFER_LMA | MSR_K6_EFER_LME);
    21082111        pMsr++; idxMsr++;
    21092112
    2110         if (ulEdx & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE)
     2113        if (ulEdx & X86_CPUID_EXT_FEATURE_EDX_LONG_MODE)
    21112114        {
    21122115            pMsr->u32IndexMSR = MSR_K8_LSTAR;
     
    21612164        if (u64CurTSC + pVCpu->hwaccm.s.vmx.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu))
    21622165        {
    2163             /* Note: VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_RDTSC_EXIT takes precedence over TSC_OFFSET */
     2166            /* Note: VMX_VMCS_CTRL_PROC_EXEC_CONTROLS_RDTSC_EXIT takes precedence over TSC_OFFSET, applies to RDTSCP too. */
    21642167            rc = VMXWriteVMCS64(VMX_VMCS_CTRL_TSC_OFFSET_FULL, pVCpu->hwaccm.s.vmx.u64TSCOffset);
    21652168            AssertRC(rc);
     
    21722175        else
    21732176        {
    2174             /* Fall back to rdtsc emulation as we would otherwise pass decreasing tsc values to the guest. */
     2177            /* Fall back to rdtsc, rdtscp emulation as we would otherwise pass decreasing tsc values to the guest. */
    21752178            LogFlow(("TSC %RX64 offset %RX64 time=%RX64 last=%RX64 (diff=%RX64, virt_tsc=%RX64)\n", u64CurTSC,
    21762179                     pVCpu->hwaccm.s.vmx.u64TSCOffset, u64CurTSC + pVCpu->hwaccm.s.vmx.u64TSCOffset,
     
    23322335        switch (pMsr->u32IndexMSR)
    23332336        {
    2334         case MSR_K8_LSTAR:
    2335             pCtx->msrLSTAR = pMsr->u64Value;
    2336             break;
    2337         case MSR_K6_STAR:
    2338             pCtx->msrSTAR = pMsr->u64Value;
    2339             break;
    2340         case MSR_K8_SF_MASK:
    2341             pCtx->msrSFMASK = pMsr->u64Value;
    2342             break;
    2343         case MSR_K8_KERNEL_GS_BASE:
    2344             pCtx->msrKERNELGSBASE = pMsr->u64Value;
    2345             break;
    2346         case MSR_K6_EFER:
    2347             /* EFER can't be changed without causing a VM-exit. */
    2348             /* Assert(pCtx->msrEFER == pMsr->u64Value); */
    2349             break;
    2350         default:
    2351             AssertFailed();
    2352             return VERR_HM_UNEXPECTED_LD_ST_MSR;
     2337            case MSR_K8_LSTAR:
     2338                pCtx->msrLSTAR = pMsr->u64Value;
     2339                break;
     2340            case MSR_K6_STAR:
     2341                pCtx->msrSTAR = pMsr->u64Value;
     2342                break;
     2343            case MSR_K8_SF_MASK:
     2344                pCtx->msrSFMASK = pMsr->u64Value;
     2345                break;
     2346            case MSR_K8_KERNEL_GS_BASE:
     2347                pCtx->msrKERNELGSBASE = pMsr->u64Value;
     2348                break;
     2349            case MSR_K6_EFER:
     2350                /* EFER can't be changed without causing a VM-exit. */
     2351                /* Assert(pCtx->msrEFER == pMsr->u64Value); */
     2352                break;
     2353            default:
     2354                AssertFailed();
     2355                return VERR_HM_UNEXPECTED_LD_ST_MSR;
    23532356        }
    23542357    }
     
    24532456    else
    24542457    {
    2455         AssertMsg(pVCpu->hwaccm.s.uCurrentASID && pCpu->uCurrentASID, ("hwaccm uCurrentASID=%lu cpu uCurrentASID=%lu\n",
    2456                                                                        pVCpu->hwaccm.s.uCurrentASID, pCpu->uCurrentASID));
     2458        AssertMsg(pVCpu->hwaccm.s.uCurrentASID && pCpu->uCurrentASID,
     2459                  ("hwaccm->uCurrentASID=%lu hwaccm->cTLBFlushes=%lu cpu->uCurrentASID=%lu cpu->cTLBFlushes=%lu\n",
     2460                   pVCpu->hwaccm.s.uCurrentASID, pVCpu->hwaccm.s.cTLBFlushes,
     2461                   pCpu->uCurrentASID, pCpu->cTLBFlushes));
    24572462
    24582463        /** @todo We never set VMCPU_FF_TLB_SHOOTDOWN anywhere so this path should
     
    40464051            /* Update EIP and continue execution. */
    40474052            Assert(cbInstr == 2);
     4053            pCtx->rip += cbInstr;
     4054            goto ResumeExecution;
     4055        }
     4056        rc = VINF_EM_RAW_EMULATE_INSTR;
     4057        break;
     4058    }
     4059
     4060    case VMX_EXIT_RDTSCP:                /* 51 Guest software attempted to execute RDTSCP. */
     4061    {
     4062        Log2(("VMX: Rdtscp\n"));
     4063        STAM_COUNTER_INC(&pVCpu->hwaccm.s.StatExitRdtscp);
     4064        rc = EMInterpretRdtscp(pVM, pVCpu, pCtx);
     4065        if (rc == VINF_SUCCESS)
     4066        {
     4067            /* Update EIP and continue execution. */
     4068            Assert(cbInstr == 3);
    40484069            pCtx->rip += cbInstr;
    40494070            goto ResumeExecution;
     
    46264647    case VMX_EXIT_PORT_IO:              /* 30 I/O instruction. */
    46274648    case VMX_EXIT_RDPMC:                /* 15 Guest software attempted to execute RDPMC. */
     4649    case VMX_EXIT_RDTSCP:               /* 51 Guest software attempted to execute RDTSCP. */
    46284650        /* already handled above */
    46294651        AssertMsg(   rc == VINF_PGM_CHANGE_MODE
  • trunk/src/VBox/VMM/VMMR0/TRPMR0.cpp

    r41965 r42024  
    6262     * Check if we're in long mode or not.
    6363     */
    64     if (    (ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_LONG_MODE)
     64    if (    (ASMCpuId_EDX(0x80000001) & X86_CPUID_EXT_FEATURE_EDX_LONG_MODE)
    6565        &&  (ASMRdMsr(MSR_K6_EFER) & MSR_K6_EFER_LMA))
    6666    {
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