VirtualBox

Changeset 25803 in vbox


Ignore:
Timestamp:
Jan 13, 2010 2:16:12 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56570
Message:

VMM: provide reasonable cache info for Intel CPUs in leaf 4 of CPUID

File:
1 edited

Legend:

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

    r24953 r25803  
    10721072        pCpuId = &pVM->cpum.s.GuestCpuIdDef;
    10731073
    1074     bool fHasMoreCaches = (*pEcx == 0);
     1074    uint32_t cCurrentCacheIndex = *pEcx;
    10751075
    10761076    *pEax = pCpuId->eax;
     
    10881088
    10891089    if (    iLeaf == 4
    1090         &&  fHasMoreCaches
     1090        &&  cCurrentCacheIndex < 3
    10911091        &&  pVM->cpum.s.enmGuestCpuVendor == CPUMCPUVENDOR_INTEL)
    10921092    {
    1093         /* Report L0 data cache, Linux'es num_cpu_cores() requires
    1094          * that to be non-0 to detect core count correctly. */
    1095         *pEax |= (1 << 5) /* level 1 */ | 1 /* 1 - data cache, 2 - i-cache, 3 - unified */ ;
    1096         *pEbx = 63 /* linesize 64 */ ;
     1093        uint32_t type, level, sharing, linesize,
     1094                 partitions, associativity, sets, cores;
     1095
     1096        /* For type: 1 - data cache, 2 - i-cache, 3 - unified */
     1097        partitions = 1;
     1098        /* Those are only to shut up compiler, as they will always
     1099           get overwritten, and compiler should be able to figure that out */
     1100        sets = associativity = sharing = level = 1;
     1101        cores = pVM->cCpus > 32 ? 32 : pVM->cCpus;
     1102        switch (cCurrentCacheIndex)
     1103        {
     1104            case 0:
     1105                type = 1;
     1106                level = 1;
     1107                sharing = 1;
     1108                linesize = 64;
     1109                associativity = 8;
     1110                sets = 64;
     1111                break;
     1112            case 1:
     1113                level = 1;
     1114                type = 2;
     1115                sharing = 1;
     1116                linesize = 64;
     1117                associativity = 8;
     1118                sets = 64;
     1119                break;
     1120            case 2:
     1121                level = 2;
     1122                type = 3;
     1123                sharing = 2;
     1124                linesize = 64;
     1125                associativity = 24;
     1126                sets = 4096;
     1127                break;
     1128        }
     1129
     1130        *pEax |= ((cores - 1) << 26)        |
     1131                 ((sharing - 1) << 14)      |
     1132                 (level << 5)               |
     1133                 1;
     1134        *pEbx = (linesize - 1)               |
     1135                ((partitions - 1) << 12)     |
     1136                ((associativity - 1) << 22); /* -1 encoding */
     1137        *pEcx = sets - 1;
    10971138    }
    10981139
     
    20762117    return enmMode;
    20772118}
    2078 
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