paging poc

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
newosdeveloper2021
Posts: 15
Joined: Sat May 01, 2021 8:47 pm

paging poc

Post by newosdeveloper2021 »

any poc of x64 paging? im struggling
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: paging poc

Post by neon »

Hi,

You might get faster responses if you gave us an idea of what you were not sure about with respect to paging. It may also be helpful for you to describe how you believe paging works so that we can discuss any potential issues with respect to understanding. We can probably make some guesses, however am sure many people here will be willing to help clarify any doubts on the subject matter. Paging is one topic where understanding how it works is critical to being able to successful implement and work with it: if you are trying to copy from a tutorial here, dont: know how it works before writing any code.

You might get lucky with getting a poc, not sure -- but a lot of folks here are happy to provide help if you provide us some details to work with.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Skyz
Posts: 11
Joined: Tue Mar 16, 2021 2:00 pm
Libera.chat IRC: Skyz
Contact:

Re: paging poc

Post by Skyz »

I'm also unsure how paging works.
Image

Plan 9 | ReactOS Hybrid Kernel_Preview
http://woodmann.com/fravia/godwin1.htm
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: paging poc

Post by nullplan »

Skyz wrote:I'm also unsure how paging works.
Again, this is way too open-ended a question to be answered in any meaningful way. I could read the manual to you, but you could also just do that on your own time. What specific thing are you having a problem with? Because as it stands now it looks like you didn't even try to read the documentation.
Carpe diem!
newosdeveloper2021
Posts: 15
Joined: Sat May 01, 2021 8:47 pm

Re: paging poc

Post by newosdeveloper2021 »

nullplan wrote:
Skyz wrote:I'm also unsure how paging works.
Again, this is way too open-ended a question to be answered in any meaningful way. I could read the manual to you, but you could also just do that on your own time. What specific thing are you having a problem with? Because as it stands now it looks like you didn't even try to read the documentation.
I read SDM, but I'd use SDM and a POC better to understand..

Do I have to make a frame for everything or just what i wanna page, is there any alternative to paging?
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: paging poc

Post by Octocontrabass »

newosdeveloper2021 wrote:Do I have to make a frame for everything or just what i wanna page,
What do you mean? In long mode, all physical memory is divided into frames. If you want to access one of those frames, you have to map it to a page to give it a virtual address.
newosdeveloper2021 wrote:is there any alternative to paging?
No. Paging is mandatory in long mode.
User avatar
Skyz
Posts: 11
Joined: Tue Mar 16, 2021 2:00 pm
Libera.chat IRC: Skyz
Contact:

Re: paging poc

Post by Skyz »

Octocontrabass wrote:
newosdeveloper2021 wrote:Do I have to make a frame for everything or just what i wanna page,
What do you mean? In long mode, all physical memory is divided into frames. If you want to access one of those frames, you have to map it to a page to give it a virtual address.
newosdeveloper2021 wrote:is there any alternative to paging?
No. Paging is mandatory in long mode.
Can you just make a new mode like short mode and avoid paging?
Last edited by Skyz on Mon Jun 07, 2021 12:25 pm, edited 1 time in total.
Image

Plan 9 | ReactOS Hybrid Kernel_Preview
http://woodmann.com/fravia/godwin1.htm
thewrongchristian
Member
Member
Posts: 426
Joined: Tue Apr 03, 2018 2:44 am

Re: paging poc

Post by thewrongchristian »

Skyz wrote:Is there a mode that it can be avoided, what's the benefit of running paging. I don't see any os using applications.
x86 protected mode doesn't use paging until it is explicitly enabled, so basic real mode and protected mode can both be used without paging.

But paging brings massive benefits:

- Simplifies process separation. With a page table per isolated address space, it is easy to control what memory is exclusively or shared mapped at a per-page per process level.
- Simplifies memory allocation. For a process logical address space, the allocated physical memory can be anywhere, it need not be contiguous. This is the basis of virtual memory, and is very difficult to do with segmentation, because contiguous virtual memory also has to be contiguous in physical memory using base/limit segmentation.
- Reduces memory usage. Because virtual memory pages can be unmapped, and mapped in on demand, not all memory a process needs has to be actually resident. Demand paging allocates memory to address spaces as it's needed, and a process rarely needs all its memory all of the time, so some can be discarded when not in use and (re-)read from disk as required.

Personally, I see paging and virtual memory management as considerably more useful and fundamental for operating systems than, for example, file systems. A minimal kernel needs to implement, if it is providing protected address spaces at all, a paging mechanism. The only systems that don't are simple embedded kernels, which provide essentially a threaded runtime to some dedicated application, which might not even have a MMU. Think IoT.

Otherwise, for a general purpose kernel, paging is fundamental, and no general purpose CPUs in common use (except x86) provide anything other than a page based MMU. Even single address space kernels benefit from paging if the CPU provides it.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: paging poc

Post by Octocontrabass »

Skyz wrote:Can you just make a new mode like short mode and avoid paging?
You can't make a new mode. You can use real mode or protected mode if you want to avoid paging. Why do you want to avoid paging?
Post Reply