LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Questions on linux kernel (https://www.linuxquestions.org/questions/linux-kernel-70/questions-on-linux-kernel-821131/)

nakul.k1 07-20-2010 08:18 PM

Questions on linux kernel
 
Hi all

i have few question relating to linux kernel memory here are the questions

1) Can Kernel space access user space memory yes or no ?
if no what happens when kernel space tries to access user space memory

2) Can Device memory(character device/chipset on the hardware board) be
mapped to user space ?

Cheers
NRK

paulsm4 07-21-2010 01:11 PM

Hi -

Quote:

1) Can Kernel space access user space memory yes or no ?

A: Yes
Quote:

2) Can Device memory(character device/chipset on the hardware board) be
mapped to user space?

A: Yes
See "mmap()"
Here are a couple of good links:
http://tldp.org/LDP/tlk/mm/memory.html

http://people.ee.ethz.ch/~arkeller/l...ace_howto.html

I understand that Robert Love has come out with a new edition of his (Most Excellent!) book on Linux kernel internals, which you might be interested in:

http://www.amazon.com/Linux-Kernel-D...dp/0672329468/

'Hope that helps .. PSM

nakul.k1 07-22-2010 10:32 AM

Thank you paul

1) I wanted to know can kernel space access user space pointer yes or no ?
if no then what happen when kernel tries to access user space pointer.

2) so you say in kernel if i need some memory from user space
then this function kmalloc(1024,GFP_USER); would work fine yes or no ?

Aquarius_Girl 08-09-2010 07:30 AM

Quote:

Originally Posted by nakul.k1 (Post 4042006)
2) so you say in kernel if i need some memory from user space
then this function kmalloc(1024,GFP_USER); would work fine yes or no ?

Read the following manual carefully.
Kmalloc allocates only in kernel-space.
http://www.fiveanddime.net/man-pages/kmalloc.9.html

Moreover I didn't understand why would anyone want to allocate user space memory from kernel space ? In what kind of cases is this required ?

nakul.k1 08-09-2010 09:25 AM

Thanks anisha

it was of great help from your end
that link you sent me clearly explains the Allocating and freeing dynamic kernel memory.


Nakul

Aquarius_Girl 08-09-2010 10:39 AM

You are most welcome :hattip:


All times are GMT -5. The time now is 12:10 AM.