VirtualBox

Changeset 58561 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Nov 4, 2015 1:35:11 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103907
Message:

CPUMR3Db.cpp: Adjusted the 'host' matching in cpumR3DbGetCpuInfo to not pick Atom profiles for Core cpus just because the march enum value is higher.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/CPUMR3Db.cpp

    r58547 r58561  
    604604
    605605
     606/**
     607 * Do we consider @a enmConsider a better match for @a enmTarget than
     608 * @a enmFound?
     609 *
     610 * Only called when @a enmConsider isn't exactly what we're looking for.
     611 *
     612 * @returns true/false.
     613 * @param   enmConsider         The new microarch to consider.
     614 * @param   enmTarget           The target microarch.
     615 * @param   enmFound            The best microarch match we've found thus far.
     616 */
     617DECLINLINE(bool) cpumR3DbIsBetterMarchMatch(CPUMMICROARCH enmConsider, CPUMMICROARCH enmTarget, CPUMMICROARCH enmFound)
     618{
     619    Assert(enmConsider != enmTarget);
     620
     621    /*
     622     * If we've got an march match, don't bother with enmConsider.
     623     */
     624    if (enmFound == enmTarget)
     625        return false;
     626
     627    /*
     628     * Found is below: Pick 'consider' if it's closer to the target or above it.
     629     */
     630    if (enmFound < enmTarget)
     631        return enmConsider > enmFound;
     632
     633    /*
     634     * Found is above: Pick 'consider' if it's also above (paranoia: or equal)
     635     *                 and but closer to the target.
     636     */
     637    return enmConsider >= enmTarget && enmConsider < enmFound;
     638}
     639
     640
     641/**
     642 * Do we consider @a enmConsider a better match for @a enmTarget than
     643 * @a enmFound?
     644 *
     645 * Only called for intel family 06h CPUs.
     646 *
     647 * @returns true/false.
     648 * @param   enmConsider         The new microarch to consider.
     649 * @param   enmTarget           The target microarch.
     650 * @param   enmFound            The best microarch match we've found thus far.
     651 */
     652static bool cpumR3DbIsBetterIntelFam06Match(CPUMMICROARCH enmConsider, CPUMMICROARCH enmTarget, CPUMMICROARCH enmFound)
     653{
     654    /* Check intel family 06h claims. */
     655    AssertReturn(enmConsider >= kCpumMicroarch_Intel_P6_Core_Atom_First && enmConsider <= kCpumMicroarch_Intel_P6_Core_Atom_End,
     656                 false);
     657    AssertReturn(enmTarget   >= kCpumMicroarch_Intel_P6_Core_Atom_First && enmTarget   <= kCpumMicroarch_Intel_P6_Core_Atom_End,
     658                 false);
     659
     660    /* Put matches out of the way. */
     661    if (enmConsider == enmTarget)
     662        return true;
     663    if (enmFound == enmTarget)
     664        return false;
     665
     666    /* If found isn't a family 06h march, whatever we're considering must be a better choice. */
     667    if (   enmFound < kCpumMicroarch_Intel_P6_Core_Atom_First
     668        || enmFound > kCpumMicroarch_Intel_P6_Core_Atom_End)
     669        return true;
     670
     671    /*
     672     * The family 06h stuff is split into three categories:
     673     *      - Common P6 heritage
     674     *      - Core
     675     *      - Atom
     676     *
     677     * Determin which of the three arguments are Atom marchs, because that's
     678     * all we need to make the right choice.
     679     */
     680    bool const fConsiderAtom = enmConsider >= kCpumMicroarch_Intel_Atom_First;
     681    bool const fTargetAtom   = enmTarget   >= kCpumMicroarch_Intel_Atom_First;
     682    bool const fFoundAtom    = enmFound    >= kCpumMicroarch_Intel_Atom_First;
     683
     684    /*
     685     * Want atom:
     686     */
     687    if (fTargetAtom)
     688    {
     689        /* Pick the atom if we've got one of each.*/
     690        if (fConsiderAtom != fFoundAtom)
     691            return fConsiderAtom;
     692        /* If we haven't got any atoms under consideration, pick a P6 or the earlier core.
     693           Note! Not entirely sure Dothan is the best choice, but it'll do for now. */
     694        if (!fConsiderAtom)
     695        {
     696            if (enmConsider > enmFound)
     697                return enmConsider <= kCpumMicroarch_Intel_P6_M_Dothan;
     698            return enmFound > kCpumMicroarch_Intel_P6_M_Dothan;
     699        }
     700        /* else: same category, default comparison rules. */
     701        Assert(fConsiderAtom && fFoundAtom);
     702    }
     703    /*
     704     * Want non-atom:
     705     */
     706    /* Pick the non-atom if we've got one of each. */
     707    else if (fConsiderAtom != fFoundAtom)
     708        return fFoundAtom;
     709    /* If we've only got atoms under consideration, pick the older one just to pick something. */
     710    else if (fConsiderAtom)
     711        return enmConsider < enmFound;
     712    else
     713        Assert(!fConsiderAtom && !fFoundAtom);
     714
     715    /*
     716     * Same basic category.  Do same compare as caller.
     717     */
     718    return cpumR3DbIsBetterMarchMatch(enmConsider, enmTarget, enmFound);
     719}
     720
     721
    606722int cpumR3DbGetCpuInfo(const char *pszName, PCPUMINFO pInfo)
    607723{
     
    677793                             || pEntry->uFamily != uFamily)
    678794                        pEntry = pCur;
    679                     else if (  pCur->enmMicroarch >= enmMicroarch
    680                              ? pCur->enmMicroarch < pEntry->enmMicroarch || pEntry->enmMicroarch < enmMicroarch
    681                              : pCur->enmMicroarch > pEntry->enmMicroarch)
     795                    /* Special march matching rules applies to intel family 06h. */
     796                    else if (     enmVendor == CPUMCPUVENDOR_INTEL
     797                               && uFamily   == 6
     798                             ? cpumR3DbIsBetterIntelFam06Match(pCur->enmMicroarch, enmMicroarch, pEntry->enmMicroarch)
     799                             : cpumR3DbIsBetterMarchMatch(pCur->enmMicroarch, enmMicroarch, pEntry->enmMicroarch))
    682800                        pEntry = pCur;
    683801                }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette