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

11

3

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?

dougvk

Posted 2013-10-06T14:50:57.610

Reputation: 317

For x86, the unused VA bits must be a sign extension of the MSbit of the VA. (ARM AArch64 provides the option of allowing 8 MSbits to be ignored by hardware so that they could be conveniently used for tags. Azul Systems Vega processor--part of a Java appliance--provided 16 bits of VA to be used for tags.) In the page table, reserved PA bits must be zero (primarily to ensure that software does not attempt to use them and break compatibility with later hardware). – Paul A. Clayton – 2013-10-18T23:38:04.400

Answers

11

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.

Wandering Logic

Posted 2013-10-06T14:50:57.610

Reputation: 496

"This can be extended up to 63-bits in the future." Well, no, not without changing the page table structure. As it is, bits 52 through 62 of the PxE are reserved for operating system use. And OSs are using them (Windows uses that field for a "working set list index"), so the processor architects are not free to expand the PFN field into them. It would of course be possible to have a PAE-like option in the future that would change the PT structure so as to allow more bits of PFN, but that would be a significant architectural change. – Jamie Hanrahan – 2014-11-07T04:50:31.030

It might be worth noting that computer architects have learned to require the upper bits to used by hardware, usually by sign extension to fit the common use of negative addresses for the OS ("What are the other bits used for?"). Also, with Ln directory entry caching, a 5-level table need not be fully walked most of the time. PTE bits 52:62 are reserved for software, so cannot be used for physical addresses without breaking compatibility, limiting 4KiB pages to 52-bits of PA. Also, Linus Torvalds famously rages against PAE (VA>PA seems to simplify "traditional" OS design). – Paul A. Clayton – 2013-10-18T22:58:35.643

3

A few points to consider, physical RAM is expensive. Sure 16 GB is cheaper now that 4GB was only a few years ago, but 2^64 (16 exabytes) ridiculously large.

So AMD's extensions of the x86 for x64 "allowed" up to 2^52 by limiting the registers. This does two things, lowers the cost of processors and improves performance. More registers that are not used means that there is a lot of empty space that must still be taken into account during operations.

And, in case you are not a math guy... The difference between three sizes is huge! I am no math guru, but by decimal 52 bit is about .02% of 64bit. 48 bit is 6% of 52. (someone check my math?)

As for why AMD allowed more physical RAM then virtual, the article states it is because AMD was thinking of servers. Servers need large amounts of physical RAM. Virtual RAM is too slow to support the average server applications for hundreds or thousands of employees.

My own thoughts: We have left the time when RAM was tiny, and hard drives had to support RAM. The price in RAM has fallen to a point where the average persona can put in more than enough RAM. Take typical applications, like Office which requires 1-2GB of RAM. My computer 7 years ago could handle that. Although with read and write speeds to disk, I would hope I never had to retrieve a 7GB file from virtual memory (using the old PM * 2.5 philosophy).

I also can only assume AMD wanted to leave room for registers that use the physical RAMs registers, like RAM on integrated GPUs.

Austin T French

Posted 2013-10-06T14:50:57.610

Reputation: 9 766