tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [Milkymist port] virtual memory management

On Feb 9, 2014, at 10:07 AM, Yann Sionneau <> 

> This seems like the easiest thing to do (because I won't have to think about 
> recursive faults) but then if I put physical addresses in my 1st level page 
> table, how does the kernel manage the page table entries?

BookE always has the MMU on and contains fixed TLB entries to make sure
all of physical ram is always mapped.

> Since the kernel runs with MMU on, using virtual addresses, it cannot 
> dereference physical pointers then it cannot add/modify/remove PTEs, right?

Wrong.  See above.  Note that on BookE, PTEs are purely a software 
construction and the H/W never reads them directly.

> I'm sure there is some kernel internal mechanism that I don't know about 
> which could help me getting the virtual address from the physical one, do you 
> know which mechanism it would be?


> Also, is it possible to make sure that everything (in kernel space) is mapped 
> so that virtual_addr = physical_addr - RAM_START_ADDR + virtual_offset
> In my case RAM_START_ADDR is 0x40000000 and I am trying to use virtual_offset 
> of 0xc0000000 (everything in my kernel ELF binary is mapped at virtual 
> address starting at 0xc0000000)
> If I can ensure that this formula is always correct I can then use a very 
> simple macro to translate "statically" a physical address to a virtual 
> address.

Not knowing how much ram you have, I can only speak in generalities. 
But in general you reserve a part of the address space for direct mapped
memory and then place the kernel about that.

For instance, you might have 512MB of RAM which you map at 0xa000.0000
and then have the kernel's mapped va space start at 0xc000.0000.

Then conversion to from PA to VA is just adding a constant while getting
the PA from a direct mapped VA is just subtraction.

> Then I have another question, who is supposed to build the kernel's page 
> table? pmap_bootstrap()?

Some part of MD code.  pmap_bootstrap() could be that.

> If so, then how do I allocate pages for that purpose? using 
> pmap_pte_pagealloc() and pmap_segtab_init() ?

usually you use pmap_steal_memory to do that.
But for mpc85xx I just allocate the kernel initial segmap in the .bss.
But the page tables were from allocated using uvm can do prebootstrap

> FYI I am using those files for my pmap:
> uvm/pmap/pmap.c
> uvm/pmap/pmap_segtab.c
> uvm/pmap/pmap_tlb.c
> I am taking inspiration from the PPC Book-E (mpc85xx) code.

Home | Main Index | Thread Index | Old Index