Call Gate( May 20)

To provide controlled access to code segments with different privilege levels, the processor provides special set of descriptors called gate descriptors. There are four kinds of gate descriptors:

• Call gates

• Trap gates

• Interrupt gates

• Task gates


Call Gates

Call gates facilitate controlled transfers of program control between different privilege levels. They are typically used only in operating systems or executives that use the privilege-level protection mechanism. Call gates are also useful for transferring program control between 16-bit and 32-bit code segments.

call-gate descriptor may reside in the GDT or in an LDT, but not in the interrupt descriptor table (IDT). It performs six functions:
• It specifies the code segment to be accessed.
• It defines an entry point for a procedure in the specified code segment.
• It specifies the privilege level required for a caller trying to access the procedure.
• If a stack switch occurs, it specifies the number of optional parameters to be copied between stacks.
• It defines the size of values to be pushed onto the target stack: 16-bit gates force 16-bit pushes and 32-bit gates force 32-bit pushes.

• It specifies whether the call-gate descriptor is valid.


Call Gate( May 20)_第1张图片



To access a call gate, a far pointer to the gate is provided as a target operand in a CALL or JMP instruction. The segment selector from this pointer identifies the call gate (see Figure 5-10); the offset from the pointer is required,but not used or checked by the processor. (The offset can be set to any value.) When the processor has accessed the call gate, it uses the segment selector from the call gate to locate the segment descriptor for the destination code segment. (This segment descriptor can be in the GDT or the LDT.) It then combines the base address from the code-segment descriptor with the offset from the call gate to form the linear address of the procedure entry point in the code segment.


Call Gate( May 20)_第2张图片



Four different privilege levels are used to check the validity of a program control transfer through a call gate:

• The CPL (current privilege level).

• The RPL (requestor's privilege level) of the call gate’s selector.

• The DPL (descriptor privilege level) of the call gate descriptor.

• The DPL of the segment descriptor of the destination code segment.

The C flag (conforming) in the segment descriptor for the destination code segment is also checked.

Call Gate( May 20)_第3张图片



The privilege checking rules are different depending on whether the control transfer was initiated with a CALL or a JMP instruction


Call Gate( May 20)_第4张图片


你可能感兴趣的:(Computer,&,OS,kernel)