public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: brace@beardog.cce.hp.com
Cc: scameron@beardog.cce.hp.com, linux-kernel@vger.kernel.org
Subject: Re: How to create a kernel virtual mapping for physical addresses.
Date: Thu, 21 Apr 2011 21:36:37 +0200	[thread overview]
Message-ID: <201104212136.38017.arnd@arndb.de> (raw)
In-Reply-To: <20110421184600.GA29746@beardog.cce.hp.com>

On Thursday 21 April 2011 20:46:00 brace@beardog.cce.hp.com wrote:
> Thanks for your reply.
> 
> I have a block of highmem that I want to map into my 32bit driver.
> This block is 256M in size.

If you have highmem enabled, there probably is not enough space
to map all of this at once into the vmalloc area. If you had
that much virtual address space, you would not need highmem ;-)

> I get the physical address and want to create a contiguous virtual buffer.
> I have been investigating vmap() as a possible solution.
> 
> I build up an array of pages as follows.
> 	pfn = physical_address >> PAGE_SHIFT
> 	for (i = 0; i < num_pages; i++) {
> 		page = pfn_to_page(pfn);
> 		page_array[i] = page;
> 		++pfn
> 	}
> 
> 	map = vmap(page_array, num_pages, VM_IOREMAP, PAGE_KERNEL);
> 
> Using the above method, I can memset the block of memory using
> map as my virtual address.
> 
> However, later, I get the following error message:
> 
> kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
> BUG: unable to handle kernel paging request at virtual address c5000840
> 
> The address 0xc5000840 is within the range of vmap()ed memory.

Maybe you have overwritten a kernel module and the kernel now
tries to execute within the mapped area?

> What should I be doing instead?

It's not clear at all what you are actually trying to do. Which driver
is this? If it's out-of-tree code, please post it here.

	Arnd

      parent reply	other threads:[~2011-04-21 19:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08 22:03 How to create a kernel virtual mapping for physical addresses brace
2011-04-19 19:51 ` Arnd Bergmann
     [not found]   ` <20110421184600.GA29746@beardog.cce.hp.com>
2011-04-21 19:36     ` Arnd Bergmann [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=201104212136.38017.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=brace@beardog.cce.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=scameron@beardog.cce.hp.com \
    /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