Re: Mapping of non-prefetchable memory and registers into user spa
- From: alberto <amoreira@xxxxxxxx>
- Date: Tue, 18 Nov 2008 08:18:54 -0800 (PST)
If all you want is to give an Administrator file access to selected
registers, you can use MmMapIoSpace to give you driver a kernel-side
virtual address of the BAR area you want to expose. You can add a
couple of IoControl calls to read and write register information, and
in the IoControl code you can choose to expose whatever view of your
register space you want to give to the caller. You can enforce
security if you want, for example, you may want to create a separate
device at AddDevice time that can only be accessed by privileged users
and that only expose those IoControl calls that give them the access
you are willing to provide. The involved buffer copies are nothing -
unless you have a really cpu-time hog kind of environment, I wouldn't
worry about performance, and you gain a lot of security by not
allowing direct real-time hardware poking even to an Administrator.
For the security bit you can take a look at "Security During Create
Operations", published by OSR Online, you can look at it at their web
site; the article also has links to additional material.
I may be giving rope for you to hang yourself with, but here goes! If
you want to give an administrator direct access to peek and poke at
registers in real time, you begin by encapsulating that functionality
in a separate device that's only available to privileged users. Then
you use MmMapIoSpace to get a kernel-side virtual address for your BAR
area; you build an MDL for it with IoAllocateMdl /
MmBuildMdlForNonPagedPool; and then when you want to expose the
visibility on user side, you use MmMapLockedPagesSpecifyCache.
But heed the warning, this is dangerous functionality that you want to
apply strict controls to, because even an Administrator can bring the
system to its knees by improperly poking at hardware registers! In my
driver, this is only accessible to the Diagnostics program, and I have
a state machine in the driver that makes sure no other program is
running on the device when the diag program opens it.
Alberto.
On Nov 12, 5:42 am, jk <j...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I've got the same problem.
I am writing a driver for a device that has an existing driver under Linux.
The Linux driver makes some of the devices register space available via a
virtual file system. The file entries contained in the file system are
accessible only by the Administrator. A memory map system call hence provides
an easy and secure way to access the device resources from userspace and no
data copying is required.
Under Linux this is common practice (/proc, /udev). Isn't there something
like that for Windows as well?
--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"driver_chris" <driverch...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F0B179EF-D797-4C2B-91AB-7A896C0C4A3F@xxxxxxxxxxxxxxxx
Can anyone tell me how to map registers and non-prefetchable memory of a
PCIe
device into an application processes' address space on Windows Vista
/Server
2008 generation OSes? A device driver exists, the resources are visible
via
virtual BAR address + offset.
Are the instructions in KM-UMGuide.doc "Creating and Sharing a Section
Object" the recommended approach? If so which device name and attributes
are
required for the OBJECT_ATTRIBUTES structure input to ZwCreateSection()
and
the flag fields in ZwMapViewOfSection() to achieve the subject goal?
If not could you briefly outline an example?
Reading mem-mgmt.doc and KM-UMGuide.doc I'm aware of issues that need to
be
addressed with the approach in question.
--
Developer (User/Driver)- Hide quoted text -
- Show quoted text -
.
- References:
- Mapping of non-prefetchable memory and registers into user space
- From: driver_chris
- Re: Mapping of non-prefetchable memory and registers into user space
- From: Doron Holan [MSFT]
- Re: Mapping of non-prefetchable memory and registers into user spa
- From: jk
- Mapping of non-prefetchable memory and registers into user space
- Prev by Date: Driver Verifier in Windows 7
- Next by Date: Re: how to minimize interrupt latency using interrupt affinity in
- Previous by thread: Re: Mapping of non-prefetchable memory and registers into user spa
- Next by thread: Re: Mapping of non-prefetchable memory and registers into user spa
- Index(es):
Relevant Pages
|
Loading