2022-10-08

Intel有一個超過100頁的文檔,專門介紹cpuid這條指令,可見這條指令涉及內(nèi)容的豐富。

記得去年的時候,曾經(jīng)有個“英布之劍”問過我這條指令,當(dāng)時并沒有給出一個滿意的回答,現(xiàn)在放假,想起來,把資料整理了一下。很久以前確實用過這條指令,其實指令本身并沒有什么難的,關(guān)鍵是看你有沒有耐心研讀完繁瑣的資料,當(dāng)然還得對CPU有一定的了解,如果“英布之劍”看到這篇文章,而且仍然需要更詳細(xì)的資料,可以給我一個聯(lián)系方式,或者相互之間可以交流一下。

cpuid就是一條讀取CPU各種信息的一條指令,大概是從80486的某個版本開始就存在了。似乎是從80386開始,當(dāng)CPU被RESET以后,CPU會在EDX寄存器中返回一個32bits的CPU簽名(Processor Identification Signature),但這時候CPU還沒有CPUID這條指令,后來出現(xiàn)了這條指令后,軟件無需以來CPU復(fù)位就可以讀出這個CPU簽名,同時還可以讀出很多CPU的相關(guān)信息。

CPUID這條指令,除了用于識別CPU(CPU的型號、家族、類型等),還可以讀出CPU支持的功能(比如是否支持MMX,是否支持4MB的頁等等),內(nèi)容的確是十分豐富。CPUID指令有兩組功能,一組返回的是基本信息,另一組返回的是擴展信息,本文介紹基本信息部分,擴展信息部分下篇中介紹。本文所在程序或程序片段,均使用MASM 6.11編譯連接,可以在DOS(包括虛擬機的DOS下)運行。

1、如何判斷CPU是否支持CPUID指令

前面說過,大概是從80486開始才有的cpuid這個指令,是不是所有的80486家族CPU都有這個指令我也不是很清楚,但在EFLAGS中的bit 21可以識別CPU是否支持CPUID指令,如下圖:
image.png

圖1

在8086和8088CPU中,F(xiàn)LAGS只有16位長,在80386CPU中,bit 21被保留未用,在支持CPUID指令的CPU中,這一位將為1。

2、CPUID指令的執(zhí)行方法

把功能代碼放在EAX寄存器中,執(zhí)行CPUID指令即可。例如:

mov eax, 1
cpuid

前面說過CPUID指令分為兩組,一組返回基本信息,一組返回擴展信息,當(dāng)執(zhí)行返回基本信息的CPUID指令時,EAX中功能代碼的bit 31為0,當(dāng)執(zhí)行返回擴展信息的CPUID指令時,EAX中的功能代碼的bit 31為1。那么不管是那組功能,如何知道EAX中的功能代碼最大可以是多少呢?根據(jù)Intel的說明,可以用如下方法:

mov eax, 0
cpuid

執(zhí)行完CPUID指令后,EAX中返回的值就是返回基本信息時,功能代碼的最大值,在執(zhí)行CPUID指令要求返回基本信息時,EAX中的值必須小于或等于該值。

mov eax, 80000000h
cpuid

執(zhí)行完CPUID指令后,EAX中返回的值就是返回擴展信息時,功能代碼的最大值,在執(zhí)行CPUID指令要求返回擴展信息時,EAX中的值必須小于或等于該值。

由于很多編譯器都不能編譯CPUID指令,所以了解CPUID指令的操作碼是必要的,CPUID指令的操作碼是:

0FA2h

3、返回基本信息的功能全貌

在實際介紹每一個功能之前,我們先通過一張圖了解一下返回基本信息的功能全貌。

圖2

4、EAX=0:獲取CPU的Vendor ID

Vendor ID這個東西,在以前介紹PCI的文章中應(yīng)該介紹過,實際上就是制造商的標(biāo)識,用下面的方法執(zhí)行該功能:

mov eax, 0
cpuid

執(zhí)行CPUID指令后,AX中返回的內(nèi)容前面已經(jīng)說過了,返回的Vendor ID固定為12個ASCII字符依次存放在EBX、EDX、ECX中,對于Intel的CPU,返回的字符串永遠(yuǎn)是:GenuineIntel。對應(yīng)在三個寄存器中的值如下:

EBX=756E6547h,EDX=49656E69h,ECX=6C65746Eh

大家可以參考圖2。

盡管本文是介紹Intel的CPUID指令,但下面還是盡我所知,列出其它廠家生產(chǎn)的IA-32架構(gòu)CPU的Vendor ID,希望能對需要這些資料的人有所幫助。
  • AMDisbetter! ---- 早期AMD K5芯片的工程樣品芯片
  • AuthenticAMD ---- AMD
  • CentourHauls ---- Centour
  • CyrixInstead ---- Cyrix
  • GenuineTMx86 或 TransmetaCPU ---- Transmeta
  • Geode by NSC ---- National Semiconductor
  • NexGenDriven ---- NexGen
  • SiS SiS SiS ---- SiS
  • RiseRiseRise ---- Rise
  • UMC UMC UMC ---- UMC
  • VIA VIA VIA ---- VIA

5、EAX=1:處理器簽名(Processor Signiture)和功能(Feature)位

mov eax, 1
cpuid
執(zhí)行完成后,處理器簽名放在EAX中,功能位及其它雜七雜八的內(nèi)容分別放在EBX、ECX和EDX中。
  • 處理器簽名(Processor Signiture):
    返回在EAX中,定義如下:
image.png
圖中的灰色區(qū)域表示沒有定義。前面說過,當(dāng)CPU復(fù)位時,會在EDX中返回處理器簽名,從80486以后,這個簽名和上面的定義完全一樣,只是放在不同的寄存器中而已。前面還提到過,80386在復(fù)位時也返回處理器簽名,但80386返回的簽名格式是和上面不同的,后面可能會提到。

通過處理器簽名,可以確定CPU的具體型號,以下是部分Intel CPU的處理器簽名數(shù)據(jù)(資料來自Intel):
image.png
前面說過,80386盡管沒有CPUID指令,但在復(fù)位時也是可以返回處理器簽名的,下面是80386返回的處理器簽名的格式:
image.png
 下面是80386處理器簽名的識別方法(資料來自Intel):
image.png
  • 關(guān)于Stepping的說明:

    Intel和AMD都有Stepping的概念,用來標(biāo)識一款同樣規(guī)模的微處理器從一開始到你用的這款處理器經(jīng)歷的設(shè)計過程,用一個字母和一個數(shù)字表示。一般來說,一款同樣規(guī)模的微處理器的第一個版本是A0,如果改進(jìn)了設(shè)計,則可以通過改變字母或者數(shù)字進(jìn)行標(biāo)識,如果僅僅改變數(shù)字(比如改成A3),說明進(jìn)行了一些輔助的改進(jìn),如果字母和數(shù)字都改變,說明改動較大,Stepping可以使用戶可以識別微處理器的版本。下面是一個Stepping的例子(不知道為什么穿上來后圖這么?。?。

  • 當(dāng)處理器簽名一樣時的處理

    有時候,從處理器簽名上仍然不能識別CPU,比如根據(jù)Intel提供的資料,Pentium II, Model 5、Pentium II Xeon, Model 5和Celeron?, Model 5的處理器簽名完全一樣,要區(qū)別他們只能通過檢查他們的高速緩存(Cache)的大小,后面將介紹使用CPUID指令獲得CPU高速緩存信息的方法,如果沒有高速緩存,則是Celeron?處理器;如果L2高速緩存為1MB或者2MB,則應(yīng)該是Pentium II Xeon處理器,其它情況則應(yīng)該是Pentium II處理器或者是只有512KB高速緩存的Pentium II Xeon處理器。

    有些情況下,如果從處理器簽名上不能區(qū)分CPU,也可以使用Brand ID(在EBX的bit7:0返回)來區(qū)分CPU,比如Pentium III, Model 8、Pentium III Xeon, Model 8和Celeron?, Model 8三種處理器的處理器簽名也是一樣的,但它們的Brand ID是不同的。

  • 關(guān)于處理器類型的定義

    在處理器簽名中的bit12:13返回的是處理器類型,其定義如下

    Value Descriptor

    00 以前的OEM處理器
    01 OverDrive?處理器
    10 多處理器(指可用于多處理器系統(tǒng))

  • 功能標(biāo)志(Feature Flag)

    在EDX和ECX中返回的功能標(biāo)志表明著該CPU都支持那些功能,EDX定義如下(資料來源與Intel):

    bit Name Description

    00 FPU FPU On-chip
    01 VME Virtual Mode Extended
    02 DE Debugging Extension
    03 PSE Page Size Extension
    04 TSC Time Stamp Counter
    05 MSR Model Specific Registers
    06 PAE Physical Address Extension
    07 MCE Machine-Check Exception
    08 CX8 CMPXCHG8 Instruction
    09 APIC On-chip APIC Hardware
    10 Reserved
    11 SEP Fast System Call
    12 MTRR Memory Type Range Registers
    13 PGE Page Global Enable
    14 MCA Machine-Check Architecture
    15 CMOV Conditional Move Instruction
    16 PAT Page Attribute Table
    17 PSE-36 36-bit Page Size Extension
    18 PSN Processor serial number is present and enabled
    19 CLFSH CLFLUSH Instruction
    20 Reserved
    21 DS Debug Store
    22 ACPI Thermal Monitor and Software Controlled Clock Facilities
    23 MMX MMX technology
    24 FXSR FXSAVE and FXSTOR Instructions
    25 SSE Streaming SIMD Extensions
    26 SSE2 Streaming SIMD Extensions 2
    27 SS Self-Snoop
    28 HTT Multi-Threading
    29 TM Thermal Monitor
    30 IA64 IA64 Capabilities
    31 PBE Pending Break Enable

    ECX定義如下(資料來自Intel):

    bit Name Description

    00 SSE3 Streaming SIMD Extensions 3
    01 Reserved
    02 DTES64 64-Bit Debug Store
    03 MONITOR MONITOR/MWAIT
    04 DS-CPL CPL Qualified Debug Store
    05 VMX Virtual Machine Extensions
    06 SMX Safer Mode Extensions
    07 EST Enhanced Intel SpeedStep? Technology
    08 TM2 Thermal Monitor 2
    09 SSSE3 Supplemental Streaming SIMD Extensions 3
    10 CNXT-ID L1 Context ID
    12:11 Reserved
    13 CX16 CMPXCHG16B
    14 xTPR xTPR Update Control
    15 PDCM Perfmon and Debug Capability
    17:16 Reserved
    18 DCA Direct Cache Access
    19 SSE4.1 Streaming SIMD Extensions 4.1
    20 SSE4.2 Streaming SIMD Extensions 4.2
    21 x2APIC Extended xAPIC Support
    22 MOVBE MOVBE Instruction
    23 POPCNT POPCNT Instruction
    25:24 Reserved
    26 XSAVE XSAVE/XSTOR States
    27 OSXSAVE
    31:28 Reserved

    下面是在DEBUG中當(dāng)EAX=0時執(zhí)行CPUID指令時的情況:

image.png
下面是在DEBUG中當(dāng)EAX=1時執(zhí)行CPUID指令時的情況
image.png

6、EAX=2:高速緩存描述符(Cache Descriptor)

mov eax, 2
cpuid

執(zhí)行完CPUID指令后,高速緩存描述符和TLB(Translation Lookable Buffer)特性將在EAX、EBX、ECX和EDX中返回,每個寄存器中的4個字節(jié)分別表示4個描述符,描述符中不同的值表示不同的含義(后面有定義),其中EAX中的最低8位(AL)的值表示要得到完整的高速緩存的信息,需要執(zhí)行EAX=2的CPUID指令的次數(shù)(一般都為1,在我這里的數(shù)臺機器里,還沒有為2的),同時,寄存器的最高位(bit 31)為0,表示該寄存器中的描述符是有效的,下面是描述符值的定義(資料來源與Intel):

Value   Cache or TLB Descriptor Description
----------------------------------------------------------------------------------------
 00h    Null
 01h    Instruction TLB: 4-KB Pages, 4-way set associative, 32 entries
 02h    Instruction TLB: 4-MB Pages, fully associative, 2 entries
 03h    Data TLB: 4-KB Pages, 4-way set associative, 64 entries
 04h    Data TLB: 4-MB Pages, 4-way set associative, 8 entries
 05h    Data TLB: 4-MB Pages, 4-way set associative, 32 entries
 06h   1st-level instruction cache: 8-KB, 4-way set associative, 32-byte line size
 08h   1st-level instruction cache: 16-KB, 4-way set associative, 32-byte line size
 09h   1st-level Instruction Cache: 32-KB, 4-way set associative, 64-byte line size
 0Ah   1st-level data cache: 8-KB, 2-way set associative, 32-byte line size
 0Ch   1st-level data cache: 16-KB, 4-way set associative, 32-byte line size
 0Dh   1st-level Data Cache: 16-KB, 4-way set associative, 64-byte line size, ECC
 21h   256-KB L2 (MLC), 8-way set associative, 64-byte line size
 22h   3rd-level cache: 512-KB, 4-way set associative, sectored cache, 64-byte line size
 23h   3rd-level cache: 1-MB, 8-way set associative, sectored cache, 64-byte line size
 25h   3rd-level cache: 2-MB, 8-way set associative, sectored cache, 64-byte line size
 29h   3rd-level cache: 4-MB, 8-way set associative, sectored cache, 64-byte line size
 2Ch   1st-level data cache: 32-KB, 8-way set associative, 64-byte line size
 30h   1st-level instruction cache: 32-KB, 8-way set associative, 64-byte line size
 39h   2nd-level cache: 128-KB, 4-way set associative, sectored cache, 64-byte line size
 3Ah   2nd-level cache: 192-KB, 6-way set associative, sectored cache, 64-byte line size
 3Bh   2nd-level cache: 128-KB, 2-way set associative, sectored cache, 64-byte line size
 3Ch   2nd-level cache: 256-KB, 4-way set associative, sectored cache, 64-byte line size
 3Dh   2nd-level cache: 384-KB, 6-way set associative, sectored cache, 64-byte line size
 3Eh   2nd-level cache: 512-KB, 4-way set associative, sectored cache, 64-byte line size
 40h   No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache
 41h   2nd-level cache: 128-KB, 4-way set associative, 32-byte line size
 42h   2nd-level cache: 256-KB, 4-way set associative, 32-byte line size
 43h   2nd-level cache: 512-KB, 4-way set associative, 32-byte line size
 44h   2nd-level cache: 1-MB, 4-way set associative, 32-byte line size
 45h   2nd-level cache: 2-MB, 4-way set associative, 32-byte line size
 46h   3rd-level cache: 4-MB, 4-way set associative, 64-byte line size
 47h   3rd-level cache: 8-MB, 8-way set associative, 64-byte line size
 48h   2nd-level cache: 3-MB, 12-way set associative, 64-byte line size, unified on-die
 49h   3rd-level cache: 4-MB, 16-way set associative, 64-byte line size(Intel Xeon
       processor MP, Family 0Fh, Model 06h) 2nd-level cache: 4-MB, 16-way set associative,
       64-byte line size
 4Ah   3rd-level cache: 6-MB, 12-way set associative, 64-byte line size
 4Bh   3rd-level cache: 8-MB, 16-way set associative, 64-byte line size
 4Ch   3rd-level cache: 12-MB, 12-way set associative, 64-byte line size
 4Dh   3rd-level cache: 16-MB, 16-way set associative, 64-byte line size
 4Eh   2nd-level cache: 6-MB, 24-way set associative, 64-byte line size
 50h   Instruction TLB: 4-KB, 2-MB or 4-MB pages, fully associative, 64 entries
 51h   Instruction TLB: 4-KB, 2-MB or 4-MB pages, fully associative, 128 entries
 52h   Instruction TLB: 4-KB, 2-MB or 4-MB pages, fully associative, 256 entries
 55h   Instruction TLB: 2-MB or 4-MB pages, fully associative, 7 entries
 56h   L1 Data TLB: 4-MB pages, 4-way set associative, 16 entries
 57h   L1 Data TLB: 4-KB pages, 4-way set associative, 16 entries
 5Ah   Data TLB0: 2-MB or 4-MB pages, 4-way associative, 32 entries
 5Bh   Data TLB: 4-KB or 4-MB pages, fully associative, 64 entries
 5Ch   Data TLB: 4-KB or 4-MB pages, fully associative, 128 entries
 5Dh   Data TLB: 4-KB or 4-MB pages, fully associative, 256 entries
 60h   1st-level data cache: 16-KB, 8-way set associative, sectored cache, 64-byte line size
 66h   1st-level data cache: 8-KB, 4-way set associative, sectored cache, 64-byte line size
 67h   1st-level data cache: 16-KB, 4-way set associative, sectored cache, 64-byte line size
 68h   1st-level data cache: 32-KB, 4 way set associative, sectored cache, 64-byte line size
 70h   Trace cache: 12K-uops, 8-way set associative
 71h   Trace cache: 16K-uops, 8-way set associative
 72h   Trace cache: 32K-uops, 8-way set associative
 73h   Trace cache: 64K-uops, 8-way set associative
 78h   2nd-level cache: 1-MB, 4-way set associative, 64-byte line size
 79h   2nd-level cache: 128-KB, 8-way set associative, sectored cache, 64-byte line size
 7Ah   2nd-level cache: 256-KB, 8-way set associative, sectored cache, 64-byte line size
 7Bh   2nd-level cache: 512-KB, 8-way set associative, sectored cache, 64-byte line size
 7Ch   2nd-level cache: 1-MB, 8-way set associative, sectored cache, 64-byte line size
 7Dh   2nd-level cache: 2-MB, 8-way set associative, 64-byte line size
 7Fh   2nd-level cache: 512-KB, 2-way set associative, 64-byte line size
 82h   2nd-level cache: 256-KB, 8-way set associative, 32-byte line size
 83h   2nd-level cache: 512-KB, 8-way set associative, 32-byte line size
 84h   2nd-level cache: 1-MB, 8-way set associative, 32-byte line size
 85h   2nd-level cache: 2-MB, 8-way set associative, 32-byte line size
 86h   2nd-level cache: 512-KB, 4-way set associative, 64-byte line size
 87h   2nd-level cache: 1-MB, 8-way set associative, 64-byte line size
 B0h   Instruction TLB: 4-KB Pages, 4-way set associative, 128 entries
 B1h   Instruction TLB: 2-MB pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries
 B2h   Instruction TLB: 4-KB pages, 4-way set associative, 64 entries
 B3h   Data TLB: 4-KB Pages, 4-way set associative, 128 entries
 B4h   Data TLB: 4-KB Pages, 4-way set associative, 256 entries
 CAh   Shared 2nd-level TLB: 4 KB pages, 4-way set associative, 512 entries
 D0h   512KB L3 Cache, 4-way set associative, 64-byte line size
 D1h   1-MB L3 Cache, 4-way set associative, 64-byte line size
 D2h   2-MB L3 Cache, 4-way set associative, 64-byte line size
 D6h   1-MB L3 Cache, 8-way set associative, 64-byte line size
 D7h   2-MB L3 Cache, 8-way set associative, 64-byte line size
 D8h   4-MB L3 Cache, 8-way set associative, 64-byte line size
 DCh   2-MB L3 Cache, 12-way set associative, 64-byte line size
 DDh   4-MB L3 Cache, 12-way set associative, 64-byte line size
 DEh   8-MB L3 Cache, 12-way set associative, 64-byte line size
 E2h   2-MB L3 Cache, 16-way set associative, 64-byte line size
 E3h   4-MB L3 Cache, 16-way set associative, 64-byte line size
 E4h   8-MB L3 Cache, 16-way set associative, 64-byte line size
 F0h   64-byte Prefetching
 F1h   128-byte Prefetching

 舉例來說,在我的機器上執(zhí)行記過如下:
image.png
 EAX、EBX、ECX和EDX的bit 31均為0,說明其中的描述符均有效,EAX中的低8位(AL)為1,說明執(zhí)行一次即可,下面是描述符含義:

05h:Data TLB: 4-MB Pages, 4-way set associative, 32 entries
B0h:Instruction TLB: 4-KB Pages, 4-way set associative, 128 entries
B1h:Instruction TLB: 2-MB pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries

56h:L1 Data TLB: 4-MB pages, 4-way set associative, 16 entries
57h:L1 Data TLB: 4-KB pages, 4-way set associative, 16 entries
F0h:64-byte Prefetching

2Ch:1st-level data cache: 32-KB, 8-way set associative, 64-byte line size
B4h:Data TLB: 4-KB Pages, 4-way set associative, 256 entries
30h:1st-level instruction cache: 32-KB, 8-way set associative, 64-byte line size
7Dh:2nd-level cache: 2-MB, 8-way set associative, 64-byte line size

7、EAX=3:處理器序列號

mov eax,3
cpuid

只有Pentium III提供該功能,486以后的CPU就不再提供該功能,據(jù)說是出于隱私的原因。查看你的處理器是否支持處理器序列號功能,可以執(zhí)行EAX=1的CPUID指令,然后查看EDX的PSN功能(bit 18),如果為1,說明你的處理器可以返回序列號,否則不支持序列號功能或者是序列號功能被關(guān)閉了。

處理器序列號一共96位,最高32位就是處理器簽名,通過執(zhí)行EAX=1的CPUID指令獲得,其余的64位在執(zhí)行EAX=3的CPUID指令后,中間32位在EDX中,最低32位在ECX中。

順便提一句,AMD所有的CPU都沒有提供過處理器序列號的功能。

CPUID指令的基本信息,其實后面還有好幾個,不過我在我這里的機器(大概有7、8臺吧),好像都不支持,大多數(shù)只支持EAX=0、1、2三個,所以后面的就不介紹了。

8、EAX=80000001h:最大擴展功能號

mov eax, 80000001h
cpuid

該功能除了能夠向(一)中介紹的那樣返回CPU支持的最大擴展功能號外,并沒有其它作用,EBX、ECX、EDX都不返回有意義的信息。

9、EAX=80000002h:返回CPU支持的擴展功能

mov eax, 80000002h
cpuid

執(zhí)行CPUID指令后,擴展功能標(biāo)志在EDX和ECX中返回,EDX中的定義如下:

 Bit    Name      Description
-------------------------------------------------------------------
10:00             Reserved
  11    SYSCALL   SYSCALL/SYSRET
19:12             Reserved
  20    XD        Bit Execution Disable Bit
28:21             Reserved
  29    Intel? 64 Intel? 64 Instruction Set Architecture
31:30             Reserved

返回在ECX中的位定義:
 Bit    Name      Description
-------------------------------------------------------------------
  0     LAHF      LAHF / SAHF
31:01             Reserved

10、EAX=80000002h、80000003h、80000004h:返回處理器名稱/商標(biāo)字符串

mov eax, 80000002h
cpuid
......
mov eax, 80000003h
cpuid
......
mov eax, 80000004h
cpuid

每次調(diào)用CPUID分別在EAX、EBX、ECX、EDX中返回16個ASCII字符,處理器名稱/商標(biāo)字串最多48個字符,前導(dǎo)字符為空格,結(jié)束字符為NULL,在寄存器中的排列順序為little-endian(即低字符在前),下面程序可以在DOS下顯示處理器名稱/商標(biāo)字串(使用MASM 6編譯)。

            .model tiny
            .386

cseg segment para public 'code'
org 100h
assume cs:cseg, ds:cseg, es:cseg
cpuid macro
db 0fh
db 0a2h
endm
begin:
mov eax, 80000000h
cpuid
cmp eax, 80000004h
jb not_supported
mov di, offset CPU_name
mov eax, 80000002h
cpuid
call save_string
mov eax, 80000003h
cpuid
call save_string
mov eax, 80000004h
cpuid
call save_string
mov dx, offset crlf
mov ah, 9
int 21h
cld
mov si, offset CPU_name
spaces:
lodsb
cmp al, ' '
jz spaces
cmp al, 0
jz done
disp_char:
mov dl, al
mov ah, 2
int 21h
lodsb
cmp al, 0
jnz disp_char
done:
mov ax, 4c00h
int 21h
not_supported:
jmp done
save_string:
mov dword ptr [di], eax
mov dword ptr [di + 4], ebx
mov dword ptr [di + 8], ecx
mov dword ptr [di + 12], edx
add di, 16
ret
crlf db 0dh, 0ah, '$'
CPU_name db 50 dup(0)
cseg ends
end begin

11、EAX=80000005h:備用

12、EAX=80000006h:擴展L2高速緩存功能

mov eax, 80000006h
cpuid

執(zhí)行完CPUID指令后,相應(yīng)信息在ECX中返回,以下是ECX中返回信息的定義:

 Bits    Description
-----------------------------------------------------------
31:16    L2 Cache size described in 1024-byte units.
15:12    L2 Cache Associativity Encodings
           00h Disabled
           01h Direct mapped
           02h 2-Way
           04h 4-Way
           06h 8-Way
           08h 16-Way
           0Fh Fully associative
11:8     Reserved
 7:0     L2 Cache Line Size in bytes. 

13、EAX=80000007h:電源管理

mov eax, 80000007h
cpuid

執(zhí)行CPUID指令后,是否支持電源管理功能在EDX的bit8中返回,其余位無意義。

14、EAX=80000008h:虛擬地址和物理地址大小

mov eax, 80000008h
cpuid

執(zhí)行CPUID指令后,物理地址的大小在EAX的bit[7:0]返回,虛擬地址的大小在EAX的bit[15:8]返回,返回的內(nèi)容為虛擬(物理)地址的位數(shù)。例如在我的機器上的運行結(jié)果如下:
image.png
表明我的機器支持36位的物理地址和48位的虛擬地址。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容