Hacker News new | ask | show | jobs
by ekr 4676 days ago
I haven't looked through it, but it probably means that you can access individual physical bytes in memory by using their physical address (there's a one to one correspondence between the physical address and the logical address of a byte).

I'm not exactly sure how that is achieved, as far as I know, in order to switch to long mode, you need to have enabled paging.

I've been myself looking to start my own OS (protected mode), but it will probably be a unix code. What this guy has done obviously deserves a lot of admiration.

2 comments

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...

Identity mapping refers to how the page tables are set up. It's hardly at odds with paging. The term doesn't even make much sense if paging isn't enabled.