VirtualBox

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


Ignore:
Timestamp:
Sep 9, 2010 3:46:29 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65711
Message:

HWACCM: Preparing for using the VMX-preemption timer.

File:
1 edited

Legend:

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

    r31402 r32361  
    4949static DECLCALLBACK(void) HWACCMR0InitCPU(RTCPUID idCpu, void *pvUser1, void *pvUser2);
    5050static              int   hwaccmR0CheckCpuRcArray(int *paRc, unsigned cErrorCodes, RTCPUID *pidCpu);
     51static bool               hwaccmR0IsSubjectToVmxPreemptionTimerErratum(void);
    5152static DECLCALLBACK(void) hwaccmR0PowerCallback(RTPOWEREVENT enmEvent, void *pvUser);
    5253
     
    8081        /** Whether we're using SUPR0EnableVTx or not. */
    8182        bool                        fUsingSUPR0EnableVTx;
     83        /** Whether we're using the preemption timer or not. */
     84        bool                        fUsePreemptTimer;
     85        /** The shift mask employed by the VMX-Preemption timer. */
     86        uint8_t                     cPreemptTimerShift;
    8287
    8388        /** Host CR4 value (set by ring-0 VMX init) */
     
    310315                                HWACCMR0Globals.vmx.fSupported = true;
    311316                                VMXDisable();
     317
     318                                /*
     319                                 * Check for the VMX-Preemption Timer and adjust for the
     320                                 * "VMX-Preemption Timer Does Not Count Down at the Rate Specified" erratum.
     321                                 */
     322                                if (  HWACCMR0Globals.vmx.msr.vmx_pin_ctls.n.allowed1
     323                                    & VMX_VMCS_CTRL_PIN_EXEC_CONTROLS_PREEMPT_TIMER)
     324                                {
     325                                    HWACCMR0Globals.vmx.fUsePreemptTimer   = true;
     326                                    HWACCMR0Globals.vmx.cPreemptTimerShift = MSR_IA32_VMX_MISC_PREEMPT_TSC_BIT(HWACCMR0Globals.vmx.msr.vmx_misc);
     327                                    if (hwaccmR0IsSubjectToVmxPreemptionTimerErratum())
     328                                        HWACCMR0Globals.vmx.cPreemptTimerShift = 0; /* This is about right most of the time here. */
     329                                }
    312330                            }
    313331
     
    455473}
    456474
     475
     476/**
     477 * Checks if the CPU is subject to the "VMX-Preemption Timer Does Not Count
     478 * Down at the Rate Specified" erratum.
     479 *
     480 * Errata names and related steppings:
     481 *      - BA86   - D0.
     482 *      - AAX65  - C2.
     483 *      - AAU65  - C2, K0.
     484 *      - AAO95  - B1.
     485 *      - AAT59  - C2.
     486 *      - AAK139 - D0.
     487 *      - AAM126 - C0, C1, D0.
     488 *      - AAN92  - B1.
     489 *      - AAJ124 - C0, D0.
     490 *
     491 *      - AAP86  - B1.
     492 *
     493 * Steppings: B1, C0, C1, C2, D0, K0.
     494 *
     495 * @returns true if subject to it, false if not.
     496 */
     497static bool hwaccmR0IsSubjectToVmxPreemptionTimerErratum(void)
     498{
     499    uint32_t u = ASMCpuId_EAX(1);
     500    u &= ~(RT_BIT_32(14) | RT_BIT_32(15) | RT_BIT_32(28) | RT_BIT_32(29) | RT_BIT_32(30) | RT_BIT_32(31));
     501    if (   u == UINT32_C(0x000206E6) /* 323344.pdf - BA86   - D0 - Intel Xeon Processor 7500 Series */
     502        || u == UINT32_C(0x00020652) /* 323056.pdf - AAX65  - C2 - Intel Xeon Processor L3406 */
     503        || u == UINT32_C(0x00020652) /* 322814.pdf - AAT59  - C2 - Intel CoreTM i7-600, i5-500, i5-400 and i3-300 Mobile Processor Series */
     504        || u == UINT32_C(0x00020652) /* 322911.pdf - AAU65  - C2 - Intel CoreTM i5-600, i3-500 Desktop Processor Series and Intel Pentium Processor G6950 */
     505        || u == UINT32_C(0x00020655) /* 322911.pdf - AAU65  - K0 - Intel CoreTM i5-600, i3-500 Desktop Processor Series and Intel Pentium Processor G6950 */
     506        || u == UINT32_C(0x000106E5) /* 322373.pdf - AAO95  - B1 - Intel Xeon Processor 3400 Series */
     507        || u == UINT32_C(0x000106E5) /* 322166.pdf - AAN92  - B1 - Intel CoreTM i7-800 and i5-700 Desktop Processor Series */
     508        || u == UINT32_C(0x000106E5) /* 320767.pdf - AAP86  - B1 - Intel Core i7-900 Mobile Processor Extreme Edition Series, Intel Core i7-800 and i7-700 Mobile Processor Series */
     509        || u == UINT32_C(0x000106A0) /*?321333.pdf - AAM126 - C0 - Intel Xeon Processor 3500 Series Specification */
     510        || u == UINT32_C(0x000106A1) /*?321333.pdf - AAM126 - C1 - Intel Xeon Processor 3500 Series Specification */
     511        || u == UINT32_C(0x000106A4) /* 320836.pdf - AAJ124 - C0 - Intel Core i7-900 Desktop Processor Extreme Edition Series and Intel Core i7-900 Desktop Processor Series */
     512        || u == UINT32_C(0x000106A5) /* 321333.pdf - AAM126 - D0 - Intel Xeon Processor 3500 Series Specification */
     513        || u == UINT32_C(0x000106A5) /* 321324.pdf - AAK139 - D0 - Intel Xeon Processor 5500 Series Specification */
     514        || u == UINT32_C(0x000106A5) /* 320836.pdf - AAJ124 - D0 - Intel Core i7-900 Desktop Processor Extreme Edition Series and Intel Core i7-900 Desktop Processor Series */
     515        )
     516        return true;
     517    return false;
     518}
     519
     520
    457521/**
    458522 * Does global Ring-0 HWACCM termination.
     
    899963    pVM->hwaccm.s.svm.fSupported            = HWACCMR0Globals.svm.fSupported;
    900964
     965    pVM->hwaccm.s.vmx.fUsePreemptTimer      = HWACCMR0Globals.vmx.fUsePreemptTimer;
     966    pVM->hwaccm.s.vmx.cPreemptTimerShift    = HWACCMR0Globals.vmx.cPreemptTimerShift;
    901967    pVM->hwaccm.s.vmx.msr.feature_ctrl      = HWACCMR0Globals.vmx.msr.feature_ctrl;
    902968    pVM->hwaccm.s.vmx.hostCR4               = HWACCMR0Globals.vmx.hostCR4;
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