免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1509 | 回复: 0
打印 上一主题 下一主题

[内存管理] linear address space最后一个页 [复制链接]

论坛徽章:
3
双鱼座
日期:2013-09-04 19:47:39天蝎座
日期:2013-12-11 20:30:532015年亚洲杯之澳大利亚
日期:2015-04-20 00:28:02
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-27 18:22 |只看该作者 |倒序浏览
             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的地址是怎么分布的.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP