From the /proc/cpuinfo we can see that currently Linux only use 48 bit virtual address size. According to the /Documentation/x86/x86_64/mm.txt, the kernel virtual address begins at ffff800000000000 - ffff80ffffffffff (=40 bits) guard hole. How to understand that? I see that there is a line read hole caused by [48:63] sign extension. Does it mean that kernel will only interpreter the low 48 bit and ignore the high 16 bit when it encounters a virtual address?
The sign-extension is due to the fact that x86-64 only uses the low-order 48 bits for addressing memory. As a precaution against programmers abusing the 16 high-order bits, the 47th bit is sign-extended. Therefore, if bit 47 is a 0, then all of bits [48:63] will also be 0, and if bit 47 is a 1, then all of bits [48:63] will be a 1. An address that has this form is called "canonical". If you try to use a non-canonical address (i.e. one where bits [48:63] != bit 47) then the hardware will raise a general protection fault.
In practice, the kernel's memory are those high addresses where the 17 high-order bits are 1, and user space memory are low memory, where the high-order bits are 0.
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