Saturday, April 11, 2015

ARMv8 - 64 bit Linux Virtual Address Space

The ARMv8 architecture introduces 64-bit support to the ARM architecture with a focus on power-efficient implementation while maintaining compatibility with existing 32-bit software. 

With 32 bit CPU , max it can support up to 4GB of virtual address space. The problem remains even if some PAE support since it focuses on the extension of physical address space not virtual address space. 

After 64 bit CPU , it can now support up to 2 ^ 64.  But at present Linux kernel we are not utilizing all 64 bits fully. This is a very huge number.

config ARM64_VA_BITS_39
bool "39-bit"
depends on ARM64_4K_PAGES

config ARM64_VA_BITS_42
bool "42-bit"
depends on ARM64_64K_PAGES

config ARM64_VA_BITS_48
bool "48-bit"
depends on ARM64_4K_PAGES

config ARM64_VA_BITS
int
default 39 if ARM64_VA_BITS_39
default 42 if ARM64_VA_BITS_42
default 48 if ARM64_VA_BITS_48

For 64k Page size Linux  uses 42 bits.
For 4k Page size it will use 48 bit or 39 bit. Depending on Hardware design we can decide which one is prefer to choose.

Number of translation tables and maximum VA range:
4KB and 4 levels => 48-bit VA
64KB and 3 levels => 48-bit VA (top table partially populated)
4KB and 3 levels => 39-bit VA (currently used by AArch64 Linux)
64KB and 2 levels => 42-bit VA

Depending on no of VA (virtual address) bits , hardware will choose the page tables as per above points.

For 32 bit CPU , 4GB virtual space is divided in to 3GB user space and 1GB kernel space.

Lets see below How it is available at 64 bit CPU:

In present linux it uses only 40 bits for physical address space.

40-bit virtual address for both user and kernel:
--------------------------------------------------------
0000000000000000-0000007fffffffff (512GB): user
[architectural gap]
ffffff8000000000-ffffffbbfffeffff (~240MB): vmalloc
ffffffbbffff0000-ffffffbcffffffff (64KB): [guard]
ffffffbc00000000-ffffffbdffffffff (8GB): vmemmap
ffffffbe00000000-ffffffbffbffffff (~8GB): [guard]
ffffffbffc000000-ffffffbfffffffff (64MB): modules
ffffffc000000000-ffffffffffffffff (256GB): mapped RAM

All user virtual addresses have 25 leading zeros and kernel addresses have 25 leading ones. Address between user space and kernel space are not used and they are used to trap illegal accesses.

There is no high memory concept in arm64. So no kmap , fixmap . Its because it has 512GB for Kernel space. So all memory has a valid kernel virtual address.

User Space virtual address becomes 512GB. So , very huge application can build at user space.

64 bit application on Armv8 Linux Kernel:


Lets discuss 32 bit app running on Armv8 64 bit kernel in next post.....

No comments:

Post a Comment