public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
* Single physical memory location has multiple virtual addresses?
@ 2006-08-01  6:51 Daniel Rodrick
  2006-08-01  9:26 ` Rajendra
  2006-08-01 10:25 ` Rajendra
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Rodrick @ 2006-08-01  6:51 UTC (permalink / raw)
  To: kernelnewbies, linux-newbie

Hi,

Suppose I have a kernel module that dynamically allocates memory (via
kmalloc) for user space. Now my doubt is whether this chunk of
physical memory would have two virtual addresses?

- One virtual address that will be used by kernel to refer to the
memory (the address returned by kmalloc)

- One virtual address as will be seen by the user space application?

Is my understanding correct?

Thanks,

Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

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

* Re: Single physical memory location has multiple virtual addresses?
  2006-08-01  6:51 Single physical memory location has multiple virtual addresses? Daniel Rodrick
@ 2006-08-01  9:26 ` Rajendra
  2006-08-01 10:25 ` Rajendra
  1 sibling, 0 replies; 3+ messages in thread
From: Rajendra @ 2006-08-01  9:26 UTC (permalink / raw)
  Cc: kernelnewbies, linux-newbie

The address returned by kmalloc is valid in kernel only, it will be
something greater then 3GB ie (0xC000 0000). This address can not
be used by user space program, it will cause segfault.  For accessing
any memory from user space you need to create a "vma" entry of the
process so that there is a mapping of some virtual address with the
physical memory allocated by kmalloc.
In short, yes you need two set of page table entries for accessing the
memory allocated by kmalloc. The kernel entry is created by kmalloc
call itself, while the user space entry has to be created by the concerned
module.

For more info on how user programs can map arbit. mem location
see mmap() man page.

regds,
~rpm
Daniel Rodrick wrote:

> Hi,
>
> Suppose I have a kernel module that dynamically allocates memory (via
> kmalloc) for user space. Now my doubt is whether this chunk of
> physical memory would have two virtual addresses?
>
> - One virtual address that will be used by kernel to refer to the
> memory (the address returned by kmalloc)
>
> - One virtual address as will be seen by the user space application?
>
> Is my understanding correct?
>
> Thanks,
>
> Dan
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

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

* Re: Single physical memory location has multiple virtual addresses?
  2006-08-01  6:51 Single physical memory location has multiple virtual addresses? Daniel Rodrick
  2006-08-01  9:26 ` Rajendra
@ 2006-08-01 10:25 ` Rajendra
  1 sibling, 0 replies; 3+ messages in thread
From: Rajendra @ 2006-08-01 10:25 UTC (permalink / raw)
  To: kernelnewbies; +Cc: linux-newbie

The address returned by kmalloc is valid in kernel only, it will be
something greater then 3GB ie (0xC000 0000). This address can not
be used by user space program, it will cause segfault.  For accessing
any memory from user space you need to create a "vma" entry of the
process so that there is a mapping of some virtual address with the
physical memory allocated by kmalloc.
In short, yes you need two set of page table entries for accessing the
memory allocated by kmalloc. The kernel entry is created by kmalloc
call itself, while the user space entry has to be created by the concerned
module.

For more info on how user programs can map arbit. mem location
see mmap() man page.

regds,
~rpm
Daniel Rodrick wrote:

> Hi,
>
> Suppose I have a kernel module that dynamically allocates memory (via
> kmalloc) for user space. Now my doubt is whether this chunk of
> physical memory would have two virtual addresses?
>
> - One virtual address that will be used by kernel to refer to the
> memory (the address returned by kmalloc)
>
> - One virtual address as will be seen by the user space application?
>
> Is my understanding correct?
>
> Thanks,
>
> Dan
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

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

end of thread, other threads:[~2006-08-01 10:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01  6:51 Single physical memory location has multiple virtual addresses? Daniel Rodrick
2006-08-01  9:26 ` Rajendra
2006-08-01 10:25 ` Rajendra

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