lkml.org 
[lkml]   [1999]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: Process VM Addr to Kernel VM Addr at Interrupt Time.
Date
<!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>&gt;&nbsp;&nbsp; I have just started looking at Linux code. So i am not sure </FONT>
<BR><FONT SIZE=2>&gt; how this fits into</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; the Linux context in terms of the Linux code/calls. But the </FONT>
<BR><FONT SIZE=2>&gt; following idea might help.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; If your sure of the address being read from the ISR.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; a) Lock that user address into memory.</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; b) Map this user page(s) into the kernel address space.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; As part of ISR, you can read the data now from this kernel </FONT>
<BR><FONT SIZE=2>&gt; address. In this case you </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; don't have to worry about if the process is currently </FONT>
<BR><FONT SIZE=2>&gt; running or not. </FONT>
</P>

<P><FONT SIZE=2>I have written some code that does this properly.&nbsp; 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.&nbsp; 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.&nbsp; 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().&nbsp; (See the bttv driver)&nbsp; While this is ugly in and of itself, it's better than the alternatives.&nbsp; 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>
\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.064 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site