免费注册 查看新帖 |

Chinaunix

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

Linux中为何设置LDT [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-20 11:15 |只看该作者 |倒序浏览
从2.2版开始,Linux让所有的进程(或叫任务)都使用相同的逻辑地址空间,因此就没有必要使用局部描述符表LDT。但内核中也用到LDT,那只是在VM86模式中运行Wine,因为就是说在Linux上模拟运行Winodws软件或DOS软件的程序时才使用。

    既然如此,那么为什么还要在GDT表中为每一个进程分别设置TSS和LDT,因为GDT总共有8192项,如此一来,可以支持的并发进程数目就下降了
    而只设置TSS就可以支持更多的并发进程,设置LDT不仅没有实际用处,反而影响了性能,这是为什么?

论坛徽章:
0
2 [报告]
发表于 2010-04-20 11:39 |只看该作者
是因为CPU需要一个LDT的地址么?

论坛徽章:
0
3 [报告]
发表于 2010-04-20 13:11 |只看该作者
回复 2# kgn28


    2.4以后的内核好像是进程共用一个LDT,那是不是LDT原本就没有必要一个进程使用一个?

论坛徽章:
0
4 [报告]
发表于 2010-04-20 13:34 |只看该作者
本帖最后由 kgn28 于 2010-04-20 13:45 编辑

wine http://www.winehq.org/ 需要修改ldt。

论坛徽章:
0
5 [报告]
发表于 2010-04-20 15:03 |只看该作者
观看。。。。。。

论坛徽章:
0
6 [报告]
发表于 2010-04-22 12:45 |只看该作者
本帖最后由 tianhailong 于 2010-04-22 12:47 编辑

回复 4# kgn28


    那么对于非wine程序,基本不适用LDT,是不是就不用设置LDT,内核中设置LDT有什么用处呢,反而限制了GDT中的项数,进而降低了Linux并发进程数?
    基础比较差,请教了!

论坛徽章:
0
7 [报告]
发表于 2010-04-22 14:20 |只看该作者
回复 6# tianhailong


    那就不清楚了,请看《understanding the linux kernel the 3rd. edition》的第二章内存寻址里面的Linux LDT一节里面讲的内容:
Most Linux User Mode applications do not make use of a Local Descriptor Table, thus the kernel defines a default LDT to be shared by most processes. The default Local Descriptor Table is stored in the default_ldt array. It includes five entries, but only two of them are effectively used by the kernel: a call gate for iBCS executables, and a call gate for Solaris /x86 executables (see the section "Execution Domains" in Chapter 20). Call gates are a mechanism provided by 80 x 86 microprocessors to change the privilege level of the CPU while invoking a predefined function; as we won't discuss them further, you should consult the Intel documentation for more details.

In some cases, however, processes may require to set up their own LDT. This turns out to be useful to applications (such as Wine) that execute segment-oriented Microsoft Windows applications. The modify_ldt( ) system call allows a process to do this.

Any custom LDT created by modify_ldt( ) also requires its own segment. When a processor starts executing a process having a custom LDT, the LDT entry in the CPU-specific copy of the GDT is changed accordingly.

User Mode applications also may allocate new segments by means of modify_ldt( ); the kernel, however, never makes use of these segments, and it does not have to keep track of the corresponding Segment Descriptors, because they are included in the custom LDT of the process.

论坛徽章:
0
8 [报告]
发表于 2015-09-18 21:16 |只看该作者
回复 7# kgn28


    既然如此,那请问我们是否可以使用modify_ldt在ldt中添加一个call gate descriptor,这个call gate descriptor指向的code segment descriptor的权限为0,这样,我们的进程调用这个call gate就能让我们的进程权限提升为0?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP