You cannot.
This keeps coming up, and even sane people like Alan Cox want to do it,
even though it is fairly obvious that it should not be done that way.
> I didn't want a kernel-space buffer that I have to copy
> (for performance reasons). Therefore, I decided to use verify_area
> as a check for existance.
>
> So, I guess I will have to do a dummy copy_to_user as an initial test?
No. That doesn't help in the least.
By the time your interrupt handler is called, the process is long long
gone and even if it was the current process it might have changed its
mapping.
Basically you should never EVER even consider writing to user space from
interrupts. EVER!
Basically, you should always use a kernel-space buffer. Just accept that
as a fundamental notion, and your life suddenly turns a lot easier.
Now, I know about zero-copy. I'm not a big believer in it, but I certainly
know about it. And having a kernel buffer does not imply that you can't do
zero-copy. It just means that you can' tdo the initial copy to user space.
Sounds contradictory? Think "mmap()". It works, it's there, and magically
all the problems go away. Don't make the mountain go to Mohammed. Instead,
think of your problem the other way around: instead of the kernel writing
to user space, think of it as user space asking to see a window of a
kernel buffer. You make a device driver that has a mmap() function, and
suddenly the device driver can write to kernel memory, and whatever it
writes magically shows up in user space too.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/