0

I'm on 32bit machine. From what I understand, User space's address ranges from 0x00000000 to 0xbfffffff, and kernel's ranges from 0xc0000000 to 0xffffffff.

But when I used pmap to see a process's memory allocation, I see that the library are loaded in around 0xf7777777. Please see the attached screenshot. Does it mean those libraries are loaded in kernel space? And when I used mmap(), I got the address from 0xe0000000. So, mmap() got memory from kernel space?

enter image description here

Barmar
  • 741,623
  • 53
  • 500
  • 612
moeseth
  • 1,855
  • 5
  • 23
  • 47
  • How much physical RAM do you have installed? – mcleod_ideafix Apr 03 '15 at 05:07
  • @mcleod_ideafix What does that have to do with it? This is about virtual memory, not physical. – Barmar Apr 03 '15 at 05:11
  • See http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory/ – Barmar Apr 03 '15 at 05:14
  • @Barmar: it may have to do: for 32-bit systems the kernel maps the first 896MB of RAM to virtual addresses 0xC0000000 and up. If the computer has less than 896MB, not all the virtual space will be covered up and holes in the memory map show up, allowing the kernel to use them to reuse them to map user code or data – mcleod_ideafix Apr 03 '15 at 05:14
  • @Barmar: no, it's not. User has 3GB of virtual address. Kernel has 1GB. – mcleod_ideafix Apr 03 '15 at 05:15
  • @mcleod_ideafix But `pmap` shows virtual address assignments. How that gets mapped to physical RAM is totally different. – Barmar Apr 03 '15 at 05:15

1 Answers1

0

I'm on 32bit machine. From what I understand, User space's address ranges from 0x00000000 to 0xbfffffff, and kernel's ranges from 0xc0000000 to 0xffffffff.

Not exactly. Kernel memory space starts at 0xC0000000, but it doesn't have to fill the entire GB. In fact, it fills up to virtual address 0xF7FFFFFF. This covers 896MB of physical memory. Virtual addresses 0xF8000000 and up are used as a 128MB window for the kernel to map any region of physical memory beyond the 896MB limit.

All user processes share the same memory map for virtual addresses 0xC0000000 and beyond, so if the kernel does not use its entire GB of virtual space, it may reuse part of it to map commonly used shared libraries, so every process can see them.

mcleod_ideafix
  • 11,128
  • 2
  • 24
  • 32
  • 1
    Some relevant kernel source: http://lxr.free-electrons.com/source/arch/x86/include/asm/processor.h?v=3.19#L839 http://lxr.free-electrons.com/source/arch/x86/Kconfig?v=3.19#L1238 – o11c Apr 03 '15 at 05:51