cat /proc/cpuinfo on a cpu flagged -lm gives
address sizes : 36 bits physical, 48 bits virtual
the page size determined with
#include <unistd.h>
int getpagesize(void);
Gives 4096 bytes.
Using the latter information I would have thought that the system uses the least significant 12 bits of an address as offset and the rest for address translation virtual to physical via TLB and page table.
How does the information from cpuinfo relate to page size?
How does the information from cpuinfo relate to page size?
It's unrelated. The physical address size gives you basically the number of address lines the CPU has (36). The virtual address size gives you the size of the virtual address space, that is how much memory a single program can address (it's 48 bits, which means it can address more than the amount of physical memory; it could be eg. multiplicated in the virtual address space). The page size is 2^12, which means, as you noted, the rest of the virtual address bits (36, which is not the 36 in physical address space) is handled by the TLB and paging mechanism.
How does the information from cpuinfo relate to page size?
It doesn't. Page size on x86_64 can be 4k, 2M (or even 1G) regardless of the (physical or virtual) "address size".
The Wikipedia entry for x86_64
has some information about how the virtual address space works.
The mapping is not done the way you describe it, but with a four-level page table. This article on LWN.net: Four-level page tables has a run-down on how it works and why it is needed. (The article talks more about the three level map, but the fourth level is just an extension to that scheme).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With