Hacker News new | ask | show | jobs
by munin 4671 days ago
virtual memory makes a translation layer between virtual addresses and physical addresses.

an identity-mapping for virtual memory is then a mapping that directly translates a VA into the same PA, so VA 5 is PA 5.

the word 'paging' is overloaded to mean, to the cpu, the act of having the mmu perform translation from a physical to a virtual address, and, having the OS perform demand-loading of certain physical pages.

so non-identity mappings would happen when you switch a VA from mapping to a PA to mapping to nothing. the OS takes the contents of the PA and stores it on disk. the next time the VA is accessed, there is a 'page fault' and the data for the page is brought in to some other available PA and the VA is remapped to that PA (if the mapping exists in the stored pages on disk).

identity mappings are very simple because they remove the layer of indirection normally present in a virtual memory system. so you can run the processor in long mode, and use as much of the memory as you can address, but have none of the benefits of disk-paging, processes, separation, etc.

it's ironic because if you used processes, your system could be more performant, because your address space only contains the pages needed to run your particular task. if you run everything in r0, then you don't even need an OS. you sidestep a lot of the challenges in writing an OS at the expense of performance...