Re: How to use make a UMA frame buffer mapping from kernel to user

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



How can I make sure it's in the right context of that user-mode process? I
need map it in the IOCTL_VIDEO_SHARE_VIDEO_MEMORY. And the current process
handle is always -1(0xFFFFFFFF).

Thanks

"Sasha Bublyk" wrote:

About MmMapLockedPagesSpecifyCache. Actually, everything is right. You can
allocate buffer in kernel space and map it to user space. But you *must* be
in the context of that user-mode process. So the sequence will be right:
ExAllocatePool
IoAllocateMdl
MmProbeAndLockPages with parameter KernelMode
MmMapLockedPagesSpecifyCache with parameter UserMode

---
Sasha Bublyk
www.sycorelogic.com



"driver_folks" <driverfolks@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:D89519C8-25FF-449B-A6B1-DD5DB8748CBF@xxxxxxxxxxxxxxxx
Thanks for comments, Tim.

1. Why we use reserved virtual space (created by MmAllocateMappingAddress
and MmMapLockedPagesWithReservedMapping) is that we can dynamicly allocate
different size of virtual memory and map it to physcial when necessary.
ExAllocatePool has to pre-allocate a large size of memory and it possesses
memory resources which won't be used.

2. I tried the MmMapLockedPagesSpecifyCache, but failed. Maybe what I did
is
wrong. Here is my steps:
a. call IoAllocateMdl;
b. call MmProbeAndLockPages;
c. call MmMapLockedPagesSpecifyCache; (the access mode is UserMode, isn't
it?).

Thanks

"Tim Roberts" wrote:

driver_folks <driverfolks@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I'm trying to implement a method to map a reserved virtual space
(created by
MmAllocateMappingAddress and MmMapLockedPagesWithReservedMapping) from
kernel
to user mode process.

This is generally considered to be a bad idea. A better idea is to
allocate the buffer in user-mode, and lock it in the kernel driver.

Why use those APIs instead of, for example, just ExAllocatePool?

From the DDK description for VideoPortMapMemory, it
seems we can do UMA (universal memory architecture) frame buffer mapping
as
suggested in the comments.

Well, sort of. Frame buffers are graphics concepts, but the same idea
applies.

The steps are:
1. Call InitializeObjectAttributes to get object attributes;
2. Call ZwOpenSection to get the handle of the section object;
3. Call ZwMapViewOfSection to get the virtual address of the view;

My question is how to set up the relation between the reserved virtual
space
and the section view, that's to say, how to find a section object to
represent the reserved virtual space? Any expert can help to give a
hint?

A much easier method is MmMapLockedPagesSpecifyCache. Make sure that you
are running in the context of the desired process first.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.



.



Relevant Pages

  • Re: How to use make a UMA frame buffer mapping from kernel to user
    ... You can allocate buffer in kernel space and map it to user space. ... MmMapLockedPagesSpecifyCache with parameter UserMode ... Why we use reserved virtual space (created by MmAllocateMappingAddress ...
    (microsoft.public.development.device.drivers)
  • Re: Merging relayfs?
    ... > kernel to implement speculative tracing, ... relayfs was prepared for low latency on move data outside kernel space, ... getting data from probes do not require organize all them in regular ... Only in all cases where buffer must be neccessarly moved outside kernel ...
    (Linux-Kernel)
  • [PATCH] Documentation update for relay interface
    ... Here's updated documentation for the relay interface, ... +efficiently log and transfer large quantities of data from the kernel ... +A 'relay channel' is a kernel->user data relay mechanism implemented ... +buffer data. ...
    (Linux-Kernel)
  • [RFC] Userspace tracing memory mappings
    ... 16 per cpu trace buffers at the same time. ... - Also need some space for the kernel to export control information. ... When the process issues its first buffer switch (that's a second added ...
    (Linux-Kernel)
  • Re: Question about memory mapping mechanism
    ... The thing is that I'd like to prevent kernel to swap these pages out, ... the buffer pages, I should increase the referrence of the pages by calling ... Well it wasn't this code in particular, but another driver I was putting ... use the infiniband approach to mmap() the user-space pages and send them ...
    (Linux-Kernel)