background image

Vol. 3A 5-15

PROTECTION

If a far call references a 16-bit call gate type (04H) in IA-32e mode, a general-protection exception (#GP) is 
generated.

When a call references a 64-bit mode call gate, actions taken are identical to those taken in 32-bit mode, with the 
following exceptions:

Stack pushes are made in eight-byte increments.

A 64-bit RIP is pushed onto the stack.

Parameter copying is not performed.

Use a matching far-return instruction size for correct operation (returns from 64-bit calls must be performed with 
a 64-bit operand-size return to process the stack correctly).

5.8.4 

Accessing a Code Segment Through a Call Gate

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.
As shown in Figure 5-11, 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.

Figure 5-10.  Call-Gate Mechanism

Offset

Segment Selector

Far Pointer to Call Gate

Required but not used by processor

Call-Gate
Descriptor

Code-Segment
Descriptor

Descriptor Table

Offset

Base

Base

Offset

Base

Segment Selector

+

Procedure

Entry Point