Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

Monthly Seminars at OSR Headquarters

East Coast USA
Windows Internals and SW Drivers, Dulles (Sterling) VA, 13 November 2017

Kernel Debugging & Crash Analysis for Windows, Nashua (Amherst) NH, 4 December 2017

Writing WDF Drivers I: Core Concepts, Nashua (Amherst) NH, 8 January 2018

WDF Drivers II: Advanced Implementation Techniques, Nashua (Amherst) NH, 15 January 2018


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 8  
01 Jan 18 03:29
Michael Rolle
xxxxxx@rolle.name
Join Date: 27 Dec 2017
Posts To This List: 9
How to access processor-specific resources (e.g., MSRs)

A few days ago I posted some stuff about hooking an ISR without knowing what vector and DIRQL I should use. I've given up on that for the moment, as the hardware is on-board AMD processors, and AMD's own driver to access this hardware seems to be relying on things within the HAL, which AMD probably had a hand in writing. Meantime, I'm trying to service the hardware periodically using a Dpc associated with a periodic timer. That's simple enough and the Dpc is getting called periodically. The problem is that the Dpc is running on an arbitrary processor, but I want to use the MSRs on a specific processor, say processor 0. If the Dpc happens to be running on processor 1, then the RDMSR and WRMSR instruction get the MSRs for processor 1. But I need the MSRs for processor 0. How do I do this??? Some ideas... (1) find out how processor 1 can get to the MSRs for processor 0, through some sort of memory mapping, I suppose, as it can get to the APIC registers through a memory map. AMD's processor programming guide doesn't have anything that I could find on this subject. (2) force the Dpc to always run on processor 0. (3) some other way to cause a function to run on processor 0. Perhaps hook it as an ISR associated with some periodic timer events. (4) run a higher-priority user thread on processor 0 that will wait for periodic timer events and then send an IOCTL to my driver, which will then work with the profiling hardware. It appears that DeviceIoControl always runs the driver's dispatch routine in the same processor. (Is this actually true?) I know I can do (4) if nothing else works. I'm hoping one of you will have a different solution. I have the impression that the whole design of drivers is oriented around the driver code not having to care which processor it's running on. Which is fine for system-wide devices or resources. But I'd like to think there's a clean way that driver code can get to resources on a specific processor.
  Message 2 of 8  
01 Jan 18 06:57
Krzysztof Uchronski
xxxxxx@gmail.com
Join Date: 27 Jan 2007
Posts To This List: 124
How to access processor-specific resources (e.g., MSRs)

You can set target CPU for your DPC run on specific processor (see KeSetTargetProcessorDpc). Kris On Mon, Jan 1, 2018 at 8:29 AM, xxxxx@rolle.name <xxxxx@lists.osr.com> wrote: > A few days ago I posted some stuff about hooking an ISR without knowing w= hat vector and DIRQL I should use. I've given up on that for the moment, a= s the hardware is on-board AMD processors, and AMD's own driver to access t= his hardware seems to be relying on things within the HAL, which AMD probab= ly had a hand in writing. > > Meantime, I'm trying to service the hardware periodically using a Dpc ass= ociated with a periodic timer. That's simple enough and the Dpc is getting= called periodically. > > The problem is that the Dpc is running on an arbitrary processor, but I w= ant to use the MSRs on a specific processor, say processor 0. If the Dpc h= appens to be running on processor 1, then the RDMSR and WRMSR instruction g= et the MSRs for processor 1. But I need the MSRs for processor 0. > > How do I do this??? Some ideas... > > (1) find out how processor 1 can get to the MSRs for processor 0, through= some sort of memory mapping, I suppose, as it can get to the APIC register= s through a memory map. AMD's processor programming guide doesn't have any= thing that I could find on this subject. > > (2) force the Dpc to always run on processor 0. > > (3) some other way to cause a function to run on processor 0. Perhaps ho= ok it as an ISR associated with some periodic timer events. > > (4) run a higher-priority user thread on processor 0 that will wait for p= eriodic timer events and then send an IOCTL to my driver, which will then w= ork with the profiling hardware. It appears that DeviceIoControl always ru= ns the driver's dispatch routine in the same processor. (Is this actually = true?) > > I know I can do (4) if nothing else works. I'm hoping one of you will ha= ve a different solution. > > I have the impression that the whole design of drivers is oriented around= the driver code not having to care which processor it's running on. Which= is fine for system-wide devices or resources. But I'd like to think there= 's a clean way that driver code can get to resources on a specific processo= r. > > > > --- > NTDEV is sponsored by OSR > > Visit the list online at: <http://www.osronline.com/showlists.cfm?list=3D= ntdev> > > MONTHLY seminars on crash dump analysis, WDF, Windows internals and softw= are drivers! > Details at <http://www.osr.com/seminars> > > To unsubscribe, visit the List Server section of OSR Online at <http://ww= w.osronline.com/page.cfm?name=3DListServer> --=20 Kris
  Message 3 of 8  
01 Jan 18 13:28
Iolanda Milani
xxxxxx@gmail.com
Join Date: 31 Dec 2017
Posts To This List: 16
How to access processor-specific resources (e.g., MSRs)

Use the solution mentioned above, and on the routine executed on the specific processor, you can execute the code for your various routines for the functionality you need to work on multiple processors.
  Message 4 of 8  
02 Jan 18 00:20
Michael Rolle
xxxxxx@rolle.name
Join Date: 27 Dec 2017
Posts To This List: 9
How to access processor-specific resources (e.g., MSRs)

Thanks, just what I wanted to know. And more questions... If I could find a list of all driver routines that pertain to a DPC, that would be helpful. Specifically, can I control the IRQL at which the DPC runs? What IRQL does a DPC run at? (at least by default).
  Message 5 of 8  
02 Jan 18 01:59
Doron Holan
xxxxxx@microsoft.com
Join Date: 08 Sep 2005
Posts To This List: 10129
How to access processor-specific resources (e.g., MSRs)

They run at dispatch level. You can raise IRQL within your routine. I have no idea how to interpret " If I could find a list of all driver routines that pertain to a DPC, that would be helpful." A Dpc is per Driver, there isn't a dpc for all driver routines. Do you mean all queues up DPCs? That information is not expose outside of the kernel. Bent from my phone ________________________________ From: xxxxx@lists.osr.com <xxxxx@lists.osr.com> on behalf of xxxxx@rolle.name <xxxxx@lists.osr.com> Sent: Monday, January 1, 2018 9:20:25 PM To: Windows System Software Devs Interest List Subject: RE:[ntdev] How to access processor-specific resources (e.g., MSRs) Thanks, just what I wanted to know. And more questions... If I could find a list of all driver routines that pertain to a DPC, that would be helpful. Specifically, can I control the IRQL at which the DPC runs? What IRQL does a DPC run at? (at least by default). --- NTDEV is sponsored by OSR Visit the list online at: <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fshowlists.cfm%3Flist%3Dntdev&data=02%7C01%7CDoron.Holan%40microsoft.com%7C59d 29538c9224dd82aba08d551a07c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636504 672327731205&sdata=ZzmrK7p2WfCasVN8vkKJkHb5zywu7Zlmns9A9EYFOoo%3D&reserved=0> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers! Details at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osr.com%2Fse minars&data=02%7C01%7CDoron.Holan%40microsoft.com%7C59d29538c9224dd82aba08d551a07 c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636504672327731205&sdata=gqxjWY6 88PxWyJbX8%2FMAWLtuRjL%2BcErWkJVaD52rcIU%3D&reserved=0> To unsubscribe, visit the List Server section of OSR Online at <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.osronline.co m%2Fpage.cfm%3Fname%3DListServer&data=02%7C01%7CDoron.Holan%40microsoft.com%7C59d 29538c9224dd82aba08d551a07c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636504 672327731205&sdata=m20ojS6W4hGdigrIe9%2F4RudT5q1Brbs5hWJ1CwDPh9E%3D&reserved=0> --
  Message 6 of 8  
16 Jan 18 21:26
Michael Rolle
xxxxxx@rolle.name
Join Date: 27 Dec 2017
Posts To This List: 9
How to access processor-specific resources (e.g., MSRs)

I guess if I want my driver to get to the MSRs on all processors, I would need a separate DPC for each one, using the KeSetTargetProcessorDpc calls. Then I would execute the DPC for the processor I want. I was hoping for some simpler, which is a way to directly access another processor's MSRs. In particular, I'm looking to do this on the AMD Ryzen. Perhaps a way of memory mapping the other processor's MSRs.
  Message 7 of 8  
Yesterday 12:42
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 11731
How to access processor-specific resources (e.g., MSRs)

xxxxx@rolle.name wrote: > I guess if I want my driver to get to the MSRs on all processors, I would need a separate DPC for each one, using the KeSetTargetProcessorDpc calls. Then I would execute the DPC for the processor I want. > > I was hoping for some simpler, which is a way to directly access another processor's MSRs. In particular, I'm looking to do this on the AMD Ryzen. Perhaps a way of memory mapping the other processor's MSRs. MSRs are not memory mapped.  They are accessed directly by special CPU instructions, and those instructions must be executed on the processor of interest.  What you're asking is the equivalent of trying to read the rax register from another processor.  They are simply not available at the silicon level. You don't actually need a set of DPCs.  You can use KeSetSystemAffinityThread to force your thread to move to another processor.  It might take some time, if that processor happens to be busy. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 8 of 8  
Yesterday 12:51
Peter Viscarola (OSR)
xxxxxx@osr.com
Join Date:
Posts To This List: 5957
List Moderator
How to access processor-specific resources (e.g., MSRs)

<quote> You don't actually need a set of DPCs. You can use KeSetSystemAffinityThread to force your thread to move to another processor. </quote> This. (actually, you want the EX version, KeSetSystemAffinityThreadEx) Peter OSR @OSRDrivers
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 02:33.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license