msr-tools 提供了三隻工具,都是與 CPU 相關的.
- rdmsr – read MSR from any CPU or all CPUs
- wrmsr – write values to MSR on any CPU or all CPUs
- msr-cpuid – show identification and feature information of any CPU
測試環境為 CentOS 7 x86_64 (虛擬機)
預設的 YUM Repo 並沒有 msr-tools 這套件,需要新增 Repo 檔 (epel-release, Extra Packages for Enterprise Linux) 來安裝.
[root@localhost ~]$ yum install -y epel-release [root@localhost ~]$ yum install -y msr-tools
先來了解一下什麼是 MSR 他是 model specific register 的縮寫,CPU 的工作模式就是透過這一些暫存器來控制,Intel MSR 可以透過搜尋 External Design Specification (EDS) Volume 2 ,裡面會針對不同家族的 CPU MSR 做說明.
要來讀取或是控制這些暫存器,可以透過 rdmsr (讀取) , wrmsr (寫入).
- rdmsr – read MSR from any CPU or all CPUs
讀取 CPU 0 的 TIME-STAMP COUNTER(0x10).
[root@localhost ~]# rdmsr -p0 0x10 1696e0384e4b
- wrmsr – write values to MSR on any CPU or all CPUs
- msr-cpuid – show identification and feature information of any CPU
顯示 CPU 0 的 CPUID[root@localhost ~]# msr-cpuid 0 Leaf Subleaf EAX EBX ECX EDX 00000000 00000000: 0000000d .... 756e6547 Genu 6c65746e ntel 49656e69 ineI 00000001 00000000: 000306a9 .... 00010800 .... ffba2203 .".. 0f8bfbff .... 00000002 00000000: 76035a01 .Z.v 00f0b2ff .... 00000000 .... 00ca0000 .... 00000003 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 00000004 00000000: 00000121 !... 01c0003f ?... 0000003f ?... 00000000 .... 00000004 00000001: 00000122 "... 01c0003f ?... 0000003f ?... 00000000 .... 00000004 00000002: 00000143 C... 01c0003f ?... 000001ff .... 00000000 .... 00000004 00000003: 00000163 c... 02c0003f ?... 00000fff .... 00000006 .... 00000005 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 00000006 00000000: 00000004 .... 00000000 .... 00000000 .... 00000000 .... 00000007 00000000: 00000000 .... 00000283 .... 00000000 .... 00000000 .... 00000008 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 00000009 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 0000000a 00000000: 07300401 ..0. 0000007f .... 00000000 .... 00000000 .... 0000000b 00000000: 00000000 .... 00000001 .... 00000100 .... 00000000 .... 0000000b 00000001: 00000000 .... 00000001 .... 00000201 .... 00000000 .... 0000000c 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 0000000d 00000000: 00000007 .... 00000340 @... 00000340 @... 00000000 .... 40000000 00000000: 40000010 ...@ 61774d56 VMwa 4d566572 reVM 65726177 ware 40000001 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000002 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000003 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000004 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000005 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000006 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000007 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000008 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000009 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 4000000a 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 4000000b 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 4000000c 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 4000000d 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 4000000e 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 4000000f 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 40000010 00000000: 0022fc9d ..". 000101d0 .... 00000000 .... 00000000 .... 80000000 00000000: 80000008 .... 00000000 .... 00000000 .... 00000000 .... 80000001 00000000: 00000000 .... 00000000 .... 00000001 .... 28100800 ...( 80000002 00000000: 20202020 49202020 I 6c65746e ntel 20295228 (R) 80000003 00000000: 65726f43 Core 294d5428 (TM) 2d356920 i5- 37323433 3427 80000004 00000000: 50432055 U CP 20402055 U @ 30382e31 1.80 007a4847 GHz. 80000005 00000000: 00000000 .... 00000000 .... 00000000 .... 00000000 .... 80000006 00000000: 00000000 .... 00000000 .... 01006040 @`.. 00000000 .... 80000007 00000000: 00000000 .... 00000000 .... 00000000 .... 00000100 .... 80000008 00000000: 0000302b +0.. 00000000 .... 00000000 .... 00000000 ....
沒有解決問題,試試搜尋本站其他內容