public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: Address translation
@ 2000-11-22 21:39 Keir Fraser
  2000-11-23  0:49 ` Pavel Machek
  2000-11-23 20:23 ` Andreas Bombe
  0 siblings, 2 replies; 7+ messages in thread
From: Keir Fraser @ 2000-11-22 21:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Keir.Fraser

> The reason that everyone else uses copy_{to,from}_user is that there
> is no way to guarantee that the userspace pointer is valid. That
> memory may have been swapped out. The copy macros are prepared to
> fault the memory in. The rest of the kernel is not.
>
> Jeff

I may be wrong on this, but I thought that copy_{to,from}_user are
only necessary if the address range you are accessing might cause a
fault which Linux cannot handle (ie. one which would cause the
application to segfault if it accessed that memory). If it is only a
matter of paging the memory in (and you are _sure_ the address range is
otherwise valid) I think the access macros are unnecessary. I would be
*very* glad if someone could confirm this, or shoot me down. :)

For instance, a kernel module I am writing allocates some memory in
the current process's address space as follows:

    down(&mm->mmap_sem);
    s->table = (void **)get_unmapped_area(0, SIZEOF_TABLE);
    if ( s->table != NULL )
        do_brk((unsigned long)s->table, SIZEOF_TABLE);
    up(&mm->mmap_sem);

Some questions:
 (1) In a "top half" thread, can I now access this memory without the
     access macros (since I know the address range is valid)?
 (2) Can I also access this memory from an interrupt/exception
     context, or must I lock it? (ie. can faults be handled from such
     a context) 
 (3) Is the above code sensible at all, or barking? It took me a while
     to figure that the above would work, and I think/hope it is the
     most elegant way to share memory between kernel and a process.

 Thanks in advance for any info!
 -- Keir Fraser

PS. Please cc me directly (kaf24@cl.cam.ac.uk) with any replies.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Address translation
@ 2000-11-21 14:41 Rubén Gallardo Fructuoso
  2000-11-21 17:20 ` Jeff Dike
  0 siblings, 1 reply; 7+ messages in thread
From: Rubén Gallardo Fructuoso @ 2000-11-21 14:41 UTC (permalink / raw)
  To: Linux-Kernel

	Hi everybody!

	I'm developing a module of file system filter and I have a question about
it. Does anybody know a function or method in order to translate an user
space pointer into a valid pointer in kernel mode?

	I'd like to avoid copying data (such as the 'copy_to_user' and
'copy_from_user' functions do) because it slows down my system.

	Thanks in advance,
	Rubén.



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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-11-24 23:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-22 21:39 Address translation Keir Fraser
2000-11-23  0:49 ` Pavel Machek
2000-11-23 20:23 ` Andreas Bombe
2000-11-23 21:04   ` Bjorn Wesen
2000-11-24 23:28     ` Andreas Bombe
  -- strict thread matches above, loose matches on Subject: below --
2000-11-21 14:41 Rubén Gallardo Fructuoso
2000-11-21 17:20 ` Jeff Dike

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox