VirtualBox

Changeset 49981 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Dec 19, 2013 10:59:28 AM (11 years ago)
Author:
vboxsync
Message:

CPUMAllMsrs.cpp: Fixed cpumLookupMsrRange to resolved aliases. Also reimplemented it as a binary search.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp

    r49972 r49981  
    47304730PCPUMMSRRANGE cpumLookupMsrRange(PVM pVM, uint32_t idMsr)
    47314731{
    4732 # if 0
    47334732    /*
    47344733     * Binary lookup.
    47354734     */
    4736 
    4737 # else
     4735    uint32_t        cRanges   = pVM->cpum.s.GuestInfo.cMsrRanges;
     4736    if (!cRanges)
     4737        return NULL;
     4738    PCPUMMSRRANGE   paRanges  = pVM->cpum.s.GuestInfo.CTX_SUFF(paMsrRanges);
     4739    for (;;)
     4740    {
     4741        uint32_t i = cRanges / 2;
     4742        if (idMsr < paRanges[i].uFirst)
     4743        {
     4744            if (i == 0)
     4745                break;
     4746            cRanges = i;
     4747        }
     4748        else if (idMsr > paRanges[i].uLast)
     4749        {
     4750            i++;
     4751            if (i >= cRanges)
     4752                break;
     4753            cRanges -= i;
     4754            paRanges = &paRanges[i];
     4755        }
     4756        else
     4757        {
     4758            if (paRanges[i].enmRdFn == kCpumMsrRdFn_MsrAlias)
     4759                return cpumLookupMsrRange(pVM, paRanges[i].uValue);
     4760            return &paRanges[i];
     4761        }
     4762    }
     4763
     4764# ifdef VBOX_STRICT
    47384765    /*
    4739      * Linear lookup.
     4766     * Linear lookup to verify the above binary search.
    47404767     */
    47414768    uint32_t        cLeft = pVM->cpum.s.GuestInfo.cMsrRanges;
     
    47444771    {
    47454772        if (idMsr >= pCur->uFirst && idMsr <= pCur->uLast)
     4773        {
     4774            AssertFailed();
     4775            if (pCur->enmRdFn == kCpumMsrRdFn_MsrAlias)
     4776                return cpumLookupMsrRange(pVM, pCur->uValue);
    47464777            return pCur;
     4778        }
    47474779        pCur++;
    47484780    }
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