Re: sleeping and waiting and tasklets



Peter,

I rely on Linux Device Drivers, 3rd Edition, an O'Reilly book a lot. This is
what they have to say about copy_*_user():

===========
unsigned long copy_to_user(void _ _user *to,
const void *from,
unsigned long count);
unsigned long copy_from_user(void *to,
const void _ _user *from,
unsigned long count);
Although these functions behave like normal memcpy functions, a little extra
care must be used when accessing user space from kernel code. The user pages
being addressed might not be currently present in memory, and the virtual
memory subsystem can put the process to sleep while the page is being
transferred into place. This happens, for example, when the page must be
retrieved from swap space. The net result for the driver writer is that any
function that accesses user space must be reentrant, must be able to execute
concurrently with other driver functions, and, in particular, must be in a
position where it can legally sleep. We return to this subject in Chapter 5.
The role of the two functions is not limited to copying data to and from
user-space: they also check whether the user space pointer is valid. If the
pointer is invalid, no copy is performed; if an invalid address is
encountered during the copy, on the other hand, only part of the data is
copied. In both cases, the return value is the amount of memory still to be
copied.
==========
This edition of the book has been updated to include the 2.6 kernel.
It looks liike it agrees with you in some places and disagrees in others. As
far as verifying the user-space pointers, they say there is validation but
you both agree on what happens when there is a problem. You were much more
detailed in your explaination.
As a result of the answers here, I have a much better understanding of the
"do not" issues.
Thanks to all of you!!
Bill

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
.



Relevant Pages

  • Re: NativeOverlapped, does it work??
    ... You need to keep that fixed in memory, and if you are using a fixed statement the memory location of the structure is subject to change. ... Instead, I would pin the structure (and then get the unsafe pointer to the structure), or marshal it to unmanaged memory, where you can hold onto the pointer for the life of the call. ... I'm trying to read some messages from a kernel mode mini-filter driver. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: PCI device driver question
    ... program to find the physical address of the pci device's memory. ... device read and write functions in the pci device driver. ... user space into kernel space (possibly to a small temporary holding ...
    (comp.os.linux.development.system)
  • [PATCH 25/39] merge common parts of uaccess.
    ... * Test whether a block of memory is a valid user space address. ... * Checks if a pointer to a block of memory in user space is valid. ... * These are the main single-value transfer routines. ...
    (Linux-Kernel)
  • Re: Question about FILE_OBJECT
    ... the use of FsContext and FsContext2 are dictated by each driver in the ... PFILE_OBJECT pointer and the same pointer value you put into FsContext. ... On the open call I allocate a context structure and add it ... on susequent irp's instead of accessing the context memory at ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Why get_user_pages fails?
    ... memory above 512M to user space and got the user space virtual ... address for that memory. ... The get_user_pagesin my driver fails. ... You're bypassing the Linux ...
    (Linux-Kernel)