以下内存布局信息在引导时由Linux内核在我的SoC平台上打印(带有4核Cortex-A53处理器和2.75GiB DRAM)
[ 0.000000] Memory: 2736316K/2883584K available (4796K kernel code, 488K rwdata, 1360K rodata, 448K init, 341K bss, 130884K reserved, 16384K cma-reserved) [ 0.000000] Virtual kernel memory layout: [ 0.000000] modules : 0xffffff8000000000 - 0xffffff8008000000 ( 128 MB) [ 0.000000] vmalloc : 0xffffff8008000000 - 0xffffffbebfff0000 ( 250 GB) [ 0.000000] .text : 0xffffff8008080000 - 0xffffff8008530000 ( 4800 KB) [ 0.000000] .rodata : 0xffffff8008530000 - 0xffffff8008690000 ( 1408 KB) [ 0.000000] .init : 0xffffff8008690000 - 0xffffff8008700000 ( 448 KB) [ 0.000000] .data : 0xffffff8008700000 - 0xffffff800877a200 ( 489 KB) [ 0.000000] .bss : 0xffffff800877a200 - 0xffffff80087cf76c ( 342 KB) [ 0.000000] fixed : 0xffffffbefe7fd000 - 0xffffffbefec00000 ( 4108 KB) [ 0.000000] PCI I/O : 0xffffffbefee00000 - 0xffffffbeffe00000 ( 16 MB) [ 0.000000] vmemmap : 0xffffffbf00000000 - 0xffffffc000000000 ( 4 GB maximum) [ 0.000000] 0xffffffbf00000000 - 0xffffffbf02c00000 ( 44 MB actual) [ 0.000000] memory : 0xffffffc000000000 - 0xffffffc0b0000000 ( 2816 MB)
使用:CONFIG_ARM64_PAGE_SHIFT=12
CONFIG_PGTABLE_LEVELS=3
CONFIG_ARM64_VA_BITS=39
总体虚拟内存布局:
--------------------> +--------------------------+ ffff:ffff:ffff:ffff | | | | | | ffff:ffc0:0000:0000 |----- Kernel (512G)-------| <-- PAGE_OFFSET | | | | ffff:ff80:0000:0000 | | --------------------> +--------------------------+ ffff:ff7f:ffff:ffff |//////////////////////////| |//////////////////////////| |//////////////////////////| |//////////////////////////| |//////////////////////////| |//////////////////////////| z //////////////////////// z |//////////////////////////| |//////////////////////////| |//////////////////////////| |//////////////////////////| |//////////////////////////| 0000:0080:0000:0000 |//////////////////////////| --------------------> +--------------------------+ 0000:007f:ffff:ffff | | | | | | | User (512G) | | | | | 0000:0000:0000:0000 | | --------------------> +--------------------------+
以及内核虚拟内存布局:
ffff:ffff:ffff:ffff +--------------------------+ | | | | z z | | | | ffff:ffc0:b000:0000 |--------------------------| 1:b000:0000 +------------------------+ | | | | | memory (2.75G) | | Physical DRAM (2.75G) | | | | | ffff:ffc0:0000:0000 +==========================+ <-- PAGE_OFFSET --> 1:0000:0000 +------------------------+ | | | | | | | vmemmap (4G) | | +----------------------+ | | | actual (44M) | | ffff:ffbf:0000:0000 +--------------------------+ |//////////////////////////| ffff:ffbe:ffe0:0000 +--------------------------+ | PCI I/O (16M) | ffff:ffbe:fee0:0000 +--------------------------+ |//////////////////////////| ffff:ffbe:fec0:0000 +--------------------------+ | fixed (4M) | ffff:ffbe:fe7f:d000 +--------------------------+ |//////////////////////////| ffff:ffbe:bfff:0000 +--------------------------+ | | | | | | | | | | | | z vmalloc (250G) z | | | | | | | | | | | | ffff:ff80:087c:f76c | +----------------------+ | | | .bss | | | | .data | | | | .init | | Kernel | | .rodata | | | | .text | | ffff:ff80:0808:0000 | +----------------------+ | ffff:ff80:0800:0000 +--------------------------+ | modules (128M) | ffff:ff80:0000:0000 +--------------------------+
from:
https://www.coder.work/article/1883139