Microsoft
Software
Hardware
Network
Question : Exporting kernel memory to user space using devmap_umem_setup
Hi,
I have a simple pseudo driver pretty much copied off the "Writing Device Drivers" tutorial. What i was trying to achieve was allocating and exporting kernel memory from this driver to the user space app. I'm not interested in exporting device memory hence i only used devmap_umem_setup in the devmap() entry point. I have a user space app that calls mmap to invoke the devmap routine. Based on the return values of all the routines involved both in the driver such as ddi_umem_alloc, devmap_setup, devmap_umem_setup and the mmap call in the user app it appears the mapping is successful. However when i set something in the user app at that memory address returned by mmap, i am not able to read it back from the driver using the ddi_umem_cookie_t. The value read back in the driver pointed to by the cookie is different than the one set by the user space app. I'm not using any offsets both in mmap and devmap_umem_setup (passing 0) and the length being passed is 4096. My question is does the ddi_umem_cookie_t set by ddi_umem_alloc point to the same memory location (after whatever address translations that need to happen) that mmap call will return given that the offsets are 0 and length is 1 page size (4096) and the addr in mmap is 0.
user app:
fd=open("/devices/pseudo/d
ummy@0:0",
O_RDWR);
mapadd = mmap64(0, len, (PROT_READ|PROT_WRITE),
MAP_SHARED, fd, 0);
driver:
xsp->umem = ddi_umem_alloc(8192,
DDI_UMEM_SLEEP | DDI_UMEM_PAGEABLE, &(xsp->ucookie));
error = devmap_setup(dev, 0, asp, addrp, 4096,
prot, maxprot, flags, credp);
error = devmap_umem_setup(handle, xsp->dip, NULL, xsp->ucookie,
0, 4096, PROT_ALL, DEVMAP_DEFAULTS, NULL);
My understanding was that i would be able to access the memory pointed to xsp->ucookie (kernel space) as well as from the mapadd (user space) but that does not seem to be the case
Any help would be much appreciated.
Thanks
Answer : Exporting kernel memory to user space using devmap_umem_setup
I think from the kernel side, you want to access the memory locations pointed to by xsp->umem. If that doesn't work, could you post the whole driver?
Random Solutions
alignment question
IIS 7 leaking private ip via https
Microsoft PKI Design
looking for a powerful ActionScript 3 isometric engine
how to insert with vb.net a date time column in sql server
Firefox css border on inside of div when embedding Flash with SWFObject, why?
Pendrivelinux to install Ubuntu Server 10.x
OAB not downloading in Outlook in Cached Mode
Outlook 2010 NK2 file
just not sure why this php script wont print out for me...