[NSWI004] MIPS specifics wrt virtual memory

Tomáš Drozdík drozdik.tomas at gmail.com
Sun Dec 29 01:55:33 CET 2019


Hi,

I was trying to grasp the notion of how virtual address spaces work on
MIPS but I'm missing something.

AFAIK so far we have been working in virtual addresses corresponding
to kseg0 i.e. range 0x8000_0000 - 0xA000_0000. The initial TBL
configuration is therefore, I presume, filled with 32 pages which
corresponds to memory limits set for tests.

The assignment says that we shall implement page allocator inside
512MB in kseg0 and on the top of that implement a heap allocator which
is just a modified version of our previous allocator. In addition to
that we shall implement a separate structure for mapping virtual
address spaces of each thread to some physical addresses in kseg0.

Therefore our page allocator would have some internal static data
structure which would store status of pages in kseg0 and page_alloc
would return physical address (i.e. virtual address from kseg0) of
allocated pages. On the top of that a heap allocator would allocate
pages from page allocator and work in that space i.e. kseg0. However
now that I add different address spaces to this i.e. new address space
for each process and even kernel one how can I make kernel heap
allocator work, since modifications to TLB would break access to it
form other threads not sharing the same AS.

I thought that in general paging should have access to physical memory
i.e. know how big memory is and what pages are allocated to which
process in its page table. Then a page allocator would return a
virtual address for a page for a given process which made the request
and a heap allocator can work on top of that in terms of virtual
addresses and I'm not sure how a kernel allocator should work in this
context.

Does this have to do with unmapped state of kseg0 and if it does what
does the TLB look like initially and how does it behave when it
encounters an address from this segment?

Next I'm not sure how is TLB exception handled, does it go to function
handle_general_exception with some special code (I found that codes
1-3 are reserved for this) and then we call tlb_refill or is it
somehow "hardwired" (in terms of address space) to where this handler
code shall be and we don't need to care about it in
handle_general_exception?

Thank you for the help.

Sincerly
Tomáš Drozdík


More information about the NSWI004 mailing list