Skip to content

Commit bc69f86

Browse files
authored
Merge pull request #5671 from martin-frbg/cpuid_x86_cache
Update x86 cache size decoding table from current sandpile.org data
2 parents 1ff3a1a + 02f5f62 commit bc69f86

File tree

1 file changed

+132
-9
lines changed

1 file changed

+132
-9
lines changed

cpuid_x86.c

Lines changed: 132 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,10 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
489489
info[12] = BITMASK(edx, 8, 0xff);
490490
info[13] = BITMASK(edx, 16, 0xff);
491491
info[14] = BITMASK(edx, 24, 0xff);
492-
492+
fprintf(stderr,"numcalls needed to retrieve all cache data %d\n",numcalls);
493493
for (i = 0; i < 15; i++) {
494494
switch (info[i]) {
495-
/* This table is from http://www.sandpile.org/ia32/cpuid.htm */
495+
/* This table is from http://www.sandpile.org/x86/cpuid.htm */
496496

497497
case 0x01:
498498
ITB.size = 4;
@@ -539,6 +539,11 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
539539
LD1.associative = 2;
540540
LD1.linesize = 32;
541541
break;
542+
case 0x0b:
543+
LITB.size = 4096;
544+
LITB.associative= 4;
545+
LITB.linesize = 4;
546+
break;
542547
case 0x0c:
543548
LD1.size = 16;
544549
LD1.associative = 4;
@@ -569,6 +574,11 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
569574
L2.associative = 6;
570575
L2.linesize = 64;
571576
break;
577+
case 0x1d:
578+
L2.size = 128;
579+
L2.associative = 2;
580+
L2.linesize = 64;
581+
break;
572582
case 0x21:
573583
L2.size = 256;
574584
L2.associative = 8;
@@ -584,6 +594,10 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
584594
L3.associative = 8;
585595
L3.linesize = 64;
586596
break;
597+
case 0x24:
598+
L2.size = 1024;
599+
L2.associative = 16;
600+
L2.linesize = 64;
587601
case 0x25:
588602
L3.size = 2048;
589603
L3.associative = 8;
@@ -634,6 +648,9 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
634648
L2.associative = 4;
635649
L2.linesize = 64;
636650
break;
651+
case 0x40:
652+
// no integrated L2 or L3 cache, old P4/P6
653+
break;
637654
case 0x41:
638655
L2.size = 128;
639656
L2.associative = 4;
@@ -754,10 +771,20 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
754771
LDTB.linesize = 16;
755772
break;
756773
case 0x57:
757-
LDTB.size = 4096;
758-
LDTB.associative = 4;
759-
LDTB.linesize = 16;
760-
break;
774+
DTB.size = 4;
775+
DTB.associative = 4;
776+
DTB.linesize = 16;
777+
break;
778+
case 0x59:
779+
DTB.size = 4;
780+
DTB.associative = 0;
781+
DTB.linesize = 16;
782+
break;
783+
case 0x5a:
784+
LDTB.size = 4096;
785+
LDTB.associative = 4;
786+
LDTB.linesize = 32;
787+
break;
761788
case 0x5b:
762789
DTB.size = 4;
763790
DTB.associative = 0;
@@ -790,6 +817,10 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
790817
LD1.associative = 8;
791818
LD1.linesize = 64;
792819
break;
820+
case 0x61:
821+
ITB.size = 4096;
822+
ITB.associative = 0;
823+
ITB.linesize = 48;
793824
case 0x63:
794825
DTB.size = 2048;
795826
DTB.associative = 4;
@@ -798,6 +829,10 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
798829
LDTB.associative = 4;
799830
LDTB.linesize = 32;
800831
break;
832+
case 0x64:
833+
DTB.size = 4;
834+
DTB.associative = 4;
835+
DTB.linesize = 512;
801836
case 0x66:
802837
LD1.size = 8;
803838
LD1.associative = 4;
@@ -813,6 +848,26 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
813848
LD1.associative = 4;
814849
LD1.linesize = 64;
815850
break;
851+
case 0x6a:
852+
DTB.size = 4;
853+
DTB.associative = 8;
854+
DTB.linesize = 64;
855+
break;
856+
case 0x6b:
857+
DTB.size = 4;
858+
DTB.associative = 8;
859+
DTB.linesize = 256;
860+
break;
861+
case 0x6c:
862+
LDTB.size = 4096;
863+
LDTB.associative= 8;
864+
LDTB.linesize = 126;
865+
break;
866+
case 0x6d:
867+
LDTB.size = 1048576;
868+
LDTB.associative= 0;
869+
LDTB.linesize = 16;
870+
break;
816871
case 0x70:
817872
LC1.size = 12;
818873
LC1.associative = 8;
@@ -882,6 +937,11 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
882937
L2.associative = 2;
883938
L2.linesize = 64;
884939
break;
940+
case 0x80:
941+
L2.size = 512;
942+
L2.associative = 8;
943+
L2.linesize = 64;
944+
break;
885945
case 0x81:
886946
L2.size = 128;
887947
L2.associative = 8;
@@ -952,6 +1012,11 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
9521012
L2DTB.associative = 0;
9531013
L2DTB.linesize = 96;
9541014
break;
1015+
case 0xa0:
1016+
DTB.size = 4;
1017+
DTB.associative = 0;
1018+
DTB.linesize = 32;
1019+
break;
9551020
case 0xb0:
9561021
ITB.size = 4;
9571022
ITB.associative = 4;
@@ -977,11 +1042,54 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
9771042
DTB.associative = 4;
9781043
DTB.linesize = 256;
9791044
break;
1045+
case 0xb5:
1046+
ITB.size = 4;
1047+
ITB.associative = 8;
1048+
ITB.linesize = 64;
1049+
break;
1050+
case 0xb6:
1051+
ITB.size = 4;
1052+
ITB.associative = 8;
1053+
ITB.linesize = 128;
1054+
break;
9801055
case 0xba:
9811056
DTB.size = 4;
9821057
DTB.associative = 4;
9831058
DTB.linesize = 64;
9841059
break;
1060+
case 0xc0:
1061+
DTB.size = 4;
1062+
DTB.associative = 4;
1063+
DTB.linesize = 8;
1064+
LDTB.size = 4096;
1065+
LDTB.associative= 4;
1066+
LDTB.linesize = 8;
1067+
break;
1068+
case 0xc1:
1069+
L2.size = 4;
1070+
L2.associative = 8;
1071+
L2.linesize = 1024;
1072+
break;
1073+
case 0xc2:
1074+
DTB.size = 2048;
1075+
DTB.associative= 4;
1076+
DTB.linesize = 16;
1077+
break;
1078+
case 0xc3:
1079+
L2.size = 4;
1080+
L2.associative = 6;
1081+
L2.linesize = 1536;
1082+
break;
1083+
case 0xc4:
1084+
DTB.size = 2048;
1085+
DTB.associative= 4;
1086+
DTB.linesize = 32;
1087+
break;
1088+
case 0xca:
1089+
L2.size = 4;
1090+
L2.associative = 4;
1091+
L2.linesize = 512;
1092+
break;
9851093
case 0xd0:
9861094
L3.size = 512;
9871095
L3.associative = 4;
@@ -1013,17 +1121,17 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
10131121
L3.linesize = 64;
10141122
break;
10151123
case 0xdc:
1016-
L3.size = 2048;
1124+
L3.size = 1536;
10171125
L3.associative = 12;
10181126
L3.linesize = 64;
10191127
break;
10201128
case 0xdd:
1021-
L3.size = 4096;
1129+
L3.size = 3072;
10221130
L3.associative = 12;
10231131
L3.linesize = 64;
10241132
break;
10251133
case 0xde:
1026-
L3.size = 8192;
1134+
L3.size = 6144;
10271135
L3.associative = 12;
10281136
L3.linesize = 64;
10291137
break;
@@ -1042,6 +1150,21 @@ int get_cacheinfo(int type, cache_info_t *cacheinfo)
10421150
L3.associative = 16;
10431151
L3.linesize = 64;
10441152
break;
1153+
case 0xea:
1154+
L3.size = 12288;
1155+
L3.associative = 24;
1156+
L3.linesize = 64;
1157+
break;
1158+
case 0xeb:
1159+
L3.size = 18432;
1160+
L3.associative = 24;
1161+
L3.linesize = 64;
1162+
break;
1163+
case 0xec:
1164+
L3.size = 24576;
1165+
L3.associative = 24;
1166+
L3.linesize = 64;
1167+
break;
10451168
}
10461169
}
10471170
}

0 commit comments

Comments
 (0)