Specifications

Intel
®
64 and IA-32 Architectures Software Developer’s Manual Documentation Changes 227
Documentation Changes
4. Updates to Chapter 5, Volume 3A
Change bars show changes to Chapter 5 of the Intel
®
64 and IA-32 Architectures Soft-
ware Developer’s Manual, Volume 3A: System Programming Guide, Part 1.
------------------------------------------------------------------------------------------
...
5.3 LIMIT CHECKING
The limit field of a segment descriptor prevents programs or procedures from addressing
memory locations outside the segment. The effective value of the limit depends on the
setting of the G (granularity) flag (see Figure 5-1). For data segments, the limit also
depends on the E (expansion direction) flag and the B (default stack pointer size and/or
upper bound) flag. The E flag is one of the bits in the type field when the segment
descriptor is for a data-segment type.
When the G flag is clear (byte granularity), the effective limit is the value of the 20-bit
limit field in the segment descriptor. Here, the limit ranges from 0 to FFFFFH (1 MByte).
When the G flag is set (4-KByte page granularity), the processor scales the value in the
limit field by a factor of 2
12
(4 KBytes). In this case, the effective limit ranges from FFFH
(4 KBytes) to FFFFFFFFH (4 GBytes). Note that when scaling is used (G flag is set), the
lower 12 bits of a segment offset (address) are not checked against the limit; for
example, note that if the segment limit is 0, offsets 0 through FFFH are still valid.
For all types of segments except expand-down data segments, the effective limit is the
last address that is allowed to be accessed in the segment, which is one less than the
size, in bytes, of the segment. The processor causes a general-protection exception (or,
if the segment is SS, a stack-fault exception) any time an attempt is made to access the
following addresses in a segment:
A byte at an offset greater than the effective limit
A word at an offset greater than the (effective-limit – 1)
A doubleword at an offset greater than the (effective-limit – 3)
A quadword at an offset greater than the (effective-limit – 7)
A double quadword at an offset greater than the (effective limit – 15)
When the effective limit is FFFFFFFFH (4 GBytes), these accesses may or may not cause
the indicated exceptions. Behavior is implementation-specific and may vary from one
execution to another.
...
5.8.8 Fast System Calls in 64-bit Mode
The SYSCALL and SYSRET instructions are designed for operating systems that use a flat
memory model (segmentation is not used). The instructions, along with SYSENTER and
SYSEXIT, are suited for IA-32e mode operation. SYSCALL and SYSRET, however, are not
supported in compatibility mode. Use CPUID to check if SYSCALL and SYSRET are avail-
able (CPUID.80000001H.EDX[bit 11] = 1).
SYSCALL is intended for use by user code running at privilege level 3 to access operating
system or executive procedures running at privilege level 0. SYSRET is intended for use