VMM/Paging

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
GhostedGaming
Member
Member
Posts: 35
Joined: Wed Jul 02, 2025 11:46 pm
Libera.chat IRC: GhostedGaming

VMM/Paging

Post by GhostedGaming »

So ive been wanting to implement paging using limine but i have no idea where to start and looking at this https://wiki.osdev.org/Paging only confuses me even more if i could get help on where to get started that would be really nice
here is my repo if you would like to look at it https://github.com/GhostedGaming/eucalypt-dos
User avatar
iansjack
Member
Member
Posts: 4908
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: VMM/Paging

Post by iansjack »

There’s a good introduction to paging here: https://os.phil-opp.com/paging-introduction/ It’s written with Rust in mind, so you can’t just cut and paste the code (which is a good thing), but it’s a good explanation of the concepts involved.
User avatar
h3tR
Posts: 9
Joined: Fri Mar 21, 2025 10:23 am
GitHub: https://github.com/h3tR

Re: VMM/Paging

Post by h3tR »

What I got from the limine specs when I looked into it for my own implementation is that Limine maps the entire memorymap to the offset found in the hhdm response. Most of it would have the present and writable flags which really isn’t ideal in the long run. Only exception on this iirc is the kernel executable which is mapped at the virtual base found in the executable address response.

This makes it easy to set up initial structures for your frame, virtual page and heap allocators but you most likely should unmap everything that you aren’t using and change the flags to something appropriate on the things you do want to keep. Another thing to keep in mind is that from my experience limine maps huge pages which isn’t ideal everywhere. If you’d want to use other page sizes instead you’re gonna need to remap that as well.
GhostedGaming
Member
Member
Posts: 35
Joined: Wed Jul 02, 2025 11:46 pm
Libera.chat IRC: GhostedGaming

Re: VMM/Paging

Post by GhostedGaming »

Would it be ok to just have every page 4kb or would i have to vary the size depending on what its for?
sounds
Member
Member
Posts: 136
Joined: Sat Feb 04, 2012 5:03 pm

Re: VMM/Paging

Post by sounds »

It's fine to design your system to use only 4k pages. After all, it's normal and expected that larger allocations would be built by mapping pages next to each other, where the pages are all the system size.

Linux used to do it, and it worked fine. Staying focused on the minimal features required to get your page table implemented will help you get to a working os fast.
GhostedGaming
Member
Member
Posts: 35
Joined: Wed Jul 02, 2025 11:46 pm
Libera.chat IRC: GhostedGaming

Re: VMM/Paging

Post by GhostedGaming »

iansjack wrote: Wed Dec 24, 2025 12:32 am There’s a good introduction to paging here: https://os.phil-opp.com/paging-introduction/ It’s written with Rust in mind, so you can’t just cut and paste the code (which is a good thing), but it’s a good explanation of the concepts involved.
Will i be able to use it with x86_64 i know there are a few differences when it comes to paging on both but i dont know how big the differences are
User avatar
iansjack
Member
Member
Posts: 4908
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: VMM/Paging

Post by iansjack »

My link references the x86_64. In addition you should look at the Intel (and/or AMD) programmer’s reference manuals.
bunny
Posts: 10
Joined: Mon Dec 22, 2025 11:34 am
Libera.chat IRC: bunny
Location: Norway

Re: VMM/Paging

Post by bunny »

Did you get the info you needed to keep going with paging? Im not nearly as smart as some of these other posters but I have been able to get past paging, and fairly recently too, so I might be able to offer tips that helped me. Also might I plug my own OS professor's lecture notes, paging is near the bottom, but if you like OS dev then you should honestly read everything he has (again Im biased lol) https://sites.cs.ucsb.edu/~rich/class/c ... index.html

happy os-dev-ing! <3
GhostedGaming
Member
Member
Posts: 35
Joined: Wed Jul 02, 2025 11:46 pm
Libera.chat IRC: GhostedGaming

Re: VMM/Paging

Post by GhostedGaming »

bunny wrote: Sun Jan 04, 2026 10:35 am Did you get the info you needed to keep going with paging? Im not nearly as smart as some of these other posters but I have been able to get past paging, and fairly recently too, so I might be able to offer tips that helped me. Also might I plug my own OS professor's lecture notes, paging is near the bottom, but if you like OS dev then you should honestly read everything he has (again Im biased lol) https://sites.cs.ucsb.edu/~rich/class/c ... index.html

happy os-dev-ing! <3
a little bit I still don't understand even though memory is just a bitmap array
bunny
Posts: 10
Joined: Mon Dec 22, 2025 11:34 am
Libera.chat IRC: bunny
Location: Norway

Re: VMM/Paging

Post by bunny »

GhostedGaming wrote: Tue Jan 06, 2026 10:01 am a little bit I still don't understand even though memory is just a bitmap array
I mean, its a bitmap array in the sense that you can think of it as a single logically contiguous region of storage but my intuition says the way you're thinking of it might be confusing you. Physical memory is a bunch of hardware single bit storage devices strung together and a physical address is how the memory controllers etc know where to find your data. When building an OS, aside from being able to allocate physical memory, we dont really want to mess around with physical addresses and so we have this layer of abstraction, virtual addresses, to help. Paging plays into this and solves some specific problems with using virtual addresses and honestly with memory in general. While there are loads of great resources out there if you would like to ask any specific questions I'll happily do my best to help you. In my humble opinion virtual memory is one of, if not the, most important things to fully understand for OS Dev, so its definitely worth pausing now to really figure it out before you get too far and have major problems.
~ Bunny <3
~ she/her
Post Reply