
Chapter 3: General-Purpose Programming
113
24593—Rev. 3.09—September 2003
AMD 64-Bit Technology
privilege level (CPL) is numerically less (more privileged) than
or equal to the RFLAGS.IOPL field, otherwise a general-
protection exception (#GP) occurs.
Only software running at CPL = 0 can change the
RFLAGS.IOPL field. Two instructions, POPF and IRET, can be
used to change the field. If application software (or any
software running at CPL>0) attempts to change RFLAGS.IOPL,
the attempt is ignored.
System software uses RFLAGS.IOPL to control the privilege
level required to access I/O-address space devices. Access can
be granted on a program-by-program basis using different
copies of RFLAGS for every program, each with a different
IOPL. RFLAGS.IOPL acts as a global control over a program’s
access to I/O-address space devices. System software can grant
less-privileged programs access to individual I/O devices
(overriding RFLAGS.IOPL) by using the I/O-permission bitmap
stored in a program’s TSS. For details about the I/O-permission
bitmap, see “I/O-Permission Bitmap” in Volume 2.
3.9
Memory Optimization
Generally, application software is unaware of the memory
hierarchy implemented within a particular system design. The
application simply sees a homogenous address space within a
single level of memory. In reality, both system and processor
implementations can use any number of techniques to speed up
accesses into memory, doing so in a manner that is transparent
to applications. Application software can be written to
maximize this speed-up even though the methods used by the
hardware are not visible to the application. This section gives
an overview of the memory hierarchy and access techniques
that can be implemented within a system design, and how
applications can optimize their use.
3.9.1
Accessing
Memory
Implementations of the AMD64 architecture
commit
the results
of each instruction—i.e., store the result of the executed
instruction in software-visible resources, such as a register
(including flags), the data cache, an internal write buffer, or
memory—in program order, which is the order specified by the
instruction sequence in a program. Transparent to the
application, implementations can execute instructions in any
order and temporarily hold out-of-order results until the