News for hackers. Stuff that matters.
Re:x86 Paging Tutorial by kruhft on Thursday March 02, 2017 @12:58PM (#13776416)
Relevant: "Ask HN: Would you design a modern CPU with virtual memory support?"

https://news.ycombinator.com/item?id=13775321

Re:x86 Paging Tutorial by bogomipz on Thursday March 02, 2017 @12:22PM (#13775975)
The author mentions:

> "In any case, the OS needs to know which address generated the Page Fault to be able to deal with the problem. This is why the nice IA32 developers set the value of cr2 to that address whenever a Page Fault occurs. The exception handler can then just look into cr2 to get the address."

The CR3 register holds address of the page table for the currently executing process and CR3 gets updated on every context switch.

Did they mean CR3? If not what is CR2? I am not familiar with the CR2 register and its significance in demand paging systems.

Re:x86 Paging Tutorial by DSMan195276 on Thursday March 02, 2017 @02:30PM (#13777372)
CR2 holds the address that the access was attempted on that faulted. So for example, if you attempt to access 0x23456789 and that faults because there is no page, CR2 contains that 0x23456789. But that might not be an "invalid" address - the OS may simply not have mapped the page in yet (Which is what happens with dynamic paging). So the OS checks the CR2, and if it is valid address the OS maps the correct page in and then returns back to the code that the program attempted to execute (Which now works).
Re:x86 Paging Tutorial by munificent on Thursday March 02, 2017 @12:43PM (#13776234)
I read it as cr2 holds the logical address that you were looking up when the page fault occurred.
Re:x86 Paging Tutorial by sigjuice on Thursday March 02, 2017 @04:49PM (#13778568)
According to "Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 3A:", http://www.intel.com/Assets/en_US/PDF/manual/253668.pdf

CR2 — Contains the page-fault linear address (the linear address that caused a page fault)

Re:x86 Paging Tutorial by Drisc0 on Thursday March 02, 2017 @01:58PM (#13777050)
This would have been useful when I was still in school
Re:x86 Paging Tutorial by fsaintjacques on Thursday March 02, 2017 @08:08AM (#13773734)
Ciro, your work is amazing.
Re:x86 Paging Tutorial by cirosantilli on Sunday March 05, 2017 @07:58AM (#13795811)
Thanks :-) Or maybe, thank my unemployment at the time :-)
Re:x86 Paging Tutorial by TempleOS on Thursday March 02, 2017 @07:30AM (#13773565)
TempleOS has two main features. Ring-0-only and no paging. (It's identity mapped because long mode requires it.)

Linux and Windows have ring 3 and paging.

Re:x86 Paging Tutorial by Retr0spectrum on Thursday March 02, 2017 @01:48PM (#13776948)
That's great, but I think it's mainly because TempleOS has different target use cases to other modern OSs.
Re:x86 Paging Tutorial by aanm1988 on Friday March 03, 2017 @05:53AM (#13782016)
> It's identity mapped because long mode requires it

How can long mode require identity mapping? Do you mean for ring 0 code?

For some reason I always thought templeOS was real mode.