Intel 253668-032US User Manual

Page of 806
Vol. 3   5-7
PROTECTION
A doubleword at an offset greater than the (effective-limit – 3)
A quadword at an offset greater than the (effective-limit – 7)
For expand-down data segments, the segment limit has the same function but is 
interpreted differently. Here, the effective limit specifies the last address that is not 
allowed to be accessed within the segment; the range of valid offsets is from (effec-
tive-limit + 1) to FFFFFFFFH if the B flag is set and from (effective-limit + 1) to FFFFH 
if the B flag is clear. An expand-down segment has maximum size when the segment 
limit is 0.
Limit checking catches programming errors such as runaway code, runaway 
subscripts, and invalid pointer calculations. These errors are detected when they 
occur, so identification of the cause is easier. Without limit checking, these errors 
could overwrite code or data in another segment.
In addition to checking segment limits, the processor also checks descriptor table 
limits. The GDTR and IDTR registers contain 16-bit limit values that the processor 
uses to prevent programs from selecting a segment descriptors outside the respec-
tive descriptor tables. The LDTR and task registers contain 32-bit segment limit value 
(read from the segment descriptors for the current LDT and TSS, respectively). The 
processor uses these segment limits to prevent accesses beyond the bounds of the 
current LDT and TSS. See Section 3.5.1, “Segment Descriptor Tables,” for more infor-
mation on the GDT and LDT limit fields; see Section 6.10, “Interrupt Descriptor Table 
(IDT),” for more 
information on the IDT limit field; and see Section 7.2.4, “Task 
Register,”
 for more information on the TSS segment limit field.
5.3.1 
Limit Checking in 64-bit Mode
In 64-bit mode, the processor does not perform runtime limit checking on code or 
data segments. However, the processor does check descriptor-table limits.
5.4 TYPE 
CHECKING
Segment descriptors contain type information in two places:
The S (descriptor type) flag.
The type field.
The processor uses this information to detect programming errors that result in an 
attempt to use a segment or gate in an incorrect or unintended manner.
The S flag indicates whether a descriptor is a system type or a code or data type. The 
type field provides 4 additional bits for use in defining various types of code, data, 
and system descriptors. Table 3-1 shows the encoding of the type field for code and 
data descriptors; Table 3-2 shows the encoding of the field for system descriptors.