A task gate descriptor provides an indirect, protected reference to a TSS. Figure 7-4 illustrates the format of a task gate.
The SELECTOR field of a task gate must refer to a TSS descriptor. The value of the RPL in this selector is not used by the processor.
The DPL field of a task gate controls the right to use the descriptor to cause a task switch. A procedure may not select a task gate descriptor unless the maximum of the selector's RPL and the CPL of the procedure is numerically less than or equal to the DPL of the descriptor. This constraint prevents untrusted procedures from causing a task switch. (Note that when a task gate is used, the DPL of the target TSS descriptor is not used for privilege checking.)
A procedure that has access to a task gate has the power to cause a task switch, just as a procedure that has access to a TSS descriptor. The 80386 has task gates in addition to TSS descriptors to satisfy three needs:
31 23 15 7 0 +-----------------+----------------+-+-----+---------+-----------------+ |##################################| | | |#################| |############(NOT USED)############|P| DPL |0 0 1 0 1|###(NOT USED)####| 4 |##################################| | | |#################| |----------------------------------+-+-----+---------+-----------------| | |###################################| | SELECTOR |############(NOT USED)#############| 0 | |###################################| +-----------------+----------------+-----------------+-----------------+
LOCAL DESCRIPTOR TABLE INTERRUPT DESCRIPTOR TABLE +-------------------------+ +-------------------------+ | | | | | TASK GATE | | TASK GATE | +------+-----+-----+------+ +------+-----+-----+------+ | | | | | | | | | | |------+-----+-----+------| |------+-----+-----+------| +--| | | +--| | | | +------------+------------+ | +------------+------------+ | | | | | | | | | | | | | +-------------------------+ | +-------------------------+ +----------------+ +-----------------+ | | GLOBAL DESCRIPTOR TABLE | | +-------------------------+ | | | | | | | TASK DESCRIPTOR | | | +------+-----+-----+------+ | | | | | | | | +->|------+-----+-----+------| +---->| | |--+ +------------+------------+ | | | | | | | +-------------------------+ | | +-------------------------+ | | | | | | | | | | | TASK STATE | | | SEGMENT | | | | | | | | | | | +-------------------------+<-+