Chinaunix

标题: linear address space最后一个页 [打印本页]

作者: kiongf    时间: 2013-07-27 18:22
标题: linear address space最后一个页
             This is also a good place to recall from the introduction that Linux sometimes has to return a pointer if
an operation succeeds, and an error code if something fails. Unfortunately, the C language only allows
a single direct return value per function, so any information about possible errors has to be encoded
into the pointer. While pointers can in general point to arbitrary locations in memory, each architecture
supported by Linux has a region in virtual address space that starts from virtual address 0 and goes at
least 4 KiB far where no senseful information can live.
The kernel can thus reuse this pointer range to
encode error codes: If the return value of fork points to an address within the aforementioned range,
then the call has failed, and the reason can be determined by the numerical value of the pointer. ERR_PTR
is a helper macro to perform the encoding of the numerical constant -EINVAL (invalid operation) into a
pointer.

这是ULKA的一段话描述4KB的'无 意义'的虚拟内存区间。这段内存区间主要负责转码error code(ERR_PTR这些函数).  
我奇怪为什么会用到0-4KB的用户空间地址。看了源码, 发现这段虚拟内存空间其实在[0xFFFF F000, 0xFFFF FFFF].
而我在ULK中的理解是 这段区间应该是被用作Fixed-mapping linear address才对的阿.
ULK也有一幅图上面Fixed-mapping linear address 延伸虚拟地址空间的最后.

b7753000-b7772000 r-xp 00000000 08:06 399284     /lib/ld-2.14.1.so
b7772000-b7773000 r--p 0001f000 08:06 399284     /lib/ld-2.14.1.so
b7773000-b7774000 rw-p 00020000 08:06 399284     /lib/ld-2.14.1.so
bfc4e000-bfc6f000 rw-p 00000000 00:00 0          [stack]
ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]

虽然不知道[vdso]是什么, 但后面确实有段4KB没有表示的虚拟地址空间

特此求问下, Kernel mode linear address space 最后128MB的地址是怎么分布的.





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2