Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Curiosity ...

Gary_Little-3Gary_Little-3 Member Posts: 1,208
In WDK documentation, I've seen CPUID referenced, but only for the
Hypervisor. __cpuid is documented but it looks like it's user mode only. Is
there a way to acquire the cpuid in the kernel?

Gary G. Little
H (952) 223-1349
C (952) 454-4629
xxxxx@comcast.net

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,004
    Gary G. Little wrote:
    > In WDK documentation, I've seen CPUID referenced, but only for the
    > Hypervisor. __cpuid is documented but it looks like it's user mode only. Is
    > there a way to acquire the cpuid in the kernel?

    __cpuid is an intrisic. It compiles to a single CPU instruction. It
    works regardless of CPU mode.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Gary_Little-3Gary_Little-3 Member Posts: 1,208
    Thanks Tim. Have you ever used it in the kernel?

    Gary G. Little
    H (952) 223-1349
    C (952) 454-4629
    xxxxx@comcast.net


    -----Original Message-----
    From: xxxxx@lists.osr.com
    [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
    Sent: Tuesday, September 07, 2010 2:35 PM
    To: Windows System Software Devs Interest List
    Subject: Re: [ntdev] Curiosity ...

    Gary G. Little wrote:
    > In WDK documentation, I've seen CPUID referenced, but only for the
    > Hypervisor. __cpuid is documented but it looks like it's user mode
    > only. Is there a way to acquire the cpuid in the kernel?

    __cpuid is an intrisic. It compiles to a single CPU instruction. It works
    regardless of CPU mode.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.


    ---
    NTDEV is sponsored by OSR

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at
    http://www.osronline.com/page.cfm?name=ListServer
  • Ken_JohnsonKen_Johnson Member - All Emails Posts: 1,559
    If applicable, I would use kernel APIs such as ExIsProcessorFeaturePresent instead of raw cpuid (which is somewhat unwieldy).

    - S


    -----Original Message-----
    From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
    Sent: Tuesday, September 07, 2010 12:29 PM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] Curiosity ...

    In WDK documentation, I've seen CPUID referenced, but only for the Hypervisor. __cpuid is documented but it looks like it's user mode only. Is there a way to acquire the cpuid in the kernel?

    Gary G. Little
    H (952) 223-1349
    C (952) 454-4629
    xxxxx@comcast.net



    ---
    NTDEV is sponsored by OSR

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,004
    Gary G. Little wrote:
    > Thanks Tim. Have you ever used it in the kernel?

    I don't recall. I have certainly used __readtsc, __readmsr, and
    __writemsr, and __cpuid is less demanding than any of those.

    Really, there's nothing to go wrong. The __cpuid intrinsic really does
    compile inline to a single CPU instruction (modulo saving the registers
    it dirties). The cpuid instruction is certainly valid in kernel mode.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Steve_ProchniakSteve_Prochniak Member Posts: 100
    Gary - We use it in the kernel without issue.
  • Gary_Little-3Gary_Little-3 Member Posts: 1,208
    Sure. However, it seems I will need my customer to pass it to the kernel
    since he requires it be tokenized using an MD5 hash. So ... he can get it
    too, hash it, and then pass me the hashed version. :)

    Thanks for the information.

    Gary G. Little
    H (952) 223-1349
    C (952) 454-4629
    xxxxx@comcast.net


    -----Original Message-----
    From: xxxxx@lists.osr.com
    [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
    Sent: Tuesday, September 07, 2010 5:23 PM
    To: Windows System Software Devs Interest List
    Subject: Re: [ntdev] Curiosity ...

    Gary G. Little wrote:
    > Thanks Tim. Have you ever used it in the kernel?

    I don't recall. I have certainly used __readtsc, __readmsr, and __writemsr,
    and __cpuid is less demanding than any of those.

    Really, there's nothing to go wrong. The __cpuid intrinsic really does
    compile inline to a single CPU instruction (modulo saving the registers it
    dirties). The cpuid instruction is certainly valid in kernel mode.

    --
    Tim Roberts, xxxxx@probo.com
    Providenza & Boekelheide, Inc.


    ---
    NTDEV is sponsored by OSR

    For our schedule of WDF, WDM, debugging and other seminars visit:
    http://www.osr.com/seminars

    To unsubscribe, visit the List Server section of OSR Online at
    http://www.osronline.com/page.cfm?name=ListServer
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Developing Minifilters 29 July 2019 OSR Seminar Space
Writing WDF Drivers 23 Sept 2019 OSR Seminar Space
Kernel Debugging 21 Oct 2019 OSR Seminar Space
Internals & Software Drivers 18 Nov 2019 Dulles, VA