Subject: KVA pitfall in initarm()
To: None <port-arm@netbsd.org>
From: Toru Nishimura <locore32@gaea.ocn.ne.jp>
List: port-arm
Date: 12/26/2004 20:53:53
Many ARM ports arrange KVA for text and data segments as two
adjuscent address ranges in the following way;
{
extern char etext[], _end[];
size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE;
u_int logical;
textsize = (textsize + PGOFSET) & ~PGOFSET;
totalsize = (totalsize + PGOFSET) & ~PGOFSET;
logical = boofoowoo; /* offset of kernel in RAM */
logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
physical_start + logical, textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
logical += pmap_map_chunk(l1pagetable, KERNEL_BASE + logical,
physical_start + logical, totalsize - textsize,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
}
This is a potetial pitfall for the case when there is a hole (segment alignment)
between text segment and data segment. Data segment would result in
be mapped incorrect KVA (it badly bited me, indeed). The right way is to map
data segment at its own offset, not the end of text. It, however, doesn't make
sense to map two since they have an idential pmap attributes. So, I propose
here to have a single pmap_map_chunk() call to cover text+data instead of two
calls. Note that the code above also does short for the case when ELF symbol
table is available next to _end address.
Toru Nishimura/ALKYL Technology