On x86 architecture, why are there fewer bits for virtual address space than physical

64-bitcomputer-architecturememory

I was reading this article on 64 bit computing, and it mentions:

For example, the AMD64 architecture as of 2011 allowed 52 bits for physical memory and 48 bits for virtual memory

I would think that it would make more sense to allow for more virtual memory than physical memory, so why is it actually the other way around?

Bonus question: What does it mean to "allow" for 52 or 48 bits on a 64 bit architecture? What are the other bits used for?

Best Answer

Here is a picture of an AMD64 page table (from the AMD Architecture Programmer's Guide, Vol. 2, Rev 3.23, 2013, page 132).

AMD64 Longmode page table

The "natural" size of a page in AMD64 architecture is 212=4096 bytes. (There are modes where you can have 221=2Mbyte pages, but we're going to ignore them for now.)

Each Page-Table Entry (PTE) (or, depending on level called PDE, PDPE or PML4E) is 64 bits = 23 bytes. So there are 29 entries per page. So 4 levels of page table gets you 4x9+12=48 bits of virtual address per process. Walking the page table is expensive, so they won't expand to 5 or 6 levels unless/until there is consumer demand.

I'm not sure why they decided on a 52-bit physical address limit. This can be extended up to 63-bits in the future. At October 2013 prices (about 1US$/Gigabit for 4Gbit chips) it would cost over 32,000,000.00 US$ to build a 252 byte memory, so it will be a while before there is any significant demand to increase the physical address limit. There are all sorts of reasons why you want to keep physical addresses as small as possible: the TLB and cache tags have to hold physical addresses, for example.

It's not necessarily backwards that there is more physical memory than virtual. Virtual memory is per process while the physical memory is shared by all processes. So a server with 48-bit virtual addresses and 252 bytes of memory could support 16 simultaneous processes and still guarantee not to need to swap.

Related Question