AMD64 Canonical Address question

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
tom9876543
Member
Member
Posts: 170
Joined: Wed Jul 18, 2007 5:51 am

AMD64 Canonical Address question

Post 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?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: AMD64 Canonical Address question

Post 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
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: AMD64 Canonical Address question

Post 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.
tom9876543
Member
Member
Posts: 170
Joined: Wed Jul 18, 2007 5:51 am

Re: AMD64 Canonical Address question

Post 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 ?
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: AMD64 Canonical Address question

Post 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.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: AMD64 Canonical Address question

Post 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 ;-))
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: AMD64 Canonical Address question

Post 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.
Post Reply