Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 04-15-2009, 09:06 AM   #1
LQ Newbie
Registered: Jan 2008
Location: india
Distribution: Fedora
Posts: 17

Rep: Reputation: 0
How to Access the User Space Variable in Kernel

How to access the user space variable in kernel space, I need to do this because if any Driver fails in module initialization i will write the status in this user space variable. So whenever i read this variable in user space, then it should have hardware's Driver Module Status(Success or Failure)
Old 04-15-2009, 11:32 AM   #2
Registered: Feb 2006
Location: Ahmedabad
Distribution: rhel5
Posts: 185
Blog Entries: 2

Rep: Reputation: 31
i dint understand the purpose.
but go through copy_from_user and copy_to_user functions
Old 04-17-2009, 05:06 PM   #3
LQ Newbie
Registered: Apr 2009
Posts: 17

Rep: Reputation: 3
Depends on how your driver is being called you may or may not do what you want.

Every thread see its own linear(virtual) address. Given any user space address it only makes sense to that user thread. No other user and kernel threads know about that address. Your application is a user thread. User thread can go to kernel mode via syscall or ioctl. User threads in kernel mode can access its own user space address. Kernel threads can only be in kernel mode and cannot access user space address.

If the driver is called by user thread in kernel mode (via syscall or ioctl) your driver may access the user space address by copy_from_user and copy_to_user. If your driver is called by kernel threads kernel threads cannot access user threads' address space because every thread sees different address space. Accessing an unknown address leads to an assert.

Your option is go through the regular syscalls and ioctls.

Last edited by titan22; 04-17-2009 at 05:09 PM.
Old 04-17-2009, 07:55 PM   #4
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,458
Blog Entries: 4

Rep: Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920Reputation: 2920
I suggest that your driver should be implemented with some sort of "initialize me" call, and if it returns a failure-status, perhaps provide a "tell me what happened most recently" call.

This strategy minimizes the possibility of "weird timing holes." The inquiring process is sitting in a known status... waiting in a syscall. "Nice and synchronous," if you know what I mean. You can validate any parameters passed in the usual fashion.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
notify user space application from the kernel space lordofring Linux - Software 2 06-22-2009 12:32 PM
synchronization between kernel space and user space rentalakranthi Programming 2 07-21-2008 01:25 PM
How to share data b/w user space and kernel space nandac Linux - Kernel 1 11-28-2006 10:15 PM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration