Re: forcibly unmap pages in driver?

Dan Maas (dmaas@dcine.com)
Tue, 5 Jun 2001 20:13:51 -0400


>> Later, the program calls the ioctl() again to set a smaller
>> buffer size, or closes the file descriptor. At this point
>> I'd like to shrink the buffer or free it completely. But I
>> can't assume that the program will be nice and munmap() the
>> region for me

> Look at drivers/char/drm, for example. At mmap time they allocate a
> vm_ops to the address space. With that you catch changes to the vma
> structure initiated by a user mmap, munmap, etc. You could also
> dynamically map the pages in using the nopage method (optional).

OK I think I have a solution... Whenever I need to re-allocate or free the
DMA buffer, I could set all of the user's corresponding page table entries
to deny all access. Then I'd get a page fault on the next access to the
buffer, and inside nopage() I could update the user's mapping or send a
SIGBUS as appropriate (hmm, just like restoring a file mapping that was
thrown away)... So I just have to figure out how to find the user's page
table entries that are pointing to the DMA buffer.

Regards,
Dan

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/