OSDev.org
https://forum.osdev.org/

The general workflow to enable memory management
https://forum.osdev.org/viewtopic.php?f=1&t=36499
Page 2 of 2

Author:  kzinti [ Fri Feb 14, 2020 10:13 am ]
Post subject:  Re: The general workflow to enable memory management

You basically have to map your page tables somewhere in your page tables so that you can access them from virtual addresses.

You want to map them in your kernel address range, so somewhere at or above 0xC0000000. You will want to do this before you remove the identity mapping of the first 4MB.

Author:  sunnysideup [ Fri Feb 14, 2020 11:27 am ]
Post subject:  Re: The general workflow to enable memory management

Or can I just keep the identity map? It seems simpler right?

Any disadvantage of keeping an identity map?

Author:  Octacone [ Fri Feb 14, 2020 1:04 pm ]
Post subject:  Re: The general workflow to enable memory management

sunnysideup wrote:
Or can I just keep the identity map? It seems simpler right?

Any disadvantage of keeping an identity map?


Yeah, because you're pretty basically ignoring the whole point of paging.
Also if your kernel is loaded at 1 MB then you won't be able to load your programs at lower addresses, such as zero.
Also don't just map 4 MB and call it a day.
You should map just enough, according to the size of your kernel. Or you will run into random errors once your code expands beyond 4 MB. Just something to keep in mind for the future.
For sure you can have certain sections identity mapped but the whole kernel, better not.
Didn't read the whole topic, just giving some general heads up.

Author:  sunnysideup [ Fri Feb 14, 2020 1:17 pm ]
Post subject:  Re: The general workflow to enable memory management

Thanks for the heads up!

However, I'm not identity mapping the kernel exactly... I'm identity mapping 0 - 4M, and mapping the kernel at 0xC0000000.... There's some overlap, sure, Eg. 0x100000 and 0xC0000000 are the same thing...
I was wondering this identity mapping should be temporary or permanent

Edit: I was doing a bit of reading, and it looks like 0-4M identity map could be a bad idea in the long run as user mode programs usually 'want' to run at virtual address 0.
Also, I'm guessing that the permanent higher half kernel map (where the kernel is permanently mapped at 0xC0000000 (or 2Gb)) is really useful for system calls, where the ISR will have linear address in the kernel space. Is this right?

Page 2 of 2 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/