Skip to contentSkip to conversation

temp. mem mappings

DISCUSSION cohutta 3 participants 5 messages Jun 5, 2001 Memory management

lore
Share & tools
lore

cohutta

author
#0 lore raw

hi-

i'm trying to map some memory during kernel init. (this is x86-specific.)
this should be temporary, unmapped after use. this memory is not in the low identity-mapped 8 MB.

currently i have this sorta working by using a new fixed mapping (linux/include/asm-i386/fixmap.h) and calling set_fixmap() which calls set_pte_phys().
after i use (access, read-only) this memory, i try to unmap it so that i can use the same virtual address again by calling set_fixmap() again.
i use pte_clear() to unmap it.
however the next time that i call set_fixmap(), set_pte_phys() gives me a pte_ERROR()...because the pte hasn't been cleared (?).
but the new mapping seems to work.

i tried to make this similar to linux/include/asm-i386/highmem.h.

what is the a preferred/correct method to map and unmap memory temporarily?

thanks.
/cohutta/

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#1 lore raw

** Reply to message from cohutta <[email protected]> on Tue, 5 Jun 2001 13:54:15 -0400

Quoted 2 lines

what is the a preferred/correct method to map and unmap memory temporarily?

Allocate a virtual memory area using vmalloc and then save and modify the pmd/pgd/pte to point to the physical memory you want. To unmap, just undo the previous steps.

Signature · 7 lines
Timur Tabi - [email protected]
Interactive Silicon - http://www.interactivesi.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/
#2 lore raw

Hi,

Quoted 9 lines · Timur Tabi

** Reply to message from cohutta <[email protected]> on Tue, 5 Jun 2001 13:54:15 -0400

Quoted 2 lines

what is the a preferred/correct method to map and unmap memory temporarily?

Allocate a virtual memory area using vmalloc and then save and modify the pmd/pgd/pte to point to the physical memory you want. To unmap, just undo the previous steps.

ioremap() is there for exactly that purpose. Playing with page tables directly is most definitely frowned upon and is unlikely to lead to portable code. ioremap() will take a physical address and return the new virtual address, and ioremap_nocache() additionally specifies the memory as being uncachable (via page table flags) so that it can be used for PCI control register remapping.

Both functions are declared in <asm/io.h> and are available on both 2.2 and 2.4.

Cheers,
Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#3 lore raw

** Reply to message from "Stephen C. Tweedie" <[email protected]> on Tue, 5 Jun 2001 19:41:36 +0100

Quoted 5 lines
Quoted 3 lines

Allocate a virtual memory area using vmalloc and then save and modify the pmd/pgd/pte to point to the physical memory you want. To unmap, just undo the previous steps.

ioremap() is there for exactly that purpose.

True, except that you can't use ioremap on normal memory, which is what I assumed he was trying to do.

Signature · 7 lines
Timur Tabi - [email protected]
Interactive Silicon - http://www.interactivesi.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/
#4 lore raw

Hi,

Quoted 8 lines · Timur Tabi
Quoted 5 lines
Quoted 3 lines

Allocate a virtual memory area using vmalloc and then save and modify the pmd/pgd/pte to point to the physical memory you want. To unmap, just undo the previous steps.

ioremap() is there for exactly that purpose.

True, except that you can't use ioremap on normal memory, which is what I assumed he was trying to do.

Normal memory is identity-mapped very early in boot anyway (except for highmem on large Intel boxes, that is, and kmap() works for that.)

--Stephen
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/