mapping and page tables?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
nullify

mapping and page tables?

Post by nullify »

Ok, I have a function map_page( ) which maps in a page of memory. Let's hypothetically say that map_page( ) is trying to map in a page that does not have the proper page table present. Should the function automatically create the page table, or return an error code?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:mapping and page tables?

Post by Pype.Clicker »

what about map_page(PGMAP_AUTO) ?

if the PGMAP_AUTO flag is set, then needed entries are automatically allocated (including page table, etc.) and otherwise an error is returned ;-)

So that you can use the very same function for memory allocation (if you're filling a large virtual array, PGMAP_AUTO is set ... if you're responding to a #page fault from user mode, PGMAP_AUTO is likely to be cleared).
Tim

Re:mapping and page tables?

Post by Tim »

What reason could there be for not allocating the page table if none exists? If there is no page table there, then the address is not mapped.
DarylD

Re:mapping and page tables?

Post by DarylD »

I agree with Tim, if you don't create a page table entry then it *wont* work.

My code just checks for the existence of a PTE when it crosses a PT boundary and creates if necessary.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:mapping and page tables?

Post by Pype.Clicker »

oh, i was assuming that maybe the user may have requested an allocation for a memory address he shouldn't request and maybe we shouldn't allocate in that case ...
nullify

Re:mapping and page tables?

Post by nullify »

Yeah, I initially was going to just have it automatically allocate everything, but then I thought it should prevent the user from allocating from areas that shouldn't be allocated, like Pype.Clicker mentioned. Figured I'd ask to see what's the best system of doing things. :-)

I like Pype.Clicker's idea with a PGMAP_AUTO type of flag to toggle the functionality, that's probably what I'll do.

Thanks for the help everyone.
Post Reply