Hi all,
I'm developing a 64-bit kernel, and I'm currently rewriting my paging mechanism, after having coded a multithread scheduler that works pretty well.
I'm using the fractal method of pointing the last PML4 entry to the PML4 itself.
My question is: when I have to clone the current address space, how can I access the paging structures of the new address space from within the current address space?
Allocate pages in another address space
- AndreaOrru
- Member
- Posts: 50
- Joined: Fri Apr 25, 2008 2:50 pm
- Location: New York
Allocate pages in another address space
Close the world, txEn eht nepO
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Allocate pages in another address space
How about temporarily "fractal mapping" the other PML4 in the current address space?
- AndreaOrru
- Member
- Posts: 50
- Joined: Fri Apr 25, 2008 2:50 pm
- Location: New York
Re: Allocate pages in another address space
Pointing the next-to-last current PML4's entry to the PML4 of the new address space? That's an idea. But it is how you do it?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Allocate pages in another address space
I dont fork(), so the situation doesn't apply to me
- AndreaOrru
- Member
- Posts: 50
- Joined: Fri Apr 25, 2008 2:50 pm
- Location: New York
Re: Allocate pages in another address space
I don't fork() too, but I map the kernel in every address space, and I create a new kernel stack for each process. Even if you don't fork, you still need some way of accessing external address spaces, doesn't you?
Close the world, txEn eht nepO
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: Allocate pages in another address space
When my kernel creates a new address space, it just takes an unused page, maps it to some temporary location, zeroes the first half of that page (which is the user part in my OS), copies the upper half from the current PML4 (which is the kernel part, that is mapped into every address space), unmaps the page again and enters the physical address of the page into the CR3 field of my process structure, which keeps track of address spaces. To fill the user part with, for example, some user space, which holds an executable, the kernel switches to the new address space, allocates user space, loads the executable and switches back to the old address space. That's it - the new address space is ready to use on the next thread switch.
- AndreaOrru
- Member
- Posts: 50
- Joined: Fri Apr 25, 2008 2:50 pm
- Location: New York
Re: Allocate pages in another address space
It seems good to me. Obviously you have to make sure not to be interrupted during the process. Thanks.
Close the world, txEn eht nepO