李庚睿的毕业论文(保护模式) - 图文 下载本文

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

call gate and the destination code segment pointed to by the call gate. If access to the destination code segment is allowed, the processor gets the segment selector for the destination code segment and an offset into that code segment from the call gate. If the call requires a change in privilege level, the processor also switches to the stack for that privilege level. (The segment selector for the new stack is obtained from the TSS for the currently running task.) Gates also facilitate transitions between 16-bit and 32-bit code segments, and vice versa. 系统段、段描述符与门 除了代码段、数据段及堆栈段构成了一个程序或过程的执行环境外,系统架构还定义了两个系统段:任务状态段(TSS)及局部描述符表(LDT)。(GDT—全局描述符表,不认为是一个段,因为它不能通过段选子和段描述符来进行访问。)每一个系统段都有一个段描述符与之对应。 系统架构还定义了一系列特殊的被调用的门描述符(包括调用门、中断门、陷阱门及任务门)。这些门给应用程序和过程提供了操纵(访问)系统程序和过程的保护通路,这些系统程序和过程与应用程序和过程具有不同的特权级。例如,一个CALL指令(汇编语言里的一条指令)通过调用门就可以访问一个与当前代码段同级或数字更低的特权级代码段中的过程。(数字越低,权值越大即具有更高特权级。) 要想通过调用门去访问一个过程,主调过程必须提供调用门的选择子。然后处理器对调用门的特权级进行检查,即比较当前特权级(CPL)与调用门特权级及由调用门指出的目标代码段特权级的大小。如果目标代码段允许访问,那么处理器就从调用门得到目标代码段的选择子及它的偏移地址。如果需要改变特权级,那么处理机器还要交换特权级堆栈。(新栈的段选子是从当前运行任务或进程的TSS中获得的)而且门还能方便的在16位与32位代码段之间转换。 下面让我们看一下普通段描述符、系统段描述符和调用门描述符的抽象图及低特权级代码段使用调用门访问高特权级代码段的具体处理过程:

第17页

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

第18页

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

第19页

标题 作者 说明 毕业论文 李超 ?所有版权作者保留 题目 时间 页数 80386保护模式与Linux内核引导分析 2005-4-1 共91页 路漫漫其修远兮,吾将上下而求所。

任务状态段和任务门

Task-State Segments and Task Gates The TSS (see Figure 2-1) defines the state of the execution environment for a task. It includes the state of the general-purpose registers, the segment registers, the EFLAGS register, the EIP register, and segment selectors and stack pointers for three stack segments (one stack each for privilege levels 0, 1, and 2). It also includes the segment selector for the LDT associated with the task and the page-table base address. All program execution in protected mode happens within the context of a task, called the current task. The segment selector for the TSS for the current task is stored in the task register. The simplest method of switching to a task is to make a call or jump to the task. Here, the segment selector for the TSS of the new task is given in the CALL or JMP instruction. In switching tasks, the processor erforms the following actions: 1. Stores the state of the current task in the current TSS. 2. Loads the task register with the segment selector for the new task. 3. Accesses the new TSS through a segment descriptor in the GDT. 4. Loads the state of the new task from the new TSS into the general-purpose registers, the segment registers, the LDTR, control register CR3 (page-table base address), the EFLAGS register, and the EIP register. 5. Begins execution of the new task. A task can also be accessed through a task gate. A task gate is similar to a call gate, except that it provides access (through a segment selector) to a TSS rather than a code segment. 任务状态段和任务门 TSS(任务状态段)定义了任务执行环境的状态。它包括通用寄存器、段寄存器、EFLAGS寄存器(标志位寄存器)、EIP寄存器(指令指针寄存器)及段选子和三个堆栈段的堆栈指针(对于特权级0、1、2,每一个都有一个堆栈)的状态,它第20页