Page 1 of 1

AMD64 Canonical Address question

Posted: Fri May 21, 2010 5:30 am
by tom9876543
Hello

As you probably know AMD decided that only 48 bit addresses are supported. As there are 64 bits the other 16bits are forced to be the same as the 47th bit. So you end up with virtual addresses 0000 0000 0000 0000 - 0000 7FFF FFFF FFFF FFFF and FFFF 8000 0000 0000 0000 - FFFF FFFF FFFF FFFF . This leaves a big hole in the middle.

My question is why didn't they just simply say bits 48 - 62 must always be zero???? I would have thought virtual address space of 0000 0000 0000 0000 - 0000 7FFF FFFF FFFF FFFF and 1000 0000 0000 0000 - 1000 7FFF FFFF FFFF FFFF was much more logical.

Of course this is very theoretical. The important thing is a 48 bit user program will work with any future 64 bit kernel, that is covered either way.

Is there any specific reason for canonical addresses that i have missed?

Re: AMD64 Canonical Address question

Posted: Fri May 21, 2010 6:05 am
by AJ
Hi,

The canonical address form, as you say, splits the address space in to a logical higher and lower half. Here, AMD have taken in to account the memory layout of most modern operating systems.

If your virtual kernel memory space starts at the top of the address space, you will be able to use the same memory layout whether the current CPU can address 48 bits, 64 bits or anything in between. The lower, user memory space simply expands upwards over CPU generations.

Cheers,
Adam

Re: AMD64 Canonical Address question

Posted: Fri May 21, 2010 6:38 am
by qw
AJ wrote:The canonical address form, as you say, splits the address space in to a logical higher and lower half. Here, AMD have taken in to account the memory layout of most modern operating systems.
And this is easily achieved by sign-extending the 48 to 64 bits.

Re: AMD64 Canonical Address question

Posted: Sat May 22, 2010 4:24 pm
by tom9876543
I am confused.

Take 32bit as an example.

I thought Windows / Linux starts at the 2GB boundary and grows UPWARDS?
Or they start at the 3GB boundary and grow upwards.

So wouldn't it be more logical for 64bit kernels to start at 0x1000 0000 0000 0000 instead of 0xFFFF 8000 0000 0000 ?

Re: AMD64 Canonical Address question

Posted: Sat May 22, 2010 6:36 pm
by JackScott
I think AMD were gambling on the fact that even considering today's bloated software, it's going to take a while before a kernel and it's drivers require (by my shockingly bad maths) 32TiB of memory.

Re: AMD64 Canonical Address question

Posted: Sun May 23, 2010 5:04 am
by Owen
The idea is that user mode occupy the lower half of the address space and kernel mode the upper half. Hence, there is always a constant boundary between user and kernel modes: 0x8000:0000:0000:0000 (Colons added for readability ;-))

Re: AMD64 Canonical Address question

Posted: Sun May 23, 2010 8:15 am
by qw
tom9876543 wrote:I thought Windows / Linux starts at the 2GB boundary and grows UPWARDS?
Or they start at the 3GB boundary and grow upwards.

So wouldn't it be more logical for 64bit kernels to start at 0x1000 0000 0000 0000 instead of 0xFFFF 8000 0000 0000 ?
What do you mean with a kernel growing upwards? That the upper half is reserved for the kernel doesn't mean that it must be loaded at the boundary exactly.