summaryrefslogtreecommitdiffstats
path: root/src/VBox/VMM/tools/VBoxCpuReport.cpp
blob: b549495bf924510a62917d9e2597e48bd3f406e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
/* $Id: VBoxCpuReport.cpp $ */
/** @file
 * VBoxCpuReport - Produces the basis for a CPU DB entry.
 */

/*
 * Copyright (C) 2013-2020 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */


/*********************************************************************************************************************************
*   Header Files                                                                                                                 *
*********************************************************************************************************************************/
#include <iprt/asm.h>
#include <iprt/asm-amd64-x86.h>
#include <iprt/buildconfig.h>
#include <iprt/ctype.h>
#include <iprt/file.h>
#include <iprt/getopt.h>
#include <iprt/initterm.h>
#include <iprt/message.h>
#include <iprt/mem.h>
#include <iprt/path.h>
#include <iprt/string.h>
#include <iprt/stream.h>
#include <iprt/symlink.h>
#include <iprt/thread.h>
#include <iprt/time.h>

#include <VBox/err.h>
#include <VBox/vmm/cpum.h>
#include <VBox/sup.h>

#include "VBoxCpuReport.h"


/*********************************************************************************************************************************
*   Structures and Typedefs                                                                                                      *
*********************************************************************************************************************************/
/** Write only register. */
#define VBCPUREPMSR_F_WRITE_ONLY      RT_BIT(0)

typedef struct VBCPUREPMSR
{
    /** The first MSR register number. */
    uint32_t        uMsr;
    /** Flags (MSRREPORT_F_XXX). */
    uint32_t        fFlags;
    /** The value we read, unless write-only.  */
    uint64_t        uValue;
} VBCPUREPMSR;


/*********************************************************************************************************************************
*   Global Variables                                                                                                             *
*********************************************************************************************************************************/
/** The CPU vendor.  Used by the MSR code. */
static CPUMCPUVENDOR    g_enmVendor = CPUMCPUVENDOR_INVALID;
/** The CPU microarchitecture.  Used by the MSR code. */
static CPUMMICROARCH    g_enmMicroarch = kCpumMicroarch_Invalid;
/** Set if g_enmMicroarch indicates an Intel NetBurst CPU. */
static bool             g_fIntelNetBurst = false;
/** The alternative report stream. */
static PRTSTREAM        g_pReportOut;
/** The alternative debug stream. */
static PRTSTREAM        g_pDebugOut;
/** Whether to skip MSR collection.   */
static bool             g_fNoMsrs = false;

/** Snooping info storage for vbCpuRepGuessScalableBusFrequencyName. */
static uint64_t         g_uMsrIntelP6FsbFrequency = UINT64_MAX;

/** The MSR accessors interface. */
static VBCPUREPMSRACCESSORS g_MsrAcc;



void vbCpuRepDebug(const char *pszMsg, ...)
{
    va_list va;

    /* Always print a copy of the report to standard error. */
    va_start(va, pszMsg);
    RTStrmPrintfV(g_pStdErr, pszMsg, va);
    va_end(va);
    RTStrmFlush(g_pStdErr);

    /* Alternatively, also print to a log file. */
    if (g_pDebugOut)
    {
        va_start(va, pszMsg);
        RTStrmPrintfV(g_pDebugOut, pszMsg, va);
        va_end(va);
        RTStrmFlush(g_pDebugOut);
    }

    /* Give the output device a chance to write / display it. */
    RTThreadSleep(1);
}


void vbCpuRepPrintf(const char *pszMsg, ...)
{
    va_list va;

    /* Output to report file, if requested. */
    if (g_pReportOut)
    {
        va_start(va, pszMsg);
        RTStrmPrintfV(g_pReportOut, pszMsg, va);
        va_end(va);
        RTStrmFlush(g_pReportOut);
    }

    /* Always print a copy of the report to standard out. */
    va_start(va, pszMsg);
    RTStrmPrintfV(g_pStdOut, pszMsg, va);
    va_end(va);
    RTStrmFlush(g_pStdOut);
}



static int vbCpuRepMsrsAddOne(VBCPUREPMSR **ppaMsrs, uint32_t *pcMsrs,
                              uint32_t uMsr, uint64_t uValue, uint32_t fFlags)
{
    /*
     * Grow the array?
     */
    uint32_t cMsrs = *pcMsrs;
    if ((cMsrs % 64) == 0)
    {
        void *pvNew = RTMemRealloc(*ppaMsrs, (cMsrs + 64) * sizeof(**ppaMsrs));
        if (!pvNew)
        {
            RTMemFree(*ppaMsrs);
            *ppaMsrs = NULL;
            *pcMsrs  = 0;
            return VERR_NO_MEMORY;
        }
        *ppaMsrs = (VBCPUREPMSR *)pvNew;
    }

    /*
     * Add it.
     */
    VBCPUREPMSR *pEntry = *ppaMsrs + cMsrs;
    pEntry->uMsr   = uMsr;
    pEntry->fFlags = fFlags;
    pEntry->uValue = uValue;
    *pcMsrs = cMsrs + 1;

    return VINF_SUCCESS;
}


/**
 * Returns the max physical address width as a number of bits.
 *
 * @returns Bit count.
 */
static uint8_t vbCpuRepGetPhysAddrWidth(void)
{
    uint8_t  cMaxWidth;
    if (!ASMHasCpuId())
        cMaxWidth = 32;
    else
    {
        uint32_t cMaxExt = ASMCpuId_EAX(0x80000000);
        if (ASMIsValidExtRange(cMaxExt)&& cMaxExt >= 0x80000008)
            cMaxWidth = ASMCpuId_EAX(0x80000008) & 0xff;
        else if (   ASMIsValidStdRange(ASMCpuId_EAX(0))
                 && (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_PSE36))
            cMaxWidth = 36;
        else
            cMaxWidth = 32;
    }
    return cMaxWidth;
}


static bool vbCpuRepSupportsPae(void)
{
    return ASMHasCpuId()
        && ASMIsValidStdRange(ASMCpuId_EAX(0))
        && (ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_PAE);
}


static bool vbCpuRepSupportsLongMode(void)
{
    return ASMHasCpuId()
        && ASMIsValidExtRange(ASMCpuId_EAX(0x80000000))
        && (ASMCpuId_EDX(0x80000001) & X86_CPUID_EXT_FEATURE_EDX_LONG_MODE);
}


static bool vbCpuRepSupportsNX(void)
{
    return ASMHasCpuId()
        && ASMIsValidExtRange(ASMCpuId_EAX(0x80000000))
        && (ASMCpuId_EDX(0x80000001) & X86_CPUID_EXT_FEATURE_EDX_NX);
}


static bool vbCpuRepSupportsX2Apic(void)
{
    return ASMHasCpuId()
        && ASMIsValidStdRange(ASMCpuId_EAX(0))
        && (ASMCpuId_ECX(1) & X86_CPUID_FEATURE_ECX_X2APIC);
}



#if 0 /* unused */
static bool msrProberWrite(uint32_t uMsr, uint64_t uValue)
{
    bool fGp;
    int rc = g_MsrAcc.pfnMsrWrite(uMsr, NIL_RTCPUID, uValue, &fGp);
    AssertRC(rc);
    return RT_SUCCESS(rc) && !fGp;
}
#endif


static bool msrProberRead(uint32_t uMsr, uint64_t *puValue)
{
    *puValue = 0;
    bool fGp;
    int rc = g_MsrAcc.pfnMsrProberRead(uMsr, NIL_RTCPUID, puValue, &fGp);
    AssertRC(rc);
    return RT_SUCCESS(rc) && !fGp;
}


/** Tries to modify the register by writing the original value to it. */
static bool msrProberModifyNoChange(uint32_t uMsr)
{
    SUPMSRPROBERMODIFYRESULT Result;
    int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, UINT64_MAX, 0, &Result);
    return RT_SUCCESS(rc)
        && !Result.fBeforeGp
        && !Result.fModifyGp
        && !Result.fAfterGp
        && !Result.fRestoreGp;
}


/** Tries to modify the register by writing zero to it. */
static bool msrProberModifyZero(uint32_t uMsr)
{
    SUPMSRPROBERMODIFYRESULT Result;
    int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, 0, 0, &Result);
    return RT_SUCCESS(rc)
        && !Result.fBeforeGp
        && !Result.fModifyGp
        && !Result.fAfterGp
        && !Result.fRestoreGp;
}


/**
 * Tries to modify each bit in the MSR and see if we can make it change.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR.
 * @param   pfIgnMask           The ignore mask to update.
 * @param   pfGpMask            The GP mask to update.
 * @param   fSkipMask           Mask of bits to skip.
 */
static int msrProberModifyBitChanges(uint32_t uMsr, uint64_t *pfIgnMask, uint64_t *pfGpMask, uint64_t fSkipMask)
{
    for (unsigned iBit = 0; iBit < 64; iBit++)
    {
        uint64_t fBitMask = RT_BIT_64(iBit);
        if (fBitMask & fSkipMask)
            continue;

        /* Set it. */
        SUPMSRPROBERMODIFYRESULT ResultSet;
        int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet);
        if (RT_FAILURE(rc))
            return RTMsgErrorRc(rc, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc);

        /* Clear it. */
        SUPMSRPROBERMODIFYRESULT ResultClear;
        rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear);
        if (RT_FAILURE(rc))
            return RTMsgErrorRc(rc, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc);

        if (ResultSet.fModifyGp || ResultClear.fModifyGp)
            *pfGpMask |= fBitMask;
        else if (   (   ((ResultSet.uBefore   ^ ResultSet.uAfter)   & fBitMask) == 0
                     && !ResultSet.fBeforeGp
                     && !ResultSet.fAfterGp)
                 && (   ((ResultClear.uBefore ^ ResultClear.uAfter) & fBitMask) == 0
                     && !ResultClear.fBeforeGp
                     && !ResultClear.fAfterGp) )
            *pfIgnMask |= fBitMask;
    }

    return VINF_SUCCESS;
}


#if 0 /* currently unused */
/**
 * Tries to modify one bit.
 *
 * @retval  -2 on API error.
 * @retval  -1 on \#GP.
 * @retval  0 if ignored.
 * @retval  1 if it changed.
 *
 * @param   uMsr                The MSR.
 * @param   iBit                The bit to try modify.
 */
static int msrProberModifyBit(uint32_t uMsr, unsigned iBit)
{
    uint64_t fBitMask = RT_BIT_64(iBit);

    /* Set it. */
    SUPMSRPROBERMODIFYRESULT ResultSet;
    int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, fBitMask, &ResultSet);
    if (RT_FAILURE(rc))
        return RTMsgErrorRc(-2, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, fBitMask, rc);

    /* Clear it. */
    SUPMSRPROBERMODIFYRESULT ResultClear;
    rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, ~fBitMask, 0, &ResultClear);
    if (RT_FAILURE(rc))
        return RTMsgErrorRc(-2, "pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, ~fBitMask, 0, rc);

    if (ResultSet.fModifyGp || ResultClear.fModifyGp)
        return -1;

    if (   (   ((ResultSet.uBefore   ^ ResultSet.uAfter)   & fBitMask) != 0
            && !ResultSet.fBeforeGp
            && !ResultSet.fAfterGp)
        || (   ((ResultClear.uBefore ^ ResultClear.uAfter) & fBitMask) != 0
            && !ResultClear.fBeforeGp
            && !ResultClear.fAfterGp) )
        return 1;

    return 0;
}
#endif


/**
 * Tries to do a simple AND+OR change and see if we \#GP or not.
 *
 * @retval  @c true if successfully modified.
 * @retval  @c false if \#GP or other error.
 *
 * @param   uMsr                The MSR.
 * @param   fAndMask            The AND mask.
 * @param   fOrMask             The OR mask.
 */
static bool msrProberModifySimpleGp(uint32_t uMsr, uint64_t fAndMask, uint64_t fOrMask)
{
    SUPMSRPROBERMODIFYRESULT Result;
    int rc = g_MsrAcc.pfnMsrProberModify(uMsr, NIL_RTCPUID, fAndMask, fOrMask, &Result);
    if (RT_FAILURE(rc))
    {
        RTMsgError("g_MsrAcc.pfnMsrProberModify(%#x,,%#llx,%#llx,): %Rrc", uMsr, fAndMask, fOrMask, rc);
        return false;
    }
    return !Result.fBeforeGp
        && !Result.fModifyGp
        && !Result.fAfterGp
        && !Result.fRestoreGp;
}




/**
 * Combination of the basic tests.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR.
 * @param   fSkipMask           Mask of bits to skip.
 * @param   pfReadOnly          Where to return read-only status.
 * @param   pfIgnMask           Where to return the write ignore mask.  Need not
 *                              be initialized.
 * @param   pfGpMask            Where to return the write GP mask.  Need not
 *                              be initialized.
 */
static int msrProberModifyBasicTests(uint32_t uMsr, uint64_t fSkipMask, bool *pfReadOnly, uint64_t *pfIgnMask, uint64_t *pfGpMask)
{
    if (msrProberModifyNoChange(uMsr))
    {
        *pfReadOnly = false;
        *pfIgnMask  = 0;
        *pfGpMask  = 0;
        return msrProberModifyBitChanges(uMsr, pfIgnMask, pfGpMask, fSkipMask);
    }

    *pfReadOnly = true;
    *pfIgnMask  = 0;
    *pfGpMask   = UINT64_MAX;
    return VINF_SUCCESS;
}



/**
 * Determines for the MSR AND mask.
 *
 * Older CPUs doesn't necessiarly implement all bits of the MSR register number.
 * So, we have to approximate how many are used so we don't get an overly large
 * and confusing set of MSRs when probing.
 *
 * @returns The mask.
 */
static uint32_t determineMsrAndMask(void)
{
#define VBCPUREP_MASK_TEST_MSRS     7
    static uint32_t const s_aMsrs[VBCPUREP_MASK_TEST_MSRS] =
    {
        /* Try a bunch of mostly read only registers: */
        MSR_P5_MC_TYPE, MSR_IA32_PLATFORM_ID, MSR_IA32_MTRR_CAP, MSR_IA32_MCG_CAP, MSR_IA32_CR_PAT,
        /* Then some which aren't supposed to be present on any CPU: */
        0x00000015, 0x00000019,
    };

    /* Get the base values. */
    uint64_t auBaseValues[VBCPUREP_MASK_TEST_MSRS];
    for (unsigned i = 0; i < RT_ELEMENTS(s_aMsrs); i++)
    {
        if (!msrProberRead(s_aMsrs[i], &auBaseValues[i]))
            auBaseValues[i] = UINT64_MAX;
        //vbCpuRepDebug("Base: %#x -> %#llx\n", s_aMsrs[i], auBaseValues[i]);
    }

    /* Do the probing. */
    unsigned iBit;
    for (iBit = 31; iBit > 8; iBit--)
    {
        uint64_t fMsrOrMask = RT_BIT_64(iBit);
        for (unsigned iTest = 0; iTest <= 64 && fMsrOrMask < UINT32_MAX; iTest++)
        {
            for (unsigned i = 0; i < RT_ELEMENTS(s_aMsrs); i++)
            {
                uint64_t uValue;
                if (!msrProberRead(s_aMsrs[i] | fMsrOrMask, &uValue))
                    uValue = UINT64_MAX;
                if (uValue != auBaseValues[i])
                {
                    uint32_t fMsrMask = iBit >= 31 ? UINT32_MAX : RT_BIT_32(iBit + 1) - 1;
                    vbCpuRepDebug("MSR AND mask: quit on iBit=%u uMsr=%#x (%#x) %llx != %llx => fMsrMask=%#x\n",
                                  iBit, s_aMsrs[i] | (uint32_t)fMsrOrMask, s_aMsrs[i], uValue, auBaseValues[i], fMsrMask);
                    return fMsrMask;
                }
            }

            /* Advance. */
            if (iBit <= 6)
                fMsrOrMask += RT_BIT_64(iBit);
            else if (iBit <= 11)
                fMsrOrMask += RT_BIT_64(iBit) * 33;
            else if (iBit <= 16)
                fMsrOrMask += RT_BIT_64(iBit) * 1025;
            else if (iBit <= 22)
                fMsrOrMask += RT_BIT_64(iBit) * 65537;
            else
                fMsrOrMask += RT_BIT_64(iBit) * 262145;
        }
    }

    uint32_t fMsrMask = RT_BIT_32(iBit + 1) - 1;
    vbCpuRepDebug("MSR AND mask: less that %u bits that matters?!? => fMsrMask=%#x\n", iBit + 1, fMsrMask);
    return fMsrMask;
}


static int findMsrs(VBCPUREPMSR **ppaMsrs, uint32_t *pcMsrs, uint32_t fMsrMask)
{
    /*
     * Gather them.
     */
    static struct { uint32_t uFirst, cMsrs; } const s_aRanges[] =
    {
        { 0x00000000, 0x00042000 },
        { 0x10000000, 0x00001000 },
        { 0x20000000, 0x00001000 },
        { 0x40000000, 0x00012000 },
        { 0x80000000, 0x00012000 },
        { 0xc0000000, 0x00022000 }, /* Had some trouble here on solaris with the tstVMM setup. */
    };

    *pcMsrs  = 0;
    *ppaMsrs = NULL;

    for (unsigned i = 0; i < RT_ELEMENTS(s_aRanges); i++)
    {
        uint32_t uMsr  = s_aRanges[i].uFirst;
        if ((uMsr & fMsrMask) != uMsr)
            continue;
        uint32_t cLeft = s_aRanges[i].cMsrs;
        while (cLeft-- > 0 && (uMsr & fMsrMask) == uMsr)
        {
            if ((uMsr & 0xfff) == 0)
            {
                vbCpuRepDebug("testing %#x...\n", uMsr);
                RTThreadSleep(22);
            }
#if 0
            else if (uMsr >= 0x00003170 && uMsr <= 0xc0000090)
            {
                vbCpuRepDebug("testing %#x...\n", uMsr);
                RTThreadSleep(250);
            }
#endif
            /* Skip 0xc0011012..13 as it seems to be bad for our health (Phenom II X6 1100T). */
            /* Ditto for 0x0000002a (EBL_CR_POWERON) and 0x00000277 (MSR_IA32_CR_PAT) on Intel (Atom 330). */
            /* And more of the same for 0x280 on Intel Pentium III. */
            if (   ((uMsr >= 0xc0011012 && uMsr <= 0xc0011013) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
                || (   (uMsr == 0x2a || uMsr == 0x277)
                    && g_enmVendor == CPUMCPUVENDOR_INTEL
                    && g_enmMicroarch == kCpumMicroarch_Intel_Atom_Bonnell)
                || (   (uMsr == 0x280)
                    && g_enmMicroarch == kCpumMicroarch_Intel_P6_III))
                vbCpuRepDebug("Skipping %#x\n", uMsr);
            else
            {
                /* Read probing normally does it. */
                uint64_t uValue = 0;
                bool     fGp    = true;
                int rc = g_MsrAcc.pfnMsrProberRead(uMsr, NIL_RTCPUID, &uValue, &fGp);
                if (RT_FAILURE(rc))
                {
                    RTMemFree(*ppaMsrs);
                    *ppaMsrs = NULL;
                    return RTMsgErrorRc(rc, "pfnMsrProberRead failed on %#x: %Rrc\n", uMsr, rc);
                }

                uint32_t fFlags;
                if (!fGp)
                    fFlags = 0;
                /* VIA/Shanghai HACK - writing to 0x0000317e on a quad core make the core unresponsive. */
                else if (uMsr == 0x0000317e && (g_enmVendor == CPUMCPUVENDOR_VIA || g_enmVendor == CPUMCPUVENDOR_SHANGHAI))
                {
                    uValue = 0;
                    fFlags = VBCPUREPMSR_F_WRITE_ONLY;
                    fGp    = *pcMsrs == 0
                          || (*ppaMsrs)[*pcMsrs - 1].uMsr != 0x0000317d
                          || (*ppaMsrs)[*pcMsrs - 1].fFlags != VBCPUREPMSR_F_WRITE_ONLY;
                }
                else
                {
                    /* Is it a write only register? */
#if 0
                    if (uMsr >= 0x00003170 && uMsr <= 0xc0000090)
                    {
                        vbCpuRepDebug("test writing %#x...\n", uMsr);
                        RTThreadSleep(250);
                    }
#endif
                    fGp = true;
                    rc = g_MsrAcc.pfnMsrProberWrite(uMsr, NIL_RTCPUID, 0, &fGp);
                    if (RT_FAILURE(rc))
                    {
                        RTMemFree(*ppaMsrs);
                        *ppaMsrs = NULL;
                        return RTMsgErrorRc(rc, "pfnMsrProberWrite failed on %#x: %Rrc\n", uMsr, rc);
                    }
                    uValue = 0;
                    fFlags = VBCPUREPMSR_F_WRITE_ONLY;

                    /*
                     * Tweaks.  On Intel CPUs we've got trouble detecting
                     * IA32_BIOS_UPDT_TRIG (0x00000079), so we have to add it manually here.
                     * Ditto on AMD with PATCH_LOADER (0xc0010020).
                     */
                    if (   uMsr == 0x00000079
                        && fGp
                        && g_enmMicroarch >= kCpumMicroarch_Intel_P6_Core_Atom_First
                        && g_enmMicroarch <= kCpumMicroarch_Intel_End)
                        fGp = false;
                    if (   uMsr == 0xc0010020
                        && fGp
                        && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First
                        && g_enmMicroarch <= kCpumMicroarch_AMD_End)
                        fGp = false;
                }

                if (!fGp)
                {
                    /* Add it. */
                    rc = vbCpuRepMsrsAddOne(ppaMsrs, pcMsrs, uMsr, uValue, fFlags);
                    if (RT_FAILURE(rc))
                        return RTMsgErrorRc(rc, "Out of memory (uMsr=%#x).\n", uMsr);
                    if (   (g_enmVendor != CPUMCPUVENDOR_VIA && g_enmVendor != CPUMCPUVENDOR_SHANGHAI)
                        || uValue
                        || fFlags)
                        vbCpuRepDebug("%#010x: uValue=%#llx fFlags=%#x\n", uMsr, uValue, fFlags);
                }
            }

            uMsr++;
        }
    }

    return VINF_SUCCESS;
}

/**
 * Get the name of the specified MSR, if we know it and can handle it.
 *
 * Do _NOT_ add any new names here without ALSO at the SAME TIME making sure it
 * is handled correctly by the PROBING CODE and REPORTED correctly!!
 *
 * @returns Pointer to name if handled, NULL if not yet explored.
 * @param   uMsr                The MSR in question.
 */
static const char *getMsrNameHandled(uint32_t uMsr)
{
    /** @todo figure out where NCU_EVENT_CORE_MASK might be... */
    switch (uMsr)
    {
        case 0x00000000: return "IA32_P5_MC_ADDR";
        case 0x00000001: return "IA32_P5_MC_TYPE";
        case 0x00000006:
            if (g_enmMicroarch >= kCpumMicroarch_Intel_First && g_enmMicroarch <= kCpumMicroarch_Intel_P6_Core_Atom_First)
                return NULL; /* TR4 / cache tag on Pentium, but that's for later. */
            return "IA32_MONITOR_FILTER_LINE_SIZE";
        //case 0x0000000e: return "P?_TR12"; /* K6-III docs */
        case 0x00000010: return "IA32_TIME_STAMP_COUNTER";
        case 0x00000017: return "IA32_PLATFORM_ID";
        case 0x00000018: return "P6_UNK_0000_0018"; /* P6_M_Dothan. */
        case 0x0000001b: return "IA32_APIC_BASE";
        case 0x00000021: return "C2_UNK_0000_0021"; /* Core2_Penryn */
        case 0x0000002a: return g_fIntelNetBurst ? "P4_EBC_HARD_POWERON" : "EBL_CR_POWERON";
        case 0x0000002b: return g_fIntelNetBurst ? "P4_EBC_SOFT_POWERON" : NULL;
        case 0x0000002c: return g_fIntelNetBurst ? "P4_EBC_FREQUENCY_ID" : NULL;
        case 0x0000002e: return "I7_UNK_0000_002e"; /* SandyBridge, IvyBridge. */
        case 0x0000002f: return "P6_UNK_0000_002f"; /* P6_M_Dothan. */
        case 0x00000032: return "P6_UNK_0000_0032"; /* P6_M_Dothan. */
        case 0x00000033: return "TEST_CTL";
        case 0x00000034: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch)
                             || CPUMMICROARCH_IS_INTEL_SILVERMONT_PLUS(g_enmMicroarch)
                              ? "MSR_SMI_COUNT" : "P6_UNK_0000_0034"; /* P6_M_Dothan. */
        case 0x00000035: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch) ? "MSR_CORE_THREAD_COUNT" : "P6_UNK_0000_0035"; /* P6_M_Dothan. */
        case 0x00000036: return "I7_UNK_0000_0036"; /* SandyBridge, IvyBridge. */
        case 0x00000039: return "C2_UNK_0000_0039"; /* Core2_Penryn */
        case 0x0000003a: return "IA32_FEATURE_CONTROL";
        case 0x0000003b: return "P6_UNK_0000_003b"; /* P6_M_Dothan. */
        case 0x0000003e: return "I7_UNK_0000_003e"; /* SandyBridge, IvyBridge. */
        case 0x0000003f: return "P6_UNK_0000_003f"; /* P6_M_Dothan. */
        case 0x00000040: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_0_FROM_IP" : "MSR_LASTBRANCH_0";
        case 0x00000041: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_1_FROM_IP" : "MSR_LASTBRANCH_1";
        case 0x00000042: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_2_FROM_IP" : "MSR_LASTBRANCH_2";
        case 0x00000043: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_3_FROM_IP" : "MSR_LASTBRANCH_3";
        case 0x00000044: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_4_FROM_IP" : "MSR_LASTBRANCH_4";
        case 0x00000045: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_5_FROM_IP" : "MSR_LASTBRANCH_5";
        case 0x00000046: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_6_FROM_IP" : "MSR_LASTBRANCH_6";
        case 0x00000047: return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_7_FROM_IP" : "MSR_LASTBRANCH_7";
        case 0x00000048: return "MSR_LASTBRANCH_8"; /*??*/
        case 0x00000049: return "MSR_LASTBRANCH_9"; /*??*/
        case 0x0000004a: return "P6_UNK_0000_004a"; /* P6_M_Dothan. */
        case 0x0000004b: return "P6_UNK_0000_004b"; /* P6_M_Dothan. */
        case 0x0000004c: return "P6_UNK_0000_004c"; /* P6_M_Dothan. */
        case 0x0000004d: return "P6_UNK_0000_004d"; /* P6_M_Dothan. */
        case 0x0000004e: return "P6_UNK_0000_004e"; /* P6_M_Dothan. */
        case 0x0000004f: return "P6_UNK_0000_004f"; /* P6_M_Dothan. */
        case 0x00000050: return "P6_UNK_0000_0050"; /* P6_M_Dothan. */
        case 0x00000051: return "P6_UNK_0000_0051"; /* P6_M_Dothan. */
        case 0x00000052: return "P6_UNK_0000_0052"; /* P6_M_Dothan. */
        case 0x00000053: return "P6_UNK_0000_0053"; /* P6_M_Dothan. */
        case 0x00000054: return "P6_UNK_0000_0054"; /* P6_M_Dothan. */
        case 0x00000060: return "MSR_LASTBRANCH_0_TO_IP"; /* Core2_Penryn */
        case 0x00000061: return "MSR_LASTBRANCH_1_TO_IP"; /* Core2_Penryn */
        case 0x00000062: return "MSR_LASTBRANCH_2_TO_IP"; /* Core2_Penryn */
        case 0x00000063: return "MSR_LASTBRANCH_3_TO_IP"; /* Core2_Penryn */
        case 0x00000064: return "MSR_LASTBRANCH_4_TO_IP"; /* Atom? */
        case 0x00000065: return "MSR_LASTBRANCH_5_TO_IP";
        case 0x00000066: return "MSR_LASTBRANCH_6_TO_IP";
        case 0x00000067: return "MSR_LASTBRANCH_7_TO_IP";
        case 0x0000006c: return "P6_UNK_0000_006c"; /* P6_M_Dothan. */
        case 0x0000006d: return "P6_UNK_0000_006d"; /* P6_M_Dothan. */
        case 0x0000006e: return "P6_UNK_0000_006e"; /* P6_M_Dothan. */
        case 0x0000006f: return "P6_UNK_0000_006f"; /* P6_M_Dothan. */
        case 0x00000079: return "IA32_BIOS_UPDT_TRIG";
        case 0x00000080: return "P4_UNK_0000_0080";
        case 0x00000088: return "BBL_CR_D0";
        case 0x00000089: return "BBL_CR_D1";
        case 0x0000008a: return "BBL_CR_D2";
        case 0x0000008b: return g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON ? "AMD_K8_PATCH_LEVEL"
                              : g_fIntelNetBurst ? "IA32_BIOS_SIGN_ID" : "BBL_CR_D3|BIOS_SIGN";
        case 0x0000008c: return "P6_UNK_0000_008c"; /* P6_M_Dothan. */
        case 0x0000008d: return "P6_UNK_0000_008d"; /* P6_M_Dothan. */
        case 0x0000008e: return "P6_UNK_0000_008e"; /* P6_M_Dothan. */
        case 0x0000008f: return "P6_UNK_0000_008f"; /* P6_M_Dothan. */
        case 0x00000090: return "P6_UNK_0000_0090"; /* P6_M_Dothan. */
        case 0x0000009b: return "IA32_SMM_MONITOR_CTL";
        case 0x000000a8: return "C2_EMTTM_CR_TABLES_0";
        case 0x000000a9: return "C2_EMTTM_CR_TABLES_1";
        case 0x000000aa: return "C2_EMTTM_CR_TABLES_2";
        case 0x000000ab: return "C2_EMTTM_CR_TABLES_3";
        case 0x000000ac: return "C2_EMTTM_CR_TABLES_4";
        case 0x000000ad: return "C2_EMTTM_CR_TABLES_5";
        case 0x000000ae: return "P6_UNK_0000_00ae"; /* P6_M_Dothan. */
        case 0x000000c1: return "IA32_PMC0";
        case 0x000000c2: return "IA32_PMC1";
        case 0x000000c3: return "IA32_PMC2";
        case 0x000000c4: return "IA32_PMC3";
        /* PMC4+ first seen on SandyBridge. The earlier cut off is just to be
           on the safe side as we must avoid P6_M_Dothan and possibly others. */
        case 0x000000c5: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PMC4" : NULL;
        case 0x000000c6: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PMC5" : NULL;
        case 0x000000c7: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PMC6" : "P6_UNK_0000_00c7"; /* P6_M_Dothan. */
        case 0x000000c8: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PMC7" : NULL;
        case 0x000000cd: return "MSR_FSB_FREQ"; /* P6_M_Dothan. */
        case 0x000000ce: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PLATFORM_INFO" : "P6_UNK_0000_00ce"; /* P6_M_Dothan. */
        case 0x000000cf: return "C2_UNK_0000_00cf"; /* Core2_Penryn. */
        case 0x000000e0: return "C2_UNK_0000_00e0"; /* Core2_Penryn. */
        case 0x000000e1: return "C2_UNK_0000_00e1"; /* Core2_Penryn. */
        case 0x000000e2: return "MSR_PKG_CST_CONFIG_CONTROL";
        case 0x000000e3: return "C2_SMM_CST_MISC_INFO"; /* Core2_Penryn. */
        case 0x000000e4: return "MSR_PMG_IO_CAPTURE_BASE";
        case 0x000000e5: return "C2_UNK_0000_00e5"; /* Core2_Penryn. */
        case 0x000000e7: return "IA32_MPERF";
        case 0x000000e8: return "IA32_APERF";
        case 0x000000ee: return "C1_EXT_CONFIG"; /* Core2_Penryn. msrtool lists it for Core1 as well. */
        case 0x000000fe: return "IA32_MTRRCAP";
        case 0x00000102: return "I7_IB_UNK_0000_0102"; /* IvyBridge. */
        case 0x00000103: return "I7_IB_UNK_0000_0103"; /* IvyBridge. */
        case 0x00000104: return "I7_IB_UNK_0000_0104"; /* IvyBridge. */
        case 0x00000116: return "BBL_CR_ADDR";
        case 0x00000118: return "BBL_CR_DECC";
        case 0x00000119: return "BBL_CR_CTL";
        case 0x0000011a: return "BBL_CR_TRIG";
        case 0x0000011b: return "P6_UNK_0000_011b"; /* P6_M_Dothan. */
        case 0x0000011c: return "C2_UNK_0000_011c"; /* Core2_Penryn. */
        case 0x0000011e: return "BBL_CR_CTL3";
        case 0x00000120: return "SILV_UNK_0000_0120"; /* Silvermont */
        case 0x00000130: return g_enmMicroarch == kCpumMicroarch_Intel_Core7_Westmere
                             || g_enmMicroarch == kCpumMicroarch_Intel_Core7_Nehalem
                              ? "CPUID1_FEATURE_MASK" : NULL;
        case 0x00000131: return g_enmMicroarch == kCpumMicroarch_Intel_Core7_Westmere
                             || g_enmMicroarch == kCpumMicroarch_Intel_Core7_Nehalem
                              ? "CPUID80000001_FEATURE_MASK" : "P6_UNK_0000_0131" /* P6_M_Dothan. */;
        case 0x00000132: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
                              ? "CPUID1_FEATURE_MASK" : NULL;
        case 0x00000133: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
                              ? "CPUIDD_01_FEATURE_MASK" : NULL;
        case 0x00000134: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
                              ? "CPUID80000001_FEATURE_MASK" : NULL;
        case 0x0000013c: return "I7_SB_AES_NI_CTL"; /* SandyBridge. Bit 0 is lock bit, bit 1 disables AES-NI. */
        case 0x00000140: return "I7_IB_UNK_0000_0140"; /* IvyBridge. */
        case 0x00000142: return "I7_IB_UNK_0000_0142"; /* IvyBridge. */
        case 0x0000014e: return "P6_UNK_0000_014e"; /* P6_M_Dothan. */
        case 0x0000014f: return "P6_UNK_0000_014f"; /* P6_M_Dothan. */
        case 0x00000150: return "P6_UNK_0000_0150"; /* P6_M_Dothan. */
        case 0x00000151: return "P6_UNK_0000_0151"; /* P6_M_Dothan. */
        case 0x00000154: return "P6_UNK_0000_0154"; /* P6_M_Dothan. */
        case 0x0000015b: return "P6_UNK_0000_015b"; /* P6_M_Dothan. */
        case 0x0000015e: return "C2_UNK_0000_015e"; /* Core2_Penryn. */
        case 0x0000015f: return "C1_DTS_CAL_CTRL"; /* Core2_Penryn. msrtool only docs this for core1! */
        case 0x00000174: return "IA32_SYSENTER_CS";
        case 0x00000175: return "IA32_SYSENTER_ESP";
        case 0x00000176: return "IA32_SYSENTER_EIP";
        case 0x00000179: return "IA32_MCG_CAP";
        case 0x0000017a: return "IA32_MCG_STATUS";
        case 0x0000017b: return "IA32_MCG_CTL";
        case 0x0000017f: return "I7_SB_ERROR_CONTROL"; /* SandyBridge. */
        case 0x00000180: return g_fIntelNetBurst ? "MSR_MCG_RAX"       : NULL;
        case 0x00000181: return g_fIntelNetBurst ? "MSR_MCG_RBX"       : NULL;
        case 0x00000182: return g_fIntelNetBurst ? "MSR_MCG_RCX"       : NULL;
        case 0x00000183: return g_fIntelNetBurst ? "MSR_MCG_RDX"       : NULL;
        case 0x00000184: return g_fIntelNetBurst ? "MSR_MCG_RSI"       : NULL;
        case 0x00000185: return g_fIntelNetBurst ? "MSR_MCG_RDI"       : NULL;
        case 0x00000186: return g_fIntelNetBurst ? "MSR_MCG_RBP"       : "IA32_PERFEVTSEL0";
        case 0x00000187: return g_fIntelNetBurst ? "MSR_MCG_RSP"       : "IA32_PERFEVTSEL1";
        case 0x00000188: return g_fIntelNetBurst ? "MSR_MCG_RFLAGS"    : "IA32_PERFEVTSEL2";
        case 0x00000189: return g_fIntelNetBurst ? "MSR_MCG_RIP"       : "IA32_PERFEVTSEL3";
        case 0x0000018a: return g_fIntelNetBurst ? "MSR_MCG_MISC"      : "IA32_PERFEVTSEL4";
        case 0x0000018b: return g_fIntelNetBurst ? "MSR_MCG_RESERVED1" : "IA32_PERFEVTSEL5";
        case 0x0000018c: return g_fIntelNetBurst ? "MSR_MCG_RESERVED2" : "IA32_PERFEVTSEL6";
        case 0x0000018d: return g_fIntelNetBurst ? "MSR_MCG_RESERVED3" : "IA32_PERFEVTSEL7";
        case 0x0000018e: return g_fIntelNetBurst ? "MSR_MCG_RESERVED4" : "IA32_PERFEVTSEL8";
        case 0x0000018f: return g_fIntelNetBurst ? "MSR_MCG_RESERVED5" : "IA32_PERFEVTSEL9";
        case 0x00000190: return g_fIntelNetBurst ? "MSR_MCG_R8"        : NULL;
        case 0x00000191: return g_fIntelNetBurst ? "MSR_MCG_R9"        : NULL;
        case 0x00000192: return g_fIntelNetBurst ? "MSR_MCG_R10"       : NULL;
        case 0x00000193: return g_fIntelNetBurst ? "MSR_MCG_R11"       : "C2_UNK_0000_0193";
        case 0x00000194: return g_fIntelNetBurst ? "MSR_MCG_R12"       : "CLOCK_FLEX_MAX";
        case 0x00000195: return g_fIntelNetBurst ? "MSR_MCG_R13"       : NULL;
        case 0x00000196: return g_fIntelNetBurst ? "MSR_MCG_R14"       : NULL;
        case 0x00000197: return g_fIntelNetBurst ? "MSR_MCG_R15"       : NULL;
        case 0x00000198: return "IA32_PERF_STATUS";
        case 0x00000199: return "IA32_PERF_CTL";
        case 0x0000019a: return "IA32_CLOCK_MODULATION";
        case 0x0000019b: return "IA32_THERM_INTERRUPT";
        case 0x0000019c: return "IA32_THERM_STATUS";
        case 0x0000019d: return "IA32_THERM2_CTL";
        case 0x0000019e: return "P6_UNK_0000_019e"; /* P6_M_Dothan. */
        case 0x0000019f: return "P6_UNK_0000_019f"; /* P6_M_Dothan. */
        case 0x000001a0: return "IA32_MISC_ENABLE";
        case 0x000001a1: return g_fIntelNetBurst ? "MSR_PLATFORM_BRV" : "P6_UNK_0000_01a1" /* P6_M_Dothan. */;
        case 0x000001a2: return g_fIntelNetBurst ? "P4_UNK_0000_01a2" : "I7_MSR_TEMPERATURE_TARGET" /* SandyBridge, IvyBridge. */;
        case 0x000001a4: return "I7_UNK_0000_01a4"; /* SandyBridge, IvyBridge. */
        case 0x000001a6: return "I7_MSR_OFFCORE_RSP_0";
        case 0x000001a7: return "I7_MSR_OFFCORE_RSP_1";
        case 0x000001a8: return "I7_UNK_0000_01a8"; /* SandyBridge, IvyBridge. */
        case 0x000001aa: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch) ? "MSR_MISC_PWR_MGMT" : "P6_PIC_SENS_CFG" /* Pentium M. */;
        case 0x000001ad: return "I7_MSR_TURBO_RATIO_LIMIT"; /* SandyBridge+, Silvermount+ */
        case 0x000001ae: return "P6_UNK_0000_01ae"; /* P6_M_Dothan. */
        case 0x000001af: return "P6_UNK_0000_01af"; /* P6_M_Dothan. */
        case 0x000001b0: return "IA32_ENERGY_PERF_BIAS";
        case 0x000001b1: return "IA32_PACKAGE_THERM_STATUS";
        case 0x000001b2: return "IA32_PACKAGE_THERM_INTERRUPT";
        case 0x000001bf: return "C2_UNK_0000_01bf"; /* Core2_Penryn. */
        case 0x000001c6: return "I7_UNK_0000_01c6"; /* SandyBridge*/
        case 0x000001c8: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_Nehalem ? "MSR_LBR_SELECT" : NULL;
        case 0x000001c9: return    g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah
                                && g_enmMicroarch <= kCpumMicroarch_Intel_P6_Core_Atom_End
                              ? "MSR_LASTBRANCH_TOS" : NULL /* Pentium M Dothan seems to have something else here. */;
        case 0x000001d3: return "P6_UNK_0000_01d3"; /* P6_M_Dothan. */
        case 0x000001d7: return g_fIntelNetBurst ? "MSR_LER_FROM_LIP" : NULL;
        case 0x000001d8: return g_fIntelNetBurst ? "MSR_LER_TO_LIP"   : NULL;
        case 0x000001d9: return "IA32_DEBUGCTL";
        case 0x000001da: return g_fIntelNetBurst ? "MSR_LASTBRANCH_TOS" : NULL;
        case 0x000001db: return g_fIntelNetBurst ? "P6_LASTBRANCH_0" : "P6_LAST_BRANCH_FROM_IP"; /* Not exclusive to P6, also AMD. */
        case 0x000001dc: return g_fIntelNetBurst ? "P6_LASTBRANCH_1" : "P6_LAST_BRANCH_TO_IP";
        case 0x000001dd: return g_fIntelNetBurst ? "P6_LASTBRANCH_2" : "P6_LAST_INT_FROM_IP";
        case 0x000001de: return g_fIntelNetBurst ? "P6_LASTBRANCH_3" : "P6_LAST_INT_TO_IP";
        case 0x000001e0: return "MSR_ROB_CR_BKUPTMPDR6";
        case 0x000001e1: return "I7_SB_UNK_0000_01e1";
        case 0x000001ef: return "I7_SB_UNK_0000_01ef";
        case 0x000001f0: return "I7_VLW_CAPABILITY"; /* SandyBridge.  Bit 1 is A20M and was implemented incorrectly (AAJ49). */
        case 0x000001f2: return "IA32_SMRR_PHYSBASE";
        case 0x000001f3: return "IA32_SMRR_PHYSMASK";
        case 0x000001f8: return "IA32_PLATFORM_DCA_CAP";
        case 0x000001f9: return "IA32_CPU_DCA_CAP";
        case 0x000001fa: return "IA32_DCA_0_CAP";
        case 0x000001fc: return "I7_MSR_POWER_CTL";

        case 0x00000200: return "IA32_MTRR_PHYS_BASE0";
        case 0x00000202: return "IA32_MTRR_PHYS_BASE1";
        case 0x00000204: return "IA32_MTRR_PHYS_BASE2";
        case 0x00000206: return "IA32_MTRR_PHYS_BASE3";
        case 0x00000208: return "IA32_MTRR_PHYS_BASE4";
        case 0x0000020a: return "IA32_MTRR_PHYS_BASE5";
        case 0x0000020c: return "IA32_MTRR_PHYS_BASE6";
        case 0x0000020e: return "IA32_MTRR_PHYS_BASE7";
        case 0x00000210: return "IA32_MTRR_PHYS_BASE8";
        case 0x00000212: return "IA32_MTRR_PHYS_BASE9";
        case 0x00000214: return "IA32_MTRR_PHYS_BASE10";
        case 0x00000216: return "IA32_MTRR_PHYS_BASE11";
        case 0x00000218: return "IA32_MTRR_PHYS_BASE12";
        case 0x0000021a: return "IA32_MTRR_PHYS_BASE13";
        case 0x0000021c: return "IA32_MTRR_PHYS_BASE14";
        case 0x0000021e: return "IA32_MTRR_PHYS_BASE15";

        case 0x00000201: return "IA32_MTRR_PHYS_MASK0";
        case 0x00000203: return "IA32_MTRR_PHYS_MASK1";
        case 0x00000205: return "IA32_MTRR_PHYS_MASK2";
        case 0x00000207: return "IA32_MTRR_PHYS_MASK3";
        case 0x00000209: return "IA32_MTRR_PHYS_MASK4";
        case 0x0000020b: return "IA32_MTRR_PHYS_MASK5";
        case 0x0000020d: return "IA32_MTRR_PHYS_MASK6";
        case 0x0000020f: return "IA32_MTRR_PHYS_MASK7";
        case 0x00000211: return "IA32_MTRR_PHYS_MASK8";
        case 0x00000213: return "IA32_MTRR_PHYS_MASK9";
        case 0x00000215: return "IA32_MTRR_PHYS_MASK10";
        case 0x00000217: return "IA32_MTRR_PHYS_MASK11";
        case 0x00000219: return "IA32_MTRR_PHYS_MASK12";
        case 0x0000021b: return "IA32_MTRR_PHYS_MASK13";
        case 0x0000021d: return "IA32_MTRR_PHYS_MASK14";
        case 0x0000021f: return "IA32_MTRR_PHYS_MASK15";

        case 0x00000250: return "IA32_MTRR_FIX64K_00000";
        case 0x00000258: return "IA32_MTRR_FIX16K_80000";
        case 0x00000259: return "IA32_MTRR_FIX16K_A0000";
        case 0x00000268: return "IA32_MTRR_FIX4K_C0000";
        case 0x00000269: return "IA32_MTRR_FIX4K_C8000";
        case 0x0000026a: return "IA32_MTRR_FIX4K_D0000";
        case 0x0000026b: return "IA32_MTRR_FIX4K_D8000";
        case 0x0000026c: return "IA32_MTRR_FIX4K_E0000";
        case 0x0000026d: return "IA32_MTRR_FIX4K_E8000";
        case 0x0000026e: return "IA32_MTRR_FIX4K_F0000";
        case 0x0000026f: return "IA32_MTRR_FIX4K_F8000";
        case 0x00000277: return "IA32_PAT";
        case 0x00000280: return "IA32_MC0_CTL2";
        case 0x00000281: return "IA32_MC1_CTL2";
        case 0x00000282: return "IA32_MC2_CTL2";
        case 0x00000283: return "IA32_MC3_CTL2";
        case 0x00000284: return "IA32_MC4_CTL2";
        case 0x00000285: return "IA32_MC5_CTL2";
        case 0x00000286: return "IA32_MC6_CTL2";
        case 0x00000287: return "IA32_MC7_CTL2";
        case 0x00000288: return "IA32_MC8_CTL2";
        case 0x00000289: return "IA32_MC9_CTL2";
        case 0x0000028a: return "IA32_MC10_CTL2";
        case 0x0000028b: return "IA32_MC11_CTL2";
        case 0x0000028c: return "IA32_MC12_CTL2";
        case 0x0000028d: return "IA32_MC13_CTL2";
        case 0x0000028e: return "IA32_MC14_CTL2";
        case 0x0000028f: return "IA32_MC15_CTL2";
        case 0x00000290: return "IA32_MC16_CTL2";
        case 0x00000291: return "IA32_MC17_CTL2";
        case 0x00000292: return "IA32_MC18_CTL2";
        case 0x00000293: return "IA32_MC19_CTL2";
        case 0x00000294: return "IA32_MC20_CTL2";
        case 0x00000295: return "IA32_MC21_CTL2";
        //case 0x00000296: return "IA32_MC22_CTL2";
        //case 0x00000297: return "IA32_MC23_CTL2";
        //case 0x00000298: return "IA32_MC24_CTL2";
        //case 0x00000299: return "IA32_MC25_CTL2";
        //case 0x0000029a: return "IA32_MC26_CTL2";
        //case 0x0000029b: return "IA32_MC27_CTL2";
        //case 0x0000029c: return "IA32_MC28_CTL2";
        //case 0x0000029d: return "IA32_MC29_CTL2";
        //case 0x0000029e: return "IA32_MC30_CTL2";
        //case 0x0000029f: return "IA32_MC31_CTL2";
        case 0x000002e0: return "I7_SB_NO_EVICT_MODE"; /* (Bits 1 & 0 are said to have something to do with no-evict cache mode used during early boot.) */
        case 0x000002e6: return "I7_IB_UNK_0000_02e6"; /* IvyBridge */
        case 0x000002e7: return "I7_IB_UNK_0000_02e7"; /* IvyBridge */
        case 0x000002ff: return "IA32_MTRR_DEF_TYPE";
        case 0x00000300: return g_fIntelNetBurst ? "P4_MSR_BPU_COUNTER0"   : "I7_SB_UNK_0000_0300" /* SandyBridge */;
        case 0x00000301: return g_fIntelNetBurst ? "P4_MSR_BPU_COUNTER1"   : NULL;
        case 0x00000302: return g_fIntelNetBurst ? "P4_MSR_BPU_COUNTER2"   : NULL;
        case 0x00000303: return g_fIntelNetBurst ? "P4_MSR_BPU_COUNTER3"   : NULL;
        case 0x00000304: return g_fIntelNetBurst ? "P4_MSR_MS_COUNTER0"    : NULL;
        case 0x00000305: return g_fIntelNetBurst ? "P4_MSR_MS_COUNTER1"    : "I7_SB_UNK_0000_0305" /* SandyBridge, IvyBridge */;
        case 0x00000306: return g_fIntelNetBurst ? "P4_MSR_MS_COUNTER2"    : NULL;
        case 0x00000307: return g_fIntelNetBurst ? "P4_MSR_MS_COUNTER3"    : NULL;
        case 0x00000308: return g_fIntelNetBurst ? "P4_MSR_FLAME_COUNTER0" : NULL;
        case 0x00000309: return g_fIntelNetBurst ? "P4_MSR_FLAME_COUNTER1" : "IA32_FIXED_CTR0";
        case 0x0000030a: return g_fIntelNetBurst ? "P4_MSR_FLAME_COUNTER2" : "IA32_FIXED_CTR1";
        case 0x0000030b: return g_fIntelNetBurst ? "P4_MSR_FLAME_COUNTER3" : "IA32_FIXED_CTR2";
        case 0x0000030c: return g_fIntelNetBurst ? "P4_MSR_IQ_COUNTER0" : NULL;
        case 0x0000030d: return g_fIntelNetBurst ? "P4_MSR_IQ_COUNTER1" : NULL;
        case 0x0000030e: return g_fIntelNetBurst ? "P4_MSR_IQ_COUNTER2" : NULL;
        case 0x0000030f: return g_fIntelNetBurst ? "P4_MSR_IQ_COUNTER3" : NULL;
        case 0x00000310: return g_fIntelNetBurst ? "P4_MSR_IQ_COUNTER4" : NULL;
        case 0x00000311: return g_fIntelNetBurst ? "P4_MSR_IQ_COUNTER5" : NULL;
        case 0x00000345: return "IA32_PERF_CAPABILITIES";
        case 0x00000360: return g_fIntelNetBurst ? "P4_MSR_BPU_CCCR0"   : NULL;
        case 0x00000361: return g_fIntelNetBurst ? "P4_MSR_BPU_CCCR1"   : NULL;
        case 0x00000362: return g_fIntelNetBurst ? "P4_MSR_BPU_CCCR2"   : NULL;
        case 0x00000363: return g_fIntelNetBurst ? "P4_MSR_BPU_CCCR3"   : NULL;
        case 0x00000364: return g_fIntelNetBurst ? "P4_MSR_MS_CCCR0"    : NULL;
        case 0x00000365: return g_fIntelNetBurst ? "P4_MSR_MS_CCCR1"    : NULL;
        case 0x00000366: return g_fIntelNetBurst ? "P4_MSR_MS_CCCR2"    : NULL;
        case 0x00000367: return g_fIntelNetBurst ? "P4_MSR_MS_CCCR3"    : NULL;
        case 0x00000368: return g_fIntelNetBurst ? "P4_MSR_FLAME_CCCR0" : NULL;
        case 0x00000369: return g_fIntelNetBurst ? "P4_MSR_FLAME_CCCR1" : NULL;
        case 0x0000036a: return g_fIntelNetBurst ? "P4_MSR_FLAME_CCCR2" : NULL;
        case 0x0000036b: return g_fIntelNetBurst ? "P4_MSR_FLAME_CCCR3" : NULL;
        case 0x0000036c: return g_fIntelNetBurst ? "P4_MSR_IQ_CCCR0"    : NULL;
        case 0x0000036d: return g_fIntelNetBurst ? "P4_MSR_IQ_CCCR1"    : NULL;
        case 0x0000036e: return g_fIntelNetBurst ? "P4_MSR_IQ_CCCR2"    : NULL;
        case 0x0000036f: return g_fIntelNetBurst ? "P4_MSR_IQ_CCCR3"    : NULL;
        case 0x00000370: return g_fIntelNetBurst ? "P4_MSR_IQ_CCCR4"    : NULL;
        case 0x00000371: return g_fIntelNetBurst ? "P4_MSR_IQ_CCCR5"    : NULL;
        case 0x0000038d: return "IA32_FIXED_CTR_CTRL";
        case 0x0000038e: return "IA32_PERF_GLOBAL_STATUS";
        case 0x0000038f: return "IA32_PERF_GLOBAL_CTRL";
        case 0x00000390: return "IA32_PERF_GLOBAL_OVF_CTRL";
        case 0x00000391: return "I7_UNC_PERF_GLOBAL_CTRL";             /* S,H,X */
        case 0x00000392: return "I7_UNC_PERF_GLOBAL_STATUS";           /* S,H,X */
        case 0x00000393: return "I7_UNC_PERF_GLOBAL_OVF_CTRL";         /* X. ASSUMING this is the same on sandybridge and later. */
        case 0x00000394: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_PERF_FIXED_CTR"  /* X */    : "I7_UNC_PERF_FIXED_CTR_CTRL"; /* >= S,H */
        case 0x00000395: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_PERF_FIXED_CTR_CTRL" /* X*/ : "I7_UNC_PERF_FIXED_CTR";      /* >= S,H */
        case 0x00000396: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_ADDR_OPCODE_MATCH" /* X */  : "I7_UNC_CBO_CONFIG";          /* >= S,H */
        case 0x00000397: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? NULL                                : "I7_SB_UNK_0000_0397";
        case 0x0000039c: return "I7_SB_MSR_PEBS_NUM_ALT";
        case 0x000003a0: return g_fIntelNetBurst ? "P4_MSR_BSU_ESCR0"   : NULL;
        case 0x000003a1: return g_fIntelNetBurst ? "P4_MSR_BSU_ESCR1"   : NULL;
        case 0x000003a2: return g_fIntelNetBurst ? "P4_MSR_FSB_ESCR0"   : NULL;
        case 0x000003a3: return g_fIntelNetBurst ? "P4_MSR_FSB_ESCR1"   : NULL;
        case 0x000003a4: return g_fIntelNetBurst ? "P4_MSR_FIRM_ESCR0"  : NULL;
        case 0x000003a5: return g_fIntelNetBurst ? "P4_MSR_FIRM_ESCR1"  : NULL;
        case 0x000003a6: return g_fIntelNetBurst ? "P4_MSR_FLAME_ESCR0" : NULL;
        case 0x000003a7: return g_fIntelNetBurst ? "P4_MSR_FLAME_ESCR1" : NULL;
        case 0x000003a8: return g_fIntelNetBurst ? "P4_MSR_DAC_ESCR0"   : NULL;
        case 0x000003a9: return g_fIntelNetBurst ? "P4_MSR_DAC_ESCR1"   : NULL;
        case 0x000003aa: return g_fIntelNetBurst ? "P4_MSR_MOB_ESCR0"   : NULL;
        case 0x000003ab: return g_fIntelNetBurst ? "P4_MSR_MOB_ESCR1"   : NULL;
        case 0x000003ac: return g_fIntelNetBurst ? "P4_MSR_PMH_ESCR0"   : NULL;
        case 0x000003ad: return g_fIntelNetBurst ? "P4_MSR_PMH_ESCR1"   : NULL;
        case 0x000003ae: return g_fIntelNetBurst ? "P4_MSR_SAAT_ESCR0"  : NULL;
        case 0x000003af: return g_fIntelNetBurst ? "P4_MSR_SAAT_ESCR1"  : NULL;
        case 0x000003b0: return g_fIntelNetBurst ? "P4_MSR_U2L_ESCR0" : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_PMC0" /* X */               : "I7_UNC_ARB_PERF_CTR0";       /* >= S,H */
        case 0x000003b1: return g_fIntelNetBurst ? "P4_MSR_U2L_ESCR1" : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_PMC1" /* X */               : "I7_UNC_ARB_PERF_CTR1";       /* >= S,H */
        case 0x000003b2: return g_fIntelNetBurst ? "P4_MSR_BPU_ESCR0" : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_PMC2" /* X */               : "I7_UNC_ARB_PERF_EVT_SEL0";   /* >= S,H */
        case 0x000003b3: return g_fIntelNetBurst ? "P4_MSR_BPU_ESCR1" : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "I7_UNC_PMC3" /* X */               : "I7_UNC_ARB_PERF_EVT_SEL1";   /* >= S,H */
        case 0x000003b4: return g_fIntelNetBurst ? "P4_MSR_IS_ESCR0"    : "I7_UNC_PMC4";
        case 0x000003b5: return g_fIntelNetBurst ? "P4_MSR_IS_ESCR1"    : "I7_UNC_PMC5";
        case 0x000003b6: return g_fIntelNetBurst ? "P4_MSR_ITLB_ESCR0"  : "I7_UNC_PMC6";
        case 0x000003b7: return g_fIntelNetBurst ? "P4_MSR_ITLB_ESCR1"  : "I7_UNC_PMC7";
        case 0x000003b8: return g_fIntelNetBurst ? "P4_MSR_CRU_ESCR0"   : NULL;
        case 0x000003b9: return g_fIntelNetBurst ? "P4_MSR_CRU_ESCR1"   : NULL;
        case 0x000003ba: return g_fIntelNetBurst ? "P4_MSR_IQ_ESCR0"    : NULL;
        case 0x000003bb: return g_fIntelNetBurst ? "P4_MSR_IQ_ESCR1"    : NULL;
        case 0x000003bc: return g_fIntelNetBurst ? "P4_MSR_RAT_ESCR0"   : NULL;
        case 0x000003bd: return g_fIntelNetBurst ? "P4_MSR_RAT_ESCR1"   : NULL;
        case 0x000003be: return g_fIntelNetBurst ? "P4_MSR_SSU_ESCR0"   : NULL;
        case 0x000003c0: return g_fIntelNetBurst ? "P4_MSR_MS_ESCR0"    : "I7_UNC_PERF_EVT_SEL0";
        case 0x000003c1: return g_fIntelNetBurst ? "P4_MSR_MS_ESCR1"    : "I7_UNC_PERF_EVT_SEL1";
        case 0x000003c2: return g_fIntelNetBurst ? "P4_MSR_TBPU_ESCR0"  : "I7_UNC_PERF_EVT_SEL2";
        case 0x000003c3: return g_fIntelNetBurst ? "P4_MSR_TBPU_ESCR1"  : "I7_UNC_PERF_EVT_SEL3";
        case 0x000003c4: return g_fIntelNetBurst ? "P4_MSR_TC_ESCR0"    : "I7_UNC_PERF_EVT_SEL4";
        case 0x000003c5: return g_fIntelNetBurst ? "P4_MSR_TC_ESCR1"    : "I7_UNC_PERF_EVT_SEL5";
        case 0x000003c6: return g_fIntelNetBurst ? NULL                 : "I7_UNC_PERF_EVT_SEL6";
        case 0x000003c7: return g_fIntelNetBurst ? NULL                 : "I7_UNC_PERF_EVT_SEL7";
        case 0x000003c8: return g_fIntelNetBurst ? "P4_MSR_IX_ESCR0"    : NULL;
        case 0x000003c9: return g_fIntelNetBurst ? "P4_MSR_IX_ESCR0"    : NULL;
        case 0x000003ca: return g_fIntelNetBurst ? "P4_MSR_ALF_ESCR0"   : NULL;
        case 0x000003cb: return g_fIntelNetBurst ? "P4_MSR_ALF_ESCR1"   : NULL;
        case 0x000003cc: return g_fIntelNetBurst ? "P4_MSR_CRU_ESCR2"   : NULL;
        case 0x000003cd: return g_fIntelNetBurst ? "P4_MSR_CRU_ESCR3"   : NULL;
        case 0x000003e0: return g_fIntelNetBurst ? "P4_MSR_CRU_ESCR4"   : NULL;
        case 0x000003e1: return g_fIntelNetBurst ? "P4_MSR_CRU_ESCR5"   : NULL;
        case 0x000003f0: return g_fIntelNetBurst ? "P4_MSR_TC_PRECISE_EVENT" : NULL;
        case 0x000003f1: return "IA32_PEBS_ENABLE";
        case 0x000003f2: return g_fIntelNetBurst ? "P4_MSR_PEBS_MATRIX_VERT" : "IA32_PEBS_ENABLE";
        case 0x000003f3: return g_fIntelNetBurst ? "P4_UNK_0000_03f3" : NULL;
        case 0x000003f4: return g_fIntelNetBurst ? "P4_UNK_0000_03f4" : NULL;
        case 0x000003f5: return g_fIntelNetBurst ? "P4_UNK_0000_03f5" : NULL;
        case 0x000003f6: return g_fIntelNetBurst ? "P4_UNK_0000_03f6" : "I7_MSR_PEBS_LD_LAT";
        case 0x000003f7: return g_fIntelNetBurst ? "P4_UNK_0000_03f7" : "I7_MSR_PEBS_LD_LAT";
        case 0x000003f8: return g_fIntelNetBurst ? "P4_UNK_0000_03f8" : "I7_MSR_PKG_C3_RESIDENCY";
        case 0x000003f9: return "I7_MSR_PKG_C6_RESIDENCY";
        case 0x000003fa: return "I7_MSR_PKG_C7_RESIDENCY";
        case 0x000003fc: return "I7_MSR_CORE_C3_RESIDENCY";
        case 0x000003fd: return "I7_MSR_CORE_C6_RESIDENCY";
        case 0x000003fe: return "I7_MSR_CORE_C7_RESIDENCY";
        case 0x00000478: return g_enmMicroarch == kCpumMicroarch_Intel_Core2_Penryn ? "CPUID1_FEATURE_MASK" : NULL;
        case 0x00000480: return "IA32_VMX_BASIC";
        case 0x00000481: return "IA32_VMX_PINBASED_CTLS";
        case 0x00000482: return "IA32_VMX_PROCBASED_CTLS";
        case 0x00000483: return "IA32_VMX_EXIT_CTLS";
        case 0x00000484: return "IA32_VMX_ENTRY_CTLS";
        case 0x00000485: return "IA32_VMX_MISC";
        case 0x00000486: return "IA32_VMX_CR0_FIXED0";
        case 0x00000487: return "IA32_VMX_CR0_FIXED1";
        case 0x00000488: return "IA32_VMX_CR4_FIXED0";
        case 0x00000489: return "IA32_VMX_CR4_FIXED1";
        case 0x0000048a: return "IA32_VMX_VMCS_ENUM";
        case 0x0000048b: return "IA32_VMX_PROCBASED_CTLS2";
        case 0x0000048c: return "IA32_VMX_EPT_VPID_CAP";
        case 0x0000048d: return "IA32_VMX_TRUE_PINBASED_CTLS";
        case 0x0000048e: return "IA32_VMX_TRUE_PROCBASED_CTLS";
        case 0x0000048f: return "IA32_VMX_TRUE_EXIT_CTLS";
        case 0x00000490: return "IA32_VMX_TRUE_ENTRY_CTLS";
        case 0x00000491: return "IA32_VMX_VMFUNC";
        case 0x000004c1: return "IA32_A_PMC0";
        case 0x000004c2: return "IA32_A_PMC1";
        case 0x000004c3: return "IA32_A_PMC2";
        case 0x000004c4: return "IA32_A_PMC3";
        case 0x000004c5: return "IA32_A_PMC4";
        case 0x000004c6: return "IA32_A_PMC5";
        case 0x000004c7: return "IA32_A_PMC6";
        case 0x000004c8: return "IA32_A_PMC7";
        case 0x000004f8: return "C2_UNK_0000_04f8"; /* Core2_Penryn. */
        case 0x000004f9: return "C2_UNK_0000_04f9"; /* Core2_Penryn. */
        case 0x000004fa: return "C2_UNK_0000_04fa"; /* Core2_Penryn. */
        case 0x000004fb: return "C2_UNK_0000_04fb"; /* Core2_Penryn. */
        case 0x000004fc: return "C2_UNK_0000_04fc"; /* Core2_Penryn. */
        case 0x000004fd: return "C2_UNK_0000_04fd"; /* Core2_Penryn. */
        case 0x000004fe: return "C2_UNK_0000_04fe"; /* Core2_Penryn. */
        case 0x000004ff: return "C2_UNK_0000_04ff"; /* Core2_Penryn. */
        case 0x00000502: return "I7_SB_UNK_0000_0502";
        case 0x00000590: return "C2_UNK_0000_0590"; /* Core2_Penryn. */
        case 0x00000591: return "C2_UNK_0000_0591"; /* Core2_Penryn. */
        case 0x000005a0: return "C2_PECI_CTL"; /* Core2_Penryn. */
        case 0x000005a1: return "C2_UNK_0000_05a1"; /* Core2_Penryn. */
        case 0x00000600: return "IA32_DS_AREA";
        case 0x00000601: return "I7_SB_MSR_VR_CURRENT_CONFIG"; /* SandyBridge, IvyBridge. */
        case 0x00000602: return "I7_IB_UNK_0000_0602";
        case 0x00000603: return "I7_SB_MSR_VR_MISC_CONFIG"; /* SandyBridge, IvyBridge. */
        case 0x00000604: return "I7_IB_UNK_0000_0602";
        case 0x00000606: return "I7_SB_MSR_RAPL_POWER_UNIT"; /* SandyBridge, IvyBridge. */
        case 0x00000609: return "I7_SB_UNK_0000_0609";  /* SandyBridge (non EP). */
        case 0x0000060a: return "I7_SB_MSR_PKGC3_IRTL"; /* SandyBridge, IvyBridge. */
        case 0x0000060b: return "I7_SB_MSR_PKGC6_IRTL"; /* SandyBridge, IvyBridge. */
        case 0x0000060c: return "I7_SB_MSR_PKGC7_IRTL"; /* SandyBridge, IvyBridge. */
        case 0x0000060d: return "I7_SB_MSR_PKG_C2_RESIDENCY"; /* SandyBridge, IvyBridge. */
        case 0x00000610: return "I7_SB_MSR_PKG_POWER_LIMIT";
        case 0x00000611: return "I7_SB_MSR_PKG_ENERGY_STATUS";
        case 0x00000613: return "I7_SB_MSR_PKG_PERF_STATUS";
        case 0x00000614: return "I7_SB_MSR_PKG_POWER_INFO";
        case 0x00000618: return "I7_SB_MSR_DRAM_POWER_LIMIT";
        case 0x00000619: return "I7_SB_MSR_DRAM_ENERGY_STATUS";
        case 0x0000061b: return "I7_SB_MSR_DRAM_PERF_STATUS";
        case 0x0000061c: return "I7_SB_MSR_DRAM_POWER_INFO";
        case 0x00000638: return "I7_SB_MSR_PP0_POWER_LIMIT";
        case 0x00000639: return "I7_SB_MSR_PP0_ENERGY_STATUS";
        case 0x0000063a: return "I7_SB_MSR_PP0_POLICY";
        case 0x0000063b: return "I7_SB_MSR_PP0_PERF_STATUS";
        case 0x00000640: return "I7_HW_MSR_PP0_POWER_LIMIT";
        case 0x00000641: return "I7_HW_MSR_PP0_ENERGY_STATUS";
        case 0x00000642: return "I7_HW_MSR_PP0_POLICY";
        case 0x00000648: return "I7_IB_MSR_CONFIG_TDP_NOMINAL";
        case 0x00000649: return "I7_IB_MSR_CONFIG_TDP_LEVEL1";
        case 0x0000064a: return "I7_IB_MSR_CONFIG_TDP_LEVEL2";
        case 0x0000064b: return "I7_IB_MSR_CONFIG_TDP_CONTROL";
        case 0x0000064c: return "I7_IB_MSR_TURBO_ACTIVATION_RATIO";
        case 0x00000660: return "SILV_CORE_C1_RESIDENCY";
        case 0x00000661: return "SILV_UNK_0000_0661";
        case 0x00000662: return "SILV_UNK_0000_0662";
        case 0x00000663: return "SILV_UNK_0000_0663";
        case 0x00000664: return "SILV_UNK_0000_0664";
        case 0x00000665: return "SILV_UNK_0000_0665";
        case 0x00000666: return "SILV_UNK_0000_0666";
        case 0x00000667: return "SILV_UNK_0000_0667";
        case 0x00000668: return "SILV_UNK_0000_0668";
        case 0x00000669: return "SILV_UNK_0000_0669";
        case 0x0000066a: return "SILV_UNK_0000_066a";
        case 0x0000066b: return "SILV_UNK_0000_066b";
        case 0x0000066c: return "SILV_UNK_0000_066c";
        case 0x0000066d: return "SILV_UNK_0000_066d";
        case 0x0000066e: return "SILV_UNK_0000_066e";
        case 0x0000066f: return "SILV_UNK_0000_066f";
        case 0x00000670: return "SILV_UNK_0000_0670";
        case 0x00000671: return "SILV_UNK_0000_0671";
        case 0x00000672: return "SILV_UNK_0000_0672";
        case 0x00000673: return "SILV_UNK_0000_0673";
        case 0x00000674: return "SILV_UNK_0000_0674";
        case 0x00000675: return "SILV_UNK_0000_0675";
        case 0x00000676: return "SILV_UNK_0000_0676";
        case 0x00000677: return "SILV_UNK_0000_0677";

        case 0x00000680: return "MSR_LASTBRANCH_0_FROM_IP";
        case 0x00000681: return "MSR_LASTBRANCH_1_FROM_IP";
        case 0x00000682: return "MSR_LASTBRANCH_2_FROM_IP";
        case 0x00000683: return "MSR_LASTBRANCH_3_FROM_IP";
        case 0x00000684: return "MSR_LASTBRANCH_4_FROM_IP";
        case 0x00000685: return "MSR_LASTBRANCH_5_FROM_IP";
        case 0x00000686: return "MSR_LASTBRANCH_6_FROM_IP";
        case 0x00000687: return "MSR_LASTBRANCH_7_FROM_IP";
        case 0x00000688: return "MSR_LASTBRANCH_8_FROM_IP";
        case 0x00000689: return "MSR_LASTBRANCH_9_FROM_IP";
        case 0x0000068a: return "MSR_LASTBRANCH_10_FROM_IP";
        case 0x0000068b: return "MSR_LASTBRANCH_11_FROM_IP";
        case 0x0000068c: return "MSR_LASTBRANCH_12_FROM_IP";
        case 0x0000068d: return "MSR_LASTBRANCH_13_FROM_IP";
        case 0x0000068e: return "MSR_LASTBRANCH_14_FROM_IP";
        case 0x0000068f: return "MSR_LASTBRANCH_15_FROM_IP";
        case 0x000006c0: return "MSR_LASTBRANCH_0_TO_IP";
        case 0x000006c1: return "MSR_LASTBRANCH_1_TO_IP";
        case 0x000006c2: return "MSR_LASTBRANCH_2_TO_IP";
        case 0x000006c3: return "MSR_LASTBRANCH_3_TO_IP";
        case 0x000006c4: return "MSR_LASTBRANCH_4_TO_IP";
        case 0x000006c5: return "MSR_LASTBRANCH_5_TO_IP";
        case 0x000006c6: return "MSR_LASTBRANCH_6_TO_IP";
        case 0x000006c7: return "MSR_LASTBRANCH_7_TO_IP";
        case 0x000006c8: return "MSR_LASTBRANCH_8_TO_IP";
        case 0x000006c9: return "MSR_LASTBRANCH_9_TO_IP";
        case 0x000006ca: return "MSR_LASTBRANCH_10_TO_IP";
        case 0x000006cb: return "MSR_LASTBRANCH_11_TO_IP";
        case 0x000006cc: return "MSR_LASTBRANCH_12_TO_IP";
        case 0x000006cd: return "MSR_LASTBRANCH_13_TO_IP";
        case 0x000006ce: return "MSR_LASTBRANCH_14_TO_IP";
        case 0x000006cf: return "MSR_LASTBRANCH_15_TO_IP";
        case 0x000006e0: return "IA32_TSC_DEADLINE";

        case 0x00000768: return "SILV_UNK_0000_0768";
        case 0x00000769: return "SILV_UNK_0000_0769";
        case 0x0000076a: return "SILV_UNK_0000_076a";
        case 0x0000076b: return "SILV_UNK_0000_076b";
        case 0x0000076c: return "SILV_UNK_0000_076c";
        case 0x0000076d: return "SILV_UNK_0000_076d";
        case 0x0000076e: return "SILV_UNK_0000_076e";

        case 0x00000c80: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_IvyBridge ? "IA32_DEBUG_INTERFACE" : NULL; /* Mentioned in an intel dataskit called 4th-gen-core-family-desktop-vol-1-datasheet.pdf. */
        case 0x00000c81: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_IvyBridge ? "I7_IB_UNK_0000_0c81"  : NULL; /* Probably related to IA32_DEBUG_INTERFACE... */
        case 0x00000c82: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_IvyBridge ? "I7_IB_UNK_0000_0c82"  : NULL; /* Probably related to IA32_DEBUG_INTERFACE... */
        case 0x00000c83: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_IvyBridge ? "I7_IB_UNK_0000_0c83"  : NULL; /* Probably related to IA32_DEBUG_INTERFACE... */

        /* 0x1000..0x1004 seems to have been used by IBM 386 and 486 clones too. */
        case 0x00001000: return "P6_DEBUG_REGISTER_0";
        case 0x00001001: return "P6_DEBUG_REGISTER_1";
        case 0x00001002: return "P6_DEBUG_REGISTER_2";
        case 0x00001003: return "P6_DEBUG_REGISTER_3";
        case 0x00001004: return "P6_DEBUG_REGISTER_4";
        case 0x00001005: return "P6_DEBUG_REGISTER_5";
        case 0x00001006: return "P6_DEBUG_REGISTER_6";
        case 0x00001007: return "P6_DEBUG_REGISTER_7";
        case 0x0000103f: return "P6_UNK_0000_103f"; /* P6_M_Dothan. */
        case 0x000010cd: return "P6_UNK_0000_10cd"; /* P6_M_Dothan. */

        case 0x00001107: return "VIA_UNK_0000_1107";
        case 0x0000110f: return "VIA_UNK_0000_110f";
        case 0x00001153: return "VIA_UNK_0000_1153";
        case 0x00001200: return "VIA_UNK_0000_1200";
        case 0x00001201: return "VIA_UNK_0000_1201";
        case 0x00001202: return "VIA_UNK_0000_1202";
        case 0x00001203: return "VIA_UNK_0000_1203";
        case 0x00001204: return "VIA_UNK_0000_1204";
        case 0x00001205: return "VIA_UNK_0000_1205";
        case 0x00001206: return "VIA_ALT_VENDOR_EBX";
        case 0x00001207: return "VIA_ALT_VENDOR_ECDX";
        case 0x00001208: return "VIA_UNK_0000_1208";
        case 0x00001209: return "VIA_UNK_0000_1209";
        case 0x0000120a: return "VIA_UNK_0000_120a";
        case 0x0000120b: return "VIA_UNK_0000_120b";
        case 0x0000120c: return "VIA_UNK_0000_120c";
        case 0x0000120d: return "VIA_UNK_0000_120d";
        case 0x0000120e: return "VIA_UNK_0000_120e";
        case 0x0000120f: return "VIA_UNK_0000_120f";
        case 0x00001210: return "VIA_UNK_0000_1210";
        case 0x00001211: return "VIA_UNK_0000_1211";
        case 0x00001212: return "VIA_UNK_0000_1212";
        case 0x00001213: return "VIA_UNK_0000_1213";
        case 0x00001214: return "VIA_UNK_0000_1214";
        case 0x00001220: return "VIA_UNK_0000_1220";
        case 0x00001221: return "VIA_UNK_0000_1221";
        case 0x00001230: return "VIA_UNK_0000_1230";
        case 0x00001231: return "VIA_UNK_0000_1231";
        case 0x00001232: return "VIA_UNK_0000_1232";
        case 0x00001233: return "VIA_UNK_0000_1233";
        case 0x00001234: return "VIA_UNK_0000_1234";
        case 0x00001235: return "VIA_UNK_0000_1235";
        case 0x00001236: return "VIA_UNK_0000_1236";
        case 0x00001237: return "VIA_UNK_0000_1237";
        case 0x00001238: return "VIA_UNK_0000_1238";
        case 0x00001239: return "VIA_UNK_0000_1239";
        case 0x00001240: return "VIA_UNK_0000_1240";
        case 0x00001241: return "VIA_UNK_0000_1241";
        case 0x00001243: return "VIA_UNK_0000_1243";
        case 0x00001245: return "VIA_UNK_0000_1245";
        case 0x00001246: return "VIA_UNK_0000_1246";
        case 0x00001247: return "VIA_UNK_0000_1247";
        case 0x00001248: return "VIA_UNK_0000_1248";
        case 0x00001249: return "VIA_UNK_0000_1249";
        case 0x0000124a: return "VIA_UNK_0000_124a";

        case 0x00001301: return "VIA_UNK_0000_1301";
        case 0x00001302: return "VIA_UNK_0000_1302";
        case 0x00001303: return "VIA_UNK_0000_1303";
        case 0x00001304: return "VIA_UNK_0000_1304";
        case 0x00001305: return "VIA_UNK_0000_1305";
        case 0x00001306: return "VIA_UNK_0000_1306";
        case 0x00001307: return "VIA_UNK_0000_1307";
        case 0x00001308: return "VIA_UNK_0000_1308";
        case 0x00001309: return "VIA_UNK_0000_1309";
        case 0x0000130d: return "VIA_UNK_0000_130d";
        case 0x0000130e: return "VIA_UNK_0000_130e";
        case 0x00001312: return "VIA_UNK_0000_1312";
        case 0x00001315: return "VIA_UNK_0000_1315";
        case 0x00001317: return "VIA_UNK_0000_1317";
        case 0x00001318: return "VIA_UNK_0000_1318";
        case 0x0000131a: return "VIA_UNK_0000_131a";
        case 0x0000131b: return "VIA_UNK_0000_131b";
        case 0x00001402: return "VIA_UNK_0000_1402";
        case 0x00001403: return "VIA_UNK_0000_1403";
        case 0x00001404: return "VIA_UNK_0000_1404";
        case 0x00001405: return "VIA_UNK_0000_1405";
        case 0x00001406: return "VIA_UNK_0000_1406";
        case 0x00001407: return "VIA_UNK_0000_1407";
        case 0x00001410: return "VIA_UNK_0000_1410";
        case 0x00001411: return "VIA_UNK_0000_1411";
        case 0x00001412: return "VIA_UNK_0000_1412";
        case 0x00001413: return "VIA_UNK_0000_1413";
        case 0x00001414: return "VIA_UNK_0000_1414";
        case 0x00001415: return "VIA_UNK_0000_1415";
        case 0x00001416: return "VIA_UNK_0000_1416";
        case 0x00001417: return "VIA_UNK_0000_1417";
        case 0x00001418: return "VIA_UNK_0000_1418";
        case 0x00001419: return "VIA_UNK_0000_1419";
        case 0x0000141a: return "VIA_UNK_0000_141a";
        case 0x0000141b: return "VIA_UNK_0000_141b";
        case 0x0000141c: return "VIA_UNK_0000_141c";
        case 0x0000141d: return "VIA_UNK_0000_141d";
        case 0x0000141e: return "VIA_UNK_0000_141e";
        case 0x0000141f: return "VIA_UNK_0000_141f";
        case 0x00001420: return "VIA_UNK_0000_1420";
        case 0x00001421: return "VIA_UNK_0000_1421";
        case 0x00001422: return "VIA_UNK_0000_1422";
        case 0x00001423: return "VIA_UNK_0000_1423";
        case 0x00001424: return "VIA_UNK_0000_1424";
        case 0x00001425: return "VIA_UNK_0000_1425";
        case 0x00001426: return "VIA_UNK_0000_1426";
        case 0x00001427: return "VIA_UNK_0000_1427";
        case 0x00001428: return "VIA_UNK_0000_1428";
        case 0x00001429: return "VIA_UNK_0000_1429";
        case 0x0000142a: return "VIA_UNK_0000_142a";
        case 0x0000142b: return "VIA_UNK_0000_142b";
        case 0x0000142c: return "VIA_UNK_0000_142c";
        case 0x0000142d: return "VIA_UNK_0000_142d";
        case 0x0000142e: return "VIA_UNK_0000_142e";
        case 0x0000142f: return "VIA_UNK_0000_142f";
        case 0x00001434: return "VIA_UNK_0000_1434";
        case 0x00001435: return "VIA_UNK_0000_1435";
        case 0x00001436: return "VIA_UNK_0000_1436";
        case 0x00001437: return "VIA_UNK_0000_1437";
        case 0x00001438: return "VIA_UNK_0000_1438";
        case 0x0000143a: return "VIA_UNK_0000_143a";
        case 0x0000143c: return "VIA_UNK_0000_143c";
        case 0x0000143d: return "VIA_UNK_0000_143d";
        case 0x00001440: return "VIA_UNK_0000_1440";
        case 0x00001441: return "VIA_UNK_0000_1441";
        case 0x00001442: return "VIA_UNK_0000_1442";
        case 0x00001449: return "VIA_UNK_0000_1449";
        case 0x00001450: return "VIA_UNK_0000_1450";
        case 0x00001451: return "VIA_UNK_0000_1451";
        case 0x00001452: return "VIA_UNK_0000_1452";
        case 0x00001453: return "VIA_UNK_0000_1453";
        case 0x00001460: return "VIA_UNK_0000_1460";
        case 0x00001461: return "VIA_UNK_0000_1461";
        case 0x00001462: return "VIA_UNK_0000_1462";
        case 0x00001463: return "VIA_UNK_0000_1463";
        case 0x00001465: return "VIA_UNK_0000_1465";
        case 0x00001466: return "VIA_UNK_0000_1466";
        case 0x00001470: return "VIA_UNK_0000_1470";
        case 0x00001471: return "VIA_UNK_0000_1471";
        case 0x00001480: return "VIA_UNK_0000_1480";
        case 0x00001481: return "VIA_UNK_0000_1481";
        case 0x00001482: return "VIA_UNK_0000_1482";
        case 0x00001483: return "VIA_UNK_0000_1483";
        case 0x00001484: return "VIA_UNK_0000_1484";
        case 0x00001485: return "VIA_UNK_0000_1485";
        case 0x00001486: return "VIA_UNK_0000_1486";
        case 0x00001490: return "VIA_UNK_0000_1490";
        case 0x00001491: return "VIA_UNK_0000_1491";
        case 0x00001492: return "VIA_UNK_0000_1492";
        case 0x00001493: return "VIA_UNK_0000_1493";
        case 0x00001494: return "VIA_UNK_0000_1494";
        case 0x00001495: return "VIA_UNK_0000_1495";
        case 0x00001496: return "VIA_UNK_0000_1496";
        case 0x00001497: return "VIA_UNK_0000_1497";
        case 0x00001498: return "VIA_UNK_0000_1498";
        case 0x00001499: return "VIA_UNK_0000_1499";
        case 0x0000149a: return "VIA_UNK_0000_149a";
        case 0x0000149b: return "VIA_UNK_0000_149b";
        case 0x0000149c: return "VIA_UNK_0000_149c";
        case 0x0000149f: return "VIA_UNK_0000_149f";
        case 0x00001523: return "VIA_UNK_0000_1523";

        case 0x00002000: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_CR0" : NULL;
        case 0x00002002: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_CR2" : NULL;
        case 0x00002003: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_CR3" : NULL;
        case 0x00002004: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_CR4" : NULL;
        case 0x0000203f: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_UNK_0000_203f" /* P6_M_Dothan. */ : NULL;
        case 0x000020cd: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_UNK_0000_20cd" /* P6_M_Dothan. */ : NULL;
        case 0x0000303f: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_UNK_0000_303f" /* P6_M_Dothan. */ : NULL;
        case 0x000030cd: return g_enmVendor == CPUMCPUVENDOR_INTEL ? "P6_UNK_0000_30cd" /* P6_M_Dothan. */ : NULL;

        case 0x0000317a: return "VIA_UNK_0000_317a";
        case 0x0000317b: return "VIA_UNK_0000_317b";
        case 0x0000317d: return "VIA_UNK_0000_317d";
        case 0x0000317e: return "VIA_UNK_0000_317e";
        case 0x0000317f: return "VIA_UNK_0000_317f";
        case 0x80000198: return "VIA_UNK_8000_0198";

        case 0xc0000080: return "AMD64_EFER";
        case 0xc0000081: return "AMD64_STAR";
        case 0xc0000082: return "AMD64_STAR64";
        case 0xc0000083: return "AMD64_STARCOMPAT";
        case 0xc0000084: return "AMD64_SYSCALL_FLAG_MASK";
        case 0xc0000100: return "AMD64_FS_BASE";
        case 0xc0000101: return "AMD64_GS_BASE";
        case 0xc0000102: return "AMD64_KERNEL_GS_BASE";
        case 0xc0000103: return "AMD64_TSC_AUX";
        case 0xc0000104: return "AMD_15H_TSC_RATE";
        case 0xc0000105: return "AMD_15H_LWP_CFG";      /* Only Family 15h? */
        case 0xc0000106: return "AMD_15H_LWP_CBADDR";   /* Only Family 15h? */
        case 0xc0000408: return "AMD_10H_MC4_MISC1";
        case 0xc0000409: return "AMD_10H_MC4_MISC2";
        case 0xc000040a: return "AMD_10H_MC4_MISC3";
        case 0xc000040b: return "AMD_10H_MC4_MISC4";
        case 0xc000040c: return "AMD_10H_MC4_MISC5";
        case 0xc000040d: return "AMD_10H_MC4_MISC6";
        case 0xc000040e: return "AMD_10H_MC4_MISC7";
        case 0xc000040f: return "AMD_10H_MC4_MISC8";
        case 0xc0010000: return "AMD_K8_PERF_CTL_0";
        case 0xc0010001: return "AMD_K8_PERF_CTL_1";
        case 0xc0010002: return "AMD_K8_PERF_CTL_2";
        case 0xc0010003: return "AMD_K8_PERF_CTL_3";
        case 0xc0010004: return "AMD_K8_PERF_CTR_0";
        case 0xc0010005: return "AMD_K8_PERF_CTR_1";
        case 0xc0010006: return "AMD_K8_PERF_CTR_2";
        case 0xc0010007: return "AMD_K8_PERF_CTR_3";
        case 0xc0010010: return "AMD_K8_SYS_CFG";
        case 0xc0010015: return "AMD_K8_HW_CFG";
        case 0xc0010016: return "AMD_K8_IORR_BASE_0";
        case 0xc0010017: return "AMD_K8_IORR_MASK_0";
        case 0xc0010018: return "AMD_K8_IORR_BASE_1";
        case 0xc0010019: return "AMD_K8_IORR_MASK_1";
        case 0xc001001a: return "AMD_K8_TOP_MEM";
        case 0xc001001d: return "AMD_K8_TOP_MEM2";
        case 0xc001001e: return "AMD_K8_MANID";
        case 0xc001001f: return "AMD_K8_NB_CFG1";
        case 0xc0010020: return "AMD_K8_PATCH_LOADER";
        case 0xc0010021: return "AMD_K8_UNK_c001_0021";
        case 0xc0010022: return "AMD_K8_MC_XCPT_REDIR";
        case 0xc0010028: return "AMD_K8_UNK_c001_0028";
        case 0xc0010029: return "AMD_K8_UNK_c001_0029";
        case 0xc001002a: return "AMD_K8_UNK_c001_002a";
        case 0xc001002b: return "AMD_K8_UNK_c001_002b";
        case 0xc001002c: return "AMD_K8_UNK_c001_002c";
        case 0xc001002d: return "AMD_K8_UNK_c001_002d";
        case 0xc0010030: return "AMD_K8_CPU_NAME_0";
        case 0xc0010031: return "AMD_K8_CPU_NAME_1";
        case 0xc0010032: return "AMD_K8_CPU_NAME_2";
        case 0xc0010033: return "AMD_K8_CPU_NAME_3";
        case 0xc0010034: return "AMD_K8_CPU_NAME_4";
        case 0xc0010035: return "AMD_K8_CPU_NAME_5";
        case 0xc001003e: return "AMD_K8_HTC";
        case 0xc001003f: return "AMD_K8_STC";
        case 0xc0010041: return "AMD_K8_FIDVID_CTL";
        case 0xc0010042: return "AMD_K8_FIDVID_STATUS";
        case 0xc0010043: return "AMD_K8_THERMTRIP_STATUS"; /* BDKG says it was removed in K8 revision C.*/
        case 0xc0010044: return "AMD_K8_MC_CTL_MASK_0";
        case 0xc0010045: return "AMD_K8_MC_CTL_MASK_1";
        case 0xc0010046: return "AMD_K8_MC_CTL_MASK_2";
        case 0xc0010047: return "AMD_K8_MC_CTL_MASK_3";
        case 0xc0010048: return "AMD_K8_MC_CTL_MASK_4";
        case 0xc0010049: return "AMD_K8_MC_CTL_MASK_5";
        case 0xc001004a: return "AMD_K8_MC_CTL_MASK_6";
        //case 0xc001004b: return "AMD_K8_MC_CTL_MASK_7";
        case 0xc0010050: return "AMD_K8_SMI_ON_IO_TRAP_0";
        case 0xc0010051: return "AMD_K8_SMI_ON_IO_TRAP_1";
        case 0xc0010052: return "AMD_K8_SMI_ON_IO_TRAP_2";
        case 0xc0010053: return "AMD_K8_SMI_ON_IO_TRAP_3";
        case 0xc0010054: return "AMD_K8_SMI_ON_IO_TRAP_CTL_STS";
        case 0xc0010055: return "AMD_K8_INT_PENDING_MSG";
        case 0xc0010056: return "AMD_K8_SMI_TRIGGER_IO_CYCLE";
        case 0xc0010057: return "AMD_10H_UNK_c001_0057";
        case 0xc0010058: return "AMD_10H_MMIO_CFG_BASE_ADDR";
        case 0xc0010059: return "AMD_10H_TRAP_CTL?"; /* Undocumented, only one google hit. */
        case 0xc001005a: return "AMD_10H_UNK_c001_005a";
        case 0xc001005b: return "AMD_10H_UNK_c001_005b";
        case 0xc001005c: return "AMD_10H_UNK_c001_005c";
        case 0xc001005d: return "AMD_10H_UNK_c001_005d";
        case 0xc0010060: return "AMD_K8_BIST_RESULT";   /* BDKG says it as introduced with revision F. */
        case 0xc0010061: return "AMD_10H_P_ST_CUR_LIM";
        case 0xc0010062: return "AMD_10H_P_ST_CTL";
        case 0xc0010063: return "AMD_10H_P_ST_STS";
        case 0xc0010064: return "AMD_10H_P_ST_0";
        case 0xc0010065: return "AMD_10H_P_ST_1";
        case 0xc0010066: return "AMD_10H_P_ST_2";
        case 0xc0010067: return "AMD_10H_P_ST_3";
        case 0xc0010068: return "AMD_10H_P_ST_4";
        case 0xc0010069: return "AMD_10H_P_ST_5";
        case 0xc001006a: return "AMD_10H_P_ST_6";
        case 0xc001006b: return "AMD_10H_P_ST_7";
        case 0xc0010070: return "AMD_10H_COFVID_CTL";
        case 0xc0010071: return "AMD_10H_COFVID_STS";
        case 0xc0010073: return "AMD_10H_C_ST_IO_BASE_ADDR";
        case 0xc0010074: return "AMD_10H_CPU_WD_TMR_CFG";
        // case 0xc0010075: return "AMD_15H_APML_TDP_LIM";
        // case 0xc0010077: return "AMD_15H_CPU_PWR_IN_TDP";
        // case 0xc0010078: return "AMD_15H_PWR_AVG_PERIOD";
        // case 0xc0010079: return "AMD_15H_DRAM_CTR_CMD_THR";
        // case 0xc0010080: return "AMD_16H_FSFM_ACT_CNT_0";
        // case 0xc0010081: return "AMD_16H_FSFM_REF_CNT_0";
        case 0xc0010111: return "AMD_K8_SMM_BASE";
        case 0xc0010112: return "AMD_K8_SMM_ADDR";
        case 0xc0010113: return "AMD_K8_SMM_MASK";
        case 0xc0010114: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV ? "AMD_K8_VM_CR"          : "AMD_K8_UNK_c001_0114";
        case 0xc0010115: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AMD_K8_IGNNE"          : "AMD_K8_UNK_c001_0115";
        case 0xc0010116: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AMD_K8_SMM_CTL"        : "AMD_K8_UNK_c001_0116";
        case 0xc0010117: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV ? "AMD_K8_VM_HSAVE_PA"    : "AMD_K8_UNK_c001_0117";
        case 0xc0010118: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV ? "AMD_10H_VM_LOCK_KEY"   : "AMD_K8_UNK_c001_0118";
        case 0xc0010119: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AMD_10H_SSM_LOCK_KEY"  : "AMD_K8_UNK_c001_0119";
        case 0xc001011a: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AMD_10H_LOCAL_SMI_STS" : "AMD_K8_UNK_c001_011a";
        case 0xc001011b: return "AMD_K8_UNK_c001_011b";
        case 0xc001011c: return "AMD_K8_UNK_c001_011c";
        case 0xc0010140: return "AMD_10H_OSVW_ID_LEN";
        case 0xc0010141: return "AMD_10H_OSVW_STS";
        case 0xc0010200: return "AMD_K8_PERF_CTL_0";
        case 0xc0010202: return "AMD_K8_PERF_CTL_1";
        case 0xc0010204: return "AMD_K8_PERF_CTL_2";
        case 0xc0010206: return "AMD_K8_PERF_CTL_3";
        case 0xc0010208: return "AMD_K8_PERF_CTL_4";
        case 0xc001020a: return "AMD_K8_PERF_CTL_5";
        //case 0xc001020c: return "AMD_K8_PERF_CTL_6";
        //case 0xc001020e: return "AMD_K8_PERF_CTL_7";
        case 0xc0010201: return "AMD_K8_PERF_CTR_0";
        case 0xc0010203: return "AMD_K8_PERF_CTR_1";
        case 0xc0010205: return "AMD_K8_PERF_CTR_2";
        case 0xc0010207: return "AMD_K8_PERF_CTR_3";
        case 0xc0010209: return "AMD_K8_PERF_CTR_4";
        case 0xc001020b: return "AMD_K8_PERF_CTR_5";
        //case 0xc001020d: return "AMD_K8_PERF_CTR_6";
        //case 0xc001020f: return "AMD_K8_PERF_CTR_7";
        case 0xc0010230: return "AMD_16H_L2I_PERF_CTL_0";
        case 0xc0010232: return "AMD_16H_L2I_PERF_CTL_1";
        case 0xc0010234: return "AMD_16H_L2I_PERF_CTL_2";
        case 0xc0010236: return "AMD_16H_L2I_PERF_CTL_3";
        //case 0xc0010238: return "AMD_16H_L2I_PERF_CTL_4";
        //case 0xc001023a: return "AMD_16H_L2I_PERF_CTL_5";
        //case 0xc001030c: return "AMD_16H_L2I_PERF_CTL_6";
        //case 0xc001023e: return "AMD_16H_L2I_PERF_CTL_7";
        case 0xc0010231: return "AMD_16H_L2I_PERF_CTR_0";
        case 0xc0010233: return "AMD_16H_L2I_PERF_CTR_1";
        case 0xc0010235: return "AMD_16H_L2I_PERF_CTR_2";
        case 0xc0010237: return "AMD_16H_L2I_PERF_CTR_3";
        //case 0xc0010239: return "AMD_16H_L2I_PERF_CTR_4";
        //case 0xc001023b: return "AMD_16H_L2I_PERF_CTR_5";
        //case 0xc001023d: return "AMD_16H_L2I_PERF_CTR_6";
        //case 0xc001023f: return "AMD_16H_L2I_PERF_CTR_7";
        case 0xc0010240: return "AMD_15H_NB_PERF_CTL_0";
        case 0xc0010242: return "AMD_15H_NB_PERF_CTL_1";
        case 0xc0010244: return "AMD_15H_NB_PERF_CTL_2";
        case 0xc0010246: return "AMD_15H_NB_PERF_CTL_3";
        //case 0xc0010248: return "AMD_15H_NB_PERF_CTL_4";
        //case 0xc001024a: return "AMD_15H_NB_PERF_CTL_5";
        //case 0xc001024c: return "AMD_15H_NB_PERF_CTL_6";
        //case 0xc001024e: return "AMD_15H_NB_PERF_CTL_7";
        case 0xc0010241: return "AMD_15H_NB_PERF_CTR_0";
        case 0xc0010243: return "AMD_15H_NB_PERF_CTR_1";
        case 0xc0010245: return "AMD_15H_NB_PERF_CTR_2";
        case 0xc0010247: return "AMD_15H_NB_PERF_CTR_3";
        //case 0xc0010249: return "AMD_15H_NB_PERF_CTR_4";
        //case 0xc001024b: return "AMD_15H_NB_PERF_CTR_5";
        //case 0xc001024d: return "AMD_15H_NB_PERF_CTR_6";
        //case 0xc001024f: return "AMD_15H_NB_PERF_CTR_7";
        case 0xc0011000: return "AMD_K7_MCODE_CTL";
        case 0xc0011001: return "AMD_K7_APIC_CLUSTER_ID"; /* Mentioned in BKDG (r3.00) for fam16h when describing EBL_CR_POWERON. */
        case 0xc0011002: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_CPUID_CTL_STD07" : NULL;
        case 0xc0011003: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_CPUID_CTL_STD06" : NULL;
        case 0xc0011004: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_CPUID_CTL_STD01" : NULL;
        case 0xc0011005: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_CPUID_CTL_EXT01" : NULL;
        case 0xc0011006: return "AMD_K7_DEBUG_STS?";
        case 0xc0011007: return "AMD_K7_BH_TRACE_BASE?";
        case 0xc0011008: return "AMD_K7_BH_TRACE_PTR?";
        case 0xc0011009: return "AMD_K7_BH_TRACE_LIM?";
        case 0xc001100a: return "AMD_K7_HDT_CFG?";
        case 0xc001100b: return "AMD_K7_FAST_FLUSH_COUNT?";
        case 0xc001100c: return "AMD_K7_NODE_ID";
        case 0xc001100d: return "AMD_K8_LOGICAL_CPUS_NUM?";
        case 0xc001100e: return "AMD_K8_WRMSR_BP?";
        case 0xc001100f: return "AMD_K8_WRMSR_BP_MASK?";
        case 0xc0011010: return "AMD_K8_BH_TRACE_CTL?";
        case 0xc0011011: return "AMD_K8_BH_TRACE_USRD?";
        case 0xc0011012: return "AMD_K7_UNK_c001_1012";
        case 0xc0011013: return "AMD_K7_UNK_c001_1013";
        case 0xc0011014: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_XCPT_BP_RIP?" : "AMD_K7_MOBIL_DEBUG?";
        case 0xc0011015: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_XCPT_BP_RIP_MASK?" : NULL;
        case 0xc0011016: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_COND_HDT_VAL?" : NULL;
        case 0xc0011017: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_COND_HDT_VAL_MASK?" : NULL;
        case 0xc0011018: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_XCPT_BP_CTL?" : NULL;
        case 0xc0011019: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver ? "AMD_16H_DR1_ADDR_MASK" : NULL;
        case 0xc001101a: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver ? "AMD_16H_DR2_ADDR_MASK" : NULL;
        case 0xc001101b: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver ? "AMD_16H_DR3_ADDR_MASK" : NULL;
        case 0xc001101d: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_NB_BIST?" : NULL;
        case 0xc001101e: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_THERMTRIP_2?" : NULL;
        case 0xc001101f: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AMD_K8_NB_CFG?" : NULL;
        case 0xc0011020: return "AMD_K7_LS_CFG";
        case 0xc0011021: return "AMD_K7_IC_CFG";
        case 0xc0011022: return "AMD_K7_DC_CFG";
        case 0xc0011023: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch) ? "AMD_15H_CU_CFG" : "AMD_K7_BU_CFG";
        case 0xc0011024: return "AMD_K7_DEBUG_CTL_2?";
        case 0xc0011025: return "AMD_K7_DR0_DATA_MATCH?";
        case 0xc0011026: return "AMD_K7_DR0_DATA_MATCH?";
        case 0xc0011027: return "AMD_K7_DR0_ADDR_MASK";
        case 0xc0011028: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_First ? "AMD_15H_FP_CFG"
                              : CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch)   ? "AMD_10H_UNK_c001_1028"
                              : NULL;
        case 0xc0011029: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_First ? "AMD_15H_DC_CFG"
                              : CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch)   ? "AMD_10H_UNK_c001_1029"
                              : NULL;
        case 0xc001102a: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AMD_15H_CU_CFG2"
                              : CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch) || g_enmMicroarch > kCpumMicroarch_AMD_15h_End
                              ? "AMD_10H_BU_CFG2" /* 10h & 16h */ : NULL;
        case 0xc001102b: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AMD_15H_CU_CFG3" : NULL;
        case 0xc001102c: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AMD_15H_EX_CFG" : NULL;
        case 0xc001102d: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AMD_15H_LS_CFG2" : NULL;
        case 0xc0011030: return "AMD_10H_IBS_FETCH_CTL";
        case 0xc0011031: return "AMD_10H_IBS_FETCH_LIN_ADDR";
        case 0xc0011032: return "AMD_10H_IBS_FETCH_PHYS_ADDR";
        case 0xc0011033: return "AMD_10H_IBS_OP_EXEC_CTL";
        case 0xc0011034: return "AMD_10H_IBS_OP_RIP";
        case 0xc0011035: return "AMD_10H_IBS_OP_DATA";
        case 0xc0011036: return "AMD_10H_IBS_OP_DATA2";
        case 0xc0011037: return "AMD_10H_IBS_OP_DATA3";
        case 0xc0011038: return "AMD_10H_IBS_DC_LIN_ADDR";
        case 0xc0011039: return "AMD_10H_IBS_DC_PHYS_ADDR";
        case 0xc001103a: return "AMD_10H_IBS_CTL";
        case 0xc001103b: return "AMD_14H_IBS_BR_TARGET";

        case 0xc0011040: return "AMD_15H_UNK_c001_1040";
        case 0xc0011041: return "AMD_15H_UNK_c001_1041";
        case 0xc0011042: return "AMD_15H_UNK_c001_1042";
        case 0xc0011043: return "AMD_15H_UNK_c001_1043";
        case 0xc0011044: return "AMD_15H_UNK_c001_1044";
        case 0xc0011045: return "AMD_15H_UNK_c001_1045";
        case 0xc0011046: return "AMD_15H_UNK_c001_1046";
        case 0xc0011047: return "AMD_15H_UNK_c001_1047";
        case 0xc0011048: return "AMD_15H_UNK_c001_1048";
        case 0xc0011049: return "AMD_15H_UNK_c001_1049";
        case 0xc001104a: return "AMD_15H_UNK_c001_104a";
        case 0xc001104b: return "AMD_15H_UNK_c001_104b";
        case 0xc001104c: return "AMD_15H_UNK_c001_104c";
        case 0xc001104d: return "AMD_15H_UNK_c001_104d";
        case 0xc001104e: return "AMD_15H_UNK_c001_104e";
        case 0xc001104f: return "AMD_15H_UNK_c001_104f";
        case 0xc0011050: return "AMD_15H_UNK_c001_1050";
        case 0xc0011051: return "AMD_15H_UNK_c001_1051";
        case 0xc0011052: return "AMD_15H_UNK_c001_1052";
        case 0xc0011053: return "AMD_15H_UNK_c001_1053";
        case 0xc0011054: return "AMD_15H_UNK_c001_1054";
        case 0xc0011055: return "AMD_15H_UNK_c001_1055";
        case 0xc0011056: return "AMD_15H_UNK_c001_1056";
        case 0xc0011057: return "AMD_15H_UNK_c001_1057";
        case 0xc0011058: return "AMD_15H_UNK_c001_1058";
        case 0xc0011059: return "AMD_15H_UNK_c001_1059";
        case 0xc001105a: return "AMD_15H_UNK_c001_105a";
        case 0xc001105b: return "AMD_15H_UNK_c001_105b";
        case 0xc001105c: return "AMD_15H_UNK_c001_105c";
        case 0xc001105d: return "AMD_15H_UNK_c001_105d";
        case 0xc001105e: return "AMD_15H_UNK_c001_105e";
        case 0xc001105f: return "AMD_15H_UNK_c001_105f";
        case 0xc0011060: return "AMD_15H_UNK_c001_1060";
        case 0xc0011061: return "AMD_15H_UNK_c001_1061";
        case 0xc0011062: return "AMD_15H_UNK_c001_1062";
        case 0xc0011063: return "AMD_15H_UNK_c001_1063";
        case 0xc0011064: return "AMD_15H_UNK_c001_1064";
        case 0xc0011065: return "AMD_15H_UNK_c001_1065";
        case 0xc0011066: return "AMD_15H_UNK_c001_1066";
        case 0xc0011067: return "AMD_15H_UNK_c001_1067";
        case 0xc0011068: return "AMD_15H_UNK_c001_1068";
        case 0xc0011069: return "AMD_15H_UNK_c001_1069";
        case 0xc001106a: return "AMD_15H_UNK_c001_106a";
        case 0xc001106b: return "AMD_15H_UNK_c001_106b";
        case 0xc001106c: return "AMD_15H_UNK_c001_106c";
        case 0xc001106d: return "AMD_15H_UNK_c001_106d";
        case 0xc001106e: return "AMD_15H_UNK_c001_106e";
        case 0xc001106f: return "AMD_15H_UNK_c001_106f";
        case 0xc0011070: return "AMD_15H_UNK_c001_1070"; /* coreboot defines this, but with a numerical name. */
        case 0xc0011071: return "AMD_15H_UNK_c001_1071";
        case 0xc0011072: return "AMD_15H_UNK_c001_1072";
        case 0xc0011073: return "AMD_15H_UNK_c001_1073";
        case 0xc0011080: return "AMD_15H_UNK_c001_1080";
    }

    /*
     * Uncore stuff on Sandy. Putting it here to avoid ugly microarch checks for each register.
     * Note! These are found on model 42 (2a) but not 45 (2d), the latter is the EP variant.
     */
    if (g_enmMicroarch == kCpumMicroarch_Intel_Core7_SandyBridge)
        switch (uMsr)
        {
            case 0x00000700: return "MSR_UNC_CBO_0_PERFEVTSEL0";
            case 0x00000701: return "MSR_UNC_CBO_0_PERFEVTSEL1";
            case 0x00000702: return "MSR_UNC_CBO_0_PERFEVTSEL2?";
            case 0x00000703: return "MSR_UNC_CBO_0_PERFEVTSEL3?";
            case 0x00000704: return "MSR_UNC_CBO_0_UNK_4";
            case 0x00000705: return "MSR_UNC_CBO_0_UNK_5";
            case 0x00000706: return "MSR_UNC_CBO_0_PER_CTR0";
            case 0x00000707: return "MSR_UNC_CBO_0_PER_CTR1";
            case 0x00000708: return "MSR_UNC_CBO_0_PER_CTR2?";
            case 0x00000709: return "MSR_UNC_CBO_0_PER_CTR3?";
            case 0x00000710: return "MSR_UNC_CBO_1_PERFEVTSEL0";
            case 0x00000711: return "MSR_UNC_CBO_1_PERFEVTSEL1";
            case 0x00000712: return "MSR_UNC_CBO_1_PERFEVTSEL2?";
            case 0x00000713: return "MSR_UNC_CBO_1_PERFEVTSEL3?";
            case 0x00000714: return "MSR_UNC_CBO_1_UNK_4";
            case 0x00000715: return "MSR_UNC_CBO_1_UNK_5";
            case 0x00000716: return "MSR_UNC_CBO_1_PER_CTR0";
            case 0x00000717: return "MSR_UNC_CBO_1_PER_CTR1";
            case 0x00000718: return "MSR_UNC_CBO_1_PER_CTR2?";
            case 0x00000719: return "MSR_UNC_CBO_1_PER_CTR3?";
            case 0x00000720: return "MSR_UNC_CBO_2_PERFEVTSEL0";
            case 0x00000721: return "MSR_UNC_CBO_2_PERFEVTSEL1";
            case 0x00000722: return "MSR_UNC_CBO_2_PERFEVTSEL2?";
            case 0x00000723: return "MSR_UNC_CBO_2_PERFEVTSEL3?";
            case 0x00000724: return "MSR_UNC_CBO_2_UNK_4";
            case 0x00000725: return "MSR_UNC_CBO_2_UNK_5";
            case 0x00000726: return "MSR_UNC_CBO_2_PER_CTR0";
            case 0x00000727: return "MSR_UNC_CBO_2_PER_CTR1";
            case 0x00000728: return "MSR_UNC_CBO_2_PER_CTR2?";
            case 0x00000729: return "MSR_UNC_CBO_2_PER_CTR3?";
            case 0x00000730: return "MSR_UNC_CBO_3_PERFEVTSEL0";
            case 0x00000731: return "MSR_UNC_CBO_3_PERFEVTSEL1";
            case 0x00000732: return "MSR_UNC_CBO_3_PERFEVTSEL2?";
            case 0x00000733: return "MSR_UNC_CBO_3_PERFEVTSEL3?";
            case 0x00000734: return "MSR_UNC_CBO_3_UNK_4";
            case 0x00000735: return "MSR_UNC_CBO_3_UNK_5";
            case 0x00000736: return "MSR_UNC_CBO_3_PER_CTR0";
            case 0x00000737: return "MSR_UNC_CBO_3_PER_CTR1";
            case 0x00000738: return "MSR_UNC_CBO_3_PER_CTR2?";
            case 0x00000739: return "MSR_UNC_CBO_3_PER_CTR3?";
            case 0x00000740: return "MSR_UNC_CBO_4_PERFEVTSEL0?";
            case 0x00000741: return "MSR_UNC_CBO_4_PERFEVTSEL1?";
            case 0x00000742: return "MSR_UNC_CBO_4_PERFEVTSEL2?";
            case 0x00000743: return "MSR_UNC_CBO_4_PERFEVTSEL3?";
            case 0x00000744: return "MSR_UNC_CBO_4_UNK_4";
            case 0x00000745: return "MSR_UNC_CBO_4_UNK_5";
            case 0x00000746: return "MSR_UNC_CBO_4_PER_CTR0?";
            case 0x00000747: return "MSR_UNC_CBO_4_PER_CTR1?";
            case 0x00000748: return "MSR_UNC_CBO_4_PER_CTR2?";
            case 0x00000749: return "MSR_UNC_CBO_4_PER_CTR3?";

        }

    /*
     * Bunch of unknown sandy bridge registers.  They might seem like the
     * nehalem based xeon stuff, but the layout doesn't match.  I bet it's the
     * same kind of registes though (i.e. uncore (UNC)).
     *
     * Kudos to Intel for keeping these a secret!  Many thanks guys!!
     */
    if (g_enmMicroarch == kCpumMicroarch_Intel_Core7_SandyBridge)
        switch (uMsr)
        {
            case 0x00000a00: return "I7_SB_UNK_0000_0a00"; case 0x00000a01: return "I7_SB_UNK_0000_0a01";
            case 0x00000a02: return "I7_SB_UNK_0000_0a02";
            case 0x00000c00: return "I7_SB_UNK_0000_0c00"; case 0x00000c01: return "I7_SB_UNK_0000_0c01";
            case 0x00000c06: return "I7_SB_UNK_0000_0c06"; case 0x00000c08: return "I7_SB_UNK_0000_0c08";
            case 0x00000c09: return "I7_SB_UNK_0000_0c09"; case 0x00000c10: return "I7_SB_UNK_0000_0c10";
            case 0x00000c11: return "I7_SB_UNK_0000_0c11"; case 0x00000c14: return "I7_SB_UNK_0000_0c14";
            case 0x00000c15: return "I7_SB_UNK_0000_0c15"; case 0x00000c16: return "I7_SB_UNK_0000_0c16";
            case 0x00000c17: return "I7_SB_UNK_0000_0c17"; case 0x00000c24: return "I7_SB_UNK_0000_0c24";
            case 0x00000c30: return "I7_SB_UNK_0000_0c30"; case 0x00000c31: return "I7_SB_UNK_0000_0c31";
            case 0x00000c32: return "I7_SB_UNK_0000_0c32"; case 0x00000c33: return "I7_SB_UNK_0000_0c33";
            case 0x00000c34: return "I7_SB_UNK_0000_0c34"; case 0x00000c35: return "I7_SB_UNK_0000_0c35";
            case 0x00000c36: return "I7_SB_UNK_0000_0c36"; case 0x00000c37: return "I7_SB_UNK_0000_0c37";
            case 0x00000c38: return "I7_SB_UNK_0000_0c38"; case 0x00000c39: return "I7_SB_UNK_0000_0c39";
            case 0x00000d04: return "I7_SB_UNK_0000_0d04";
            case 0x00000d10: return "I7_SB_UNK_0000_0d10"; case 0x00000d11: return "I7_SB_UNK_0000_0d11";
            case 0x00000d12: return "I7_SB_UNK_0000_0d12"; case 0x00000d13: return "I7_SB_UNK_0000_0d13";
            case 0x00000d14: return "I7_SB_UNK_0000_0d14"; case 0x00000d15: return "I7_SB_UNK_0000_0d15";
            case 0x00000d16: return "I7_SB_UNK_0000_0d16"; case 0x00000d17: return "I7_SB_UNK_0000_0d17";
            case 0x00000d18: return "I7_SB_UNK_0000_0d18"; case 0x00000d19: return "I7_SB_UNK_0000_0d19";
            case 0x00000d24: return "I7_SB_UNK_0000_0d24";
            case 0x00000d30: return "I7_SB_UNK_0000_0d30"; case 0x00000d31: return "I7_SB_UNK_0000_0d31";
            case 0x00000d32: return "I7_SB_UNK_0000_0d32"; case 0x00000d33: return "I7_SB_UNK_0000_0d33";
            case 0x00000d34: return "I7_SB_UNK_0000_0d34"; case 0x00000d35: return "I7_SB_UNK_0000_0d35";
            case 0x00000d36: return "I7_SB_UNK_0000_0d36"; case 0x00000d37: return "I7_SB_UNK_0000_0d37";
            case 0x00000d38: return "I7_SB_UNK_0000_0d38"; case 0x00000d39: return "I7_SB_UNK_0000_0d39";
            case 0x00000d44: return "I7_SB_UNK_0000_0d44";
            case 0x00000d50: return "I7_SB_UNK_0000_0d50"; case 0x00000d51: return "I7_SB_UNK_0000_0d51";
            case 0x00000d52: return "I7_SB_UNK_0000_0d52"; case 0x00000d53: return "I7_SB_UNK_0000_0d53";
            case 0x00000d54: return "I7_SB_UNK_0000_0d54"; case 0x00000d55: return "I7_SB_UNK_0000_0d55";
            case 0x00000d56: return "I7_SB_UNK_0000_0d56"; case 0x00000d57: return "I7_SB_UNK_0000_0d57";
            case 0x00000d58: return "I7_SB_UNK_0000_0d58"; case 0x00000d59: return "I7_SB_UNK_0000_0d59";
            case 0x00000d64: return "I7_SB_UNK_0000_0d64";
            case 0x00000d70: return "I7_SB_UNK_0000_0d70"; case 0x00000d71: return "I7_SB_UNK_0000_0d71";
            case 0x00000d72: return "I7_SB_UNK_0000_0d72"; case 0x00000d73: return "I7_SB_UNK_0000_0d73";
            case 0x00000d74: return "I7_SB_UNK_0000_0d74"; case 0x00000d75: return "I7_SB_UNK_0000_0d75";
            case 0x00000d76: return "I7_SB_UNK_0000_0d76"; case 0x00000d77: return "I7_SB_UNK_0000_0d77";
            case 0x00000d78: return "I7_SB_UNK_0000_0d78"; case 0x00000d79: return "I7_SB_UNK_0000_0d79";
            case 0x00000d84: return "I7_SB_UNK_0000_0d84";
            case 0x00000d90: return "I7_SB_UNK_0000_0d90"; case 0x00000d91: return "I7_SB_UNK_0000_0d91";
            case 0x00000d92: return "I7_SB_UNK_0000_0d92"; case 0x00000d93: return "I7_SB_UNK_0000_0d93";
            case 0x00000d94: return "I7_SB_UNK_0000_0d94"; case 0x00000d95: return "I7_SB_UNK_0000_0d95";
            case 0x00000d96: return "I7_SB_UNK_0000_0d96"; case 0x00000d97: return "I7_SB_UNK_0000_0d97";
            case 0x00000d98: return "I7_SB_UNK_0000_0d98"; case 0x00000d99: return "I7_SB_UNK_0000_0d99";
            case 0x00000da4: return "I7_SB_UNK_0000_0da4";
            case 0x00000db0: return "I7_SB_UNK_0000_0db0"; case 0x00000db1: return "I7_SB_UNK_0000_0db1";
            case 0x00000db2: return "I7_SB_UNK_0000_0db2"; case 0x00000db3: return "I7_SB_UNK_0000_0db3";
            case 0x00000db4: return "I7_SB_UNK_0000_0db4"; case 0x00000db5: return "I7_SB_UNK_0000_0db5";
            case 0x00000db6: return "I7_SB_UNK_0000_0db6"; case 0x00000db7: return "I7_SB_UNK_0000_0db7";
            case 0x00000db8: return "I7_SB_UNK_0000_0db8"; case 0x00000db9: return "I7_SB_UNK_0000_0db9";
        }

    /*
     * Ditto for ivy bridge (observed on the i5-3570).  There are some haswell
     * and sandybridge related docs on registers in this ares, but either
     * things are different for ivy or they're very incomplete.  Again, kudos
     * to intel!
     */
    if (g_enmMicroarch == kCpumMicroarch_Intel_Core7_IvyBridge)
        switch (uMsr)
        {
            case 0x00000700: return "I7_IB_UNK_0000_0700"; case 0x00000701: return "I7_IB_UNK_0000_0701";
            case 0x00000702: return "I7_IB_UNK_0000_0702"; case 0x00000703: return "I7_IB_UNK_0000_0703";
            case 0x00000704: return "I7_IB_UNK_0000_0704"; case 0x00000705: return "I7_IB_UNK_0000_0705";
            case 0x00000706: return "I7_IB_UNK_0000_0706"; case 0x00000707: return "I7_IB_UNK_0000_0707";
            case 0x00000708: return "I7_IB_UNK_0000_0708"; case 0x00000709: return "I7_IB_UNK_0000_0709";
            case 0x00000710: return "I7_IB_UNK_0000_0710"; case 0x00000711: return "I7_IB_UNK_0000_0711";
            case 0x00000712: return "I7_IB_UNK_0000_0712"; case 0x00000713: return "I7_IB_UNK_0000_0713";
            case 0x00000714: return "I7_IB_UNK_0000_0714"; case 0x00000715: return "I7_IB_UNK_0000_0715";
            case 0x00000716: return "I7_IB_UNK_0000_0716"; case 0x00000717: return "I7_IB_UNK_0000_0717";
            case 0x00000718: return "I7_IB_UNK_0000_0718"; case 0x00000719: return "I7_IB_UNK_0000_0719";
            case 0x00000720: return "I7_IB_UNK_0000_0720"; case 0x00000721: return "I7_IB_UNK_0000_0721";
            case 0x00000722: return "I7_IB_UNK_0000_0722"; case 0x00000723: return "I7_IB_UNK_0000_0723";
            case 0x00000724: return "I7_IB_UNK_0000_0724"; case 0x00000725: return "I7_IB_UNK_0000_0725";
            case 0x00000726: return "I7_IB_UNK_0000_0726"; case 0x00000727: return "I7_IB_UNK_0000_0727";
            case 0x00000728: return "I7_IB_UNK_0000_0728"; case 0x00000729: return "I7_IB_UNK_0000_0729";
            case 0x00000730: return "I7_IB_UNK_0000_0730"; case 0x00000731: return "I7_IB_UNK_0000_0731";
            case 0x00000732: return "I7_IB_UNK_0000_0732"; case 0x00000733: return "I7_IB_UNK_0000_0733";
            case 0x00000734: return "I7_IB_UNK_0000_0734"; case 0x00000735: return "I7_IB_UNK_0000_0735";
            case 0x00000736: return "I7_IB_UNK_0000_0736"; case 0x00000737: return "I7_IB_UNK_0000_0737";
            case 0x00000738: return "I7_IB_UNK_0000_0738"; case 0x00000739: return "I7_IB_UNK_0000_0739";
            case 0x00000740: return "I7_IB_UNK_0000_0740"; case 0x00000741: return "I7_IB_UNK_0000_0741";
            case 0x00000742: return "I7_IB_UNK_0000_0742"; case 0x00000743: return "I7_IB_UNK_0000_0743";
            case 0x00000744: return "I7_IB_UNK_0000_0744"; case 0x00000745: return "I7_IB_UNK_0000_0745";
            case 0x00000746: return "I7_IB_UNK_0000_0746"; case 0x00000747: return "I7_IB_UNK_0000_0747";
            case 0x00000748: return "I7_IB_UNK_0000_0748"; case 0x00000749: return "I7_IB_UNK_0000_0749";

        }
    return NULL;
}


/**
 * Gets the name of an MSR.
 *
 * This may return a static buffer, so the content should only be considered
 * valid until the next time this function is called!.
 *
 * @returns MSR name.
 * @param   uMsr                The MSR in question.
 */
static const char *getMsrName(uint32_t uMsr)
{
    const char *pszReadOnly = getMsrNameHandled(uMsr);
    if (pszReadOnly)
        return pszReadOnly;

    /*
     * This MSR needs looking into, return a TODO_XXXX_XXXX name.
     */
    static char s_szBuf[32];
    RTStrPrintf(s_szBuf, sizeof(s_szBuf), "TODO_%04x_%04x", RT_HI_U16(uMsr), RT_LO_U16(uMsr));
    return s_szBuf;
}



/**
 * Gets the name of an MSR range.
 *
 * This may return a static buffer, so the content should only be considered
 * valid until the next time this function is called!.
 *
 * @returns MSR name.
 * @param   uMsr                The first MSR in the range.
 */
static const char *getMsrRangeName(uint32_t uMsr)
{
    switch (uMsr)
    {
        case 0x00000040:
            return g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah ? "MSR_LASTBRANCH_n_FROM_IP" : "MSR_LASTBRANCH_n";
        case 0x00000060:
            if (g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah)
                return "MSR_LASTBRANCH_n_TO_IP";
            break;

        case 0x000003f8:
        case 0x000003f9:
        case 0x000003fa:
            return "I7_MSR_PKG_Cn_RESIDENCY";
        case 0x000003fc:
        case 0x000003fd:
        case 0x000003fe:
            return "I7_MSR_CORE_Cn_RESIDENCY";

        case 0x00000400:
            return "IA32_MCi_CTL_STATUS_ADDR_MISC";

        case 0x00000680:
            return "MSR_LASTBRANCH_n_FROM_IP";
        case 0x000006c0:
            return "MSR_LASTBRANCH_n_TO_IP";

        case 0x00000800: case 0x00000801: case 0x00000802: case 0x00000803:
        case 0x00000804: case 0x00000805: case 0x00000806: case 0x00000807:
        case 0x00000808: case 0x00000809: case 0x0000080a: case 0x0000080b:
        case 0x0000080c: case 0x0000080d: case 0x0000080e: case 0x0000080f:
            return "IA32_X2APIC_n";
    }

    static char s_szBuf[96];
    const char *pszReadOnly = getMsrNameHandled(uMsr);
    if (pszReadOnly)
    {
        /*
         * Replace the last char with 'n'.
         */
        RTStrCopy(s_szBuf, sizeof(s_szBuf), pszReadOnly);
        size_t off = strlen(s_szBuf);
        if (off > 0)
            off--;
        if (off + 1 < sizeof(s_szBuf))
        {
            s_szBuf[off] = 'n';
            s_szBuf[off + 1] = '\0';
        }
    }
    else
    {
        /*
         * This MSR needs looking into, return a TODO_XXXX_XXXX_n name.
         */
        RTStrPrintf(s_szBuf, sizeof(s_szBuf), "TODO_%04x_%04x_n", RT_HI_U16(uMsr), RT_LO_U16(uMsr));
    }
    return s_szBuf;
}


/**
 * Returns the function name for MSRs that have one or two.
 *
 * @returns Function name if applicable, NULL if not.
 * @param   uMsr            The MSR in question.
 * @param   pfTakesValue    Whether this MSR function takes a value or not.
 *                          Optional.
 */
static const char *getMsrFnName(uint32_t uMsr, bool *pfTakesValue)
{
    bool fTmp;
    if (!pfTakesValue)
        pfTakesValue = &fTmp;

    *pfTakesValue = false;

    switch (uMsr)
    {
        case 0x00000000: return "Ia32P5McAddr";
        case 0x00000001: return "Ia32P5McType";
        case 0x00000006:
            if (g_enmMicroarch >= kCpumMicroarch_Intel_First && g_enmMicroarch <= kCpumMicroarch_Intel_P6_Core_Atom_First)
                return NULL; /* TR4 / cache tag on Pentium, but that's for later. */
            return "Ia32MonitorFilterLineSize";
        case 0x00000010: return "Ia32TimestampCounter";
        case 0x00000017: *pfTakesValue = true; return "Ia32PlatformId";
        case 0x0000001b: return "Ia32ApicBase";
        case 0x0000002a: *pfTakesValue = true; return g_fIntelNetBurst ? "IntelP4EbcHardPowerOn" : "IntelEblCrPowerOn";
        case 0x0000002b: *pfTakesValue = true; return g_fIntelNetBurst ? "IntelP4EbcSoftPowerOn" : NULL;
        case 0x0000002c: *pfTakesValue = true; return g_fIntelNetBurst ? "IntelP4EbcFrequencyId" : NULL;
        //case 0x00000033: return "IntelTestCtl";
        case 0x00000034: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch)
                             || CPUMMICROARCH_IS_INTEL_SILVERMONT_PLUS(g_enmMicroarch)
                              ? "IntelI7SmiCount" : NULL;
        case 0x00000035: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch) ? "IntelI7CoreThreadCount" : NULL;
        case 0x0000003a: return "Ia32FeatureControl";

        case 0x00000040:
        case 0x00000041:
        case 0x00000042:
        case 0x00000043:
        case 0x00000044:
        case 0x00000045:
        case 0x00000046:
        case 0x00000047:
            return "IntelLastBranchFromToN";

        case 0x0000008b: return g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON
                              ? "AmdK8PatchLevel" : "Ia32BiosSignId";
        case 0x0000009b: return "Ia32SmmMonitorCtl";

        case 0x000000a8:
        case 0x000000a9:
        case 0x000000aa:
        case 0x000000ab:
        case 0x000000ac:
        case 0x000000ad:
            *pfTakesValue = true;
            return "IntelCore2EmttmCrTablesN";

        case 0x000000c1:
        case 0x000000c2:
        case 0x000000c3:
        case 0x000000c4:
            return "Ia32PmcN";
        case 0x000000c5:
        case 0x000000c6:
        case 0x000000c7:
        case 0x000000c8:
            if (g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First)
                return "Ia32PmcN";
            return NULL;

        case 0x000000cd: *pfTakesValue = true; return "IntelP6FsbFrequency";
        case 0x000000ce: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch)  ? "IntelPlatformInfo" : NULL;
        case 0x000000e2: return "IntelPkgCStConfigControl";
        case 0x000000e3: return "IntelCore2SmmCStMiscInfo";
        case 0x000000e4: return "IntelPmgIoCaptureBase";
        case 0x000000e7: return "Ia32MPerf";
        case 0x000000e8: return "Ia32APerf";
        case 0x000000ee: return "IntelCore1ExtConfig";
        case 0x000000fe: *pfTakesValue = true; return "Ia32MtrrCap";
        case 0x00000119: *pfTakesValue = true; return "IntelBblCrCtl";
        case 0x0000011e: *pfTakesValue = true; return "IntelBblCrCtl3";

        case 0x00000130: return g_enmMicroarch == kCpumMicroarch_Intel_Core7_Westmere
                             || g_enmMicroarch == kCpumMicroarch_Intel_Core7_Nehalem
                              ? "IntelCpuId1FeatureMaskEcdx" : NULL;
        case 0x00000131: return g_enmMicroarch == kCpumMicroarch_Intel_Core7_Westmere
                             || g_enmMicroarch == kCpumMicroarch_Intel_Core7_Nehalem
                              ? "IntelCpuId80000001FeatureMaskEcdx" : NULL;
        case 0x00000132: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
                              ? "IntelCpuId1FeatureMaskEax" : NULL;
        case 0x00000133: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
                              ? "IntelCpuId1FeatureMaskEcdx" : NULL;
        case 0x00000134: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
                              ? "IntelCpuId80000001FeatureMaskEcdx" : NULL;
        case 0x0000013c: return "IntelI7SandyAesNiCtl";
        case 0x0000015f: return "IntelCore1DtsCalControl";
        case 0x00000174: return "Ia32SysEnterCs";
        case 0x00000175: return "Ia32SysEnterEsp";
        case 0x00000176: return "Ia32SysEnterEip";
        case 0x00000179: *pfTakesValue = true; return "Ia32McgCap";
        case 0x0000017a: return "Ia32McgStatus";
        case 0x0000017b: return "Ia32McgCtl";
        case 0x0000017f: return "IntelI7SandyErrorControl"; /* SandyBridge. */
        case 0x00000186: return "Ia32PerfEvtSelN";
        case 0x00000187: return "Ia32PerfEvtSelN";
        case 0x00000193: return /*g_fIntelNetBurst ? NULL :*/ NULL /* Core2_Penryn. */;
        case 0x00000194: if (g_fIntelNetBurst) break;   *pfTakesValue = true; return "IntelFlexRatio";
        case 0x00000198: *pfTakesValue = true; return "Ia32PerfStatus";
        case 0x00000199: *pfTakesValue = true; return "Ia32PerfCtl";
        case 0x0000019a: *pfTakesValue = true; return "Ia32ClockModulation";
        case 0x0000019b: *pfTakesValue = true; return "Ia32ThermInterrupt";
        case 0x0000019c: *pfTakesValue = true; return "Ia32ThermStatus";
        case 0x0000019d: *pfTakesValue = true; return "Ia32Therm2Ctl";
        case 0x000001a0: *pfTakesValue = true; return "Ia32MiscEnable";
        case 0x000001a2: *pfTakesValue = true; return "IntelI7TemperatureTarget";
        case 0x000001a6: return "IntelI7MsrOffCoreResponseN";
        case 0x000001a7: return "IntelI7MsrOffCoreResponseN";
        case 0x000001aa: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch) ? "IntelI7MiscPwrMgmt" : NULL /*"P6PicSensCfg"*/;
        case 0x000001ad: *pfTakesValue = true; return "IntelI7TurboRatioLimit"; /* SandyBridge+, Silvermount+ */
        case 0x000001c8: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_Nehalem ? "IntelI7LbrSelect" : NULL;
        case 0x000001c9: return    g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah
                                && g_enmMicroarch <= kCpumMicroarch_Intel_P6_Core_Atom_End
                              ? "IntelLastBranchTos" : NULL /* Pentium M Dothan seems to have something else here. */;
        case 0x000001d7: return g_fIntelNetBurst ? "P6LastIntFromIp" : NULL;
        case 0x000001d8: return g_fIntelNetBurst ? "P6LastIntToIp"   : NULL;
        case 0x000001d9: return "Ia32DebugCtl";
        case 0x000001da: return g_fIntelNetBurst ? "IntelLastBranchTos" : NULL;
        case 0x000001db: return g_fIntelNetBurst ? "IntelLastBranchFromToN" : "P6LastBranchFromIp";
        case 0x000001dc: return g_fIntelNetBurst ? "IntelLastBranchFromToN" : "P6LastBranchToIp";
        case 0x000001dd: return g_fIntelNetBurst ? "IntelLastBranchFromToN" : "P6LastIntFromIp";
        case 0x000001de: return g_fIntelNetBurst ? "IntelLastBranchFromToN" : "P6LastIntToIp";
        case 0x000001f0: return "IntelI7VirtualLegacyWireCap"; /* SandyBridge. */
        case 0x000001f2: return "Ia32SmrrPhysBase";
        case 0x000001f3: return "Ia32SmrrPhysMask";
        case 0x000001f8: return "Ia32PlatformDcaCap";
        case 0x000001f9: return "Ia32CpuDcaCap";
        case 0x000001fa: return "Ia32Dca0Cap";
        case 0x000001fc: return "IntelI7PowerCtl";

        case 0x00000200: case 0x00000202: case 0x00000204: case 0x00000206:
        case 0x00000208: case 0x0000020a: case 0x0000020c: case 0x0000020e:
        case 0x00000210: case 0x00000212: case 0x00000214: case 0x00000216:
        case 0x00000218: case 0x0000021a: case 0x0000021c: case 0x0000021e:
            return "Ia32MtrrPhysBaseN";
        case 0x00000201: case 0x00000203: case 0x00000205: case 0x00000207:
        case 0x00000209: case 0x0000020b: case 0x0000020d: case 0x0000020f:
        case 0x00000211: case 0x00000213: case 0x00000215: case 0x00000217:
        case 0x00000219: case 0x0000021b: case 0x0000021d: case 0x0000021f:
            return "Ia32MtrrPhysMaskN";
        case 0x00000250:
        case 0x00000258: case 0x00000259:
        case 0x00000268: case 0x00000269: case 0x0000026a: case 0x0000026b:
        case 0x0000026c: case 0x0000026d: case 0x0000026e: case 0x0000026f:
            return "Ia32MtrrFixed";
        case 0x00000277: *pfTakesValue = true; return "Ia32Pat";

        case 0x00000280: case 0x00000281:  case 0x00000282: case 0x00000283:
        case 0x00000284: case 0x00000285:  case 0x00000286: case 0x00000287:
        case 0x00000288: case 0x00000289:  case 0x0000028a: case 0x0000028b:
        case 0x0000028c: case 0x0000028d:  case 0x0000028e: case 0x0000028f:
        case 0x00000290: case 0x00000291:  case 0x00000292: case 0x00000293:
        case 0x00000294: case 0x00000295:  //case 0x00000296: case 0x00000297:
        //case 0x00000298: case 0x00000299:  case 0x0000029a: case 0x0000029b:
        //case 0x0000029c: case 0x0000029d:  case 0x0000029e: case 0x0000029f:
            return "Ia32McNCtl2";

        case 0x000002ff: return "Ia32MtrrDefType";
        //case 0x00000305: return g_fIntelNetBurst ? TODO : NULL;
        case 0x00000309: return g_fIntelNetBurst ? NULL /** @todo P4 */ : "Ia32FixedCtrN";
        case 0x0000030a: return g_fIntelNetBurst ? NULL /** @todo P4 */ : "Ia32FixedCtrN";
        case 0x0000030b: return g_fIntelNetBurst ? NULL /** @todo P4 */ : "Ia32FixedCtrN";
        case 0x00000345: *pfTakesValue = true; return "Ia32PerfCapabilities";
        /* Note! Lots of P4 MSR 0x00000360..0x00000371. */
        case 0x0000038d: return "Ia32FixedCtrCtrl";
        case 0x0000038e: *pfTakesValue = true; return "Ia32PerfGlobalStatus";
        case 0x0000038f: return "Ia32PerfGlobalCtrl";
        case 0x00000390: return "Ia32PerfGlobalOvfCtrl";
        case 0x00000391: return "IntelI7UncPerfGlobalCtrl";             /* S,H,X */
        case 0x00000392: return "IntelI7UncPerfGlobalStatus";           /* S,H,X */
        case 0x00000393: return "IntelI7UncPerfGlobalOvfCtrl";          /* X. ASSUMING this is the same on sandybridge and later. */
        case 0x00000394: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncPerfFixedCtr"  /* X */   : "IntelI7UncPerfFixedCtrCtrl"; /* >= S,H */
        case 0x00000395: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncPerfFixedCtrCtrl" /* X*/ : "IntelI7UncPerfFixedCtr";     /* >= S,H */
        case 0x00000396: return g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncAddrOpcodeMatch" /* X */ : "IntelI7UncCBoxConfig";       /* >= S,H */
        case 0x0000039c: return "IntelI7SandyPebsNumAlt";
         /* Note! Lots of P4 MSR 0x000003a0..0x000003e1. */
        case 0x000003b0: return g_fIntelNetBurst ? NULL : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncPmcN" /* X */            : "IntelI7UncArbPerfCtrN";      /* >= S,H */
        case 0x000003b1: return g_fIntelNetBurst ? NULL : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncPmcN" /* X */            : "IntelI7UncArbPerfCtrN";      /* >= S,H */
        case 0x000003b2: return g_fIntelNetBurst ? NULL : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncPmcN" /* X */            : "IntelI7UncArbPerfEvtSelN";   /* >= S,H */
        case 0x000003b3: return g_fIntelNetBurst ? NULL : g_enmMicroarch < kCpumMicroarch_Intel_Core7_SandyBridge ? "IntelI7UncPmcN" /* X */            : "IntelI7UncArbPerfEvtSelN";   /* >= S,H */
        case 0x000003b4: case 0x000003b5: case 0x000003b6: case 0x000003b7:
            return g_fIntelNetBurst ? NULL : "IntelI7UncPmcN";
        case 0x000003c0: case 0x000003c1: case 0x000003c2: case 0x000003c3:
        case 0x000003c4: case 0x000003c5: case 0x000003c6: case 0x000003c7:
            return g_fIntelNetBurst ? NULL : "IntelI7UncPerfEvtSelN";
        case 0x000003f1: return "Ia32PebsEnable";
        case 0x000003f6: return g_fIntelNetBurst ? NULL /*??*/ : "IntelI7PebsLdLat";
        case 0x000003f8: return g_fIntelNetBurst ? NULL : "IntelI7PkgCnResidencyN";
        case 0x000003f9: return "IntelI7PkgCnResidencyN";
        case 0x000003fa: return "IntelI7PkgCnResidencyN";
        case 0x000003fc: return "IntelI7CoreCnResidencyN";
        case 0x000003fd: return "IntelI7CoreCnResidencyN";
        case 0x000003fe: return "IntelI7CoreCnResidencyN";

        case 0x00000478: return g_enmMicroarch == kCpumMicroarch_Intel_Core2_Penryn ? "IntelCpuId1FeatureMaskEcdx" : NULL;
        case 0x00000480: *pfTakesValue = true; return "Ia32VmxBasic";
        case 0x00000481: *pfTakesValue = true; return "Ia32VmxPinbasedCtls";
        case 0x00000482: *pfTakesValue = true; return "Ia32VmxProcbasedCtls";
        case 0x00000483: *pfTakesValue = true; return "Ia32VmxExitCtls";
        case 0x00000484: *pfTakesValue = true; return "Ia32VmxEntryCtls";
        case 0x00000485: *pfTakesValue = true; return "Ia32VmxMisc";
        case 0x00000486: *pfTakesValue = true; return "Ia32VmxCr0Fixed0";
        case 0x00000487: *pfTakesValue = true; return "Ia32VmxCr0Fixed1";
        case 0x00000488: *pfTakesValue = true; return "Ia32VmxCr4Fixed0";
        case 0x00000489: *pfTakesValue = true; return "Ia32VmxCr4Fixed1";
        case 0x0000048a: *pfTakesValue = true; return "Ia32VmxVmcsEnum";
        case 0x0000048b: *pfTakesValue = true; return "Ia32VmxProcBasedCtls2";
        case 0x0000048c: *pfTakesValue = true; return "Ia32VmxEptVpidCap";
        case 0x0000048d: *pfTakesValue = true; return "Ia32VmxTruePinbasedCtls";
        case 0x0000048e: *pfTakesValue = true; return "Ia32VmxTrueProcbasedCtls";
        case 0x0000048f: *pfTakesValue = true; return "Ia32VmxTrueExitCtls";
        case 0x00000490: *pfTakesValue = true; return "Ia32VmxTrueEntryCtls";
        case 0x00000491: *pfTakesValue = true; return "Ia32VmxVmFunc";

        case 0x000004c1:
        case 0x000004c2:
        case 0x000004c3:
        case 0x000004c4:
        case 0x000004c5:
        case 0x000004c6:
        case 0x000004c7:
        case 0x000004c8:
            return "Ia32PmcN";

        case 0x000005a0: return "IntelCore2PeciControl"; /* Core2_Penryn. */

        case 0x00000600: return "Ia32DsArea";
        case 0x00000601: *pfTakesValue = true; return "IntelI7SandyVrCurrentConfig";
        case 0x00000603: *pfTakesValue = true; return "IntelI7SandyVrMiscConfig";
        case 0x00000606: *pfTakesValue = true; return "IntelI7SandyRaplPowerUnit";
        case 0x0000060a: *pfTakesValue = true; return "IntelI7SandyPkgCnIrtlN";
        case 0x0000060b: *pfTakesValue = true; return "IntelI7SandyPkgCnIrtlN";
        case 0x0000060c: *pfTakesValue = true; return "IntelI7SandyPkgCnIrtlN";
        case 0x0000060d: *pfTakesValue = true; return "IntelI7SandyPkgC2Residency";

        case 0x00000610: *pfTakesValue = true; return "IntelI7RaplPkgPowerLimit";
        case 0x00000611: *pfTakesValue = true; return "IntelI7RaplPkgEnergyStatus";
        case 0x00000613: *pfTakesValue = true; return "IntelI7RaplPkgPerfStatus";
        case 0x00000614: *pfTakesValue = true; return "IntelI7RaplPkgPowerInfo";
        case 0x00000618: *pfTakesValue = true; return "IntelI7RaplDramPowerLimit";
        case 0x00000619: *pfTakesValue = true; return "IntelI7RaplDramEnergyStatus";
        case 0x0000061b: *pfTakesValue = true; return "IntelI7RaplDramPerfStatus";
        case 0x0000061c: *pfTakesValue = true; return "IntelI7RaplDramPowerInfo";
        case 0x00000638: *pfTakesValue = true; return "IntelI7RaplPp0PowerLimit";
        case 0x00000639: *pfTakesValue = true; return "IntelI7RaplPp0EnergyStatus";
        case 0x0000063a: *pfTakesValue = true; return "IntelI7RaplPp0Policy";
        case 0x0000063b: *pfTakesValue = true; return "IntelI7RaplPp0PerfStatus";
        case 0x00000640: *pfTakesValue = true; return "IntelI7RaplPp1PowerLimit";
        case 0x00000641: *pfTakesValue = true; return "IntelI7RaplPp1EnergyStatus";
        case 0x00000642: *pfTakesValue = true; return "IntelI7RaplPp1Policy";
        case 0x00000648: *pfTakesValue = true; return "IntelI7IvyConfigTdpNominal";
        case 0x00000649: *pfTakesValue = true; return "IntelI7IvyConfigTdpLevel1";
        case 0x0000064a: *pfTakesValue = true; return "IntelI7IvyConfigTdpLevel2";
        case 0x0000064b: return "IntelI7IvyConfigTdpControl";
        case 0x0000064c: return "IntelI7IvyTurboActivationRatio";

        case 0x00000660: return "IntelAtSilvCoreC1Recidency";

        case 0x00000680: case 0x00000681: case 0x00000682: case 0x00000683:
        case 0x00000684: case 0x00000685: case 0x00000686: case 0x00000687:
        case 0x00000688: case 0x00000689: case 0x0000068a: case 0x0000068b:
        case 0x0000068c: case 0x0000068d: case 0x0000068e: case 0x0000068f:
        //case 0x00000690: case 0x00000691: case 0x00000692: case 0x00000693:
        //case 0x00000694: case 0x00000695: case 0x00000696: case 0x00000697:
        //case 0x00000698: case 0x00000699: case 0x0000069a: case 0x0000069b:
        //case 0x0000069c: case 0x0000069d: case 0x0000069e: case 0x0000069f:
            return "IntelLastBranchFromN";
        case 0x000006c0: case 0x000006c1: case 0x000006c2: case 0x000006c3:
        case 0x000006c4: case 0x000006c5: case 0x000006c6: case 0x000006c7:
        case 0x000006c8: case 0x000006c9: case 0x000006ca: case 0x000006cb:
        case 0x000006cc: case 0x000006cd: case 0x000006ce: case 0x000006cf:
        //case 0x000006d0: case 0x000006d1: case 0x000006d2: case 0x000006d3:
        //case 0x000006d4: case 0x000006d5: case 0x000006d6: case 0x000006d7:
        //case 0x000006d8: case 0x000006d9: case 0x000006da: case 0x000006db:
        //case 0x000006dc: case 0x000006dd: case 0x000006de: case 0x000006df:
            return "IntelLastBranchToN";
        case 0x000006e0: return "Ia32TscDeadline"; /** @todo detect this correctly! */

        case 0x00000c80: return g_enmMicroarch > kCpumMicroarch_Intel_Core7_Nehalem ? "Ia32DebugInterface" : NULL;

        case 0xc0000080: return "Amd64Efer";
        case 0xc0000081: return "Amd64SyscallTarget";
        case 0xc0000082: return "Amd64LongSyscallTarget";
        case 0xc0000083: return "Amd64CompSyscallTarget";
        case 0xc0000084: return "Amd64SyscallFlagMask";
        case 0xc0000100: return "Amd64FsBase";
        case 0xc0000101: return "Amd64GsBase";
        case 0xc0000102: return "Amd64KernelGsBase";
        case 0xc0000103: return "Amd64TscAux";
        case 0xc0000104: return "AmdFam15hTscRate";
        case 0xc0000105: return "AmdFam15hLwpCfg";
        case 0xc0000106: return "AmdFam15hLwpCbAddr";
        case 0xc0000408: return "AmdFam10hMc4MiscN";
        case 0xc0000409: return "AmdFam10hMc4MiscN";
        case 0xc000040a: return "AmdFam10hMc4MiscN";
        case 0xc000040b: return "AmdFam10hMc4MiscN";
        case 0xc000040c: return "AmdFam10hMc4MiscN";
        case 0xc000040d: return "AmdFam10hMc4MiscN";
        case 0xc000040e: return "AmdFam10hMc4MiscN";
        case 0xc000040f: return "AmdFam10hMc4MiscN";
        case 0xc0010000: return "AmdK8PerfCtlN";
        case 0xc0010001: return "AmdK8PerfCtlN";
        case 0xc0010002: return "AmdK8PerfCtlN";
        case 0xc0010003: return "AmdK8PerfCtlN";
        case 0xc0010004: return "AmdK8PerfCtrN";
        case 0xc0010005: return "AmdK8PerfCtrN";
        case 0xc0010006: return "AmdK8PerfCtrN";
        case 0xc0010007: return "AmdK8PerfCtrN";
        case 0xc0010010: *pfTakesValue = true; return "AmdK8SysCfg";
        case 0xc0010015: return "AmdK8HwCr";
        case 0xc0010016: case 0xc0010018: return "AmdK8IorrBaseN";
        case 0xc0010017: case 0xc0010019: return "AmdK8IorrMaskN";
        case 0xc001001a: case 0xc001001d: return "AmdK8TopOfMemN";
        case 0xc001001f: return "AmdK8NbCfg1";
        case 0xc0010020: return "AmdK8PatchLoader";
        case 0xc0010022: return "AmdK8McXcptRedir";
        case 0xc0010030: case 0xc0010031: case 0xc0010032:
        case 0xc0010033: case 0xc0010034: case 0xc0010035:
            return "AmdK8CpuNameN";
        case 0xc001003e: *pfTakesValue = true; return "AmdK8HwThermalCtrl";
        case 0xc001003f: return "AmdK8SwThermalCtrl";
        case 0xc0010041: *pfTakesValue = true; return "AmdK8FidVidControl";
        case 0xc0010042: *pfTakesValue = true; return "AmdK8FidVidStatus";
        case 0xc0010044: case 0xc0010045: case 0xc0010046: case 0xc0010047:
        case 0xc0010048: case 0xc0010049: case 0xc001004a: //case 0xc001004b:
            return "AmdK8McCtlMaskN";
        case 0xc0010050: case 0xc0010051: case 0xc0010052: case 0xc0010053:
            return "AmdK8SmiOnIoTrapN";
        case 0xc0010054: return "AmdK8SmiOnIoTrapCtlSts";
        case 0xc0010055: return "AmdK8IntPendingMessage";
        case 0xc0010056: return "AmdK8SmiTriggerIoCycle";
        case 0xc0010058: return "AmdFam10hMmioCfgBaseAddr";
        case 0xc0010059: return "AmdFam10hTrapCtlMaybe";
        case 0xc0010061: *pfTakesValue = true; return "AmdFam10hPStateCurLimit";
        case 0xc0010062: *pfTakesValue = true; return "AmdFam10hPStateControl";
        case 0xc0010063: *pfTakesValue = true; return "AmdFam10hPStateStatus";
        case 0xc0010064: case 0xc0010065: case 0xc0010066: case 0xc0010067:
        case 0xc0010068: case 0xc0010069: case 0xc001006a: case 0xc001006b:
            *pfTakesValue = true; return "AmdFam10hPStateN";
        case 0xc0010070: *pfTakesValue = true; return "AmdFam10hCofVidControl";
        case 0xc0010071: *pfTakesValue = true; return "AmdFam10hCofVidStatus";
        case 0xc0010073: return "AmdFam10hCStateIoBaseAddr";
        case 0xc0010074: return "AmdFam10hCpuWatchdogTimer";
        // case 0xc0010075: return "AmdFam15hApmlTdpLimit";
        // case 0xc0010077: return "AmdFam15hCpuPowerInTdp";
        // case 0xc0010078: return "AmdFam15hPowerAveragingPeriod";
        // case 0xc0010079: return "AmdFam15hDramCtrlCmdThrottle";
        // case 0xc0010080: return "AmdFam16hFreqSensFeedbackMonActCnt0";
        // case 0xc0010081: return "AmdFam16hFreqSensFeedbackMonRefCnt0";
        case 0xc0010111: return "AmdK8SmmBase";     /** @todo probably misdetected ign/gp due to locking */
        case 0xc0010112: return "AmdK8SmmAddr";     /** @todo probably misdetected ign/gp due to locking */
        case 0xc0010113: return "AmdK8SmmMask";     /** @todo probably misdetected ign/gp due to locking */
        case 0xc0010114: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV ? "AmdK8VmCr" : NULL;        /** @todo probably misdetected due to locking */
        case 0xc0010115: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AmdK8IgnNe" : NULL;
        case 0xc0010116: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AmdK8SmmCtl" : NULL;
        case 0xc0010117: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV ? "AmdK8VmHSavePa" : NULL;   /** @todo probably misdetected due to locking */
        case 0xc0010118: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV ? "AmdFam10hVmLockKey" : NULL;
        case 0xc0010119: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AmdFam10hSmmLockKey" : NULL; /* Not documented by BKDG, found in netbsd patch. */
        case 0xc001011a: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm      ? "AmdFam10hLocalSmiStatus" : NULL;
        case 0xc0010140: *pfTakesValue = true; return "AmdFam10hOsVisWrkIdLength";
        case 0xc0010141: *pfTakesValue = true; return "AmdFam10hOsVisWrkStatus";
        case 0xc0010200: case 0xc0010202: case 0xc0010204: case 0xc0010206:
        case 0xc0010208: case 0xc001020a: //case 0xc001020c: case 0xc001020e:
            return "AmdK8PerfCtlN";
        case 0xc0010201: case 0xc0010203: case 0xc0010205: case 0xc0010207:
        case 0xc0010209: case 0xc001020b: //case 0xc001020d: case 0xc001020f:
            return "AmdK8PerfCtrN";
        case 0xc0010230: case 0xc0010232: case 0xc0010234: case 0xc0010236:
        //case 0xc0010238: case 0xc001023a: case 0xc001030c: case 0xc001023e:
            return "AmdFam16hL2IPerfCtlN";
        case 0xc0010231: case 0xc0010233: case 0xc0010235: case 0xc0010237:
        //case 0xc0010239: case 0xc001023b: case 0xc001023d: case 0xc001023f:
            return "AmdFam16hL2IPerfCtrN";
        case 0xc0010240: case 0xc0010242: case 0xc0010244: case 0xc0010246:
        //case 0xc0010248: case 0xc001024a: case 0xc001024c: case 0xc001024e:
            return "AmdFam15hNorthbridgePerfCtlN";
        case 0xc0010241: case 0xc0010243: case 0xc0010245: case 0xc0010247:
        //case 0xc0010249: case 0xc001024b: case 0xc001024d: case 0xc001024f:
            return "AmdFam15hNorthbridgePerfCtrN";
        case 0xc0011000: *pfTakesValue = true; return "AmdK7MicrocodeCtl";
        case 0xc0011001: *pfTakesValue = true; return "AmdK7ClusterIdMaybe";
        case 0xc0011002: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AmdK8CpuIdCtlStd07hEbax" : NULL;
        case 0xc0011003: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AmdK8CpuIdCtlStd06hEcx"  : NULL;
        case 0xc0011004: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AmdK8CpuIdCtlStd01hEdcx" : NULL;
        case 0xc0011005: return g_enmMicroarch >= kCpumMicroarch_AMD_K8_First ? "AmdK8CpuIdCtlExt01hEdcx" : NULL;
        case 0xc0011006: return "AmdK7DebugStatusMaybe";
        case 0xc0011007: return "AmdK7BHTraceBaseMaybe";
        case 0xc0011008: return "AmdK7BHTracePtrMaybe";
        case 0xc0011009: return "AmdK7BHTraceLimitMaybe";
        case 0xc001100a: return "AmdK7HardwareDebugToolCfgMaybe";
        case 0xc001100b: return "AmdK7FastFlushCountMaybe";
        case 0xc001100c: return "AmdK7NodeId"; /** @todo dunno if this was there is K7 already. Kinda doubt it. */
        case 0xc0011019: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver ? "AmdK7DrXAddrMaskN" : NULL;
        case 0xc001101a: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver ? "AmdK7DrXAddrMaskN" : NULL;
        case 0xc001101b: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver ? "AmdK7DrXAddrMaskN" : NULL;
        case 0xc0011020: return "AmdK7LoadStoreCfg";
        case 0xc0011021: return "AmdK7InstrCacheCfg";
        case 0xc0011022: return "AmdK7DataCacheCfg";
        case 0xc0011023: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch) ? "AmdFam15hCombUnitCfg" : "AmdK7BusUnitCfg";
        case 0xc0011024: return "AmdK7DebugCtl2Maybe";
        case 0xc0011025: return "AmdK7Dr0DataMatchMaybe";
        case 0xc0011026: return "AmdK7Dr0DataMaskMaybe";
        case 0xc0011027: return "AmdK7DrXAddrMaskN";
        case 0xc0011028: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_First ? "AmdFam15hFpuCfg" : NULL;
        case 0xc0011029: return g_enmMicroarch >= kCpumMicroarch_AMD_15h_First ? "AmdFam15hDecoderCfg" : NULL;
        case 0xc001102a: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AmdFam15hCombUnitCfg2"
                              : CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch) || g_enmMicroarch > kCpumMicroarch_AMD_15h_End
                              ? "AmdFam10hBusUnitCfg2" /* 10h & 16h */ : NULL;
        case 0xc001102b: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AmdFam15hCombUnitCfg3" : NULL;
        case 0xc001102c: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AmdFam15hExecUnitCfg" : NULL;
        case 0xc001102d: return CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch)   ? "AmdFam15hLoadStoreCfg2" : NULL;
        case 0xc0011030: return "AmdFam10hIbsFetchCtl";
        case 0xc0011031: return "AmdFam10hIbsFetchLinAddr";
        case 0xc0011032: return "AmdFam10hIbsFetchPhysAddr";
        case 0xc0011033: return "AmdFam10hIbsOpExecCtl";
        case 0xc0011034: return "AmdFam10hIbsOpRip";
        case 0xc0011035: return "AmdFam10hIbsOpData";
        case 0xc0011036: return "AmdFam10hIbsOpData2";
        case 0xc0011037: return "AmdFam10hIbsOpData3";
        case 0xc0011038: return "AmdFam10hIbsDcLinAddr";
        case 0xc0011039: return "AmdFam10hIbsDcPhysAddr";
        case 0xc001103a: return "AmdFam10hIbsCtl";
        case 0xc001103b: return "AmdFam14hIbsBrTarget";
    }
    return NULL;
}


/**
 * Names CPUMCPU variables that MSRs corresponds to.
 *
 * @returns The variable name @a uMsr corresponds to, NULL if no variable.
 * @param   uMsr                The MSR in question.
 */
static const char *getMsrCpumCpuVarName(uint32_t uMsr)
{
    switch (uMsr)
    {
        case 0x00000250: return "GuestMsrs.msr.MtrrFix64K_00000";
        case 0x00000258: return "GuestMsrs.msr.MtrrFix16K_80000";
        case 0x00000259: return "GuestMsrs.msr.MtrrFix16K_A0000";
        case 0x00000268: return "GuestMsrs.msr.MtrrFix4K_C0000";
        case 0x00000269: return "GuestMsrs.msr.MtrrFix4K_C8000";
        case 0x0000026a: return "GuestMsrs.msr.MtrrFix4K_D0000";
        case 0x0000026b: return "GuestMsrs.msr.MtrrFix4K_D8000";
        case 0x0000026c: return "GuestMsrs.msr.MtrrFix4K_E0000";
        case 0x0000026d: return "GuestMsrs.msr.MtrrFix4K_E8000";
        case 0x0000026e: return "GuestMsrs.msr.MtrrFix4K_F0000";
        case 0x0000026f: return "GuestMsrs.msr.MtrrFix4K_F8000";
        case 0x00000277: return "Guest.msrPAT";
        case 0x000002ff: return "GuestMsrs.msr.MtrrDefType";
    }
    return NULL;
}


/**
 * Checks whether the MSR should read as zero for some reason.
 *
 * @returns true if the register should read as zero, false if not.
 * @param   uMsr                The MSR.
 */
static bool doesMsrReadAsZero(uint32_t uMsr)
{
    switch (uMsr)
    {
        case 0x00000088: return true; // "BBL_CR_D0" - RAZ until understood/needed.
        case 0x00000089: return true; // "BBL_CR_D1" - RAZ until understood/needed.
        case 0x0000008a: return true; // "BBL_CR_D2" - RAZ until understood/needed.

        /* Non-zero, but unknown register. */
        case 0x0000004a:
        case 0x0000004b:
        case 0x0000004c:
        case 0x0000004d:
        case 0x0000004e:
        case 0x0000004f:
        case 0x00000050:
        case 0x00000051:
        case 0x00000052:
        case 0x00000053:
        case 0x00000054:
        case 0x0000008c:
        case 0x0000008d:
        case 0x0000008e:
        case 0x0000008f:
        case 0x00000090:
        case 0xc0011011:
            return true;
    }

    return false;
}


/**
 * Gets the skip mask for the given MSR.
 *
 * @returns Skip mask (0 means skipping nothing).
 * @param   uMsr                The MSR.
 */
static uint64_t getGenericSkipMask(uint32_t uMsr)
{
    switch (uMsr)
    {
        case 0x0000013c: return 3; /* AES-NI lock bit ++. */

        case 0x000001f2: return UINT64_C(0xfffff00f); /* Ia32SmrrPhysBase - Only writable in SMM. */
        case 0x000001f3: return UINT64_C(0xfffff800); /* Ia32SmrrPhysMask - Only writable in SMM. */

        /* these two have lock bits. */
        case 0x0000064b: return UINT64_C(0x80000003);
        case 0x0000064c: return UINT64_C(0x800000ff);

        case 0xc0010015: return 1; /* SmmLock bit */

        /* SmmLock effect: */
        case 0xc0010111: return UINT32_MAX;
        case 0xc0010112: return UINT64_C(0xfffe0000) | ((RT_BIT_64(vbCpuRepGetPhysAddrWidth()) - 1) & ~(uint64_t)UINT32_MAX);
        case 0xc0010113: return UINT64_C(0xfffe773f) | ((RT_BIT_64(vbCpuRepGetPhysAddrWidth()) - 1) & ~(uint64_t)UINT32_MAX);
        case 0xc0010116: return 0x1f;

        case 0xc0010114: return RT_BIT_64(3) /* SVM lock */ | RT_BIT_64(4) /* SvmeDisable */;

        /* Canonical */
        case 0xc0011034:
        case 0xc0011038:
        case 0xc001103b:
            return UINT64_C(0xffff800000000000);

        case 0x00000060: case 0x00000061: case 0x00000062: case 0x00000063:
        case 0x00000064: case 0x00000065: case 0x00000066: case 0x00000067:
        case 0x00000040: case 0x00000041: case 0x00000042: case 0x00000043:
        case 0x00000044: case 0x00000045: case 0x00000046: case 0x00000047:
        case 0x00000600:
            if (g_enmMicroarch >= kCpumMicroarch_Intel_Core2_First)
                return UINT64_C(0xffff800000000000);
            break;


        /* Write only bits. */
        case 0xc0010041: return RT_BIT_64(16); /* FIDVID_CTL.InitFidVid */

        /* Time counters - fudge them to avoid incorrect ignore masks. */
        case 0x00000010:
        case 0x000000e7:
        case 0x000000e8:
            return RT_BIT_32(29) - 1;
    }
    return 0;
}




/** queryMsrWriteBadness return values. */
typedef enum
{
    /** . */
    VBCPUREPBADNESS_MOSTLY_HARMLESS = 0,
    /** Not a problem if accessed with care. */
    VBCPUREPBADNESS_MIGHT_BITE,
    /** Worse than a bad james bond villain. */
    VBCPUREPBADNESS_BOND_VILLAIN
} VBCPUREPBADNESS;


/**
 * Backlisting and graylisting of MSRs which may cause tripple faults.
 *
 * @returns Badness factor.
 * @param   uMsr                The MSR in question.
 */
static VBCPUREPBADNESS queryMsrWriteBadness(uint32_t uMsr)
{
    /** @todo Having trouble in the 0xc0010247,0xc0011006,?? region on Bulldozer. */
    /** @todo Having trouble in the 0xc001100f,0xc001100d,?? region on Opteron
     *        2384. */

    switch (uMsr)
    {
        case 0x00000050:
        case 0x00000051:
        case 0x00000052:
        case 0x00000053:
        case 0x00000054:

        case 0x00001006:
        case 0x00001007:
            return VBCPUREPBADNESS_BOND_VILLAIN;

        case 0x0000120e:
        case 0x00001233:
        case 0x00001239:
        case 0x00001249:
        case 0x0000124a:
        case 0x00001404:
        case 0x00001405:
        case 0x00001413:
        case 0x0000142c: /* Caused rip to be set to 297 or some such weirdness... */
        case 0x0000142e:
        case 0x00001435:
        case 0x00001436:
        case 0x00001438:
        case 0x0000317f:
            if (g_enmVendor == CPUMCPUVENDOR_VIA || g_enmVendor == CPUMCPUVENDOR_SHANGHAI)
                return VBCPUREPBADNESS_BOND_VILLAIN;
            break;

        case 0xc0010010:
        case 0xc0010016:
        case 0xc0010017:
        case 0xc0010018:
        case 0xc0010019:
        case 0xc001001a:
        case 0xc001001d:
        case 0xc0010064: /* P-state fequency, voltage, ++. */
        case 0xc0010065: /* P-state fequency, voltage, ++. */
        case 0xc0010066: /* P-state fequency, voltage, ++. */
        case 0xc0010067: /* P-state fequency, voltage, ++. */
        case 0xc0010068: /* P-state fequency, voltage, ++. */
        case 0xc0010069: /* P-state fequency, voltage, ++. */
        case 0xc001006a: /* P-state fequency, voltage, ++. */
        case 0xc001006b: /* P-state fequency, voltage, ++. */
        case 0xc0010070: /* COFVID Control. */
        case 0xc001101e:
        case 0xc0011021: /* IC_CFG (instruction cache configuration) */
        case 0xc0011023: /* CU_CFG (combined unit configuration) */
        case 0xc001102c: /* EX_CFG (execution unit configuration) */
            return VBCPUREPBADNESS_BOND_VILLAIN;

        case 0xc0011012:
            if (CPUMMICROARCH_IS_AMD_FAM_0FH(g_enmMicroarch))
                return VBCPUREPBADNESS_MIGHT_BITE;
            break;

        /* KVM MSRs that are unsafe to touch. */
        case 0x00000011: /* KVM */
        case 0x00000012: /* KVM */
            return VBCPUREPBADNESS_BOND_VILLAIN;

        /*
         * The TSC is tricky -- writing it isn't a problem, but if we put back the original
         * value, we'll throw it out of whack. If we're on an SMP OS that uses the TSC for timing,
         * we'll likely kill it, especially if we can't do the modification very quickly.
         */
        case 0x00000010: /* IA32_TIME_STAMP_COUNTER */
            if (!g_MsrAcc.fAtomic)
                return VBCPUREPBADNESS_BOND_VILLAIN;
            break;

        /*
         * The following MSRs are not safe to modify in a typical OS if we can't do it atomically,
         * i.e. read/modify/restore without allowing any other code to execute. Everything related
         * to syscalls will blow up in our face if we go back to userland with modified MSRs.
         */
//        case 0x0000001b: /* IA32_APIC_BASE */
        case 0xc0000081: /* MSR_K6_STAR */
        case 0xc0000082: /* AMD64_STAR64 */
        case 0xc0000083: /* AMD64_STARCOMPAT */
        case 0xc0000084: /* AMD64_SYSCALL_FLAG_MASK */
        case 0xc0000100: /* AMD64_FS_BASE */
        case 0xc0000101: /* AMD64_GS_BASE */
        case 0xc0000102: /* AMD64_KERNEL_GS_BASE */
            if (!g_MsrAcc.fAtomic)
                return VBCPUREPBADNESS_MIGHT_BITE;
            break;

        case 0x000001a0: /* IA32_MISC_ENABLE */
        case 0x00000199: /* IA32_PERF_CTL */
            return VBCPUREPBADNESS_MIGHT_BITE;

        case 0x000005a0: /* C2_PECI_CTL */
        case 0x000005a1: /* C2_UNK_0000_05a1 */
            if (g_enmVendor == CPUMCPUVENDOR_INTEL)
                return VBCPUREPBADNESS_MIGHT_BITE;
            break;

        case 0x00002000: /* P6_CR0. */
        case 0x00002003: /* P6_CR3. */
        case 0x00002004: /* P6_CR4. */
            if (g_enmVendor == CPUMCPUVENDOR_INTEL)
                return VBCPUREPBADNESS_MIGHT_BITE;
            break;
        case 0xc0000080: /* MSR_K6_EFER */
            return VBCPUREPBADNESS_MIGHT_BITE;
    }
    return VBCPUREPBADNESS_MOSTLY_HARMLESS;
}


/**
 * Checks if this might be a VIA/Shanghai dummy register.
 *
 * @returns true if it's a dummy, false if it isn't.
 * @param   uMsr                The MSR.
 * @param   uValue              The value.
 * @param   fFlags              The flags.
 */
static bool isMsrViaShanghaiDummy(uint32_t uMsr, uint64_t uValue, uint32_t fFlags)
{
    if (g_enmVendor != CPUMCPUVENDOR_VIA && g_enmVendor != CPUMCPUVENDOR_SHANGHAI)
        return false;

    if (uValue)
        return false;

    if (fFlags)
        return false;

    switch (uMsr)
    {
        case 0x00000010:
        case 0x0000001b:
        case 0x000000c1:
        case 0x000000c2:
        case 0x0000011e:
        case 0x00000186:
        case 0x00000187:
        //case 0x00000200 ... (mtrrs will be detected)
            return false;

        case 0xc0000080:
        case 0xc0000081:
        case 0xc0000082:
        case 0xc0000083:
            if (vbCpuRepSupportsLongMode())
                return false;
            break;
    }

    if (uMsr >= 0x00001200 && uMsr <= 0x00003fff && queryMsrWriteBadness(uMsr) != VBCPUREPBADNESS_MOSTLY_HARMLESS)
        return false;

    if (   !msrProberModifyNoChange(uMsr)
        && !msrProberModifyZero(uMsr))
        return false;

    uint64_t fIgnMask  = 0;
    uint64_t fGpMask   = 0;
    int rc = msrProberModifyBitChanges(uMsr, &fIgnMask, &fGpMask, 0);
    if (RT_FAILURE(rc))
        return false;

    if (fIgnMask != UINT64_MAX)
        return false;
    if (fGpMask != 0)
        return false;

    return true;
}


/**
 * Adjusts the ignore and GP masks for MSRs which contains canonical addresses.
 *
 * @param   uMsr                The MSR.
 * @param   pfIgn               Pointer to the ignore mask.
 * @param   pfGp                Pointer to the GP mask.
 */
static void adjustCanonicalIgnAndGpMasks(uint32_t uMsr, uint64_t *pfIgn, uint64_t *pfGp)
{
    RT_NOREF1(pfIgn);
    if (!vbCpuRepSupportsLongMode())
        return;
    switch (uMsr)
    {
        case 0x00000175:
        case 0x00000176:
        case 0x000001da:
        case 0x000001db:
        case 0x000001dc:
        case 0x000001de:
        case 0x00000600:
            if (*pfGp == UINT64_C(0xffff800000000000))
                *pfGp = 0;
            break;
        case 0x000001dd:
            if (*pfGp == UINT64_C(0x7fff800000000000) || *pfGp == UINT64_C(0xffff800000000000)) /* why is the top bit writable? */
                *pfGp = 0;
            break;

        case 0xc0000082:
        case 0xc0000083:
        case 0xc0000100:
        case 0xc0000101:
        case 0xc0000102:
            *pfGp = 0;
            break;
    }
}



/**
 * Prints a 64-bit value in the best way.
 *
 * @param   uValue              The value.
 */
static void printMsrValueU64(uint64_t uValue)
{
    if (uValue == 0)
        vbCpuRepPrintf(", 0");
    else if (uValue == UINT16_MAX)
        vbCpuRepPrintf(", UINT16_MAX");
    else if (uValue == UINT32_MAX)
        vbCpuRepPrintf(", UINT32_MAX");
    else if (uValue == UINT64_MAX)
        vbCpuRepPrintf(", UINT64_MAX");
    else if (uValue == UINT64_C(0xffffffff00000000))
        vbCpuRepPrintf(", ~(uint64_t)UINT32_MAX");
    else if (uValue <= (UINT32_MAX >> 1))
        vbCpuRepPrintf(", %#llx", uValue);
    else if (uValue <= UINT32_MAX)
        vbCpuRepPrintf(", UINT32_C(%#llx)", uValue);
    else
        vbCpuRepPrintf(", UINT64_C(%#llx)", uValue);
}


/**
 * Prints the newline after an MSR line has been printed.
 *
 * This is used as a hook to slow down the output and make sure the remote
 * terminal or/and output file has received the last update before we go and
 * crash probing the next MSR.
 */
static void printMsrNewLine(void)
{
    vbCpuRepPrintf("\n");
#if 1
    RTThreadSleep(8);
#endif
}

static int printMsrWriteOnly(uint32_t uMsr, const char *pszWrFnName, const char *pszAnnotation)
{
    if (!pszWrFnName)
        pszWrFnName = "IgnoreWrite";
    vbCpuRepPrintf(pszAnnotation
                   ? "    MFN(%#010x, \"%s\", WriteOnly, %s), /* %s */"
                   : "    MFN(%#010x, \"%s\", WriteOnly, %s),",
                   uMsr, getMsrName(uMsr), pszWrFnName, pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrValueReadOnly(uint32_t uMsr, uint64_t uValue, const char *pszAnnotation)
{
    vbCpuRepPrintf("    MVO(%#010x, \"%s\"", uMsr, getMsrName(uMsr));
    printMsrValueU64(uValue);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}



static int printMsrValueIgnoreWritesNamed(uint32_t uMsr, uint64_t uValue, const char *pszName, const char *pszAnnotation)
{
    vbCpuRepPrintf("    MVI(%#010x, \"%s\"", uMsr, pszName);
    printMsrValueU64(uValue);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrValueIgnoreWrites(uint32_t uMsr, uint64_t uValue, const char *pszAnnotation)
{
    return printMsrValueIgnoreWritesNamed(uMsr, uValue, getMsrName(uMsr), pszAnnotation);
}


static int printMsrValueExtended(uint32_t uMsr, uint64_t uValue, uint64_t fIgnMask, uint64_t fGpMask,
                                  const char *pszAnnotation)
{
    vbCpuRepPrintf("    MVX(%#010x, \"%s\"", uMsr, getMsrName(uMsr));
    printMsrValueU64(uValue);
    printMsrValueU64(fIgnMask);
    printMsrValueU64(fGpMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrRangeValueReadOnly(uint32_t uMsr, uint32_t uLast, uint64_t uValue, const char *pszAnnotation)
{
    vbCpuRepPrintf("    RVO(%#010x, %#010x, \"%s\"", uMsr, uLast, getMsrRangeName(uMsr));
    printMsrValueU64(uValue);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrRangeValueIgnoreWritesNamed(uint32_t uMsr, uint32_t uLast, uint64_t uValue, const char *pszName, const char *pszAnnotation)
{
    vbCpuRepPrintf("    RVI(%#010x, %#010x, \"%s\"", uMsr, uLast, pszName);
    printMsrValueU64(uValue);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrRangeValueIgnoreWrites(uint32_t uMsr, uint32_t uLast, uint64_t uValue, const char *pszAnnotation)
{
    return printMsrRangeValueIgnoreWritesNamed(uMsr, uLast, uValue, getMsrRangeName(uMsr), pszAnnotation);
}


static int printMsrFunction(uint32_t uMsr, const char *pszRdFnName, const char *pszWrFnName, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    MFN(%#010x, \"%s\", %s, %s),", uMsr, getMsrName(uMsr), pszRdFnName, pszWrFnName);
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionReadOnly(uint32_t uMsr, const char *pszRdFnName, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    vbCpuRepPrintf("    MFO(%#010x, \"%s\", %s),", uMsr, getMsrName(uMsr), pszRdFnName);
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionIgnoreWrites(uint32_t uMsr, const char *pszRdFnName, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    vbCpuRepPrintf("    MFI(%#010x, \"%s\", %s),", uMsr, getMsrName(uMsr), pszRdFnName);
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionIgnoreMask(uint32_t uMsr, const char *pszRdFnName, const char *pszWrFnName,
                                      uint64_t fIgnMask, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    MFW(%#010x, \"%s\", %s, %s", uMsr, getMsrName(uMsr), pszRdFnName, pszWrFnName);
    printMsrValueU64(fIgnMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionExtended(uint32_t uMsr, const char *pszRdFnName, const char *pszWrFnName, uint64_t uValue,
                                    uint64_t fIgnMask, uint64_t fGpMask, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    MFX(%#010x, \"%s\", %s, %s", uMsr, getMsrName(uMsr), pszRdFnName, pszWrFnName);
    printMsrValueU64(uValue);
    printMsrValueU64(fIgnMask);
    printMsrValueU64(fGpMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionExtendedIdxVal(uint32_t uMsr, const char *pszRdFnName, const char *pszWrFnName, uint64_t uValue,
                                          uint64_t fIgnMask, uint64_t fGpMask, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    MFX(%#010x, \"%s\", %s, %s, %#x", uMsr, getMsrName(uMsr), pszRdFnName, pszWrFnName, uValue);
    printMsrValueU64(fIgnMask);
    printMsrValueU64(fGpMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionCpumCpu(uint32_t uMsr, const char *pszRdFnName, const char *pszWrFnName,
                                   const char *pszCpumCpuStorage, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    if (!pszCpumCpuStorage)
        pszCpumCpuStorage = getMsrCpumCpuVarName(uMsr);
    if (!pszCpumCpuStorage)
        return RTMsgErrorRc(VERR_NOT_FOUND, "Missing CPUMCPU member for %#s (%#x)\n", getMsrName(uMsr), uMsr);
    vbCpuRepPrintf("    MFS(%#010x, \"%s\", %s, %s, %s),", uMsr, getMsrName(uMsr), pszRdFnName, pszWrFnName, pszCpumCpuStorage);
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrFunctionCpumCpuEx(uint32_t uMsr, const char *pszRdFnName, const char *pszWrFnName,
                                     const char *pszCpumCpuStorage, uint64_t fIgnMask, uint64_t fGpMask,
                                     const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    if (!pszCpumCpuStorage)
        pszCpumCpuStorage = getMsrCpumCpuVarName(uMsr);
    if (!pszCpumCpuStorage)
        return RTMsgErrorRc(VERR_NOT_FOUND, "Missing CPUMCPU member for %#s (%#x)\n", getMsrName(uMsr), uMsr);
    vbCpuRepPrintf("    MFZ(%#010x, \"%s\", %s, %s, %s", uMsr, getMsrName(uMsr), pszRdFnName, pszWrFnName, pszCpumCpuStorage);
    printMsrValueU64(fIgnMask);
    printMsrValueU64(fGpMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrRangeFunction(uint32_t uMsr, uint32_t uLast, const char *pszRdFnName, const char *pszWrFnName,
                                 const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    RFN(%#010x, %#010x, \"%s\", %s, %s),", uMsr, uLast, getMsrRangeName(uMsr), pszRdFnName, pszWrFnName);
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrRangeFunctionEx(uint32_t uMsr, uint32_t uLast, const char *pszRdFnName, const char *pszWrFnName,
                                   uint64_t uValue, uint64_t fIgnMask, uint64_t fGpMask, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    RSN(%#010x, %#010x, \"%s\", %s, %s", uMsr, uLast, getMsrRangeName(uMsr), pszRdFnName, pszWrFnName);
    printMsrValueU64(uValue);
    printMsrValueU64(fIgnMask);
    printMsrValueU64(fGpMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrRangeFunctionExIdxVal(uint32_t uMsr, uint32_t uLast, const char *pszRdFnName, const char *pszWrFnName,
                                         uint64_t uValue, uint64_t fIgnMask, uint64_t fGpMask, const char *pszAnnotation)
{
    if (!pszRdFnName)
        pszRdFnName = getMsrFnName(uMsr, NULL);
    if (!pszWrFnName)
        pszWrFnName = pszRdFnName;
    vbCpuRepPrintf("    RSN(%#010x, %#010x, \"%s\", %s, %s, %#x",
                   uMsr, uLast, getMsrRangeName(uMsr), pszRdFnName, pszWrFnName, uValue);
    printMsrValueU64(fIgnMask);
    printMsrValueU64(fGpMask);
    vbCpuRepPrintf("),");
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}


static int printMsrAlias(uint32_t uMsr, uint32_t uTarget, const char *pszAnnotation)
{
    vbCpuRepPrintf("    MAL(%#010x, \"%s\", %#010x),", uMsr, getMsrName(uMsr), uTarget);
    if (pszAnnotation)
        vbCpuRepPrintf(" /* %s */", pszAnnotation);
    printMsrNewLine();
    return VINF_SUCCESS;
}



static const char *annotateValue(uint64_t uValue)
{
    static char s_szBuf[40];
    if (uValue <= UINT32_MAX)
        RTStrPrintf(s_szBuf, sizeof(s_szBuf), "value=%#llx", uValue);
    else
        RTStrPrintf(s_szBuf, sizeof(s_szBuf), "value=%#x`%08x", RT_HI_U32(uValue), RT_LO_U32(uValue));
    return s_szBuf;
}


static const char *annotateValueExtra(const char *pszExtra, uint64_t uValue)
{
    static char s_szBuf[40];
    if (uValue <= UINT32_MAX)
        RTStrPrintf(s_szBuf, sizeof(s_szBuf), "%s value=%#llx", pszExtra, uValue);
    else
        RTStrPrintf(s_szBuf, sizeof(s_szBuf), "%s value=%#x`%08x", pszExtra, RT_HI_U32(uValue), RT_LO_U32(uValue));
    return s_szBuf;
}


static const char *annotateIfMissingBits(uint64_t uValue, uint64_t fBits)
{
    static char s_szBuf[80];
    if ((uValue & fBits) == fBits)
        return annotateValue(uValue);
    RTStrPrintf(s_szBuf, sizeof(s_szBuf), "XXX: Unexpected value %#llx - wanted bits %#llx to be set.", uValue, fBits);
    return s_szBuf;
}


static int reportMsr_Generic(uint32_t uMsr, uint32_t fFlags, uint64_t uValue)
{
    int         rc;
    bool        fTakesValue = false;
    const char *pszFnName   = getMsrFnName(uMsr, &fTakesValue);

    if (fFlags & VBCPUREPMSR_F_WRITE_ONLY)
        rc = printMsrWriteOnly(uMsr, pszFnName, NULL);
    else
    {
        bool    fReadAsZero = doesMsrReadAsZero(uMsr);
        fTakesValue = fTakesValue && !fReadAsZero;


        switch (queryMsrWriteBadness(uMsr))
        {
            /* This is what we're here for... */
            case VBCPUREPBADNESS_MOSTLY_HARMLESS:
            {
                if (   msrProberModifyNoChange(uMsr)
                    || msrProberModifyZero(uMsr))
                {
                    uint64_t fSkipMask = getGenericSkipMask(uMsr);
                    uint64_t fIgnMask  = 0;
                    uint64_t fGpMask   = 0;
                    rc = msrProberModifyBitChanges(uMsr, &fIgnMask, &fGpMask, fSkipMask);
                    if (RT_FAILURE(rc))
                        return rc;
                    adjustCanonicalIgnAndGpMasks(uMsr, &fIgnMask, &fGpMask);

                    if (pszFnName)
                    {
                        if (fGpMask == 0 && fIgnMask == UINT64_MAX && !fTakesValue)
                            rc = printMsrFunctionIgnoreWrites(uMsr, pszFnName, annotateValue(uValue));
                        else if (fGpMask == 0 && fIgnMask == 0 && (!fTakesValue || uValue == 0))
                            rc = printMsrFunction(uMsr, pszFnName, pszFnName, annotateValue(uValue));
                        else
                            rc = printMsrFunctionExtended(uMsr, pszFnName, pszFnName, fTakesValue ? uValue : 0,
                                                          fIgnMask, fGpMask, annotateValue(uValue));
                    }
                    else if (fGpMask == 0 && fIgnMask == UINT64_MAX)
                        rc = printMsrValueIgnoreWrites(uMsr, fReadAsZero ? 0 : uValue, fReadAsZero ? annotateValue(uValue) : NULL);
                    else
                        rc = printMsrValueExtended(uMsr, fReadAsZero ? 0 : uValue, fIgnMask, fGpMask,
                                                   fReadAsZero ? annotateValue(uValue) : NULL);
                }
                /* Most likely read-only. */
                else if (pszFnName && !fTakesValue)
                    rc = printMsrFunctionReadOnly(uMsr, pszFnName, annotateValue(uValue));
                else if (pszFnName)
                    rc = printMsrFunctionExtended(uMsr, pszFnName, "ReadOnly", uValue, 0, 0, annotateValue(uValue));
                else if (fReadAsZero)
                    rc = printMsrValueReadOnly(uMsr, 0, annotateValue(uValue));
                else
                    rc = printMsrValueReadOnly(uMsr, uValue, NULL);
                break;
            }

            /* These should have special handling, so just do a simple
               write back same value check to see if it's writable. */
            case VBCPUREPBADNESS_MIGHT_BITE:
                if (msrProberModifyNoChange(uMsr))
                {
                    if (pszFnName && !fTakesValue)
                        rc = printMsrFunction(uMsr, pszFnName, pszFnName, annotateValueExtra("Might bite.", uValue));
                    else if (pszFnName)
                        rc = printMsrFunctionExtended(uMsr, pszFnName, pszFnName, uValue, 0, 0,
                                                      annotateValueExtra("Might bite.", uValue));
                    else if (fReadAsZero)
                        rc = printMsrValueIgnoreWrites(uMsr, 0, annotateValueExtra("Might bite.", uValue));
                    else
                        rc = printMsrValueIgnoreWrites(uMsr, uValue, "Might bite.");
                }
                else if (pszFnName && !fTakesValue)
                    rc = printMsrFunctionReadOnly(uMsr, pszFnName, annotateValueExtra("Might bite.", uValue));
                else if (pszFnName)
                    rc = printMsrFunctionExtended(uMsr, pszFnName, "ReadOnly", uValue, 0, UINT64_MAX,
                                                  annotateValueExtra("Might bite.", uValue));
                else if (fReadAsZero)
                    rc = printMsrValueReadOnly(uMsr, 0, annotateValueExtra("Might bite.", uValue));
                else
                    rc = printMsrValueReadOnly(uMsr, uValue, "Might bite.");
                break;


            /* Don't try anything with these guys. */
            case VBCPUREPBADNESS_BOND_VILLAIN:
            default:
                if (pszFnName && !fTakesValue)
                    rc = printMsrFunction(uMsr, pszFnName, pszFnName, annotateValueExtra("Villain?", uValue));
                else if (pszFnName)
                    rc = printMsrFunctionExtended(uMsr, pszFnName, pszFnName, uValue, 0, 0,
                                                  annotateValueExtra("Villain?", uValue));
                else if (fReadAsZero)
                    rc = printMsrValueIgnoreWrites(uMsr, 0, annotateValueExtra("Villain?", uValue));
                else
                    rc = printMsrValueIgnoreWrites(uMsr, uValue, "Villain?");
                break;
        }
    }

    return rc;
}


static int reportMsr_GenRangeFunctionEx(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t cMax, const char *pszRdWrFnName,
                                        uint32_t uMsrBase, bool fEarlyEndOk, bool fNoIgnMask, uint64_t fSkipMask, uint32_t *pidxLoop)
{
    uint32_t uMsr   = paMsrs[0].uMsr;
    uint32_t iRange = uMsr - uMsrBase;
    Assert(cMax > iRange);
    cMax -= iRange;

    /* Resolve default function name. */
    if (!pszRdWrFnName)
    {
        pszRdWrFnName = getMsrFnName(uMsr, NULL);
        if (!pszRdWrFnName)
            return RTMsgErrorRc(VERR_INVALID_PARAMETER, "uMsr=%#x no function name\n", uMsr);
    }

    /* Figure the possible register count. */
    if (cMax > cMsrs)
        cMax = cMsrs;
    uint32_t cRegs = 1;
    while (   cRegs < cMax
           && paMsrs[cRegs].uMsr == uMsr + cRegs)
        cRegs++;

    /* Probe the first register and check that the others exhibit
       the same characteristics. */
    bool     fReadOnly0;
    uint64_t fIgnMask0, fGpMask0;
    int rc = msrProberModifyBasicTests(uMsr, fSkipMask, &fReadOnly0, &fIgnMask0, &fGpMask0);
    if (RT_FAILURE(rc))
        return rc;

    const char *pszAnnotation = NULL;
    for (uint32_t i = 1; i < cRegs; i++)
    {
        bool     fReadOnlyN;
        uint64_t fIgnMaskN, fGpMaskN;
        rc = msrProberModifyBasicTests(paMsrs[i].uMsr, fSkipMask, &fReadOnlyN, &fIgnMaskN, &fGpMaskN);
        if (RT_FAILURE(rc))
            return rc;
        if (   fReadOnlyN != fReadOnly0
            || (fIgnMaskN != fIgnMask0 && !fNoIgnMask)
            || fGpMaskN   != fGpMask0)
        {
            if (!fEarlyEndOk && !isMsrViaShanghaiDummy(uMsr, paMsrs[i].uValue, paMsrs[i].fFlags))
            {
                vbCpuRepDebug("MSR %s (%#x) range ended unexpectedly early on %#x: ro=%d ign=%#llx/%#llx gp=%#llx/%#llx [N/0]\n",
                              getMsrNameHandled(uMsr), uMsr, paMsrs[i].uMsr,
                              fReadOnlyN, fReadOnly0, fIgnMaskN, fIgnMask0, fGpMaskN, fGpMask0);
                pszAnnotation = "XXX: The range ended earlier than expected!";
            }
            cRegs = i;
            break;
        }
    }

    /*
     * Report the range (or single MSR as it might be).
     */
    *pidxLoop += cRegs - 1;

    if (fNoIgnMask)
        fIgnMask0 = 0;
    bool fSimple = fIgnMask0 == 0
                && (fGpMask0 == 0 || (fGpMask0 == UINT64_MAX && fReadOnly0))
                && iRange == 0;
    if (cRegs == 1)
        return printMsrFunctionExtendedIdxVal(uMsr, pszRdWrFnName, fReadOnly0 ? "ReadOnly" : pszRdWrFnName,
                                              iRange, fIgnMask0, fGpMask0,
                                              pszAnnotation ? pszAnnotation : annotateValue(paMsrs[0].uValue));
    if (fSimple)
        return printMsrRangeFunction(uMsr, uMsr + cRegs - 1,
                                     pszRdWrFnName, fReadOnly0 ? "ReadOnly" : pszRdWrFnName, pszAnnotation);

    return printMsrRangeFunctionExIdxVal(uMsr, uMsr + cRegs - 1, pszRdWrFnName, fReadOnly0 ? "ReadOnly" : pszRdWrFnName,
                                         iRange /*uValue*/, fIgnMask0, fGpMask0, pszAnnotation);
}


static int reportMsr_GenRangeFunction(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t cMax, const char *pszRdWrFnName,
                                      uint32_t *pidxLoop)
{
    return reportMsr_GenRangeFunctionEx(paMsrs, cMsrs, cMax, pszRdWrFnName, paMsrs[0].uMsr, false /*fEarlyEndOk*/, false /*fNoIgnMask*/,
                                        getGenericSkipMask(paMsrs[0].uMsr), pidxLoop);
}


/**
 * Generic report for an MSR implemented by functions, extended version.
 *
 * @returns VBox status code.
 * @param   uMsr            The MSR.
 * @param   pszRdWrFnName   The read/write function name, optional.
 * @param   uValue          The MSR range value.
 * @param   fSkipMask       Mask of bits to skip.
 * @param   fNoGpMask       Mask of bits to remove from the GP mask after
 *                          probing
 * @param   pszAnnotate     Annotation.
 */
static int reportMsr_GenFunctionEx(uint32_t uMsr, const char *pszRdWrFnName, uint32_t uValue,
                                   uint64_t fSkipMask, uint64_t fNoGpMask, const char *pszAnnotate)
{
    /* Resolve default function name. */
    if (!pszRdWrFnName)
    {
        pszRdWrFnName = getMsrFnName(uMsr, NULL);
        if (!pszRdWrFnName)
            return RTMsgErrorRc(VERR_INVALID_PARAMETER, "uMsr=%#x no function name\n", uMsr);
    }

    /* Probe the register and report. */
    uint64_t fIgnMask = 0;
    uint64_t fGpMask  = 0;
    int rc = msrProberModifyBitChanges(uMsr, &fIgnMask, &fGpMask, fSkipMask);
    if (RT_SUCCESS(rc))
    {
        fGpMask &= ~fNoGpMask;

        if (fGpMask == UINT64_MAX && uValue == 0 && !msrProberModifyZero(uMsr))
            rc = printMsrFunctionReadOnly(uMsr, pszRdWrFnName, pszAnnotate);
        else if (fIgnMask == UINT64_MAX && fGpMask == 0 && uValue == 0)
            rc = printMsrFunctionIgnoreWrites(uMsr, pszRdWrFnName, pszAnnotate);
        else if (fIgnMask != 0 && fGpMask == 0 && uValue == 0)
            rc = printMsrFunctionIgnoreMask(uMsr, pszRdWrFnName, NULL, fIgnMask, pszAnnotate);
        else if (fIgnMask == 0 && fGpMask == 0 && uValue == 0)
            rc = printMsrFunction(uMsr, pszRdWrFnName, NULL, pszAnnotate);
        else
            rc = printMsrFunctionExtended(uMsr, pszRdWrFnName, NULL, uValue, fIgnMask, fGpMask, pszAnnotate);
    }
    return rc;
}


/**
 * Reports a VIA/Shanghai dummy range.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MSR entry in the range.
 */
static int reportMsr_ViaShanghaiDummyRange(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    /* Figure how many. */
    uint32_t uMsr  = paMsrs[0].uMsr;
    uint32_t cRegs = 1;
    while (   cRegs < cMsrs
           && paMsrs[cRegs].uMsr == uMsr + cRegs
           && isMsrViaShanghaiDummy(paMsrs[cRegs].uMsr, paMsrs[cRegs].uValue, paMsrs[cRegs].fFlags))
    {
        cRegs++;
        if (!(cRegs % 0x80))
            vbCpuRepDebug("VIA dummy detection %#llx..%#llx (%#x regs)...\n", uMsr, uMsr + cRegs - 1, cRegs);
    }

    /* Advance. */
    *pidxLoop += cRegs - 1;

    /* Report it/them. */
    char szName[80];
    if (cRegs == 1)
    {
        RTStrPrintf(szName, sizeof(szName), "ZERO_%04x_%04x", RT_HI_U16(uMsr), RT_LO_U16(uMsr));
        return printMsrValueIgnoreWritesNamed(uMsr, 0, szName, NULL);
    }

    uint32_t uMsrLast = uMsr +  cRegs - 1;
    RTStrPrintf(szName, sizeof(szName), "ZERO_%04x_%04x_THRU_%04x_%04x",
                RT_HI_U16(uMsr), RT_LO_U16(uMsr), RT_HI_U16(uMsrLast), RT_LO_U16(uMsrLast));
    return printMsrRangeValueIgnoreWritesNamed(uMsr, uMsrLast, 0, szName, NULL);
}


/**
 * Special function for reporting the IA32_APIC_BASE register, as it seems to be
 * causing trouble on newer systems.
 *
 * @returns
 * @param   uMsr                The MSR number.
 * @param   uValue              The value.
 */
static int reportMsr_Ia32ApicBase(uint32_t uMsr, uint64_t uValue)
{
    /* Trouble with the generic treatment of both the "APIC Global Enable" and
       "Enable x2APIC mode" bits on an i7-3820QM running OS X 10.8.5.  */
    uint64_t fSkipMask = RT_BIT_64(11);
    if (vbCpuRepSupportsX2Apic())
        fSkipMask |= RT_BIT_64(10);
    /* For some reason, twiddling this bit kills a Tualatin PIII-S. */
    if (g_enmMicroarch == kCpumMicroarch_Intel_P6_III)
        fSkipMask |= RT_BIT(9);

    /* If the OS uses the APIC, we have to be super careful. */
    if (!g_MsrAcc.fAtomic)
        fSkipMask |= UINT64_C(0x0000000ffffff000);

    return reportMsr_GenFunctionEx(uMsr, "Ia32ApicBase", uValue, fSkipMask, 0, NULL);
}


/**
 * Special function for reporting the IA32_MISC_ENABLE register, as it seems to
 * be causing trouble on newer systems.
 *
 * @returns
 * @param   uMsr                The MSR number.
 * @param   uValue              The value.
 */
static int reportMsr_Ia32MiscEnable(uint32_t uMsr, uint64_t uValue)
{
    uint64_t fSkipMask = 0;

    if (   (   g_enmMicroarch >= kCpumMicroarch_Intel_Core7_Broadwell
            && g_enmMicroarch <= kCpumMicroarch_Intel_Core7_End)
        || (   g_enmMicroarch >= kCpumMicroarch_Intel_Atom_Airmount
            && g_enmMicroarch <= kCpumMicroarch_Intel_Atom_End)
       )
    {
        vbCpuRepPrintf("WARNING: IA32_MISC_ENABLE probing needs hacking on this CPU!\n");
        RTThreadSleep(128);
    }

    /* If the OS is using MONITOR/MWAIT we'd better not disable it! */
    if (!g_MsrAcc.fAtomic)
        fSkipMask |= RT_BIT(18);

    /* The no execute related flag is deadly if clear.  */
    if (   !(uValue & MSR_IA32_MISC_ENABLE_XD_DISABLE)
        && (   g_enmMicroarch <  kCpumMicroarch_Intel_First
            || g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah
            || vbCpuRepSupportsNX() ) )
        fSkipMask |= MSR_IA32_MISC_ENABLE_XD_DISABLE;

    uint64_t fIgnMask = 0;
    uint64_t fGpMask  = 0;
    int rc = msrProberModifyBitChanges(uMsr, &fIgnMask, &fGpMask, fSkipMask);
    if (RT_SUCCESS(rc))
        rc = printMsrFunctionExtended(uMsr, "Ia32MiscEnable", "Ia32MiscEnable", uValue,
                                      fIgnMask, fGpMask, annotateValue(uValue));
    return rc;
}


/**
 * Verifies that MTRR type field works correctly in the given MSR.
 *
 * @returns VBox status code (failure if bad MSR behavior).
 * @param   uMsr                The MSR.
 * @param   iBit                The first bit of the type field (8-bit wide).
 * @param   cExpected           The number of types expected - PAT=8, MTRR=7.
 */
static int msrVerifyMtrrTypeGPs(uint32_t uMsr, uint32_t iBit, uint32_t cExpected)
{
    uint32_t uEndTypes = 0;
    while (uEndTypes < 255)
    {
        bool fGp = !msrProberModifySimpleGp(uMsr, ~(UINT64_C(0xff) << iBit), (uint64_t)uEndTypes << iBit);
        if (!fGp && (uEndTypes == 2 || uEndTypes == 3))
            return RTMsgErrorRc(VERR_INVALID_PARAMETER, "MTRR types %u does not cause a GP as it should. (msr %#x)\n",
                                uEndTypes, uMsr);
        if (fGp && uEndTypes != 2 && uEndTypes != 3)
            break;
        uEndTypes++;
    }
    if (uEndTypes != cExpected)
        return RTMsgErrorRc(VERR_INVALID_PARAMETER, "MTRR types detected to be %#x (msr %#x). Expected %#x.\n",
                            uEndTypes, uMsr, cExpected);
    return VINF_SUCCESS;
}


/**
 * Deals with the variable MTRR MSRs.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first variable MTRR MSR (200h).
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MTRR MSR entry.
 */
static int reportMsr_Ia32MtrrPhysBaseMaskN(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    uint32_t uMsr = paMsrs[0].uMsr;

    /* Count them. */
    uint32_t cRegs = 1;
    while (   cRegs < cMsrs
           && paMsrs[cRegs].uMsr == uMsr + cRegs
           && !isMsrViaShanghaiDummy(paMsrs[cRegs].uMsr, paMsrs[cRegs].uValue, paMsrs[cRegs].fFlags) )
        cRegs++;
    if (cRegs & 1)
        return RTMsgErrorRc(VERR_INVALID_PARAMETER, "MTRR variable MSR range is odd: cRegs=%#x\n", cRegs);
    if (cRegs > 0x20)
        return RTMsgErrorRc(VERR_INVALID_PARAMETER, "MTRR variable MSR range is too large: cRegs=%#x\n", cRegs);

    /* Find a disabled register that we can play around with. */
    uint32_t iGuineaPig;
    for (iGuineaPig = 0; iGuineaPig < cRegs; iGuineaPig += 2)
        if (!(paMsrs[iGuineaPig + 1].uValue & RT_BIT_32(11)))
            break;
    if (iGuineaPig >= cRegs)
        iGuineaPig = cRegs - 2;
    vbCpuRepDebug("iGuineaPig=%#x -> %#x\n", iGuineaPig, uMsr + iGuineaPig);

    /* Probe the base.  */
    uint64_t fIgnBase = 0;
    uint64_t fGpBase  = 0;
    int rc = msrProberModifyBitChanges(uMsr + iGuineaPig, &fIgnBase, &fGpBase, 0);
    if (RT_FAILURE(rc))
        return rc;
    rc = msrVerifyMtrrTypeGPs(uMsr + iGuineaPig, 0, 7);
    if (RT_FAILURE(rc))
        return rc;
    vbCpuRepDebug("fIgnBase=%#llx fGpBase=%#llx\n", fIgnBase, fGpBase);

    /* Probing the mask is relatively straight forward. */
    uint64_t fIgnMask = 0;
    uint64_t fGpMask  = 0;
    rc = msrProberModifyBitChanges(uMsr + iGuineaPig + 1, &fIgnMask, &fGpMask, 0x800); /* enabling it may cause trouble */
    if (RT_FAILURE(rc))
        return rc;
    vbCpuRepDebug("fIgnMask=%#llx fGpMask=%#llx\n", fIgnMask, fGpMask);

    /* Validate that the whole range subscribes to the apprimately same GP rules. */
    for (uint32_t i = 0; i < cRegs; i += 2)
    {
        uint64_t fSkipBase = ~fGpBase;
        uint64_t fSkipMask = ~fGpMask;
        if (!(paMsrs[i + 1].uValue & RT_BIT_32(11)))
            fSkipBase = fSkipMask = 0;
        fSkipBase |= 0x7;           /* Always skip the type. */
        fSkipMask |= RT_BIT_32(11); /* Always skip the enable bit. */

        vbCpuRepDebug("i=%#x fSkipBase=%#llx fSkipMask=%#llx\n", i, fSkipBase, fSkipMask);

        if (!(paMsrs[i + 1].uValue & RT_BIT_32(11)))
        {
            rc = msrVerifyMtrrTypeGPs(uMsr + iGuineaPig, 0, 7);
            if (RT_FAILURE(rc))
                return rc;
        }

        uint64_t fIgnBaseN = 0;
        uint64_t fGpBaseN  = 0;
        rc = msrProberModifyBitChanges(uMsr + i, &fIgnBaseN, &fGpBaseN, fSkipBase);
        if (RT_FAILURE(rc))
            return rc;

        if (   fIgnBaseN != (fIgnBase & ~fSkipBase)
            || fGpBaseN  != (fGpBase  & ~fSkipBase) )
            return RTMsgErrorRc(VERR_INVALID_PARAMETER,
                                "MTRR PHYS BASE register %#x behaves differently from %#x: ign=%#llx/%#llx gp=%#llx/%#llx (fSkipBase=%#llx)\n",
                                uMsr + i, uMsr + iGuineaPig,
                                fIgnBaseN, fIgnBase & ~fSkipBase, fGpBaseN, fGpBase & ~fSkipBase, fSkipBase);

        uint64_t fIgnMaskN = 0;
        uint64_t fGpMaskN  = 0;
        rc = msrProberModifyBitChanges(uMsr + i + 1, &fIgnMaskN, &fGpMaskN, fSkipMask);
        if (RT_FAILURE(rc))
            return rc;
        if (   fIgnMaskN != (fIgnMask & ~fSkipMask)
            || fGpMaskN  != (fGpMask  & ~fSkipMask) )
            return RTMsgErrorRc(VERR_INVALID_PARAMETER,
                                "MTRR PHYS MASK register %#x behaves differently from %#x: ign=%#llx/%#llx gp=%#llx/%#llx (fSkipMask=%#llx)\n",
                                uMsr + i + 1, uMsr + iGuineaPig + 1,
                                fIgnMaskN, fIgnMask & ~fSkipMask, fGpMaskN, fGpMask & ~fSkipMask, fSkipMask);
    }

    /* Print the whole range. */
    fGpBase &= ~(uint64_t)0x7; /* Valid type bits, see msrVerifyMtrrTypeGPs(). */
    for (uint32_t i = 0; i < cRegs; i += 2)
    {
        printMsrFunctionExtendedIdxVal(uMsr + i,     "Ia32MtrrPhysBaseN", NULL, i / 2, fIgnBase, fGpBase,
                                       annotateValue(paMsrs[i].uValue));
        printMsrFunctionExtendedIdxVal(uMsr + i + 1, "Ia32MtrrPhysMaskN", NULL, i / 2, fIgnMask, fGpMask,
                                       annotateValue(paMsrs[i + 1].uValue));
    }

    *pidxLoop += cRegs - 1;
    return VINF_SUCCESS;
}


/**
 * Deals with fixed MTRR and PAT MSRs, checking the 8 memory type fields.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR.
 */
static int reportMsr_Ia32MtrrFixedOrPat(uint32_t uMsr)
{
    /* Had a spot of trouble on an old macbook pro with core2 duo T9900 (penryn)
       running 64-bit win81pe. Not giving PAT such a scrutiny fixes it. */
    if (   uMsr != 0x00000277
        || (  g_enmVendor == CPUMCPUVENDOR_INTEL
            ? g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First
            : g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON
            ? g_enmMicroarch != kCpumMicroarch_AMD_K8_90nm_AMDV
            : true) )
    {
        /* Every 8 bytes is a type, check the type ranges one by one. */
        for (uint32_t iBit = 0; iBit < 64; iBit += 8)
        {
            int rc = msrVerifyMtrrTypeGPs(uMsr, iBit, 7 + (uMsr == 0x00000277));
            if (RT_FAILURE(rc))
                return rc;
        }
    }

    return printMsrFunctionCpumCpu(uMsr, NULL, NULL, NULL, NULL);
}


/**
 * Deals with IA32_MTRR_DEF_TYPE.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR.
 */
static int reportMsr_Ia32MtrrDefType(uint32_t uMsr)
{
    uint64_t fGpMask  = 0;
    uint64_t fIgnMask = 0;
    if (g_enmMicroarch == kCpumMicroarch_AMD_K8_90nm_AMDV)
    {
        /* Problematic CPU! Fake it for now. */
        fGpMask = ~(uint64_t)0xc07;
        fIgnMask = 0;
    }
    else
    {
        int rc = msrVerifyMtrrTypeGPs(uMsr, 0, 7);
        if (RT_FAILURE(rc))
            return rc;

        rc = msrProberModifyBitChanges(uMsr, &fIgnMask, &fGpMask, 0x7);
        if (RT_FAILURE(rc))
            return rc;
        Assert(!(fGpMask & 7)); Assert(!(fIgnMask & 7));
    }

    return printMsrFunctionCpumCpuEx(uMsr, NULL, NULL, NULL, fIgnMask, fGpMask, NULL);
}


/**
 * Deals with the Machine Check (MC) MSRs in the 400h+ area.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MC MSR (400h).
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MC MSR entry.
 */
static int reportMsr_Ia32McCtlStatusAddrMiscN(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    uint32_t uMsr = paMsrs[0].uMsr;

    /* Count them. */
    uint32_t cRegs = 1;
    uint32_t cDetectedRegs = 1;
    while (   cDetectedRegs < cMsrs
           && (   paMsrs[cDetectedRegs].uMsr == uMsr + cRegs
               || (cRegs & 3) == 2 /* ADDR may or may not be there, depends on STATUS and CPU. */
               || (cRegs & 3) == 3 /* MISC may or may not be there, depends on STATUS and CPU. */
               || cRegs == 0x13 /* MC4_MISC may not be there, depends on CPU. */
               || cRegs == 0x14 /* MC5_CTL may not be there, depends on CPU. */)
           && cRegs < 0x7f )
    {
        if (paMsrs[cDetectedRegs].uMsr == uMsr + cRegs)
            cDetectedRegs++;
        cRegs++;
    }
    if (cRegs & 3)
        return RTMsgErrorRc(VERR_INVALID_PARAMETER, "MC MSR range is odd: cRegs=%#x\n", cRegs);

    /* Just report them.  We don't bother probing here as the CTL format
       and such seems to be a lot of work to test correctly and changes between
       cpu generations.  */
    *pidxLoop += cDetectedRegs - 1;
    return printMsrRangeFunction(uMsr, uMsr + cRegs - 1, "Ia32McCtlStatusAddrMiscN", NULL, NULL);
}



/**
 * Deals with the X2APIC msrs.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first X2APIC MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last X2APIC MSR entry.
 */
static int reportMsr_GenX2Apic(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    /* Advance. */
    uint32_t cRegs = 1;
    while (   cRegs < cMsrs
           && paMsrs[cRegs].uMsr <= 0x8ff)
        cRegs++;
    *pidxLoop += cRegs - 1;

    /* Just emit an X2APIC range. */
    return printMsrRangeFunction(0x800, 0x8ff, "Ia32X2ApicN", NULL, NULL);
}


/**
 * Deals carefully with the EFER register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_Amd64Efer(uint32_t uMsr, uint64_t uValue)
{
    uint64_t fSkipMask = 0;
    if (vbCpuRepSupportsLongMode())
    {
        fSkipMask |= MSR_K6_EFER_LME;
        if (!g_MsrAcc.fAtomic && (uValue & MSR_K6_EFER_SCE))
            fSkipMask |= MSR_K6_EFER_SCE;
    }
    if (   (uValue & MSR_K6_EFER_NXE)
        || vbCpuRepSupportsNX())
        fSkipMask |= MSR_K6_EFER_NXE;

    /* NetBurst prescott 2MB (model 4) hung or triple faulted here.  The extra
       sleep or something seemed to help for some screwed up reason. */
    if (g_fIntelNetBurst)
    {
        // This doesn't matter:
        //fSkipMask |= MSR_K6_EFER_SCE;
        //if (vbCpuRepSupportsLongMode())
        //    fSkipMask |= MSR_K6_EFER_LMA;
        //vbCpuRepDebug("EFER - netburst workaround - ignore SCE & LMA (fSkipMask=%#llx)\n", fSkipMask);

        vbCpuRepDebug("EFER - netburst sleep fudge - fSkipMask=%#llx\n", fSkipMask);
        RTThreadSleep(1000);
    }

    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, MSR_K6_EFER_LMA, NULL);
}


/**
 * Deals with the MC4_MISCn (n >= 1) range and the following reserved MSRs.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MSR entry in the range.
 */
static int reportMsr_AmdFam10hMc4MiscN(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    /* Count registers. */
    uint32_t cRegs = 1;
    while (   cRegs < cMsrs
           && cRegs < 8
           && paMsrs[cRegs].uMsr == paMsrs[0].uMsr + cRegs)
        cRegs++;

    /* Probe & report used MSRs. */
    uint64_t fIgnMask = 0;
    uint64_t fGpMask  = 0;
    uint32_t cUsed    = 0;
    while (cUsed < cRegs)
    {
        uint64_t fIgnMaskN = 0;
        uint64_t fGpMaskN  = 0;
        int rc = msrProberModifyBitChanges(paMsrs[cUsed].uMsr, &fIgnMaskN, &fGpMaskN, 0);
        if (RT_FAILURE(rc))
            return rc;
        if (fIgnMaskN == UINT64_MAX || fGpMaskN == UINT64_MAX)
            break;
        if (cUsed == 0)
        {
            fIgnMask = fIgnMaskN;
            fGpMask  = fGpMaskN;
        }
        else if (   fIgnMaskN != fIgnMask
                 || fGpMaskN  != fGpMask)
            return RTMsgErrorRc(VERR_NOT_EQUAL, "AmdFam16hMc4MiscN mismatch: fIgn=%#llx/%#llx fGp=%#llx/%#llx uMsr=%#x\n",
                                fIgnMaskN, fIgnMask, fGpMaskN, fGpMask, paMsrs[cUsed].uMsr);
        cUsed++;
    }
    if (cUsed > 0)
        printMsrRangeFunctionEx(paMsrs[0].uMsr, paMsrs[cUsed - 1].uMsr, "AmdFam10hMc4MiscN", NULL, 0, fIgnMask, fGpMask, NULL);

    /* Probe & report reserved MSRs. */
    uint32_t cReserved = 0;
    while (cUsed + cReserved < cRegs)
    {
        fIgnMask = fGpMask = 0;
        int rc = msrProberModifyBitChanges(paMsrs[cUsed + cReserved].uMsr, &fIgnMask, &fGpMask, 0);
        if (RT_FAILURE(rc))
            return rc;
        if ((fIgnMask != UINT64_MAX && fGpMask != UINT64_MAX) || paMsrs[cUsed + cReserved].uValue)
            return RTMsgErrorRc(VERR_NOT_EQUAL,
                                "Unexpected reserved AmdFam16hMc4MiscN: fIgn=%#llx fGp=%#llx uMsr=%#x uValue=%#llx\n",
                                fIgnMask, fGpMask, paMsrs[cUsed + cReserved].uMsr, paMsrs[cUsed + cReserved].uValue);
        cReserved++;
    }
    if (cReserved > 0 && fIgnMask == UINT64_MAX)
        printMsrRangeValueIgnoreWrites(paMsrs[cUsed].uMsr, paMsrs[cUsed + cReserved - 1].uMsr, 0, NULL);
    else if (cReserved > 0 && fGpMask == UINT64_MAX)
        printMsrRangeValueReadOnly(paMsrs[cUsed].uMsr, paMsrs[cUsed + cReserved - 1].uMsr, 0, NULL);

    *pidxLoop += cRegs - 1;
    return VINF_SUCCESS;
}


/**
 * Deals with the AMD PERF_CTL range.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MSR entry in the range.
 */
static int reportMsr_AmdK8PerfCtlN(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    uint32_t uMsr = paMsrs[0].uMsr;
    Assert(uMsr == 0xc0010000);

    /* Family 15h (bulldozer +) aliases these registers sparsely onto c001020x. */
    if (CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
    {
        for (uint32_t i = 0; i < 4; i++)
            printMsrAlias(uMsr + i, 0xc0010200 + i * 2, NULL);
        *pidxLoop += 3;
    }
    else
        return reportMsr_GenRangeFunction(paMsrs, cMsrs, 4, "AmdK8PerfCtlN", pidxLoop);
    return VINF_SUCCESS;
}


/**
 * Deals with the AMD PERF_CTR range.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MSR entry in the range.
 */
static int reportMsr_AmdK8PerfCtrN(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    uint32_t uMsr = paMsrs[0].uMsr;
    Assert(uMsr == 0xc0010004);

    /* Family 15h (bulldozer +) aliases these registers sparsely onto c001020x. */
    if (CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
    {
        for (uint32_t i = 0; i < 4; i++)
            printMsrAlias(uMsr + i, 0xc0010201 + i * 2, NULL);
        *pidxLoop += 3;
    }
    else
        return reportMsr_GenRangeFunction(paMsrs, cMsrs, 4, "AmdK8PerfCtrN", pidxLoop);
    return VINF_SUCCESS;
}


/**
 * Deals carefully with the SYS_CFG register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdK8SysCfg(uint32_t uMsr, uint64_t uValue)
{
    uint64_t fSkipMask = 0;

    /* Bit 21 (MtrrTom2En) is marked reserved in family 0fh, while in family
       10h BKDG this changes (as does the document style).  Testing this bit
       causes bulldozer running win64 to restart, thus this special treatment. */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K10)
        fSkipMask |= RT_BIT(21);

    /* Turns out there are more killer bits here, at least on Opteron 2384.
       Skipping all known bits. */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_90nm_AMDV /* Not sure when introduced - harmless? */)
        fSkipMask |= RT_BIT(22); /* Tom2ForceMemTypeWB */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
        fSkipMask |= RT_BIT(21); /* MtrrTom2En */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
        fSkipMask |= RT_BIT(20); /* MtrrVarDramEn*/
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
        fSkipMask |= RT_BIT(19); /* MtrrFixDramModEn */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
        fSkipMask |= RT_BIT(18); /* MtrrFixDramEn */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
        fSkipMask |= RT_BIT(17); /* SysUcLockEn */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
        fSkipMask |= RT_BIT(16); /* ChgToDirtyDis */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First && g_enmMicroarch < kCpumMicroarch_AMD_15h_First)
        fSkipMask |= RT_BIT(10); /* SetDirtyEnO */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K8_First && g_enmMicroarch < kCpumMicroarch_AMD_15h_First)
        fSkipMask |= RT_BIT(9);  /* SetDirtyEnS */
    if (   CPUMMICROARCH_IS_AMD_FAM_0FH(g_enmMicroarch)
        || CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch))
        fSkipMask |= RT_BIT(8);  /* SetDirtyEnE */
    if (   CPUMMICROARCH_IS_AMD_FAM_0FH(g_enmMicroarch)
        || CPUMMICROARCH_IS_AMD_FAM_11H(g_enmMicroarch) )
        fSkipMask |= RT_BIT(7)   /* SysVicLimit */
                  |  RT_BIT(6)   /* SysVicLimit */
                  |  RT_BIT(5)   /* SysVicLimit */
                  |  RT_BIT(4)   /* SysAckLimit */
                  |  RT_BIT(3)   /* SysAckLimit */
                  |  RT_BIT(2)   /* SysAckLimit */
                  |  RT_BIT(1)   /* SysAckLimit */
                  |  RT_BIT(0)   /* SysAckLimit */;

    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals carefully with the HWCR register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdK8HwCr(uint32_t uMsr, uint64_t uValue)
{
    uint64_t fSkipMask = 0;

    /* Trouble on Opteron 2384, skip some of the known bits. */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_K10 && !CPUMMICROARCH_IS_AMD_FAM_11H(g_enmMicroarch))
        fSkipMask |= /*RT_BIT(10)*/ 0  /* MonMwaitUserEn */
                  |  RT_BIT(9);  /* MonMwaitDis */
    fSkipMask |= RT_BIT(8);      /* #IGNNE port emulation */
    if (   CPUMMICROARCH_IS_AMD_FAM_0FH(g_enmMicroarch)
        || CPUMMICROARCH_IS_AMD_FAM_11H(g_enmMicroarch) )
        fSkipMask |= RT_BIT(7)   /* DisLock */
                  |  RT_BIT(6);  /* FFDis (TLB flush filter) */
    fSkipMask |= RT_BIT(4);      /* INVD to WBINVD */
    fSkipMask |= RT_BIT(3);      /* TLBCACHEDIS */
    if (   CPUMMICROARCH_IS_AMD_FAM_0FH(g_enmMicroarch)
        || CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch)
        || CPUMMICROARCH_IS_AMD_FAM_11H(g_enmMicroarch) )
        fSkipMask |= RT_BIT(1);  /* SLOWFENCE */
    fSkipMask |= RT_BIT(0);      /* SMMLOCK */

    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals carefully with a IORRBasei register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdK8IorrBaseN(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = RT_BIT(4) | RT_BIT(3);
    fSkipMask |= (RT_BIT_64(vbCpuRepGetPhysAddrWidth()) - 1) & X86_PAGE_4K_BASE_MASK;
    return reportMsr_GenFunctionEx(uMsr, NULL, (uMsr - 0xc0010016) / 2, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals carefully with a IORRMaski register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdK8IorrMaskN(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = RT_BIT(11);
    fSkipMask |= (RT_BIT_64(vbCpuRepGetPhysAddrWidth()) - 1) & X86_PAGE_4K_BASE_MASK;
    return reportMsr_GenFunctionEx(uMsr, NULL, (uMsr - 0xc0010017) / 2, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals carefully with a IORRMaski register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdK8TopMemN(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = (RT_BIT_64(vbCpuRepGetPhysAddrWidth()) - 1) & ~(RT_BIT_64(23) - 1);
    return reportMsr_GenFunctionEx(uMsr, NULL, uMsr == 0xc001001d, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals with the AMD P-state config range.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MSR entry in the range.
 */
static int reportMsr_AmdFam10hPStateN(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t *pidxLoop)
{
    uint32_t uMsr = paMsrs[0].uMsr;
    AssertRelease(uMsr == 0xc0010064);

    /* Count them. */
    uint32_t cRegs = 1;
    while (   cRegs < 8
           && cRegs < cMsrs
           && paMsrs[cRegs].uMsr == uMsr + cRegs)
        cRegs++;

    /* Figure out which bits we should skip when probing.  This is based on
       specs and may need adjusting for real life when handy. */
    uint64_t fSkipMask = RT_BIT_64(63);             /* PstateEn */
    fSkipMask |= RT_BIT_64(41) | RT_BIT_64(40);     /* IddDiv */
    fSkipMask |= UINT64_C(0x000000ff00000000);      /* IddValue */
    if (CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch))
        fSkipMask |= UINT32_C(0xfe000000);          /* NbVid - Northbridge VID */
    if (   CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch)
        || CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
        fSkipMask |= RT_BIT_32(22);                 /* NbDid or NbPstate. */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver) /* ?? - listed in 10-1Fh model BDKG as well asFam16h */
        fSkipMask |= RT_BIT_32(16);                 /* CpuVid[7] */
    fSkipMask |= UINT32_C(0x0000fe00);              /* CpuVid[6:0] */
    fSkipMask |= UINT32_C(0x000001c0);              /* CpuDid */
    fSkipMask |= UINT32_C(0x0000003f);              /* CpuFid */

    /* Probe and report them one by one since we're passing values instead of
       register indexes to the functions. */
    for (uint32_t i = 0; i < cRegs; i++)
    {
        uint64_t fIgnMask = 0;
        uint64_t fGpMask = 0;
        int rc = msrProberModifyBitChanges(uMsr + i, &fIgnMask, &fGpMask, fSkipMask);
        if (RT_FAILURE(rc))
            return rc;
        printMsrFunctionExtended(uMsr + i, "AmdFam10hPStateN", NULL, paMsrs[i].uValue, fIgnMask, fGpMask,
                                 annotateValue(paMsrs[i].uValue));
    }

    /* Advance. */
    *pidxLoop += cRegs - 1;
    return VINF_SUCCESS;
}


/**
 * Deals carefully with a COFVID control register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdFam10hCofVidControl(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = 0;
    if (CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch))
        fSkipMask |= UINT32_C(0xfe000000);          /* NbVid - Northbridge VID */
    else if (g_enmMicroarch >= kCpumMicroarch_AMD_15h_First) /* Listed in preliminary Fam16h BDKG. */
        fSkipMask |= UINT32_C(0xff000000);          /* NbVid - Northbridge VID - includes bit 24 for Fam15h and Fam16h. Odd... */
    if (   CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch)
        || g_enmMicroarch >= kCpumMicroarch_AMD_15h_First) /* Listed in preliminary Fam16h BDKG. */
        fSkipMask |= RT_BIT_32(22);                 /* NbDid or NbPstate. */
    if (g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver) /* ?? - listed in 10-1Fh model BDKG as well asFam16h */
        fSkipMask |= RT_BIT_32(20);                 /* CpuVid[7] */
    fSkipMask |= UINT32_C(0x00070000);              /* PstatId */
    fSkipMask |= UINT32_C(0x0000fe00);              /* CpuVid[6:0] */
    fSkipMask |= UINT32_C(0x000001c0);              /* CpuDid */
    fSkipMask |= UINT32_C(0x0000003f);              /* CpuFid */

    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals with the AMD [|L2I_|NB_]PERF_CT[LR] mixed ranges.
 *
 * Mixed here refers to the control and counter being in mixed in pairs as
 * opposed to them being two separate parallel arrays like in the 0xc0010000
 * area.
 *
 * @returns VBox status code.
 * @param   paMsrs              Pointer to the first MSR.
 * @param   cMsrs               The number of MSRs in the array @a paMsr.
 * @param   cMax                The max number of MSRs (not counters).
 * @param   pidxLoop            Index variable that should be advanced to the
 *                              last MSR entry in the range.
 */
static int reportMsr_AmdGenPerfMixedRange(VBCPUREPMSR const *paMsrs, uint32_t cMsrs, uint32_t cMax, uint32_t *pidxLoop)
{
    uint32_t uMsr = paMsrs[0].uMsr;

    /* Count them. */
    uint32_t cRegs = 1;
    while (   cRegs < cMax
           && cRegs < cMsrs
           && paMsrs[cRegs].uMsr == uMsr + cRegs)
        cRegs++;
    if (cRegs & 1)
        return RTMsgErrorRc(VERR_INVALID_PARAMETER, "PERF range at %#x is odd: cRegs=%#x\n", uMsr, cRegs);

    /* Report them as individual entries, using default names and such. */
    for (uint32_t i = 0; i < cRegs; i++)
    {
        uint64_t fIgnMask = 0;
        uint64_t fGpMask  = 0;
        int rc = msrProberModifyBitChanges(uMsr + i, &fIgnMask, &fGpMask, 0);
        if (RT_FAILURE(rc))
            return rc;
        printMsrFunctionExtendedIdxVal(uMsr + i, NULL, NULL, i / 2, fIgnMask, fGpMask, annotateValue(paMsrs[i].uValue));
    }

    /* Advance. */
    *pidxLoop += cRegs - 1;
    return VINF_SUCCESS;
}


/**
 * Deals carefully with a LS_CFG register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdK7InstrCacheCfg(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = RT_BIT_64(9) /* DIS_SPEC_TLB_RLD */;
    if (CPUMMICROARCH_IS_AMD_FAM_10H(g_enmMicroarch))
        fSkipMask |= RT_BIT_64(14); /* DIS_IND */
    if (CPUMMICROARCH_IS_AMD_FAM_16H(g_enmMicroarch))
        fSkipMask |= RT_BIT_64(26); /* DIS_WIDEREAD_PWR_SAVE */
    if (CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
    {
        fSkipMask |= 0x1e;          /* DisIcWayFilter */
        fSkipMask |= RT_BIT_64(39); /* DisLoopPredictor */
        fSkipMask |= RT_BIT_64(27); /* Unknown killer bit, possibly applicable to other microarchs. */
        fSkipMask |= RT_BIT_64(28); /* Unknown killer bit, possibly applicable to other microarchs. */
    }
    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals carefully with a CU_CFG register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdFam15hCombUnitCfg(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = RT_BIT_64(23) /* L2WayLock  */
                       | RT_BIT_64(22) /* L2FirstLockWay */
                       | RT_BIT_64(21) /* L2FirstLockWay */
                       | RT_BIT_64(20) /* L2FirstLockWay */
                       | RT_BIT_64(19) /* L2FirstLockWay */
                       | RT_BIT_64(10) /* DcacheAggressivePriority */;
    fSkipMask |= RT_BIT_64(46) | RT_BIT_64(45); /* Killer field. Seen bit 46 set, 45 clear. Messing with either means reboot/BSOD. */
    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, 0, annotateValue(uValue));
}


/**
 * Deals carefully with a EX_CFG register.
 *
 * @returns VBox status code.
 * @param   uMsr                The MSR number.
 * @param   uValue              The current value.
 */
static int reportMsr_AmdFam15hExecUnitCfg(uint32_t uMsr, uint64_t uValue)
{
    /* Skip know bits here, as harm seems to come from messing with them. */
    uint64_t fSkipMask = RT_BIT_64(54) /* LateSbzResync  */;
    fSkipMask |= RT_BIT_64(35); /* Undocumented killer bit. */
    return reportMsr_GenFunctionEx(uMsr, NULL, uValue, fSkipMask, 0, annotateValue(uValue));
}



static int produceMsrReport(VBCPUREPMSR *paMsrs, uint32_t cMsrs)
{
    vbCpuRepDebug("produceMsrReport\n");
    RTThreadSleep(500);

    for (uint32_t i = 0; i < cMsrs; i++)
    {
        uint32_t    uMsr       = paMsrs[i].uMsr;
        uint32_t    fFlags     = paMsrs[i].fFlags;
        uint64_t    uValue     = paMsrs[i].uValue;
        int         rc;
#if 0
        //if (uMsr < 0x00000000)
        //    continue;
        if (uMsr >= 0x00000277)
        {
            vbCpuRepDebug("produceMsrReport: uMsr=%#x (%s)...\n", uMsr, getMsrNameHandled(uMsr));
            RTThreadSleep(1000);
        }
#endif
        /*
         * Deal with write only regs first to avoid having to avoid them all the time.
         */
        if (fFlags & VBCPUREPMSR_F_WRITE_ONLY)
        {
            if (uMsr == 0x00000079)
                rc = printMsrWriteOnly(uMsr, NULL, NULL);
            else
                rc = reportMsr_Generic(uMsr, fFlags, uValue);
        }
        /*
         * VIA implement MSRs in a interesting way, so we have to select what we
         * want to handle there to avoid making the code below unreadable.
         */
        /** @todo r=klaus check if Shanghai CPUs really are behaving the same */
        else if (isMsrViaShanghaiDummy(uMsr, uValue, fFlags))
            rc = reportMsr_ViaShanghaiDummyRange(&paMsrs[i], cMsrs - i, &i);
        /*
         * This shall be sorted by uMsr as much as possible.
         */
        else if (uMsr == 0x00000000 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON) && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
            rc = printMsrAlias(uMsr, 0x00000402, NULL);
        else if (uMsr == 0x00000001 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON) && g_enmMicroarch >= kCpumMicroarch_AMD_K8_First)
            rc = printMsrAlias(uMsr, 0x00000401, NULL); /** @todo not 101% correct on Fam15h and later, 0xc0010015[McstatusWrEn] effect differs. */
        else if (uMsr == 0x0000001b)
            rc = reportMsr_Ia32ApicBase(uMsr, uValue);
        else if (uMsr == 0x00000040 && g_enmMicroarch <= kCpumMicroarch_Intel_P6_M_Dothan)
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 8 /*cMax*/, "IntelLastBranchFromToN", &i);
        else if (uMsr == 0x00000040)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 8 /*cMax*/, "IntelLastBranchToN", uMsr, false,
                                              true, getGenericSkipMask(uMsr), &i);
        else if (uMsr == 0x00000060 && g_enmMicroarch >= kCpumMicroarch_Intel_Core_Yonah)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 8 /*cMax*/, "IntelLastBranchFromN", uMsr, false,
                                              true, getGenericSkipMask(uMsr), &i);
        else if (uMsr == 0x000000c1)
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i,
                                            g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? 8 : 4 /*cMax*/,
                                            NULL, &i);
        else if (uMsr == 0x00000186 && !g_fIntelNetBurst)
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 8 /*cMax*/, "Ia32PerfEvtSelN", &i);
        else if (uMsr == 0x000001a0)
            rc = reportMsr_Ia32MiscEnable(uMsr, uValue);
        else if (uMsr >= 0x000001a6 && uMsr <= 0x000001a7)
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 2 /*cMax*/, "IntelI7MsrOffCoreResponseN", &i);
        else if (uMsr == 0x000001db && g_fIntelNetBurst)
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 4 /*cMax*/, "IntelLastBranchFromToN", &i);
        else if (uMsr == 0x00000200)
            rc = reportMsr_Ia32MtrrPhysBaseMaskN(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr >= 0x00000250 && uMsr <= 0x00000279)
            rc = reportMsr_Ia32MtrrFixedOrPat(uMsr);
        else if (uMsr >= 0x00000280 && uMsr <= 0x00000295)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 22 /*cMax*/, NULL, 0x00000280, true /*fEarlyEndOk*/, false, 0, &i);
        else if (uMsr == 0x000002ff)
            rc = reportMsr_Ia32MtrrDefType(uMsr);
        else if (uMsr >= 0x00000309 && uMsr <= 0x0000030b && !g_fIntelNetBurst)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 3 /*cMax*/, NULL, 0x00000309, true /*fEarlyEndOk*/, false, 0, &i);
        else if ((uMsr == 0x000003f8 || uMsr == 0x000003fc || uMsr == 0x0000060a) && !g_fIntelNetBurst)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 4, NULL, uMsr - 3, true, false, 0, &i);
        else if ((uMsr == 0x000003f9 || uMsr == 0x000003fd || uMsr == 0x0000060b) && !g_fIntelNetBurst)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 8, NULL, uMsr - 6, true, false, 0, &i);
        else if ((uMsr == 0x000003fa || uMsr == 0x000003fe || uMsr == 0x0000060c) && !g_fIntelNetBurst)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 8, NULL, uMsr - 7, true, false, 0, &i);
        else if (uMsr >= 0x00000400 && uMsr <= 0x00000477)
            rc = reportMsr_Ia32McCtlStatusAddrMiscN(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr == 0x000004c1)
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 8, NULL, &i);
        else if (uMsr == 0x00000680 || uMsr == 0x000006c0)
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 16, NULL, uMsr, false, false,
                                              g_fIntelNetBurst
                                              ? UINT64_C(0xffffffffffffff00) /* kludge */
                                              : UINT64_C(0xffff800000000000), &i);
        else if (uMsr >= 0x00000800 && uMsr <= 0x000008ff)
            rc = reportMsr_GenX2Apic(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr == 0x00002000 && g_enmVendor == CPUMCPUVENDOR_INTEL)
            rc = reportMsr_GenFunctionEx(uMsr, "IntelP6CrN", 0, X86_CR0_PE | X86_CR0_PG, 0,
                                         annotateIfMissingBits(uValue, X86_CR0_PE | X86_CR0_PE | X86_CR0_ET));
        else if (uMsr == 0x00002002 && g_enmVendor == CPUMCPUVENDOR_INTEL)
            rc = reportMsr_GenFunctionEx(uMsr, "IntelP6CrN", 2, 0, 0, annotateValue(uValue));
        else if (uMsr == 0x00002003 && g_enmVendor == CPUMCPUVENDOR_INTEL)
        {
            uint64_t fCr3Mask = (RT_BIT_64(vbCpuRepGetPhysAddrWidth()) - 1) & (X86_CR3_PAE_PAGE_MASK | X86_CR3_AMD64_PAGE_MASK);
            if (!vbCpuRepSupportsPae())
                fCr3Mask &= X86_CR3_PAGE_MASK | X86_CR3_AMD64_PAGE_MASK;
            rc = reportMsr_GenFunctionEx(uMsr, "IntelP6CrN", 3, fCr3Mask, 0, annotateValue(uValue));
        }
        else if (uMsr == 0x00002004 && g_enmVendor == CPUMCPUVENDOR_INTEL)
            rc = reportMsr_GenFunctionEx(uMsr, "IntelP6CrN", 4,
                                         X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE | X86_CR4_SMXE, 0,
                                         annotateValue(uValue));
        else if (uMsr == 0xc0000080)
            rc = reportMsr_Amd64Efer(uMsr, uValue);
        else if (uMsr >= 0xc0000408 && uMsr <= 0xc000040f)
            rc = reportMsr_AmdFam10hMc4MiscN(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr == 0xc0010000 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8PerfCtlN(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr == 0xc0010004 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8PerfCtrN(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr == 0xc0010010 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8SysCfg(uMsr, uValue);
        else if (uMsr == 0xc0010015 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8HwCr(uMsr, uValue);
        else if ((uMsr == 0xc0010016 || uMsr == 0xc0010018) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8IorrBaseN(uMsr, uValue);
        else if ((uMsr == 0xc0010017 || uMsr == 0xc0010019) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8IorrMaskN(uMsr, uValue);
        else if ((uMsr == 0xc001001a || uMsr == 0xc001001d) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK8TopMemN(uMsr, uValue);
        else if (uMsr == 0xc0010030 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 6, "AmdK8CpuNameN", &i);
        else if (uMsr >= 0xc0010044 && uMsr <= 0xc001004a && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 7, "AmdK8McCtlMaskN", 0xc0010044, true /*fEarlyEndOk*/, false, 0, &i);
        else if (uMsr == 0xc0010050 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_GenRangeFunction(&paMsrs[i], cMsrs - i, 4, "AmdK8SmiOnIoTrapN", &i);
        else if (uMsr == 0xc0010064 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdFam10hPStateN(&paMsrs[i], cMsrs - i, &i);
        else if (uMsr == 0xc0010070 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdFam10hCofVidControl(uMsr, uValue);
        else if ((uMsr == 0xc0010118 || uMsr == 0xc0010119) && getMsrFnName(uMsr, NULL) && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = printMsrFunction(uMsr, NULL, NULL, annotateValue(uValue)); /* RAZ, write key. */
        else if (uMsr == 0xc0010200 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdGenPerfMixedRange(&paMsrs[i], cMsrs - i, 12, &i);
        else if (uMsr == 0xc0010230 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdGenPerfMixedRange(&paMsrs[i], cMsrs - i, 8, &i);
        else if (uMsr == 0xc0010240 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdGenPerfMixedRange(&paMsrs[i], cMsrs - i, 8, &i);
        else if (uMsr == 0xc0011019 && g_enmMicroarch >= kCpumMicroarch_AMD_15h_Piledriver && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 3, "AmdK7DrXAddrMaskN", 0xc0011019 - 1,
                                              false /*fEarlyEndOk*/, false /*fNoIgnMask*/, 0, &i);
        else if (uMsr == 0xc0011021 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_AmdK7InstrCacheCfg(uMsr, uValue);
        else if (uMsr == 0xc0011023 && CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
            rc = reportMsr_AmdFam15hCombUnitCfg(uMsr, uValue);
        else if (uMsr == 0xc0011027 && (g_enmVendor == CPUMCPUVENDOR_AMD || g_enmVendor == CPUMCPUVENDOR_HYGON))
            rc = reportMsr_GenRangeFunctionEx(&paMsrs[i], cMsrs - i, 1, "AmdK7DrXAddrMaskN", 0xc0011027,
                                              false /*fEarlyEndOk*/, false /*fNoIgnMask*/, 0, &i);
        else if (uMsr == 0xc001102c && CPUMMICROARCH_IS_AMD_FAM_15H(g_enmMicroarch))
            rc = reportMsr_AmdFam15hExecUnitCfg(uMsr, uValue);
        /* generic handling. */
        else
            rc = reportMsr_Generic(uMsr, fFlags, uValue);

        if (RT_FAILURE(rc))
            return rc;

        /*
         *  A little ugly snooping.
         */
        if (uMsr == 0x000000cd && !(fFlags & VBCPUREPMSR_F_WRITE_ONLY))
            g_uMsrIntelP6FsbFrequency = uValue;
    }

    return VINF_SUCCESS;
}


/**
 * Custom MSR hacking & probing.
 *
 * Called when the '-d' option is given.
 *
 * @returns VBox status code.
 */
static int hackingMsrs(void)
{
#if 0
    vbCpuRepDebug("\nhackingMsrs:\n"); RTStrmFlush(g_pDebugOut); RTThreadSleep(2000);

    uint32_t uMsr = 0xc0000081;
    vbCpuRepDebug("%#x: msrProberModifyNoChange -> %RTbool\n", uMsr, msrProberModifyNoChange(uMsr));
    RTThreadSleep(3000);

    vbCpuRepDebug("%#x: msrProberModifyBit 30 -> %d\n", uMsr, msrProberModifyBit(uMsr, 30));
    RTThreadSleep(3000);

    vbCpuRepDebug("%#x: msrProberModifyZero -> %RTbool\n", uMsr, msrProberModifyZero(uMsr));
    RTThreadSleep(3000);

    for (uint32_t i = 0; i < 63; i++)
    {
        vbCpuRepDebug("%#x: bit=%02u -> %d\n", msrProberModifyBit(uMsr, i));
        RTThreadSleep(500);
    }
#else

    uint32_t uMsr = 0xc0010010;
    uint64_t uValue = 0;
    msrProberRead(uMsr, &uValue);
    reportMsr_AmdK8SysCfg(uMsr, uValue);
#endif
    return VINF_SUCCESS;
}


static int probeMsrs(bool fHacking, const char *pszNameC, const char *pszCpuDesc,
                     char *pszMsrMask, size_t cbMsrMask)
{
    /* Initialize the mask. */
    if (pszMsrMask && cbMsrMask)
        RTStrCopy(pszMsrMask, cbMsrMask, "UINT32_MAX /** @todo */");

    /*
     * Are MSRs supported by the CPU?
     */
    if (   !ASMIsValidStdRange(ASMCpuId_EAX(0))
        || !(ASMCpuId_EDX(1) & X86_CPUID_FEATURE_EDX_MSR) )
    {
        vbCpuRepDebug("Skipping MSR probing, CPUID indicates there isn't any MSR support.\n");
        return VINF_SUCCESS;
    }
    if (g_fNoMsrs)
    {
        vbCpuRepDebug("Skipping MSR probing (--no-msr).\n");
        return VINF_SUCCESS;
    }

    /*
     * First try the the support library (also checks if we can really read MSRs).
     */
    int rc = VbCpuRepMsrProberInitSupDrv(&g_MsrAcc);
    if (RT_FAILURE(rc))
    {
#ifdef VBCR_HAVE_PLATFORM_MSR_PROBER
        /* Next try a platform-specific interface. */
        rc = VbCpuRepMsrProberInitPlatform(&g_MsrAcc);
#endif
        if (RT_FAILURE(rc))
        {
            vbCpuRepDebug("warning: Unable to initialize any MSR access interface (%Rrc), skipping MSR detection.\n", rc);
            return VINF_SUCCESS;
        }
    }

    uint64_t uValue;
    bool     fGp;
    rc = g_MsrAcc.pfnMsrProberRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp);
    if (RT_FAILURE(rc))
    {
        vbCpuRepDebug("warning: MSR probing not supported by the support driver (%Rrc), skipping MSR detection.\n", rc);
        return VINF_SUCCESS;
    }
    vbCpuRepDebug("MSR_IA32_TSC: %#llx fGp=%RTbool\n", uValue, fGp);
    rc = g_MsrAcc.pfnMsrProberRead(0xdeadface, NIL_RTCPUID, &uValue, &fGp);
    vbCpuRepDebug("0xdeadface: %#llx fGp=%RTbool rc=%Rrc\n", uValue, fGp, rc);

    /*
     * Initialize globals we use.
     */
    uint32_t uEax, uEbx, uEcx, uEdx;
    ASMCpuIdExSlow(0, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
    if (!ASMIsValidStdRange(uEax))
        return RTMsgErrorRc(VERR_NOT_SUPPORTED, "Invalid std CPUID range: %#x\n", uEax);
    g_enmVendor = CPUMR3CpuIdDetectVendorEx(uEax, uEbx, uEcx, uEdx);

    ASMCpuIdExSlow(1, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
    g_enmMicroarch = CPUMR3CpuIdDetermineMicroarchEx(g_enmVendor,
                                                     ASMGetCpuFamily(uEax),
                                                     ASMGetCpuModel(uEax, g_enmVendor == CPUMCPUVENDOR_INTEL),
                                                     ASMGetCpuStepping(uEax));
    g_fIntelNetBurst = CPUMMICROARCH_IS_INTEL_NETBURST(g_enmMicroarch);

    /*
     * Do the probing.
     */
    if (fHacking)
        rc = hackingMsrs();
    else
    {
        /* Determine the MSR mask. */
        uint32_t fMsrMask = determineMsrAndMask();
        if (fMsrMask == UINT32_MAX)
            RTStrCopy(pszMsrMask, cbMsrMask, "UINT32_MAX");
        else
            RTStrPrintf(pszMsrMask, cbMsrMask, "UINT32_C(%#x)", fMsrMask);

        /* Detect MSR. */
        VBCPUREPMSR    *paMsrs;
        uint32_t        cMsrs;
        rc = findMsrs(&paMsrs, &cMsrs, fMsrMask);
        if (RT_FAILURE(rc))
            return rc;

        /* Probe the MSRs and spit out the database table. */
        vbCpuRepPrintf("\n"
                       "#ifndef CPUM_DB_STANDALONE\n"
                       "/**\n"
                       " * MSR ranges for %s.\n"
                       " */\n"
                       "static CPUMMSRRANGE const g_aMsrRanges_%s[] =\n{\n",
                       pszCpuDesc,
                       pszNameC);
        rc = produceMsrReport(paMsrs, cMsrs);
        vbCpuRepPrintf("};\n"
                       "#endif /* !CPUM_DB_STANDALONE */\n"
                       "\n"
                       );

        RTMemFree(paMsrs);
        paMsrs = NULL;
    }
    if (g_MsrAcc.pfnTerm)
        g_MsrAcc.pfnTerm();
    RT_ZERO(g_MsrAcc);
    return rc;
}


static int produceCpuIdArray(const char *pszNameC, const char *pszCpuDesc)
{
    /*
     * Collect the data.
     */
    PCPUMCPUIDLEAF  paLeaves;
    uint32_t        cLeaves;
    int rc = CPUMR3CpuIdCollectLeaves(&paLeaves, &cLeaves);
    if (RT_FAILURE(rc))
        return RTMsgErrorRc(rc, "CPUMR3CollectCpuIdInfo failed: %Rrc\n", rc);

    /*
     * Dump the array.
     */
    vbCpuRepPrintf("\n"
                   "#ifndef CPUM_DB_STANDALONE\n"
                   "/**\n"
                   " * CPUID leaves for %s.\n"
                   " */\n"
                   "static CPUMCPUIDLEAF const g_aCpuIdLeaves_%s[] = \n{\n",
                   pszCpuDesc,
                   pszNameC);
    for (uint32_t i = 0; i < cLeaves; i++)
    {
        vbCpuRepPrintf("    { %#010x, %#010x, ", paLeaves[i].uLeaf, paLeaves[i].uSubLeaf);
        if (paLeaves[i].fSubLeafMask == UINT32_MAX)
            vbCpuRepPrintf("UINT32_MAX, ");
        else
            vbCpuRepPrintf("%#010x, ", paLeaves[i].fSubLeafMask);
        vbCpuRepPrintf("%#010x, %#010x, %#010x, %#010x, ",
                     paLeaves[i].uEax, paLeaves[i].uEbx, paLeaves[i].uEcx, paLeaves[i].uEdx);
        if (paLeaves[i].fFlags == 0)
            vbCpuRepPrintf("0 },\n");
        else
        {
            vbCpuRepPrintf("0");
            uint32_t fFlags = paLeaves[i].fFlags;
            if (paLeaves[i].fFlags & CPUMCPUIDLEAF_F_INTEL_TOPOLOGY_SUBLEAVES)
            {
                vbCpuRepPrintf(" | CPUMCPUIDLEAF_F_INTEL_TOPOLOGY_SUBLEAVES");
                fFlags &= ~CPUMCPUIDLEAF_F_INTEL_TOPOLOGY_SUBLEAVES;
            }
            if (paLeaves[i].fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC_ID)
            {
                vbCpuRepPrintf(" | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID");
                fFlags &= ~CPUMCPUIDLEAF_F_CONTAINS_APIC_ID;
            }
            if (paLeaves[i].fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)
            {
                vbCpuRepPrintf(" | CPUMCPUIDLEAF_F_CONTAINS_APIC");
                fFlags &= ~CPUMCPUIDLEAF_F_CONTAINS_APIC;
            }
            if (fFlags)
            {
                RTMemFree(paLeaves);
                return RTMsgErrorRc(rc, "Unknown CPUID flags %#x\n", fFlags);
            }
            vbCpuRepPrintf(" },\n");
        }
    }
    vbCpuRepPrintf("};\n"
                   "#endif /* !CPUM_DB_STANDALONE */\n"
                   "\n");
    RTMemFree(paLeaves);
    return VINF_SUCCESS;
}


static const char *cpuVendorToString(CPUMCPUVENDOR enmCpuVendor)
{
    switch (enmCpuVendor)
    {
        case CPUMCPUVENDOR_INTEL:       return "Intel";
        case CPUMCPUVENDOR_AMD:         return "AMD";
        case CPUMCPUVENDOR_VIA:         return "VIA";
        case CPUMCPUVENDOR_CYRIX:       return "Cyrix";
        case CPUMCPUVENDOR_SHANGHAI:    return "Shanghai";
        case CPUMCPUVENDOR_HYGON:       return "Hygon";
        case CPUMCPUVENDOR_INVALID:
        case CPUMCPUVENDOR_UNKNOWN:
        case CPUMCPUVENDOR_32BIT_HACK:
            break;
    }
    return "invalid-cpu-vendor";
}


/**
 * Takes a shot a the bus frequency name (last part).
 *
 * @returns Name suffix.
 */
static const char *vbCpuRepGuessScalableBusFrequencyName(void)
{
    if (CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch))
        return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge ? "100MHZ" : "133MHZ";

    if (g_uMsrIntelP6FsbFrequency != UINT64_MAX)
        switch (g_uMsrIntelP6FsbFrequency & 0x7)
        {
            case 5: return "100MHZ";
            case 1: return "133MHZ";
            case 3: return "167MHZ";
            case 2: return "200MHZ";
            case 0: return "267MHZ";
            case 4: return "333MHZ";
            case 6: return "400MHZ";
        }

    return "UNKNOWN";
}


static int produceCpuReport(void)
{
    /*
     * Figure the cpu vendor.
     */
    if (!ASMHasCpuId())
        return RTMsgErrorRc(VERR_NOT_SUPPORTED, "No CPUID support.\n");
    uint32_t uEax, uEbx, uEcx, uEdx;
    ASMCpuIdExSlow(0, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
    if (!ASMIsValidStdRange(uEax))
        return RTMsgErrorRc(VERR_NOT_SUPPORTED, "Invalid std CPUID range: %#x\n", uEax);

    CPUMCPUVENDOR enmVendor = CPUMR3CpuIdDetectVendorEx(uEax, uEbx, uEcx, uEdx);
    if (enmVendor == CPUMCPUVENDOR_UNKNOWN)
        return RTMsgErrorRc(VERR_NOT_IMPLEMENTED, "Unknown CPU vendor: %.4s%.4s%.4s\n", &uEbx, &uEdx, &uEcx);
    vbCpuRepDebug("CPU Vendor: %s - %.4s%.4s%.4s\n", CPUMR3CpuVendorName(enmVendor), &uEbx, &uEdx, &uEcx);

    /*
     * Determine the micro arch.
     */
    ASMCpuIdExSlow(1, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
    CPUMMICROARCH enmMicroarch = CPUMR3CpuIdDetermineMicroarchEx(enmVendor,
                                                                 ASMGetCpuFamily(uEax),
                                                                 ASMGetCpuModel(uEax, enmVendor == CPUMCPUVENDOR_INTEL),
                                                                 ASMGetCpuStepping(uEax));

    /*
     * Generate a name.
     */
    char  szName[16*3+1];
    char  szNameC[16*3+1];
    char  szNameRaw[16*3+1];
    char *pszName    = szName;
    char *pszCpuDesc = (char *)"";

    ASMCpuIdExSlow(0x80000000, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
    if (ASMIsValidExtRange(uEax) && uEax >= UINT32_C(0x80000004))
    {
        /* Get the raw name and strip leading spaces. */
        ASMCpuIdExSlow(0x80000002, 0, 0, 0, &szNameRaw[0 +  0], &szNameRaw[4 +  0], &szNameRaw[8 +  0], &szNameRaw[12 +  0]);
        ASMCpuIdExSlow(0x80000003, 0, 0, 0, &szNameRaw[0 + 16], &szNameRaw[4 + 16], &szNameRaw[8 + 16], &szNameRaw[12 + 16]);
        ASMCpuIdExSlow(0x80000004, 0, 0, 0, &szNameRaw[0 + 32], &szNameRaw[4 + 32], &szNameRaw[8 + 32], &szNameRaw[12 + 32]);
        szNameRaw[48] = '\0';
        pszCpuDesc = RTStrStrip(szNameRaw);
        vbCpuRepDebug("Name2: %s\n", pszCpuDesc);

        /* Reduce the name. */
        pszName = strcpy(szName, pszCpuDesc);

        static const char * const s_apszSuffixes[] =
        {
            "CPU @",
        };
        for (uint32_t i = 0; i < RT_ELEMENTS(s_apszSuffixes); i++)
        {
            char *pszHit = strstr(pszName, s_apszSuffixes[i]);
            if (pszHit)
                RT_BZERO(pszHit, strlen(pszHit));
        }

        static const char * const s_apszWords[] =
        {
            "(TM)", "(tm)", "(R)", "(r)", "Processor", "CPU", "@",
        };
        for (uint32_t i = 0; i < RT_ELEMENTS(s_apszWords); i++)
        {
            const char *pszWord = s_apszWords[i];
            size_t      cchWord = strlen(pszWord);
            char       *pszHit;
            while ((pszHit = strstr(pszName, pszWord)) != NULL)
                memset(pszHit, ' ', cchWord);
        }

        RTStrStripR(pszName);
        for (char *psz = pszName; *psz; psz++)
            if (RT_C_IS_BLANK(*psz))
            {
                size_t cchBlanks = 1;
                while (RT_C_IS_BLANK(psz[cchBlanks]))
                    cchBlanks++;
                *psz = ' ';
                if (cchBlanks > 1)
                    memmove(psz + 1, psz + cchBlanks, strlen(psz + cchBlanks) + 1);
            }
        pszName = RTStrStripL(pszName);
        vbCpuRepDebug("Name: %s\n", pszName);

        /* Make it C/C++ acceptable. */
        strcpy(szNameC, pszName);
        unsigned offDst = 0;
        for (unsigned offSrc = 0; ; offSrc++)
        {
            char ch = szNameC[offSrc];
            if (!RT_C_IS_ALNUM(ch) && ch != '_' && ch != '\0')
                ch = '_';
            if (ch == '_' && offDst > 0 && szNameC[offDst - 1] == '_')
                offDst--;
            szNameC[offDst++] = ch;
            if (!ch)
                break;
        }
        while (offDst > 1 && szNameC[offDst - 1] == '_')
            szNameC[--offDst] = '\0';

        vbCpuRepDebug("NameC: %s\n", szNameC);
    }
    else
    {
        ASMCpuIdExSlow(1, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
        RTStrPrintf(szNameC, sizeof(szNameC), "%s_%u_%u_%u", cpuVendorToString(enmVendor), ASMGetCpuFamily(uEax),
                    ASMGetCpuModel(uEax, enmVendor == CPUMCPUVENDOR_INTEL), ASMGetCpuStepping(uEax));
        pszCpuDesc = pszName = szNameC;
        vbCpuRepDebug("Name/NameC: %s\n", szNameC);
    }

    /*
     * Print a file header, if we're not outputting to stdout (assumption being
     * that stdout is used while hacking the reporter and too much output is
     * unwanted).
     */
    if (g_pReportOut)
    {
        RTTIMESPEC Now;
        char       szNow[64];
        RTTimeSpecToString(RTTimeNow(&Now), szNow, sizeof(szNow));
        char *pchDot = strchr(szNow, '.');
        if (pchDot)
            strcpy(pchDot, "Z");

        vbCpuRepPrintf("/* $" "Id" "$ */\n"
                       "/** @file\n"
                       " * CPU database entry \"%s\".\n"
                       " * Generated at %s by VBoxCpuReport v%sr%s on %s.%s.\n"
                       " */\n"
                       "\n"
                       "/*\n"
                       " * Copyright (C) 2013-2020 Oracle Corporation\n"
                       " *\n"
                       " * This file is part of VirtualBox Open Source Edition (OSE), as\n"
                       " * available from http://www.virtualbox.org. This file is free software;\n"
                       " * you can redistribute it and/or modify it under the terms of the GNU\n"
                       " * General Public License (GPL) as published by the Free Software\n"
                       " * Foundation, in version 2 as it comes in the \"COPYING\" file of the\n"
                       " * VirtualBox OSE distribution. VirtualBox OSE is distributed in the\n"
                       " * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.\n"
                       " */\n"
                       "\n"
                       "#ifndef VBOX_CPUDB_%s_h\n"
                       "#define VBOX_CPUDB_%s_h\n"
                       "#ifndef RT_WITHOUT_PRAGMA_ONCE\n"
                       "# pragma once\n"
                       "#endif\n"
                       "\n",
                       pszName,
                       szNow, RTBldCfgVersion(), RTBldCfgRevisionStr(), RTBldCfgTarget(), RTBldCfgTargetArch(),
                       szNameC, szNameC);
    }

    /*
     * Extract CPUID based data.
     */
    int rc = produceCpuIdArray(szNameC, pszCpuDesc);
    if (RT_FAILURE(rc))
        return rc;

    CPUMUNKNOWNCPUID enmUnknownMethod;
    CPUMCPUID       DefUnknown;
    rc = CPUMR3CpuIdDetectUnknownLeafMethod(&enmUnknownMethod, &DefUnknown);
    if (RT_FAILURE(rc))
        return RTMsgErrorRc(rc, "CPUMR3DetectCpuIdUnknownMethod failed: %Rrc\n", rc);
    vbCpuRepDebug("enmUnknownMethod=%s\n", CPUMR3CpuIdUnknownLeafMethodName(enmUnknownMethod));

    /*
     * Do the MSRs, if we can.
     */
    char szMsrMask[64];
    probeMsrs(false /*fHacking*/, szNameC, pszCpuDesc, szMsrMask, sizeof(szMsrMask));

    /*
     * Emit the CPUMDBENTRY record.
     */
    ASMCpuIdExSlow(1, 0, 0, 0, &uEax, &uEbx, &uEcx, &uEdx);
    vbCpuRepPrintf("\n"
                   "/**\n"
                   " * Database entry for %s.\n"
                   " */\n"
                   "static CPUMDBENTRY const g_Entry_%s = \n"
                   "{\n"
                   "    /*.pszName          = */ \"%s\",\n"
                   "    /*.pszFullName      = */ \"%s\",\n"
                   "    /*.enmVendor        = */ CPUMCPUVENDOR_%s,\n"
                   "    /*.uFamily          = */ %u,\n"
                   "    /*.uModel           = */ %u,\n"
                   "    /*.uStepping        = */ %u,\n"
                   "    /*.enmMicroarch     = */ kCpumMicroarch_%s,\n"
                   "    /*.uScalableBusFreq = */ CPUM_SBUSFREQ_%s,\n"
                   "    /*.fFlags           = */ 0,\n"
                   "    /*.cMaxPhysAddrWidth= */ %u,\n"
                   "    /*.fMxCsrMask       = */ %#010x,\n"
                   "    /*.paCpuIdLeaves    = */ NULL_ALONE(g_aCpuIdLeaves_%s),\n"
                   "    /*.cCpuIdLeaves     = */ ZERO_ALONE(RT_ELEMENTS(g_aCpuIdLeaves_%s)),\n"
                   "    /*.enmUnknownCpuId  = */ CPUMUNKNOWNCPUID_%s,\n"
                   "    /*.DefUnknownCpuId  = */ { %#010x, %#010x, %#010x, %#010x },\n"
                   "    /*.fMsrMask         = */ %s,\n"
                   "    /*.cMsrRanges       = */ ZERO_ALONE(RT_ELEMENTS(g_aMsrRanges_%s)),\n"
                   "    /*.paMsrRanges      = */ NULL_ALONE(g_aMsrRanges_%s),\n"
                   "};\n"
                   "\n"
                   "#endif /* !VBOX_CPUDB_%s_h */\n"
                   "\n",
                   pszCpuDesc,
                   szNameC,
                   pszName,
                   pszCpuDesc,
                   CPUMR3CpuVendorName(enmVendor),
                   ASMGetCpuFamily(uEax),
                   ASMGetCpuModel(uEax, enmVendor == CPUMCPUVENDOR_INTEL),
                   ASMGetCpuStepping(uEax),
                   CPUMR3MicroarchName(enmMicroarch),
                   vbCpuRepGuessScalableBusFrequencyName(),
                   vbCpuRepGetPhysAddrWidth(),
                   CPUMR3DeterminHostMxCsrMask(),
                   szNameC,
                   szNameC,
                   CPUMR3CpuIdUnknownLeafMethodName(enmUnknownMethod),
                   DefUnknown.uEax,
                   DefUnknown.uEbx,
                   DefUnknown.uEcx,
                   DefUnknown.uEdx,
                   szMsrMask,
                   szNameC,
                   szNameC,
                   szNameC
                   );

    return VINF_SUCCESS;
}


int main(int argc, char **argv)
{
    int rc = RTR3InitExe(argc, &argv, 0 /*fFlags*/);
    if (RT_FAILURE(rc))
        return RTMsgInitFailure(rc);

    /*
     * Argument parsing?
     */
    static const RTGETOPTDEF s_aOptions[] =
    {
        { "--msrs-only", 'm', RTGETOPT_REQ_NOTHING },
        { "--msrs-dev",  'd', RTGETOPT_REQ_NOTHING },
        { "--no-msrs",   'n', RTGETOPT_REQ_NOTHING },
        { "--output",    'o', RTGETOPT_REQ_STRING  },
        { "--log",       'l', RTGETOPT_REQ_STRING  },
    };
    RTGETOPTSTATE State;
    RTGetOptInit(&State, argc, argv, &s_aOptions[0], RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);

    enum
    {
        kCpuReportOp_Normal,
        kCpuReportOp_MsrsOnly,
        kCpuReportOp_MsrsHacking
    } enmOp = kCpuReportOp_Normal;
    g_pReportOut = NULL;
    g_pDebugOut  = NULL;
    const char *pszOutput   = NULL;
    const char *pszDebugOut = NULL;

    int iOpt;
    RTGETOPTUNION ValueUnion;
    while ((iOpt = RTGetOpt(&State, &ValueUnion)) != 0)
    {
        switch (iOpt)
        {
            case 'm':
                enmOp = kCpuReportOp_MsrsOnly;
                break;

            case 'd':
                enmOp = kCpuReportOp_MsrsHacking;
                break;

            case 'n':
                g_fNoMsrs = true;
                break;

            case 'o':
                pszOutput = ValueUnion.psz;
                break;

            case 'l':
                pszDebugOut = ValueUnion.psz;
                break;

            case 'h':
                RTPrintf("Usage: VBoxCpuReport [-m|--msrs-only] [-d|--msrs-dev] [-n|--no-msrs] [-h|--help] [-V|--version] [-o filename.h] [-l debug.log]\n");
                RTPrintf("Internal tool for gathering information to the VMM CPU database.\n");
                return RTEXITCODE_SUCCESS;
            case 'V':
                RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
                return RTEXITCODE_SUCCESS;
            default:
                return RTGetOptPrintError(iOpt, &ValueUnion);
        }
    }

    /*
     * Open the alternative debug log stream.
     */
    if (pszDebugOut)
    {
        if (RTFileExists(pszDebugOut) && !RTSymlinkExists(pszDebugOut))
        {
            char szOld[RTPATH_MAX];
            rc = RTStrCopy(szOld, sizeof(szOld), pszDebugOut);
            if (RT_SUCCESS(rc))
                rc = RTStrCat(szOld, sizeof(szOld), ".old");
            if (RT_SUCCESS(rc))
                RTFileRename(pszDebugOut, szOld, RTFILEMOVE_FLAGS_REPLACE);
        }
        rc = RTStrmOpen(pszDebugOut, "w", &g_pDebugOut);
        if (RT_FAILURE(rc))
        {
            RTMsgError("Error opening '%s': %Rrc", pszDebugOut, rc);
            g_pDebugOut = NULL;
        }
    }

    /*
     * Do the requested job.
     */
    rc = VERR_INTERNAL_ERROR;
    switch (enmOp)
    {
        case kCpuReportOp_Normal:
            /* switch output file. */
            if (pszOutput)
            {
                if (RTFileExists(pszOutput) && !RTSymlinkExists(pszOutput))
                {
                    char szOld[RTPATH_MAX];
                    rc = RTStrCopy(szOld, sizeof(szOld), pszOutput);
                    if (RT_SUCCESS(rc))
                        rc = RTStrCat(szOld, sizeof(szOld), ".old");
                    if (RT_SUCCESS(rc))
                        RTFileRename(pszOutput, szOld, RTFILEMOVE_FLAGS_REPLACE);
                }
                rc = RTStrmOpen(pszOutput, "w", &g_pReportOut);
                if (RT_FAILURE(rc))
                {
                    RTMsgError("Error opening '%s': %Rrc", pszOutput, rc);
                    break;
                }
            }
            rc = produceCpuReport();
            break;
        case kCpuReportOp_MsrsOnly:
        case kCpuReportOp_MsrsHacking:
            rc = probeMsrs(enmOp == kCpuReportOp_MsrsHacking, NULL, NULL, NULL, 0);
            break;
    }

    /*
     * Close the output files.
     */
    if (g_pReportOut)
    {
        RTStrmClose(g_pReportOut);
        g_pReportOut = NULL;
    }

    if (g_pDebugOut)
    {
        RTStrmClose(g_pDebugOut);
        g_pDebugOut = NULL;
    }

    return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
}