Is kernel space mapped into user space on Linux x86?

后端 未结 2 1466
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-21 20:05

It seems that on Windows 32 bit, kernel will reserve 1G of virtual memory from the totally 4G user virtual memory space and map some of the kernel space int

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-21 20:13

    Is there any similiar situation on 32 bit Linux?

    Yes. On 32-bit Linux, by default, the kernel reserves the high quarter of the address space (the 1G from C0000000 to the top of memory) for its own use.

    If so, how can we see the whole memory layout ?

    You can't. /proc/pid/maps only displays mappings which are present in userspace. Kernel memory is not accessible from userspace applications, so it is not shown.

    Keep in mind the reason why this arrangement is used - while the kernel is active, it needs to be able to install its own mappings while still keeping userspace mappings active (so that, for instance, it can copy data from or to userspace). It accomplishes this by reserving that high memory range for itself.

    The locations of memory mappings within the kernel is not relevant to anything besides the kernel itself, so it is not exposed to userspace at all except by accident, or in some debug messages.

提交回复
热议问题