Messages in this thread | | | From | Eric Lowe <> | Subject | RE: Process VM Addr to Kernel VM Addr at Interrupt Time. | Date | Thu, 29 Apr 1999 08:56:03 -0400 |
| |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2448.0"> <TITLE>RE: Process VM Addr to Kernel VM Addr at Interrupt Time.</TITLE> </HEAD> <BODY>
<P><FONT SIZE=2>> I have just started looking at Linux code. So i am not sure </FONT> <BR><FONT SIZE=2>> how this fits into</FONT> <BR><FONT SIZE=2>> the Linux context in terms of the Linux code/calls. But the </FONT> <BR><FONT SIZE=2>> following idea might help.</FONT> <BR><FONT SIZE=2>> </FONT> <BR><FONT SIZE=2>> If your sure of the address being read from the ISR.</FONT> <BR><FONT SIZE=2>> </FONT> <BR><FONT SIZE=2>> a) Lock that user address into memory.</FONT> <BR><FONT SIZE=2>> b) Map this user page(s) into the kernel address space.</FONT> <BR><FONT SIZE=2>> </FONT> <BR><FONT SIZE=2>> As part of ISR, you can read the data now from this kernel </FONT> <BR><FONT SIZE=2>> address. In this case you </FONT> <BR><FONT SIZE=2>> don't have to worry about if the process is currently </FONT> <BR><FONT SIZE=2>> running or not. </FONT> </P>
<P><FONT SIZE=2>I have written some code that does this properly. It properly locks pages, handles copy-on-write pages, and detects (and throws out, as it should) attempts to lock mmap'd or page cache memory. However, there is still a FATAL flaw in the code-- since the driver thread that locked the buffers runs in process context, if the process is killed while the driver is blocked awaiting DMA completion -- and the device is writing into user space -- the device can potentially be STILL DMA'ing into that memory after it has been free'd by the kernel, put into the page cache, allocated to a new process, etc.</FONT></P>
<P><FONT SIZE=2>Without a mechanism to allow the driver to be notified the process has died to stop the DMA disk buffers could be destroyed, processes overwritten, etc. This is a BAD THING.</FONT></P>
<P><FONT SIZE=2>The ultimate solution to this will more than likely be a method to map vmalloc()'d kernel memory into user space via mmap(). (See the bttv driver) While this is ugly in and of itself, it's better than the alternatives. There are simply too many issues to consider here to make it a viable solution, unless a way becomes apparent to handle page cache memory DMA, peer-to-peer DMA, and callbacks without much extra effort (yeah right).</FONT></P>
<P><FONT SIZE=2>--</FONT> <BR><FONT SIZE=2>Eric Lowe</FONT> <BR><FONT SIZE=2>elowe@systran.com</FONT> <BR><FONT SIZE=2>Software Engineer Co-op, Systran Corporation</FONT> <BR><FONT SIZE=2>937-252-5601 x330</FONT> <BR><FONT SIZE=2>((my apologies for the HTML garbage, it's put on by my e-mail gateway))</FONT> </P>
</BODY> </HTML> | |