mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: Stevie-O <oliver@klozoff.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Aliasing physical memory using virtual memory (from a d
Date: Thu, 18 Sep 2003 12:32:13 +0200	[thread overview]
Message-ID: <20030918103212.GA7174@vana.vc.cvut.cz> (raw)
In-Reply-To: <3F6905FE.5030106@klozoff.com>

On Wed, Sep 17, 2003 at 09:10:22PM -0400, Stevie-O wrote:
> Stevie-O wrote:
> 
> >
> >I grepped my 2.4 kernel source for 'vmap' and the only results that 
> >seemed meaningful were vmap_pte_range or vmap_pmd_range in 

2.4.22-ac1 has it. In mm/vmalloc.c. You cannot (well, I believe) use
any functions which take page array if pages were not allocated one
by one. Maybe you can try using page and page+1, but I'm under
impression that it will not work as expected, and that you'll hit
some BUG() somewhere.

> >mips/mm/umap.c and mips64/mm/umap.c. Is this documented somewhere? I 
> >suffer from the 'i'm new at this, but this looks possible' syndrome. I 
> >don't actually know how anything is accomplished.
> >
> >Btw, am I right about kmalloc(35000) effectively grabbing 64K?

Yes.  

> I did a freetext search of the LXR for 'remap' and came up with this 
> function:
> 
> 820 /*
> 821  * maps a range of physical memory into the requested pages. the old
> 822  * mappings are removed. any references to nonexistent pages results
> 823  * in null mappings (currently treated as "copy-on-access")
> 824  */
> 825 static inline void remap_pte_range(pte_t * pte, unsigned long address, 
> unsigned long size,
> 826         unsigned long phys_addr, pgprot_t prot)

Unavailable outside of mm. You must use remap_page_range. And this function
can only remap memory which does not have its 'struct page' (i.e. MMIO on
PCI busses) or pages marked as Reserved. So if you want to use it on
regular memory, you must mark pages reserved... And then you have to do
black magic to correctly remove 'PageReserved' bit at correct time - if 
process does fork, and you'll clear this bit too early, you'll get
page_count < 0 and BUG(). If you'll do that too late, you'll leak memory.
vmmon did this in the past, but it was impossible to get it right under all
possible circumstances.

Other problem is that this functions is targeted for remapping userspace
addresses, not kernel space, and I would not trust this function for using
with from in kernel space. Definitely 2.6.x with 4G/4G patch will do bad
things.
						Best regards,
							Petr Vandrovec
							vandrove@vc.cvut.cz

      reply	other threads:[~2003-09-18 10:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-18  0:19 Petr Vandrovec
2003-09-18  0:40 ` Stevie-O
2003-09-18  1:10   ` Stevie-O
2003-09-18 10:32     ` Petr Vandrovec [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=20030918103212.GA7174@vana.vc.cvut.cz \
    --to=vandrove@vc.cvut.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@klozoff.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

all inboxes | Powered by JetHome®