Skip to content

Instantly share code, notes, and snippets.

@kaiwan
Last active August 2, 2020 03:41
Show Gist options
  • Save kaiwan/59d11cebd48b7e234697bdb4e6d0ab96 to your computer and use it in GitHub Desktop.
Save kaiwan/59d11cebd48b7e234697bdb4e6d0ab96 to your computer and use it in GitHub Desktop.
Summary of the VAS layout on the Linux OS for different CPUs
Aarch64
DUT: Raspberry Pi 3B+
- via the LLKD ch7/show_kernel_seg LKM:
[...]
[ 4171.867794] llkd_minsysinfo(): minimal platform info:
CPU: Aarch64, little-endian; 64-bit OS.
[ 4171.867798]
Some Kernel Details [by decreasing address]
+-------------------------------------------------------------+
[ 4171.867804] | [ . . . ] |
|fixmap region: 0xfffffdfffe5fb000 - 0xfffffdfffea00000 | [ 4 MB] |
[ 4171.867809] |module region: 0xffff800008000000 - 0xffff800010000000 | [ 128 MB] |
[ 4171.867814] |vmalloc region: 0xffff800010000000 - 0xfffffdffbfff0000 | [132119295 MB = 129022 GB]
[ 4171.867820] |lowmem region: 0xffff000000000000 - 0xffff00003b400000 | [ 948 MB = 0 GB]
| (above:PAGE_OFFSET - highmem) |
[ 4171.867824] | [ . . . ] |
[ 4171.867836] +------------ Above is kernel-seg; below, user VAS ----------+
| [ . . . ] |
|Process environment 0x0000ffffccab68d3 - 0x0000ffffccab6fe7 | [ 1812 bytes]
| arguments 0x0000ffffccab68a8 - 0x0000ffffccab68d3 | [ 43 bytes]
| stack start 0x0000ffffccab58d0 |
| heap segment 0x0000aaaad5c9f000 - 0x0000aaaad5cc0000 | [ 135168 bytes]
|static data segment 0x0000aaaacc5eeca0 - 0x0000aaaacc5f00c0 | [ 5152 bytes]
| text segment 0x0000aaaacc5b8000 - 0x0000aaaacc5de614 | [ 157204 bytes]
| [ . . . ] |
+-------------------------------------------------------------+
[ 4171.867842] Above: TASK_SIZE = 0x0001000000000000 size of userland [ 262144 GB]
# userspace memory regions (VMAs) = 35
Above statistics are wrt 'current' thread (see below):
[ 4171.867850] 003) insmod :29755 | ...0 /* show_userspace_info() */
rpi64 show_kernel_seg $
---
Via the 'procmap' util:
rpi64 procmap $ ./procmap --pid=3979 --verbose
[...]
Detected machine type: ARM-64, 64-bit system & OS
--------------------------------------------------
[v] System details detected ::
--------------------------------------------------
FIXADDR_START = fffffdfffe5fb000
MODULES_VADDR = ffff800008000000
MODULES_END = ffff800010000000
VMALLOC_START = ffff800010000000
VMALLOC_END = fffffdffbfff0000
PAGE_OFFSET = ffff000000000000
high_memory = ffff00003b400000
TASK_SIZE = 0001000000000000
ARCH = Aarch64
IS_64_BIT = 1
PAGE_SIZE = 4096
KERNEL_VAS_SIZE_TB = 256
USER_VAS_SIZE_TB = 256
KERNEL_VAS_SIZE = 281474976710656
USER_VAS_SIZE = 281474976710656
HIGHEST_KVA = 0xffffffffffffffff
START_KVA = ffff000000000000
START_KVA_DEC = 18446462598732840960
NONCANONICAL_REG_SIZE_HEX = 0xfffe000000000000
NONCANONICAL_REG_SIZE = 18446181123756130304
END_UVA = ffffffffffff
END_UVA_DEC = 281474976710655
START_UVA = 0x0
--------------------------------------------------
[...]
<< the actual 'map' is shown seperately as the 'stitched' screenshots file below >>
---
[=====--- End memory map for 3979:bash ---=====]
[Pathname: /usr/bin/bash ]
[v] sudo ls -l /usr/bin/bash
-rwxr-xr-x 1 root root 1215072 Feb 25 12:03 /usr/bin/bash
[v] sudo file /usr/bin/bash
/usr/bin/bash: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=2ee5bcc1055c34df331b2493918ee6bb7119df1c, for GNU/Linux 3.7.0, stripped
[v] sudo ldd /usr/bin/bash
linux-vdso.so.1 (0x0000ffff895c5000)
libtinfo.so.6 => /lib/aarch64-linux-gnu/libtinfo.so.6 (0x0000ffff89415000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffff89401000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff89290000)
/lib/ld-linux-aarch64.so.1 (0x0000ffff89595000)
=== Statistics ===
Total Kernel VAS (Virtual Address Space):
281474976710656 bytes = 274877906944.000000 KB = 268435456.000000 MB = 262144.000000 GB = 256.000000 TB
Total User VAS (Virtual Address Space):
281474976710656 bytes = 274877906944.000000 KB = 268435456.000000 MB = 262144.000000 GB = 256.000000 TB
=== Statistics for Userspace: ===
For PID 3979:bash
44 VMAs (segments or mappings), 10 sparse regions (includes NULL trap page)
Total User VAS that is Sparse memory:
422212640657407 bytes = 412317031891.999023 KB = 402653351.457030 MB = 393216.163532 GB = 384.000159 TB
i.e. 150.000062%
Total User VAS that's valid (mapped) memory:
11100160 bytes = 10840.000000 KB = 10.585937 MB
i.e. 0.000004%
===
Total reported memory (RAM) on this system:
952328192 bytes = 930008.000000 KB = 908.210937 MB
Memory Usage stats for process PID 3979:bash
Via ps(1):
%MEM=0 VSZ=10840 KB RSS=5764 KB
[v] smem(8) not installed? skipping...
rpi64 procmap $
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment