Page 1 of 1

understanding paging

Posted: Tue May 25, 2021 5:18 pm
by newosdeveloper2021
How do you setup paging, so you can page anywhere.. I'm wondering if you can page and "un-page" memory?

I'm wondering about any POC of properly setting up paging on x64 so I can understand properly

If I turn on paging, would the CPU only recognize addresses that map to a page? Like no physical addresses? As in paging the entire RAM or just certain parts?

I'm struggling to understand paging

Re: understanding paging

Posted: Tue May 25, 2021 5:37 pm
by Octocontrabass
newosdeveloper2021 wrote:I'm wondering if you can page and "un-page" memory?
Yes, you are free to add and remove mappings at any time. On x86, you need to make sure you flush the TLB appropriately.
newosdeveloper2021 wrote:If I turn on paging, would the CPU only recognize addresses that map to a page? Like no physical addresses?
It depends on the CPU. On x86, turning on paging means only the page tables use physical addresses, and everything else uses virtual addresses. In order to read or write data at a virtual address, your page tables have to specify which physical address to use for that virtual address. You don't have to specify a physical address for every virtual address.
newosdeveloper2021 wrote:As in paging the entire RAM or just certain parts?
It's up to you. Some 64-bit operating systems map all of RAM somewhere only the kernel can access. Others only map memory that they're using, and leave unused memory unmapped.