public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
From: Rajendra <rpm@solidcore.com>
To: kernelnewbies@nl.linux.org
Cc: linux-newbie@vger.kernel.org
Subject: Re: Single physical memory location has multiple virtual addresses?
Date: Tue, 01 Aug 2006 15:55:25 +0530	[thread overview]
Message-ID: <44CF2C15.9030908@solidcore.com> (raw)
In-Reply-To: <292693080607312351m116cdd2wd4d7fd889d46581f@mail.gmail.com>

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

      parent reply	other threads:[~2006-08-01 10:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44CF2C15.9030908@solidcore.com \
    --to=rpm@solidcore.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-newbie@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox