Vous êtes sur la page 1sur 1567

d

is

te

re

U
nR
eg

-
-

d
re
te
is
U
nR
eg
-

-


- - - -
- -

-- -
--

is

te

re

Intel Core 2 Processor (Penryn)


Intel Nehalem Processor
Intel Atom Processor
AMD Opteron Processor (Barcelona)
Intel 32/64-bit x86 Software Architecture
AMD 32/64-bit x86 Software Architecture
x86 Assembly Language Programming
Protected Mode Programming
PC Virtualization
IO Virtualization (IOV)
Computer Architectures with Intel Chipsets
Intel QuickPath Interconnect (QPI)
PCI Express 2.0
USB 2.0
USB 3.0
Embedded USB 2.0 Workshop
PCI
PCI-X
Modern DRAM Architecture
SAS
Serial ATA
High Speed Design
EMI / EMC
Bluetooth Wireless Product Development
SMT Manufacturing
SMT Testing

U
nR
eg

re

te

is

U
nR
eg
d

te

re

U
nR
eg

is

- -

- -
-- -- -- -
--- - -- - -
- - -

re

te

U
nR
eg

is

- - - -
-- - -
- -- -
-
-

-

-- - -- - --
- - -

--
-

-- -

U
nR
eg

is

te

re

re

te

is

U
nR
eg
d

re

Basic Terms and Concepts


Mode/SubMode
-
-

te

- ----
--- -

--
- -
-


-
- ---
--
--
- -
-
-- - --

-
- -

-
-

U
nR
eg

is

- - -
- ---
-

- -
--- -


-- -

- -
- --

-
- --
- -

re

- - -
--- -

U
nR
eg

- -
-
- -
-

is

te

- -

- - -- -


-

-

te

re

- -

-
-- -
-
-

- - -
-
-
-
-
-
-

is


- - -

U
nR
eg


- --
- -
- -
-
--- - ---
-- --
-- - -
-- -
- -

- -
-
-
- -
-


- -

-
-
--


-

te

re

-




-

U
nR
eg

is

-
-
--
-
-

--
- -
-
-
-
--
- - -
- -


- --
---
-
--
-- - -

U
nR
eg

is

te

re

-
-
-



-- -
- -
- --
-
-- - -
- ---
-- -
-
-- --
- - - -
-
-
- --
- --
-
-
-

-
-
- -
-


-


-
--

-- -
-
- -

- -
- - - -

-
- -

U
nR
eg

is

te

re

-
- - -


-
-
- -
- --
-

-
- -

-- - -- -
- -
- -
-
-- - -- -
- -
- -
- -- -
- -
- -- -
- - -
- -
-


-- - -
-
-
-
-- -
- -
-- -
-- -
-- -
- --

U
nR
eg

is

te

re

--
-
- -



-
--



-
-

- -
--
-
-
-


- -
- --

- -



- -

-


-
--
-
-
-
-
-

U
nR
eg

is

te

re

--

-- - --


-

- -
- -- -
--
-
- -
- -- -
--
-
- -
--
-
-
-- -

--
--
- --
-
-
-


-- -
--
-
- --
--
-
-
-
-
-

--
-- -

U
nR
eg

is

te

re




--
--
-- -

-
-- -
--
-
- -
- -
-
-
--

--
-


-- -
-- - --
-
--

-
-- -

-
-
-
--

-
- -
- -
- - ---
-

- -
- -

U
nR
eg

is

te

re






-

-


- -
--
-
-
-
-
-

--
- -


- -
- - -
- -
- - -
- --
- -- - -
- -

-
-


-
-
-
-
--
-

U
nR
eg

is

te

re



- -


-
-
-
-
- -
-
-



-
-
- -
-



-

-

-

- --- -
- -
-- -
-
- -- -
- --
- -
-
-- -

- --- - -

-
- --


-
-


-
- -

- -
-

re

--

te

--

--

U
nR
eg

is

-
- - --
- - -
-- -
- -
-- -
-
-
- --

- - -


-

- --

-
-
-


- -

-
-
-




-

- -

U
nR
eg

is

te

re



-
-
-- --
-
-
--

- - -


- - -


-


-
-

--
-

-
-

- -

-
-

U
nR
eg

is

te

re




-

-


-
-



--
-


--
-

-
-

-


-

-


-
-

-
-
-
-



re


-








-

-

U
nR
eg

is

te

-
-

--

--




-

-- - - -


- -

- -

- -


-

U
nR
eg

is

te

re

--

-- - -

-
-
-

--
-- -
- - -
-
--
-
-
- --
-

- -- -

-
-
-
--


- -

-



-


-- --

-

---

U
nR
eg

is

te

re

--

-
-
-
--
-



-- -
-
-

- -

-- -

- -


-
--
--
-

-- -
-
- --
-


-
- -

--


-
-
-

U
nR
eg

is

te

re

- -




- -

-- -
-

-
-


- -
-

-
- -

- -

- -
-
-

-

- -
-
-



- --
-- - -
---


-- -

U
nR
eg

is

te

re


--- -
- --
-

- -
-
- -
-
---
-
-
-
- -
-
-- -
-- -
- -
- -
-
- -- ----
-


-
-




- - -
-
- -
- - -
- ---

-
-
-

- -
-

U
nR
eg

is

te

re

- - -
-
-
-
-
-


-- - -
-
-
- -
-
- - -
- -
-
- -
-
- -
-
-
--
-
- -
-

- -
- -

-
-
-


-
-
- -

- -
- - -

U
nR
eg

is

te

re

- -
- - -
- -
-

--


--
--
--

-
--

-
-

- - -
-

-
- -
- -
- -
- -

- -- -

- -
- --
-

- -

- -



U
nR
eg

is

te

re

-



-
- -
-

-


-
- -

-
--
-


-

- --

-


-
-
-
-
-
-
-

- - -
- -
-

- -

--
--

U
nR
eg

is

te

re

-

-
--

--
--
-

-
--
- - -

--
--

-
--

--
--
-

-
--

--
--
-

-
--
-
--
--
-

-
--

--
--

U
nR
eg

is

te

re

-

-
--

--
--
-


- --


-
--

--
--
-


-
--
--
--
--
-

-
--

--
--
-

-
--
-
--
--
-

U
nR
eg

is

te

re

-
--

--
--
-

-
--

--
--
-

-
--

--
--
-


-
--
-
-



--
--
-
- -
- -

-
--

--
- --
-
--

U
nR
eg

is

te

re

-
---

- ---
---
---

-
--

--
--
-

-
--

--
--
-

-
--

-


- -

-

- - --
-- -
-

- - -

---
-

U
nR
eg

is

te

re

--
- -
-

--
---
-
- --
- --
--
-
-
- - -
- -
-
-
- --



--
--

--
--

-
-
-- -
-
---
-

- -
-
- -

-


-
-

U
nR
eg

is

te

re

-
-

--

- -
- -
- -
-- -
-
- - -
-

-


-
---
-


- - -
- - -
- -
-- --
-- -



-
---

--
-- -


- -
-

-
-

-
-
-

U
nR
eg

is

te

re

-
-
--


-
-

-

-
-
--

--

-
-
-
- -

-
- -

- -
-- --

-
-
-
-
-
- - --


- --

U
nR
eg

is

te

re

-


- - - -


-
-

-
--
--
- --

- -
--
-
-

-
-
--

-
-
-
-

- - - -
-



-

-
-

- -


--

-


-
-- -- -
-

-
-
-

re

U
nR
eg

is

te





-
-
- -
- -
-
- - - -
--
--
--
-


-- -
- -
-
-



- - -
-- - -

U
nR
eg

is

te

re

-

-- -
-
-
---
- -- -
-- - -
- -

-
- -
-
- -

---
-
- -
-
---
-
- -
-





---




-
-
-


-
-


- -
- - - -
-
-

-
-

-- -

U
nR
eg

is

te

re

--
- -
-
--
-- -




-
- -

--


-
-




-

- -
-
--

te

re

-
--
-- -
-
- --
-- --
- ---
- ---
- - -- -

-
-
- -
- -
- -
- -
-
--

is

U
nR
eg

-
-
- -
--
- -
-
--
-
--
-
-
-

- --


-

-- --
- -

U
nR
eg

is

te

re









-
-

- -
-

-- -- -
-- -- -
- -- -
- -
--
--
- --
-
- - ---
-
--
-- -
--

--
--
--
- --
--
--
-
--

- --

-

U
nR
eg

is

te

re


-
--
--
-- --
-
--
-
-

-
-
-
- -
-

-
-
- -
-
-


- -
- - -

--
--

-
- --
--

- -
-
-
- -

is

te

re

-

-- - -
- -

- -


-

-- --
-
-

-- -- - -
- -

-

---
-

U
nR
eg


-


-
-
--




-

--

-
-
- --
-
-
- -
- ---

U
nR
eg

is

te

re

- -
--
- -
- -

-- - --
- -


--
--
--

-
- -

- -
- -

--
-- --



-
- -

-


- -

U
nR
eg

is

te

re

- -
- -
-


- -
- -
-
-
- -



- - -
-- - --


- ---


- --
-
- -- -
-- -
-


- -

-

-
--

- -
- -
-
-
- -

U
nR
eg

is

te

re

-

---
- -





-- -
-- -
--


-- -
-- -
-

-
-
-






- -
-

- -
---
-
- -
- ---

-

-

U
nR
eg

is

te

re


-
- --
- -

-

-


-- - -
- -
- -

-- -
-- ---
---
--
-- - -
-- - -
-- - - - --
--- - --
-- -
-- -- -
---
-
-

-
-

- --
-

-
- --

- -
- --
- --

U
nR
eg

is

te

re

- -
--- --
--

- --
- -- --
- -
-
-- -
-- -
-
--
-- --
-
--
-- -
-

- --
- --
- -


--

-
--
- --
-- -

-

-
-
-- --
-

- -
---- -
- -
--

U
nR
eg

is

te

re

-
-
-


-
-
-
- - -
- --

- -
-- -
- -

--
-
-

---
-
-
---
-
-
-
- - --
- -
-- -
- -
-
-
- -
-
- --
-
- -
-
-
-- -

- - --

U
nR
eg

is

te

re





-



-- ---

--


-
-


-
-
-
---
- - -

-




-



-



-

-
-
- -
- -

re

-


- - -
--

--
--
--
- -


-
-- -
-
-

te

--

U
nR
eg

is

re

te

is

U
nR
eg
d

is

te

re

-- --


- -
-
-
--- -
--
- -
- -
-
-
-
-
-
- -
- -
-



- -
-
--
-

--

-- - -
-- -
-- - -
-- -

- - -- -
- - -- -
-- -

- -

-
-
- -

U
nR
eg

is

te

re

-
-
-
-
-
-
- -
-
- -- -
- -
--
-
- -
-
--
--
--

-


--
- --






-

-
-


- -
- -
- -
- -
-
-
-

U
nR
eg

is

te

re

- -
- -
-- - - -
-
-

- -
- -
-
-
-
-


-
-
- -
-
-


-
-
-
- -
-
-
-
---
-- -
-

-

-
-

-
-

-
-

U
nR
eg

re

te

is

-

-
-
- -
- -
-
-

- - -
-- -
-- -
-- - - --
-- - - --
-- - - --
-- - - --
-- - - --
- --

- --- -
--
---
---
---
---
-
---

-
-


--
-- --



-
-


U
nR
eg

is

te

re



-- -
---
- --
--
--





-
-


-
--
-- --




- --
-

- - -

-
-

-
-
-
- -
- -
-



-

U
nR
eg

is

te

re


-
- -
- - - -- - -
-
- - -
- - -
- - --
- -
-
-
-
- -
-
- - -- -
- -- -
- -
-
-
-
-
- - -
- - -
- -
- -


-
- -
-



-




-- -


U
nR
eg

re

te

is


-


- - -



---



-
- -

-- -
- - - ---
- -- -
-- - --
-

-
- -
-- - -

--


---
---
-
-
-

- -




-
-
-

U
nR
eg

re

te

is

-

-
-
-
- - -
- -
- -- - -
-- - -
- -
-
-
-

-
- -
-
-
-
-



-
-
-
- -
-
-
-
-
-
--
- -
-

-
-


- --
-

U
nR
eg

is

te

re

-


- -

-

- -

- -
- -
-- - -
-- -

-- -

-- -
-
-
-

-- -
--
-- --


-
-
- -




-


- -
- -
--
--
--
-

U
nR
eg

re

te

is

- - -
- -
-
- - --
- - -
- - -
-




-
--



-


---

-
-


--
-

-
-
-
-






-
-
- -
- -

U
nR
eg

is

te

re

-
- -
-
---
-
-
-
-
- - --
- - ---
- - ---

- -

- -
-
- --
-- -
-- -- -
-
- -
- -
-- -
--
-- -
-
- -
- -
-
- -
- -
-- -

--- -
---
- ---
- -


--
-
---

U
nR
eg

re

te

is


--
-
---
-
- --
-

---
---
-- -
- -

- -
- -
- - -



-
-
-
-
-
-
- --
-

-
- -
- -
- - -
--

- -
- -
- - -

U
nR
eg

is

te

re

-
-
- --
- -
- -
-
-

-
--
-- --
--
-- -
- -
-- -
-
-



-
- -







- - -


- --

- -
- - - - - -
-- -
-- -
-- -
-- -
-

U
nR
eg

re

te

is

-

-
- -- - -
- -
--
--
-
--
--
- - --
- -


- - -
- -
- --
- -
- -
---
-
-
- -
-

- -
- -
--
-- - - -
- -
-
-
- - -
- -
-
-
-
-
- -
-
-
-

U
nR
eg

is

te

re

- -
- - -
-
-




-
-
-
-
-
-- -

-
- -

-
-
- -
- - - -
- - -
- -
-
- -
--
-
--
--
-
-
- -

- --
---
- -
-
- -
-
-
-

U
nR
eg

is

te

re

-
-
-
-

- -
-
--- -

--
- -
--
--
-
- -
- -
- -
- -
- -
- -
-
-
-
-
--
- --
-- -
--


-
-- -
-
-- -
-- -
-
--
--
-- --
--

-

U
nR
eg

is

te

re

-
-
-- -
--
-


--
-
-
--
- -
-- -
--- -
--- -
-
- -
-

-
- -
-
-

-
-
- --
- -
-
-- -
--
-
-
-- --
--
-
-
--
--
-- - -
- -

U
nR
eg

re

te

is

U
nR
eg
d

-
Is This the Book for You?

- - -
- - -
-- - -- - -

U
nR
eg

A Moving Target

is

te

re

- -
- - -
-
- - - - -
- - -

- -
- - - - - -- -
-

x86 Instruction Set Architecture (ISA)


- - -
-

- - -
-- -
- -
- - -
-- -
- -

x86 Instruction Set Architecture


Glossary of Terms
- --

32-/64-bit x86 Instruction Set Architecture Specification


- - - -
- - --
-

re

-
-
-
-
-

te

is

- - -

U
nR
eg

- - - - --
- - -- - - -- - -- -
- -- - - ---
- - -

-- - - - -
- -
-- - - - -
- - - -
-
- -- --
- - -
- -- ---
- -
--

The Specification Is the Final Word


- -- - -
- -

About This Book


Book Organization
- - - -
- ----
--- -
Basic Terms and Concepts
Mode/SubMode
-
-

te

U
nR
eg

--
- -
-



-
- ---
--
--
- -
-
-- - --

-
- -


-
-

is

re

- - -
- ---
-

- -
--- -


-- -

x86 Instruction Set Architecture


- -
- --

- - -
--- -

-
- --
- -

re

- -
-
- -
-

te

- -

- - -- -

U
nR
eg

-

-

is

Topics Outside the Scope of This Book


The CPUID Instruction

- - - - -
- - -
- - -

Detailed Description of Hyper-Threading


- - - -
- -

About This Book


Detailed Description of Performance Monitoring
- - -
- - -
-

Documentation Conventions

U
nR
eg

is

re

- -


- -


- -
- -



te

- - - -

- --

- - --
- --
- - --
- --
- -- -
- - -
- - - ---- - - - -

Trademarks
-- - - -- --
- - - - --
-- -

x86 Instruction Set Architecture

re

U
nR
eg

--

- -

is

--

te

-
- -- - -
-

Visit Our Web Site

- - - --
-

- -
- ---
---
- ---
-
- -

About This Book


We Want Your Feedback
- - -- ---
-


--

re

U
nR
eg

is

te


-
-

--

U
nR
eg

is

te

re

x86 Instruction Set Architecture

Part 1

U
nR
eg

The Next Part

te

Basic Terms and Concepts


Mode/SubMode
-
-

is

re

- ---- -- -

- - --

re

te

is

U
nR
eg
d

- -
-

This Chapter

re

- - - -
- -- -
- - - -

te

The Next Chapter

U
nR
eg

ISA Definition

is

- - -- - - --

- - --
- -- -- -- -

This Book Focuses on the Common Intel/AMD ISA


- - - -
--- - - --
- - - - - -
- --

For Simplicity, Intel Terminology Is Used Throughout


- - -
- - -

11

x86 Instruction Set Architecture


Some Terms in This Chapter May Be New To the Reader
- -
- - - -
-
- - -

Two x86 ISA Architectures

- -
---
- - ---

te

re

--- -
- -

U
nR
eg

is

- - - - -
- - -
- - -
--
- --
-- -- - - -
-- - - -- -

- - - -- -- - - - - -
- - -- - - -

12

Chapter 1: Basic Terms and Concepts


--

--- -
-
-
--

--

- --

--
--
--
--

te

re

--

is

Processors, Cores and Logical Processors

U
nR
eg

- - - - --
- --
-
- -- - - -

- - -
- - -
- - -
- -- -
- -

---
- - - -
- -- - - --
- - - -
- - - - - -
- - -- - -
-- - --
- - - -- -

13

x86 Instruction Set Architecture


-
- - -
-
- - ---

- - - - --
- - -
- - -- --
- - - - --

re

- - - - ---
- - - --
- - -- - - -
-- - - - - - --

is

te

- - -- - -
- - - -
- - --- ---
--- -
-

U
nR
eg

Fundamental Processing Engine: Logical Processor


- - - --- -
--- --
- -- -- -
- --- - --
--

14

Chapter 1: Basic Terms and Concepts

-- --

- --

--
--

--
--

--

is

IA Instructions vs. Micro-ops

te

re

--

U
nR
eg

RISC Instructions Sets Are Simple


- - - -
- - -- - - -
- - - -
- - - -- -
- - -

- --- -
- -- - - -
- - - -
- -- - -
- --
- --

x86 Instruction Set Is Complex


-
- - -
- - --

15

x86 Instruction Set Architecture


- -- - -
- -

- --- -
- -- - -
-
- - - -
- -- - -
- - --
- --

But You Cant Leave It Behind

is

te

re

- --
- --- - -


--
-

U
nR
eg

Complexity vs. Speed Dictated a Break With the Past


-- - -- - -
-- -- -
--
- - - --
--- -
-- - -
- - - - -
-- - -
- - - --
--- -

Why Not Publish a Micro-Op ISA?


-- - - - -
- - -
--
--- - --

16

Chapter 1: Basic Terms and Concepts


- - -
- - - -
--
- - - -
- - -
- - - - -
- -
- - -

Some Important Definitions

te

Virtual vs. Physical Memory

re

- - - - -

is

- - -
---

U
nR
eg

- --
-

-
--

-- - --


--

--
- - - - --
- --- --- - -- -
- - - --
-- -

--- -
- - - - -
-- -- - -- -
-- --
- -- -

17

x86 Instruction Set Architecture


- --
-

- - -- -- - -
-- - -- - -
-- - - - - - -- - -
- - -- -


--

re

Other Important Terms

te

- - -- - -
- -


- --- -

-- - -
-- - - -
- -- ---
- -
-
- - -
- -
- --
- -- - --
- --
- -
- -- -- -
- - - --
- - - -
- - -

U
nR
eg

is

18

Chapter 1: Basic Terms and Concepts


- -

is

te

re


--
- -
-- ---
-
- -- -
- - - -
-- - --
-
- -- -
- -- -
- -- ---
-- - -
--
- -
- ---
-
- -- - -
--
-- -
-
- -
- - - --
--

U
nR
eg

19

x86 Instruction Set Architecture


- -
-

- - -- - -- --
-
- -
-
- -
- - - -
- -
- - - -

- -
- -- - - -
- --- -
- -
- - ---
- - --
--- --
- -- - - - -
- --

U
nR
eg

is

te

re

20

The Previous Chapter

re

- - -
-- -
- - -

te

This Chapter

U
nR
eg

The Next Chapter

is

- - - -- -
--

- - - -
--
- - -

Basic Execution Modes

-- - - --- -- - -
- - -
-

21

x86 Instruction Set Architecture

re

is

--


U
nR
eg

te

22

--

Chapter 2: Mode/SubMode Introduction

--- -
--- -

-


--


- --
-
- --
- --
- - - -- - - -
- - - --
- -- - -- --
--
- -

-- - -
--
- -- - -
- -- - -- -

- - -
- -
- - -
- -
-- -
--- - - -
- - -
- - - -

- -- - -

U
nR
eg

is

te

re


-
-

23

x86 Instruction Set Architecture


- -

- - --


-
- - - - -
- - -
-
- - -

- -- -

- --
-
- --
- - -
- -
-
-
- - -- -
-
- - - -- -
-
-- -
- --
- - - --
- -- --
--- --

-

-
- -
- -- -

U
nR
eg

is

te

re

24

Chapter 2: Mode/SubMode Introduction


IA-32 SubModes
- -
-

- -- - -

-- -
---
-- - - --
-
-
-
-- - -
- -
-
-
- -

-
- -- -
- ---
--
-

- --
- - --
- - -- - -

- - - -
-- -
--- -
- -- -
-

U
nR
eg

is

te

re

25

x86 Instruction Set Architecture


-

- -
- - -- - -
- -
-- -- - -
- - -- - -

-
- -- -
- -- -- --
- - -
-
- - --
-- - --
- - --- -
-
- --
- - -
-- - -- -- -

- -
- - - -
- -
-- -
- --

-
--
- -- -
- - - -
- -- - --
--

U
nR
eg

is

te

re

26

Chapter 2: Mode/SubMode Introduction


-

-
-
- - -- --
-
- --
- -
- -- -- -
- -- - --
--- -
- - -

- - -
-
- -
- - -
- -

- -- -
-- - - -
-

U
nR
eg

is

te

re

- - -- -- -
- - -
-- - -
- -- --
-- - -
--- - -
-
- -
-- - - - -
--

27

x86 Instruction Set Architecture


IA-32e SubModes
- -
-

-- -- -

- -
-
- -- -
- - -
- - -
- - -- --

-- -
- -- -
-
- -- -
- - - - - -
-- --


-- -- -- -
-- --
-- -
--- - - -- -
- -- -
--- - -- - -
--- - - -- -
- - - --

- -- - -
-- -
--
--
--
--
-- -- - - -
- - - ---
-

U
nR
eg

is

te

re

28

Chapter 2: Mode/SubMode Introduction


-

- --- -
-- -
-
-
-- -
-
-
-- -
--
-

- -- -
- - --
- - - -
-

-- - - -
-
- - --
- - -- - -
- - -- -
- - - --
- - - - -
-- -
-- -

-- -
-- - -
-- - -
-- -

U
nR
eg

is

te

re

29

x86 Instruction Set Architecture


Mode Switching Basics
Initial Switch from IA-32 to IA-32e Mode
-
- - - - - -
- -
- -

U
nR
eg

is

te

re

- -- - - - -
-
- -- -
- - - --
- - - -- - - -

- - - -- -
- -- --- - -
- - -
- - -- -
-
-- -
- -
- - - -- -
- -- -
-- -
--
-
- --- - - - --
-
- - - --
-
- - - --
-
- - - --
-
- - - - --
- - -

30

Chapter 2: Mode/SubMode Introduction

U
nR
eg

is

te

re

31

x86 Instruction Set Architecture

-
--- -
- -- - -
- -
- --

- - -


-
-- - -
- - - -- --
-

- -
- --- - -- -

- -- -
-- -- - -- - -- -
- - - -
--

U
nR
eg

is

te

re

-- -

- - -- -
- - --- -
-- - - -
- -- -

- - --
-- -

- -
- - - -
-

32

Chapter 2: Mode/SubMode Introduction


-
-- -
-- - - -
-- - - -
--- - --- - - - -- -

- -
- -- - -

--

-- - -
-- - ---
- -
--- -- - -
- -- - --
- - --

is

te

re

U
nR
eg

IA-32e SubMode Selection

-- - -
- - - - -
--

-- - --
- -
-
-
- -
- -
-
- --
-
- -
-

-- - - - -- - - -

33

x86 Instruction Set Architecture

-- - -
- -

-- - -
- -

-- - -
-

-

re

- -- -
- - -
- - - -

U
nR
eg

is

te

- -

34

Chapter 2: Mode/SubMode Introduction


- -

- -

- -

- - - --

- - --

- -

-
- -
- - -

is

-
- - - -
-
-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

- -
- -
-


te

- - - -
- - -
- -
- - - -
-
- - - -
- - -

re

- -

- -

-
- - - - - -
- --


-
-
-

- - - -

-- --
- - --

U
nR
eg

35

x86 Instruction Set Architecture

- -

- - - --

- - --

-
- -
- -


-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

U
nR
eg

36

- - - -
- --

- -
- -
-


-
- -
- - -
- -

- -


-
-
-

-- --
- - --

- - - -

re

te

is

Chapter 2: Mode/SubMode Introduction

- - --


- -

- - --

- - --

- - - --

- -

- - -


-
- -
- -
-
-- -
- -
- -- --
- -
-- - -

- --

U
nR
eg

- - - --
- --

- -
- -
-


re

-
- -
- - -

te

is


- -
-
-
- -

- -

- -


-
- -
-
- -

--
- - - --
- --
- -

- --

- - - -

37

x86 Instruction Set Architecture


Protected/Compatibility 16-/32-bit SubModes
-
-

U
nR
eg

re

te

-- - - - -
- - -
-- - - - -
- - -
--
-- - -
- - -
- - -
-- - -
- - -
- - -
--
-- - - -
- - -

is

38

Chapter 2: Mode/SubMode Introduction

--- -

U
nR
eg

-


- -
- - --
-

- -
- -

-- - - - --
- - --
- - -- -- -
-
- - - -- -
-
- - -- - -

is

te

re

-


-
- -
--
-

- -
- -
-- - - - --
- - --
- - -- -- -
-
- - - -- -
-
- - -- - -

39

U
nR
eg

is

te

re

x86 Instruction Set Architecture

40

re

The Previous Chapter

te

- - --
- --

This Chapter

is

- - - - -
--
- - -

U
nR
eg

The Next Chapter

- - --
- - - - - -
- -- -
-- - - - -
--- --

41

x86 Instruction Set Architecture


Major Evolutionary Developments
- - - -
--- - -
- - - -
-- -- -
-

--

re

te

- --

is

- - --
- - --

U
nR
eg

- - - - -
-

- - --

--

42

Chapter 3: A (very) Brief History

- -
- --
--
-
--
- -

-- --
- -
-- -
- -- -
-
-- -

---
- -
-- -
- -
-- --

U
nR
eg

is

te

re

43

x86 Instruction Set Architecture


-


-
- --
-- - - -

- - -- - -
-- -
- --
- -
-- - - --
- - -
-- -
-- --- - - -
- - --
-
-- --- - - --

- - - --
-
-- -- - -
- - -
-
-
--
-- -
- -
-- --

U
nR
eg

is

te

re

- -

44

Chapter 3: A (very) Brief History


-

- -

-- - ---
- - -- - -- - - -
- -
- -
- -- -
- -- - - -
- --

- -- -
- - - --
- -- -
-- - --
-- -- -
-- - - -
-- -

U
nR
eg

is

te

re


- - - -- --

--
- --
--
-- - - - - -
-- -
--- --

-
-- - --
-

45

x86 Instruction Set Architecture


-

- -
- - -
--
- - --
-- - -
-- - - - -
-- - -- -
- - -- -

- -


is

U
nR
eg

16-bit Mode Background

te

re

8086 and Real Mode

-
- -- -

--

--

-- -

- --
- -- - --
- --

46

Chapter 3: A (very) Brief History


--

--
- --
- --
- --
-
- --

- --


- --
- - - -- - --
-
- - --
- -

- -
- --
- - - -- -
- -
- - -
- -- - - - -
- -
-
--
- - - --
- - -
- - -
- -- - --

- - - - -
- -
-
- -

U
nR
eg

is

te

re

- -- -
- - -

47

x86 Instruction Set Architecture


--

--

--- -
-
---

286 Introduced 16-bit Protected Mode

is

te

re


- - - -- -
- - -- - -
- --- -
-- - - -
-- -

U
nR
eg

-- --

--

- -- -
-- - --
- -- - -- -

- - -- -
- -
--

48

Chapter 3: A (very) Brief History


-- --

---
- -- --
- - - - --

- -- --
-- - - -
-
- -
- -- --
- -- - -
-- -
- - -

- - -
- -

- - -

-- -- -
- - - -

U
nR
eg

is

te

re

--

- -
-- -
- - -- -
- -- -


-
-- - -
- - -- -
- --

- - --
- - -

-
- -
- - -- - -
-

49

x86 Instruction Set Architecture


-- --

--
- -- -
- - -

--- -
-
---


- -
- -
- -
- - -

U
nR
eg

is

te

re

50

Chapter 3: A (very) Brief History


- -

- -

- -

- - - --

- - --

- -

-
- - - -
-
-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

U
nR
eg

is

- -
- -
-


te

- - - -
- - -
- -
- - - -
-
- - - -
- - -

re

-
- -
- - -

- -

- -

-
- - - - - -
- --


-
-
-

- - - -

-- --
- - --

386 Supported Both 16- and 32-bit Protected Mode


-- ---
-
-- -


- -
- - - - -

51

x86 Instruction Set Architecture

-- - -
---
-- - - - -
- - - -
-- - -
---
-- - - - -
- - - -

- -- - - -- -
- - - - - --

re

--

-- -
--
- -- - -- -
-- -- - -- -
- - - -
-- - -
--

U
nR
eg

is

--

te

52

- -- -
- -

-- - - -

Chapter 3: A (very) Brief History


--

---
- - -- -
-- --
- - - - --

- -- --
-- - - -
-
- - -- --
- -- -
-- -
- - - -
-

- - -
- - -

- - - -

-- - -- -
- - - -

U
nR
eg

is

te

re

--

53

x86 Instruction Set Architecture


--

--
- -
-- -
- - -
-- - --
-

-
-- - -
- - -- -
--

- - --
- - -

-
-
- - -- - -

- -- - -

U
nR
eg

is

te

re

--- -
-

---


- -
- -
- -
- - -
- - - - --
-
- -
- - -

54

Chapter 3: A (very) Brief History


- -

- -

- - - --

- - --

-
- -
- -


-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

U
nR
eg

re

- -
- -
-


te

is

- - - -
- --

- -

- -


-
-
-

-- --
- - --

- - - -

-
- -
- - -

The Intel Microarchitecture Families


-- - -
--

55

x86 Instruction Set Architecture

--

-
- --
-
--

- --
-
- --

-- - - -

--- - --

--- - -
-

U
nR
eg

is

te

re

- --
-

- -
--- --
-

56

Chapter 3: A (very) Brief History


A Brief Timeline
-- ---
- - - - -
- - - - - - -
- - -
- -

-
--
- -

-
--
- -

-
--
- -

te

is

U
nR
eg

re

-
-
- -- -
--
- -

- -

57

x86 Instruction Set Architecture


- -

-
-- ---

-
--
- -

- --
-
--

- - -- -

re

U
nR
eg

is

te

-
--
- -

- - - --
--
-
- -- -

- - -- -
-
-
- -
-

- -- -
-

58

Chapter 3: A (very) Brief History


- -

U
nR
eg

-
--
- -


-- - -
--
- - -- -
-
- -


- -
- - -
--
-
- -
-

- -
-
-
- --- -
- --
- -- - -
- - - --
-

re

te

is


-- - --
-
-
- - -
- -
- -- -
-- -

59

x86 Instruction Set Architecture


- -

-- --
- -
-

-
--

re

te

U
nR
eg

--
- - -
-
--
--
--
- -

- - - - --


-
-
- - -
-
-

is

60

-- -
-
- -
- -

Chapter 3: A (very) Brief History


- -

- -

- -
-

-

-
- - -


-- -
--
- -

- --

- -- -
- -
--
-
- - --
-

-
-
-
- --

U
nR
eg

is

te

re

--

- - - -
- -
-
- ---
- -
---
- -
- -

61

U
nR
eg

is

te

re

x86 Instruction Set Architecture

62

The Previous Chapter

re

- - -
- --
-

te

This Chapter

U
nR
eg

is

- - - --
- - - - - -
- -- -
-- - - -
--- --

The Next Chapter

- - - -
- - -

- - - - - -
-
--
- - -
- -
- --
---
-
-
-- - -
-
-

63

x86 Instruction Set Architecture

-
--
-
- -

State After Reset


- - --- --
- - - - --
- -

re

U
nR
eg

te

-- - -

- - - -
- - -
- - -
--
- -
- -
- -
- -

is

64

Chapter 4: State After Reset

--
--
--
--
-

--
-- -

-
-

- -- -

te

--


--

- -

U
nR
eg


--

is

re

65

x86 Instruction Set Architecture

-- -
- -

-
--

--
- - -
- - -

- -
-

- -
-
-- -
- - -- --
-
- -
-- - -

- - -

- ---
-
- -- -- -
-- -- -- --

- - - -
- - - - -
- -
-
- - ---
-
-- -

U
nR
eg

is

te

re

66

Chapter 4: State After Reset


-- -
- -

- - -
-- -
- -
- - -
-- -
- - -
- -- - - -

- -
- -
- -
- - -
-- -
-- -
- -- -- - -
-- -
- --

-- -
-- -
- -

-
- -
- -
- --
---
- - -


- - -
-- -
-- -- -
- -- --
- --
-- ---
- - --

U
nR
eg

is

te

re

67

x86 Instruction Set Architecture


-- -
- -

- -
- - --
- - -
- -- - -- -- - - - --
- - -
--
- - - --
- - - --
- - - --
- -
- -
- - - -

- - - --
- - - --
- - -
- - -- -
-- -

U
nR
eg

is

te

re

- -

- -

- -
- -

- - -

- - -

--- - - -
- -
- - -
- -
- -

68

Chapter 4: State After Reset


-- -
-

--

- - --
--
- -
- - - -
- -
--
- --
-
- - -
- -
- - --
- - -
- --
-


--

- -- - - --
- -- -- -
--
- --
-
- - -
- -
- - --

U
nR
eg

is

te

re

- -

--

- - -
- - -
- --
- --
-
- - -
- -
- - --
- - -

-- - --
- - - -

69

x86 Instruction Set Architecture


-- -
- -

-
- -

- - -
- -
- -
-- --

- - -
-- -- --
- -

- -
- --
- --

- -
- --
-- -
--

U
nR
eg

is

te

re

- - -
- - - -
- --

-
- -

- - -
- -
- - - --
- --

-
- -

70

Chapter 4: State After Reset


-- -
- -

-
- - - -
- - -
- - -
--
- --

- - - -


--

-- -
- -- -
- -- -
- -- - - -

- - - --
- - - -
- -- - -
- - -
-
-- - - - -

U
nR
eg

is

te

re

--

- - -
---

--

-
-- -
- -- --- -
-- - - --
- - -
-

71

x86 Instruction Set Architecture


-- -
- -

-
-- -
- - -
- - -
- - - -
- -
- - -- -
- - - - -
-
- - - -
- -- -

- -
--

-
- - - -
- - - --
- - -
- - - -
- - -
- -
- -
-- -
- -
-
-
--
-- --
- -- --

U
nR
eg

is

te

re

- -

- -

- -

---
- - -

---
-


--

72

Chapter 4: State After Reset


-- -
- -

- ---
-

-
- - --
-

Soft Reset

te

re

- - - - - -
-- - - - - - - -
- - -- - - -
- - - -

- -- - --
- - ---

--
- - --
-- - --
-- ---

U
nR
eg

is

- - -- -

Boot Strap Processor (BSP) Selection


- -
--- -- -
--
-- - -- -- --
-
- - - -- --

- --- - - - --
- ---
- -
--

73

x86 Instruction Set Architecture


- --- -- ---
--
-
- -
--- - - --
- -
- - - -
--
--- -
-
--
- - - - --
-- - -
-- - - -

te

AP Discovery and Configuration

re

U
nR
eg

is

--- - - --- - -
- -- --
-
- --- - - -
-- -
- - - - --
- - -- - -- -
-- - - -- -
-- ---- - -

- - -- -

Initial Memory Reads

--- -
--- - - -- -
- - -- -- - - - - -
- -

74

- - -- --

Chapter 4: State After Reset

- -- -
-- -
- -- - - --

- - -- -

U
nR
eg

is

te

re

- - -- - - - -
- - - - -
-
- -- -
-- - ---
- - -
- - --
- - - - --
- - - - --
-- -- - - ---
- - - -
- - - -
- - -
- - -
- -- -- - - -- -
- - - -- -
- - - - -
- - - -- ---
--- - - -
-- - -
- -- -- -
- - --

75

U
nR
eg

is

te

re

x86 Instruction Set Architecture

76

The Previous Part

re

- - ----

This Part

is

--
- -
-



-
- ---
--
--
- -
-
-- - --

-
- -


-
-

U
nR
eg

te

- - --
--- -

The Next Part

U
nR
eg

is

te

re

-
-


--

re

The Previous Chapter

is

This Chapter

te

- - --
- - - -
- - - -
-- - -
--- --

U
nR
eg

- - - - - -
- -

- - - - - -
-
--
- - -
- -
- --
---
-
-
-- - -
-
-
-
--
-
- -

79

x86 Instruction Set Architecture


The Next Chapter
- - - -
- - - - - -
- -

The Pre-386 Register Sets

re

- - - - - -
- - - - - ---
- -- - -- -

8086 Register Set

is

- -- -
- -
--
- -

U
nR
eg

te

- - - -- -
-

- -

- -- -

- - -- -
- - -- -

80

Chapter 5: Intro to the IA-32 Ecosystem


-
-

te

re

is

U
nR
eg










-
- -- -

81

x86 Instruction Set Architecture


286 Register Set
-- -

- -
--
- -
- -
- -
- -

re

- - - -
- - -

U
nR
eg

-
-

- -- -

is

te

- -

- -

- -

- - -- -
- - -- -

82

Chapter 5: Intro to the IA-32 Ecosystem

- -

re

te

- -

is

U
nR
eg

- -









83

x86 Instruction Set Architecture


IA-32 Register Set Overview
-- - - -
-- - - -
- -- - -


-

U
nR
eg

is

te

re

- -- -
- - -- -

84

Chapter 5: Intro to the IA-32 Ecosystem

--
--
--
--
-

--
-- -

-
-

re

- -- -

is

--

te


--

U
nR
eg

- -


--

Control Registers
- -- -- -
- -- -- --
-- --

85

x86 Instruction Set Architecture

re

- --
- -
- -- - --
-- - --- -
-- - -- -- -
- - -
- -- -
- --- - -- --

-- --
- - - - --
-- -- - --
--
- - -
- - - - --
- - -- - --

- -- -

te

U
nR
eg

is


-

-


-
-
-
--

86

Chapter 5: Intro to the IA-32 Ecosystem

- --

is

- --

te

re

-
-

-

- - - -

U
nR
eg

- -




- -- -

- - -

--

87

x86 Instruction Set Architecture


Status/Control Register (Eflags)
-- -
- - - - -

- - - - -
- - -- --
- -
- - - -

te

--- - - - - - - - - - -

--- - - - - - - - - - - -

re

- - - -- - -

is

- - - - -

U
nR
eg

- -

- -

-




-
- -









88

Chapter 5: Intro to the IA-32 Ecosystem


Instruction Fetch Facilities
- -

General

re

U
nR
eg

is

- - -
- -
- - - -
-- - -
-
- - -- --
- - - -
-- - - -
-- -- - -
- - -
- -- -
- - - -
- -- --
-

te

--- - - -
-- - - - -- -
-

- - -
-- - -
-

--- - - - - -
- - - -
- - - -
--- - - - - -
- - - -
- - - -

89

x86 Instruction Set Architecture


Branch Prediction Logic
- - -- -- - - -
- --
- --- -
- -- -

U
nR
eg

is

te

re

-- -- - -
- -
-- -
-
- - -- - -
-
-
- - --
-- -
- -
- -
- - --
--

-- -- -

General Purpose Data Registers


-- -

--
- - - -
-- - -

90

-- - -- - -
- -- - - -
-
-- - -
-- - - - -
- - -- -- -
--

Chapter 5: Intro to the IA-32 Ecosystem

- -
-- - - -
- - - -
- -
-- - - -
- - -- -
- - - - - -- -
- - - -
-- - - - - - -
- - - -- -
-

is

te

re

- --- - -- - -
- -- - - ---
- -- - - -
-- - - - - - - -- -

U
nR
eg

--- - - --

91

x86 Instruction Set Architecture


Defining Memory Regions/Characteristics
-- -- - - - --
--

MTRRs
-- -

-- -

is

Segment Registers

te

re

-- -
-- -
- -- - -- -
-- - -- -
-

U
nR
eg

- - -- - --
- - --

92

- -
- - --
- - -
- --
-
- -- -- -

- - -

-
- - --
- - -
- -
- - -- -
- - -

Chapter 5: Intro to the IA-32 Ecosystem

U
nR
eg

is

te

re

- --

- -- -- -

- --
-
-
- - --
- - - -

-- - -

- -
- - -- -
- - - - -
- -- -
- -- -- -

- --
- -
- - -
- - - --
- - - -

- - --

--
--
- -
-

Address Translation Facilities


-- - -

Interrupt/Exception Facilities
- -
- -- - -

93

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -
- -
-- -
- -
- - -- -
--
- - - --
- -
- - - -

- - --
- - --- - -
- - - -- ---
- -- - -
-- - -
- - - -

- -- -- -
- --
- -- -- - -
- - - ---
-- - -
- - - -
- -- - -
- -
- - - -
- - - - - -
--

--


- -

Kernel Facilities
-- - --

94

- -
- -

Chapter 5: Intro to the IA-32 Ecosystem

- -
- - -

--

--
- -
-

Real Mode Has No Memory Protection

te

re

- - - -
- - - - - -
- -- -
- - - - --
-

U
nR
eg

Introduction

is

Memory Protection in Protected Mode

-- -
- - -- - - - -
-
- -- -

Segment Selection in Protected Mode


- - -- -

- - - -- -
--
- - - -

- - -- - -
-- - -
- - -
- - - -

95

x86 Instruction Set Architecture


- -- - -
-- - --

- --

- -- -

Access Rights Check

re

- -
-- -
-- - -
-
-
- -

te

- -- - -
-- -

U
nR
eg

is

- - - - -
-

The Descriptor Tables

- - -

- - - - -- --
--
- - - -
- -- -- -

Descriptor Table Registers

- - - -
- - -- - - -

- --
- -

- - - -- -
-- - - - - -- - -

96

Chapter 5: Intro to the IA-32 Ecosystem


- - - -
- - - - -
--
- -

Task Data Structure

U
nR
eg

-- - -
- -
- - - - -
-

is

te

re

- --- - -- -
- - -
- - -
- - - - - - -
- - -
- - - -
- -- - -- -- -
- - - -
- - - -

Address Translation Facilities


--

- - -- -
-- - --

Effective/Virtual/Linear/Physical Addresses
-

-- - -- - -
-- -
- -
-- -- -
-

97

x86 Instruction Set Architecture

re

-- - - - -
-- - - -- - - - -- - -
-- -
- - --
--
- -- -
-- - --
- - - -- - --
- -
-- - -- -- - - --
- - -- - - -- -
-- - - --

te

Introduction to Address Translation (Paging)

U
nR
eg

is

-- - - -
- - -
-

RAM Is Finite and Cant Hold Everything


- -- -
-- - -
- - -
-- - --
-

98

- - -
- - - -
- - -
- - - -
--- -
- - -
- --
- - -
- - - -
-
-- -

Chapter 5: Intro to the IA-32 Ecosystem

- -- -
- - - -- -
-

RAM and Mass Storage Are Managed on a Page Basis

re

This Requires a Series of Directories

- --
- - - -- - -
- -- - - - -
- - - - - -- - - - - - - -
- -- - -
- - -

U
nR
eg

- - - - -
-
- -
- - - -

-
- -- -

-- - -- -
-

is

te

-- - - -

Malloc Request

- -
- --- - -
-- - --

- - - -
- - -
- - - - -
--
- - -- -
- -

99

x86 Instruction Set Architecture

- - - -
--
- - - - -- - -
- - -
- -
- - - - -
- -
- -
- - -
- -

Problem: Non-Contiguous Memory Allocation

te

re

- - - - -- -
- - - -
-- - - -
--- - - - - - -

is

Malloc Returns a Virtual Address to the Application

U
nR
eg

- - - --
- -- - --
-- - -- --
-- - - - -
----
- - - - - - -
--- - - -
-- --
- -- - - - -- --- --
-- - -- - - --
-
-- - -

100

- - - - -
- - -- - - --
-- -
- --
- - - --
- -
- -
- - - -- - -

Chapter 5: Intro to the IA-32 Ecosystem


- - -
--

IA-32 Applications Have a 4GB Virtual Address Space

-- -- -
-- --
-- - -- - - -
-- -- -- -
-- - -
- - -
-- -

-- -

is

Legacy FP Facilities

te

re

- - -
-- - - -
-- -

U
nR
eg

In the Beginning, FPU Was External and Optional


--- - ---
-
-- - -
- - - - -- - -
-

- ---
-
-
-

101

x86 Instruction Set Architecture


It Was Slow...
- - --
- - --
- -
-- - - -- -
-

486DX Integrated It

te

re

-- -
-- - - -

x87 Register Set

is

- - - -

U
nR
eg

x87 FP Instruction Set

- - -- - - -
- --
-
- - -

General Purpose Instruction Set


- -- - --- - - - -

MMX Facilities
-- -
- -

102

Chapter 5: Intro to the IA-32 Ecosystem


Introduction
- - - - - - - --
-- - -
-

SIMD Programming Model

U
nR
eg

is

te

re

-- -- - - - -
- - - - - - - -
- - - - -
- - -
- - -
- - - -
-- - ---
-
- -- - --
- --

--

--

- -- -

103

x86 Instruction Set Architecture


SSE Facilities
-- -
- --
-

Introduction

U
nR
eg

is

-- -- - -
- -
-- --
- - - - - -
- -- - - - -
-
-- - -- -

- - -
- -
- -- - - -
- -
--- -
-
-
-

te

re

-- -
-- - -
- -- -- -
- - -
--

Motivation
- - --
-
- -
- - - - -

104

Chapter 5: Intro to the IA-32 Ecosystem


--
-- --
- ---
- -
- -

- - -
-
- -
-
-
-- - -
-
- - --
-

re

is

te

- - -
- - -
-

U
nR
eg

Instruction Set

- - - - -- --
-- -- -- -
--

Model-Specific Registers
-- -

General
-- -- - -- -
-
- --
- -
- -
- - -

105

x86 Instruction Set Architecture


- - -- -
-- - -

Accessing the MSRs


- -- - --
- - - -
- - -
- -
- -
- - -
- -

- - - -
- - -- -
- -
- - - -

is

te

re

U
nR
eg

Debug Facilities

-- -

--- --
- - - --- -- -- - --

106

- -
-- - --
- --
- - -
-- - -
-- -- - -
- - - -
- - - -
-- - -
-- -
- -
- - - --

Chapter 5: Intro to the IA-32 Ecosystem


- - - --

Automatic Task Switching Mechanism

U
nR
eg

is

te

re

--- - -
- - - -
- - - -
-- -

107

U
nR
eg

is

te

re

x86 Instruction Set Architecture

108

-
-

re

The Previous Chapter

is

- - - - - -
-
--
- - -
- -
- --
---
-
-
-- - -
-
-
-
--
-
- -

U
nR
eg

te

- - - - - -

This Chapter
- -- - - - -
- - - - -
- -

109

x86 Instruction Set Architecture


The Next Chapter
- -
- - -

- -
- --
-

-
- -
- -
- -
- -
-

-- - -
-- -
-
- -

--

-


- -

te

U
nR
eg

is

re

Why a Comprehensive Instruction Set Listing Isnt


Included
- - -
- - - - -
- - - - -
- - - - -
- - - - - - -- -
- - --- - - - - ---
- --- ----

110

Chapter 6: Instruction Set Expansion


- - - -- - -

386 Instruction Set


- - -- --- -

re

- -

- -
-

is

te

- -- -

-- -

U
nR
eg

--

111

x86 Instruction Set Architecture


-
-

-
-
---
--

- -

- -

- -

- -

- -

re

te

-
- -

- -

is

- - -

U
nR
eg

- -

- - -

- -


--

112

Chapter 6: Instruction Set Expansion


-
-

- -

- -

re

is

te

--

U
nR
eg

--

-
-- -

- -
--

- -

- -

113

x86 Instruction Set Architecture


-
-

re

is

te

-- -

- -

- -

- -

U
nR
eg

---

-
---


--

114

Chapter 6: Instruction Set Expansion


-
-

- -

te

U
nR
eg

is

re

-- --

--

--

--

--

115

x86 Instruction Set Architecture


-
-


-- --

te

is

re

-- -

U
nR
eg

--

--

116

Chapter 6: Instruction Set Expansion


-
-
- -

- -
-

- -
-- -

is

te

re

- -

U
nR
eg

-- --

Instruction Set (as of March, 2009)


-- - -
- ---
- --
-

- --
--

117

x86 Instruction Set Architecture


- --
--
--
--
--
--
--
--
- --
--
-- --
- -

re

U
nR
eg

is

- - -


-
-
-
-

te

- --

- -

- --
- - --
- - --

118

Chapter 6: Instruction Set Expansion


-
-

--


--

--

--

U
nR
eg

is

te

re

119

x86 Instruction Set Architecture


-
-

- -

- - -- -

- -- -

is

U
nR
eg

120

te

re

Chapter 6: Instruction Set Expansion


-
-

- -

- -

- -

--

re

--

- -

U
nR
eg

is

te

121

x86 Instruction Set Architecture


-
-

- -

- -

- -

- -

U
nR
eg

is

te

re

--

--

--

--

122

Chapter 6: Instruction Set Expansion


-
-

- -

--

--

--

--

re

te

is

U
nR
eg

- -

123

x86 Instruction Set Architecture


-
-

U
nR
eg

is

te

re

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

- -

124

Chapter 6: Instruction Set Expansion


-
-

-
- -

- -

- -

- -

U
nR
eg

is

te

re

- -

- -

- -

- -

- -

- -

125

x86 Instruction Set Architecture


-

- -

- -

- -

U
nR
eg

is

- --

te

re

-
-
-
-

-- -

--

- -

126

Chapter 6: Instruction Set Expansion


-
-

- -

--

U
nR
eg

is

te

re

- -

127

x86 Instruction Set Architecture


-
-

te

is

U
nR
eg

re

128

Chapter 6: Instruction Set Expansion


-
-

- -

U
nR
eg

is

te

re

- -

129

x86 Instruction Set Architecture


-
-

-- -- - -

- - -

- - -

- - -

- - -

- - -

- - -

te

re

is

--

- -

- -

U
nR
eg

- -

- -

130

Chapter 6: Instruction Set Expansion


-
-

-
- -

- -

- -

-- -

-- -

re

- -

is

te

U
nR
eg

- -

- -

- - - -

- - - -

- - - -

131

x86 Instruction Set Architecture


-
-

-
-

- -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

- - - -

U
nR
eg

is

te

re

- -

132

Chapter 6: Instruction Set Expansion


-
-

- -

- -

- -

- -

re

te

--

is

--

U
nR
eg

133

x86 Instruction Set Architecture


-
-

-- - - - - -

- -
- -

-
-

-
- -

-
-

-
- -

U
nR
eg

is

te

re

- - -

- --
-

-- -

- -

- -

- -

- -

134

Chapter 6: Instruction Set Expansion


-
-

-
- -

- -

- - -

- - -

- - - -

- - -

- -

- -

is

te

re

-- - - -

- -

- - - - -

- - - -
- -

U
nR
eg

-- -

- -

- -

- -

- -

-- -

- - -

135

x86 Instruction Set Architecture


-
-

- - -
-

- - -
-

-- - - - -

- -

-
-

- -

is

te

re

U
nR
eg

- -

- -

- -

- -

- -

- -

- -

136

Chapter 6: Instruction Set Expansion


-
-

- - - -

- - -

- - - - - -

- -

- -
-

- -
---

- - -

U
nR
eg

is

te

re

-- -

- - -

- -
- -

- - -

- --
-

137

x86 Instruction Set Architecture


-
-

-- - -

- - -

- -

- -

- -

- -

- - -

- - - -

- -

- -

U
nR
eg

is

te

re

-- -

- -

- -

- -

- -

-- -

- -

138

Chapter 6: Instruction Set Expansion


-
-

- - - -
- -

- - - -
- -

-- -- - -

- - -
-

- - -
-

te

re

-- - - - -

-
-

U
nR
eg

is

- -

- -

-
-

- -

- -

- -

- - - -

- - - -

- -

- - -
-

139

x86 Instruction Set Architecture


-
-

-
-

- - -

- -

-
-

re

--

--

- -

U
nR
eg

is

te

- -

- - -

140

Chapter 6: Instruction Set Expansion


-
-

-
- - -
-

- - - -

- -
-

-- - - --
- ---

- -

re

te


- -

is

- - -- -
-

U
nR
eg

-
--

- - -
- - - -
-

- - - -
-

141

x86 Instruction Set Architecture


-
-

-- - - -
- - - -
- - -
- -
- - - -
- -

- - - - -
- - - -
- - -
- -
- -
- - -
- -
- -
-

- - - -
- - - -
- - -
- - - -

- - - -
- - - - -
- -
- - - -
- - -

U
nR
eg

is

te

re

-- - -
-

-- - -
-

142

Chapter 6: Instruction Set Expansion


-
-

-
-- - - - - -
- - - -
- - - - -

-- -- - --

- -- -
- -- -
-

re

te

- - -
- - - - -
-- -

- - -
- - - - - -
-- -

- - -
- - - - -
-- -

- -
- - - - -
- - - -
- - --
-

- -
- - - - -
- - - -
- - - --
-

U
nR
eg

is

143

x86 Instruction Set Architecture


-
-

-
- -
- - - - -
- - - -
- - --
-

- - - -

- - -

- - -

re

- - -
- -
- -
- - --
-

U
nR
eg

is

te

- -

- - -
- -
- - -
- --
- - -
- - -
- - - -
- - -
-

144

- - -
- - - -
- - -
- - - - -
- - - - -

Chapter 6: Instruction Set Expansion


-
-

- - -
- - -
- --


- -

- - -
-
- -

re

te


--

- - -- -
-

- - - -
-

U
nR
eg

is

- -

- - -

- -
- -
- - - -
- - - -
- - - -
-

145

x86 Instruction Set Architecture


-
-

- - - -
- - - -
-

- - - -
- - -
-

- - -
- - - -
- -

- - - -
- - -
- -

- - - -
- - - -
-

U
nR
eg

is

te

re

- - - -
- - - -

- -

- -

- -

- -

- -

- -

- -

- -

146

Chapter 6: Instruction Set Expansion


-
-

--
- - - -
-

- - -

- -

te

- - --

re

- - - -
-- - - -

--
- - - - -
- - -
- - - -
- -

U
nR
eg

is

- -
-

- -
-

- -
-

- -
- -

- -
- -

- -
- -

147

x86 Instruction Set Architecture


-
-

-
- -
- -

-
- -


- -


- -


- -


- -


- -

U
nR
eg

is

te

re


- -


- -


- -


- -


- -

148

Chapter 6: Instruction Set Expansion


-
-

- - -

- - -
- -


- -
- - -
- -
- -

re

- - - -
-- - -
- - - -

--

U
nR
eg

is

te

- - -

-- -

--

-- -

--

-- -

149

x86 Instruction Set Architecture


-
-

- -

-
-

--
- -
-

- - - - - -
- - -
- -

re

te

- -

- -

- -

U
nR
eg

is

- -

- -
- -

- -
- -

- --

- - -
-

- -

- - - -

150

Chapter 6: Instruction Set Expansion


-
-

-
-- - - -

- - -

- --

-
- -

--

U
nR
eg

is

te

re

--

- - --

- - --

-- --

- -- --

- - -

151

x86 Instruction Set Architecture


-
-

-
- - -

- -

--

--

- -

--

- - -
--

- -- -

U
nR
eg

is

te

re

- --

- - - --
- -

- -

- - - - -
- --
-

- - -- -

152

Chapter 6: Instruction Set Expansion


-
-

-
- - -

- -
- - -

- --
- -

-- --
- -

-- --

- - - --
-- -
-

-
-- - -- -
- - -

- -- - -
--

U
nR
eg

is

te

re

- - -

- - -

--- -
- - - - -
-

153

x86 Instruction Set Architecture


-
-

-
-

- - --- -

U
nR
eg

is

te

re

154

The Previous Chapter

te

This Chapter

re

- - - - - -
- - - - -
- -


- -
- --
-

-
- -
- -
- -
- -
-

-- - -
-- -
-
- -

--

-

U
nR
eg

is

- - -
- - -

155

x86 Instruction Set Architecture



- -

The Next Chapter


- -
- -

is

te

re


- -

-
-
-
--
-

--
--

-

U
nR
eg

64-bit Machine Language Instruction Format


- - - - -
- --
-

- --
- -

A Complex Instruction Set with Roots in the Past


- -- - -
- - -
- - -- -
-- - - --
-
-- --- - -

156

Chapter 7: 32-bit Machine Language Instruction Format


- -- -
- --

Effective Operand Size


Introduction

- - - - -
- -

re

te

- - - - - -
- -- --
- - - - - --

is

Operand Size in 16- and 32-bit Code Segments

U
nR
eg

-- - -
-- - -
-- - - -
-

- - - -
-
- -
-

- - - -
-
- -
-

157

x86 Instruction Set Architecture




-

- -- -
- - -
- - - - - -
- -

re

-
- - -
- - - -
-

- -
-

U
nR
eg

is

te

-
- - -
- - - -
-
- -
-

- -- -
- - -
- - - - - -
- -

Operand Size in 64-bit Code Segments


- -
- -- - - - -- - -
- - -- - - -- ---

158

Chapter 7: 32-bit Machine Language Instruction Format


-- - - -
-- - - - - -
- - --
- -
- - -
-- - -- -
--- - -
-- -
-

-- - -
- - -
- -
- - -

te

re

- --
- --- -
-

U
nR
eg

is

- ---
- -- -
-

- - -
- -

-
-
-

159

x86 Instruction Set Architecture






-

- - -
- -

-
-
-

- - -
- -

-
-
-

is

te

re

-
- - -
-

-
-
-

-

- -

U
nR
eg

- -
- -
-- - -

Instruction Composition
- -
-

160

Chapter 7: 32-bit Machine Language Instruction Format

-
- - -
- - --
- - - - - -
- - - --
--
- -

- -- - - - - - -
-- -
- - - -
-- -
-
--
- -
- -

U
nR
eg

is

te

re

-- - -
- - - -
--
--

-
-
-
-

- - -
--
- - - - -

161

x86 Instruction Set Architecture


-

- - -
-
-- --
-

--


- -
-- -
- -

-
- - - --
-
- - -
- - -- - -
-

U
nR
eg

is

te

re

Instruction Format Basics

- - - - -
- -
-- - -
- - - -
- - - - -
-- -
- - - --
- - -

162

Chapter 7: 32-bit Machine Language Instruction Format

U
nR
eg

is

te

re

163

x86 Instruction Set Architecture

- -
-- -
- -- - -
- -- -
- -- -
- -
- - - -- -
-
-- - -
-- -
-

te

re

- -

U
nR
eg

is

-

-
-


- -- --

- -- --

164

Chapter 7: 32-bit Machine Language Instruction Format


- -

- - -
-- - -
-
- --
- -
--
- - -- -
-

- - -
-
- --

- - -
- -- - -
- -
- -- - --
- - --
-
-
-- -

U
nR
eg

is

te

re

- -

-

-

- -
-
-
-
-

-
-
-- - - -

165

x86 Instruction Set Architecture


- -

- -

- -
- -
- - -

re




-

-

-

te

- -
- -
-- - - -
- - --
- -
-
- --

U
nR
eg

is



- - -
-- -
-
-
-- --
- -

- -
-

166

Chapter 7: 32-bit Machine Language Instruction Format


- -

- -
- -- -
- --
--

is

te

re

- --
- - --
- -- - -- -
- --
-- - - - - --
- - - - - -
- - --



-
- - -

U
nR
eg

-
- -
- - - -
- - -
--



-- -- - -
-

167

x86 Instruction Set Architecture


- -

- -
- - -
-- -
- - - - -



- -
-
- -
-

te

re

- -

U
nR
eg

In the Beginning

is

Opcode (Instruction Identification)

- -
--
- -- -
- - -- -- -- -
- --- - -- -
-

168

Chapter 7: 32-bit Machine Language Instruction Format



-

-

re

te

U
nR
eg

is

1-byte Opcodes

- --- -- -
- - -
- -
- - - -

-
- - - - -
- -- - - - -
- - - -- --
- -
- - -
-
- - -
--

169

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-

- - -- - --
-
-

- -- - -

-
-- --
- - - -
- - - -
- - - -

- -- -
- -- -
- - -
- -
- -
-
- -- -
- - -

- --
- -- -

- - -
- - - -
- - - - -
- - -
- - - -
- -- - --
- - - - - - -
- -- --
- - - -- -
--
- - -

170

Chapter 7: 32-bit Machine Language Instruction Format

U
nR
eg

is

te

re

--

171

x86 Instruction Set Architecture



- - - -







re

- -
-- -

te

2-byte Opcodes Use 2-Level Lookup

is

2nd-Level Opcode Map Introduced in 286

U
nR
eg

--
- - -
- -- - -
-- - -
- - --

--
--
- -

Instructions with 2-byte Opcodes: Five Possible Forms


- --- -- -
- - --
- - -
- - -
- -
- - -
--

172

Chapter 7: 32-bit Machine Language Instruction Format

U
nR
eg

is

te

re

- -
- -
- - - -
- -
- - - - --
- - -

- -
- -
-
- -- -
- - -

- --
- -- -

- -
- - - - - - - - - - - -
- - - -
-- - -- -
- -- - - - -
-- --
- A 2-byte opcode preceded by a prefix byte being used in a non-stan-

dard manner (see Special Use of Prefix Bytes on page 177) that alters
the characteristics of the instruction. - - -
- -

- - - -- -
--
- - -

- - -

173

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-- - -

174

Chapter 7: 32-bit Machine Language Instruction Format

U
nR
eg

is

te

re

-- -

175

x86 Instruction Set Architecture


3-byte Opcodes Use 3-Level Lookup
3-Level Opcode Maps Introduced in Pentium 4 Prescott
-- -
-
-
- -

Currently There Are Two 3rd-Level Maps Defined

te

- --
--
-
--
-- - -

is

re

- - -

- - -
- -
- --
--
--
- -
-
--
--

U
nR
eg

Instructions with 3-byte Opcodes: Three Possible Forms


- --
- - - -
-
- - -
- --

- - - - --
- -

176

Chapter 7: 32-bit Machine Language Instruction Format


- -
- -
-
- -- -
- - -

- --
- -- -

- A 3-byte opcode preceded by a prefix byte being used in a non-standard

manner (see Special Use of Prefix Bytes on page 177) that alters the
characteristics of the instruction. - - - -

is

te

re

- - - -- -
--
- - -

Special Use of Prefix Bytes

U
nR
eg

- - --
-- - - - -
-
- - -
- - - - - -
- - -

- - --
-- -
- - --
-
- -
- -- -
- - -

-- - - -
-
-

177

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-- - -

178

Chapter 7: 32-bit Machine Language Instruction Format

U
nR
eg

is

te

re

-- -

179

x86 Instruction Set Architecture


Opcode Micro-Maps (Groups)
- -- - -
- - -
- - - -
-

Micro-Maps Associated with 1-byte Opcodes

re

U
nR
eg

te

- -
- - - - -- - -
- - - -
--
- - -

- - -
-
- -

- - - -
-
- - -
- -- - -
- - -- - -
- -

is

-- -
- - - -
- - - -

Some Opcodes Employ 2 x 8 Micro-Maps


- --

180

--
--
- - -
- -

Chapter 7: 32-bit Machine Language Instruction Format


- - -
- -

- -


-
-

re

- - --
-
-- --

te

- - - -
-
- -- -- -- -
- -
- - -

is


- - - --
-
- - -
- - -
- -- -

U
nR
eg

- -

- - -

181

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- - -- -

182

Chapter 7: 32-bit Machine Language Instruction Format


Micro-Maps Associated with 2-byte Opcodes
- - - - -- - -
- - -
- - -
- -
-

is

U
nR
eg

te

re

- - -- -

- --

183

x86 Instruction Set Architecture

--

--

te

re

is

U
nR
eg

184

Chapter 7: 32-bit Machine Language Instruction Format



-
-

-
-

-
-

-
-

is

-
-

U
nR
eg

-
-

te

re

-
-

185

x86 Instruction Set Architecture

--

re

te

- - -

is

U
nR
eg

186

Chapter 7: 32-bit Machine Language Instruction Format

re

3-byte Opcodes Dont Use Micro-Maps

te

- -
-

is

x87 FP Opcodes Inhabit Opcode Mini-Maps

U
nR
eg

- - - -
- -
- -
-- -
-
-- - -


- - -
-- --
--

- - - -
-- --
--

187

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-- -

188

Chapter 7: 32-bit Machine Language Instruction Format


Special Opcode Fields
-
- - - -
-- - - -
- - - --
-- - -- -
- - -

- -

- -


-
--
- -

- -



-
- -

-
- -

-
- -
-

te

is

U
nR
eg

re

189

x86 Instruction Set Architecture


- --

- -

--
- - -
--



-



--

-
-
-
- - -

-- - - - -
- -- -
- -
- -
-
- -
- -

U
nR
eg

is

te

re

190

- -
- - -- - -
- --
-
- -
- -
- -
- -
- -
- -
-
-

Chapter 7: 32-bit Machine Language Instruction Format


- --

- -


-- - -- -
-
-
-
- -
- -

-- - -
- - -
- -
- - -
- -

-- -
- -
- -
- -- - - -- -
-
- -
- -

U
nR
eg

is

te

re

191

x86 Instruction Set Architecture


-
--

-
--

re


- -

-
--

U
nR
eg

is

te

- -


- - -
- - -
-
- -- -
-- -
-
- - - --
-
- - - --
-- - -
- - -
- -
- - -
- - - - - -
- - - - -- -
-

- -
- -

-
- - -

192

Chapter 7: 32-bit Machine Language Instruction Format

- - - -







te

re

- -
-- -

-
-- - -

U
nR
eg

is

193

x86 Instruction Set Architecture


--

--

--

--

re

U
nR
eg

is

te

- - -- -

--
--
--

Operand Identification
General

- --
- - - ---

- - -
- --
- -
- - -
- -
-

- - -- - -
-

194

Chapter 7: 32-bit Machine Language Instruction Format


Specifying Registers as Operands
- - - - --
- -

- - --
- -- - -

te

re

- -

-
- -

-
- -
- -

-
-
-
- -
-
-
-

- - -
-

-
-

-

-

-
-

U
nR
eg

is

- -

195

x86 Instruction Set Architecture


- -
-


- -


- -

-
-

Implicit Register Specification

re

- - - -
- -- - -

te

Explicit Register Specification in Opcode

U
nR
eg

is

-- - -
-- -

- -- -- - - -
- -

Explicit Register Specification in ModRM Byte


--
- - --
- -- - -- - -
- - -
-
- -- - -
-

196

Chapter 7: 32-bit Machine Language Instruction Format

te

re

- - -
-
- -- - - -- --
- - -
-
- -- - -
-
-- -
- - -- -
-- - --
- -

- - -
- -- -
-
-
- -

-

is

-- - - - -
-- -- --
- - - - -
- - - -
- - -
-- -
- -

-
-
-- - -
- - - -
- - -
--
- - - - -
- -- --
- - - -
-
-- --
-- -

U
nR
eg

197

x86 Instruction Set Architecture

re

--
- - - - -
- -- --
- - - -
-
-- --
-- -
--
- - -- --

--
- - -- -

te

- - - - - -

U
nR
eg

is

Addressing a Memory-Based Operand


Instruction Can Specify Only One Memory-Based Operand
- - - -
- - -
-

198

Chapter 7: 32-bit Machine Language Instruction Format


-- - - -

-- -

-- - - -
- - - -
--

-- - - -
- - -- -
- --

--
- -

-- -
-- -
-
-
-

- -
-- - --
-
-
-
-
- - - - -
- - -

U
nR
eg

is

te

re

--

199

x86 Instruction Set Architecture


- -- -- -
-- - -

re

- -
-- - - - -
- - - -
-- - -- --

-- - - -


-
- -- -- --

te

Addressing Memory Using the ModRM Byte

U
nR
eg

is

- -
- - -
-- - - - -- -
-- - - --
- -- --
- --

-- -
- -- -
- - -- - -
-
- - - -
--
- - - -
--
- - -
- -- --
-- - - -
- - --
-

200

Chapter 7: 32-bit Machine Language Instruction Format

-- --
- - - -

-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-

re

te

is

U
nR
eg

201

x86 Instruction Set Architecture


-- -

te

re

- -- -
- - -- - -
-
- - - -
--
- - - -
--
- --
- -- - - -
- --

-
- - -
-- - - -
-

202

U
nR
eg

--
- - - -

is

-- -

--
-

Chapter 7: 32-bit Machine Language Instruction Format


-- -

U
nR
eg

-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-

re

te

is

Using the SIB Byte to Access a Data Structure


- --
- -- - -
-- - - -
-- -
- -
- - - -
- - -- -
- - -- -
- -
-- - - - - - - -
- -

- - -- - - -
-- -
- - -- - - -

203

x86 Instruction Set Architecture

- - -- -
- - -

- - -- - - -
-- -
- -

- - -- - - -
-- -
- -

re

- -
-- -

U
nR
eg

is

te

-
--

- -- - -

-
- -
-- -

- - -- - - -

204

Chapter 7: 32-bit Machine Language Instruction Format


-

- -








-
-
-
-

te

re

U
nR
eg

- -

is

-- -

205

x86 Instruction Set Architecture


-- -

re

te

--

U
nR
eg

is

- - - -- -
-

-
-

-- --
- - - - -
-

Near and Far Branch Target Addressing


- - --
-- - -

206

Chapter 7: 32-bit Machine Language Instruction Format


-
- - -
- - - -
- - -
-
- - -
- -
-- -
-
- - - -


- -


- - -
- - -
-

- -
- - -
- -

- -
- - -
-
-- - -
- -- -

U
nR
eg

is

te

re

207

x86 Instruction Set Architecture


-


- -
- - - -
-
- -

-
-
-
-
- - -
- -
-
-
-
-
- -
-


- -


- -
- - - -
-

- - -
- -
-
-- - -
- -- -

U
nR
eg

is

te

re

208

Chapter 7: 32-bit Machine Language Instruction Format


-

- -
- - - -
-
- -

-
-
-
- -
- - -
-
-
-
-
-
- -
-

U
nR
eg

is

te

re

Specifying an Immediate Value As an Operand


-- -
- -- -
- --
- - -
-
- - -- -
- - - -
- - - -
---
- - -
-- - - - - - ---
- - -
-
-
- - -

209

x86 Instruction Set Architecture

U
nR
eg

is

te

re


- -
- -
-- - - - - ---
-- - -
-
-
- - -

--
- -- -
- - -- -
-- - -
- -- -
- - - - -
- - - - ---
-- - -

- --
- -
- - -
-
- -
--
- -- -

Instruction Prefixes

- -
- --
-- - -

210


--

-
-
-- -
- -

Chapter 7: 32-bit Machine Language Instruction Format


-
- - - -
-- - - --
- -

Operand Size Override Prefix (66h)

- - - - -
- -

te

re

U
nR
eg

In 32-bit Mode

is

- - - - - - -
-- -- - - - - --

-- - -
- - --
- -- - -
- -
-- --- - - -
- - - -
- -
- - -
-
- - - - - -

211

x86 Instruction Set Architecture

-
--



-

--
-
-

212

U
nR
eg

is

te

re


-

- -



- -

--
-
-

Chapter 7: 32-bit Machine Language Instruction Format


-

-

-

U
nR
eg

In 16-bit Mode

is

te

re

- - --


-

--
-
-

-- -

- - - -
- -
-

-- - - -
- --
--- - - - - - -
- -
- - - - -
- - - -

Special Usage of 66h Prefix


- -

213

x86 Instruction Set Architecture

-
--


-

- -

re

te

is

U
nR
eg

Address Size Override Prefix (67h)


-- - -
- - --
- -- - -
- --- -
-- --- -- - -
- -- - -
- - --
- -- - -
- ---
- -- ---
-- - - - - --
- -

In 32-Bit Mode
- -- -- -

214

Chapter 7: 32-bit Machine Language Instruction Format


-- -
- - -- -
- -
- - - --
- - - - -

In 16-Bit Mode
-- -

- - - -
- -
-

re

- -- -- -

U
nR
eg

is

te

-- -
- - -- - -
-
- - - --
- - - - -

Lock Prefix

Shared Resource Concept

-- -- - - --
--- -- -
-- - - - - -
-

- - - -
- - - - -
- - -
- - - - -
- -
- - - -
- -- - - -
- - -
-

215

x86 Instruction Set Architecture

- - -

- - -
-
- --- -
- - - - -- - -
- - - - - - - -
- - - - -
- - - -
-- --

Race Condition Can Present Problem

U
nR
eg

te

- -- - -
- - -- --
- - - -
- -- -
- - - --
- - - - - -
- - -
-- - - -
- -
- -- - -
-- - - - -
- - -
- - -
- -- -- - -

is

re

- --

-- - ---
- -

Guaranteeing Atomicity of Read/Modify/Write


- - - --
- - --
---
-- --
-- --- -
-

216

Chapter 7: 32-bit Machine Language Instruction Format


-- -- -
- - -
- - - - - -
-
- -- -
-
- --
--- - - -
-- - - - -
- - -
-- - -
- - -
- - ---
- - -- - - - - -
--

te

re

U
nR
eg

is

- - - - -
-- -
- - -- --
- --- -
- - -

Use Locked RMW to Obtain and Give Up Semaphore Ownership


- -

- - - -
- - - - -
-

-- - - - ---- - -
- - -
- - -
- -- --
-- - - -
- - - - -
- -- -

217

x86 Instruction Set Architecture


- - -- - - - -

Instructions That Accept Lock Prefix


- -- -
- --
--
-

- --
--

- -

-

re

U
nR
eg

Normal Usage

is

Repeat Prefixes

te

- - --

- - - -
- --- - - - - -
- - -
-

218

- - - - - - -
-
-

- -- - - -- - -
- -- -
-
- - -- --
--
-
--
- - -
- -

Chapter 7: 32-bit Machine Language Instruction Format


-
- -
- - -
-- - - -
- -
- -
- -
-- -- - -
- - - - - -

- -
- -
- - - -

- - - -
-
-
- - - -
- -

- - - - -
- - - -

- -

- - - -
- -
- - - --
-

- - -
-- -- - -
- - -
- - - -
- - -


- - -
-- -- - -
- - -

U
nR
eg

is

te

re

219

x86 Instruction Set Architecture


- - - -
- - -

Special Usage
- -

Segment Override Prefix

General

re

- -

te

U
nR
eg

is

-- -- - -
- -- - - - -
- -
-- - - -
- - - -
-

-
-
-
-
--

-
-
-
-
-

- - - -
- --

220

- --
- - - -
- -- - - -- -
- - - -

Chapter 7: 32-bit Machine Language Instruction Format


Usage In String Operations
- --

- -- - -
- - - - --
- -- - - -
- - -
- -- -
-

Segment Override Use With MMX and SSE1 - 4 Instructions

te

Branch Hint Prefix

re

-- - - - -
--- -

U
nR
eg

is

--- -
- - -
- - -
- -
-
- - - - - -
- -
- - - -
- - -

- - -
- - - - - - --
- -

-

- -- -
- -- --
--

221

x86 Instruction Set Architecture


Summary of Instruction Set Formats
- -- - -



-






-




-- -
- - -
- --

U
nR
eg

is

te

re

222


-
-- --- - -
- - -
-

-- -
- - -
- -
-

Chapter 7: 32-bit Machine Language Instruction Format


- -- - -
-

-

-
-- -
-
-
- -
- - -
- --
-- - - -


-

-
-- -
-
- -- - -
- - - -
-- -
- - -
- -- -

U
nR
eg

is

te

re

223

x86 Instruction Set Architecture


- -- - -
-


-

-

-

-
-- -
-
- -- - -
- - - -
-- -
- - -
- -- -

- - - --

224

U
nR
eg

is

te

re

- - - -

-
- -

Chapter 7: 32-bit Machine Language Instruction Format


- -- - -
-

-

-

-

-

-
-- -
-
- - - --
- - - - -
- -- -
- - -


-

-
-- -
-
- - -- -
- - - --
-
- - -
- - --
-
--
- --
- - --- --

U
nR
eg

is

te

re

225

x86 Instruction Set Architecture


- -- - -
-


-

-

-
-- -
-
- - -
-- -- -
- -- -
- - -
- -
--
- --
- - --- --

U
nR
eg

is

te

re

226

re

The Previous Chapter

is


- -
- --
-

-
- -
- -
- -
- -
-

-- - -
-- -
-
- -

--

-


- -

U
nR
eg

te

- -
- -

227

x86 Instruction Set Architecture


This Chapter
- - - -

re


- -

-
-
-
--
-

--
--

-

The Next Chapter

te

-
-
-
-
--
-

-
-
-
-
- -
-
-

-
-
- -
-

-

U
nR
eg

is

- - -
-

228

Chapter 8: Real Mode (8086 Emulation)


8086 Emulation
- ---
--- -

- -- ---
-
- - -

- -
- -

re

--
- --- -
- -

- --- --
- -

--

--- -
-- - -- -
- ---
-- -
--

--

-
- - - -
-
-- --
- - - --

-- -
-- -- -
- - - -
-- - -
--

U
nR
eg

is

te

229

x86 Instruction Set Architecture


- -
- -


--

- -
-- - -
--
-

- ---
- -

- --
-
-- -- -
-

- -

-- -
- -

-- -
-

U
nR
eg

is

te

re

--

-- -

- - - - --
- -- - -
- -
-- --
- - --
--
-
- --
- - --

230

Chapter 8: Real Mode (8086 Emulation)


--
-- -
- --
--
--

- - --
- -
- -

- --

is

te

--

re

- --

U
nR
eg

--

Unused Facilities

- -- --
- - -
-

- -
- - - -
- - --
- -- - -- -

-- -
-- -
- -
- - -
-
-

231

x86 Instruction Set Architecture

- - - --
- - -

Real Mode OS Environment


- --- --
--- -

Single-Task OS Environment Overview

te

re

--- - - -
- -
- -
-
- -



--

U
nR
eg

is

-- --- -
-

Command Line Interface (CLI)


- - -- -- -- - - - -
- ---
--- - -
-
- - - -- - -
-- - -
- - -
-

232

Chapter 8: Real Mode (8086 Emulation)


Program Loader
- --

U
nR
eg

is

te

re

- - - --
-- -
- -

--- -
--- - - - --
- --- -
-
- -
- - - --
- -
- - - - -

- - - --

- - - - - - - -
-- -
- - - -- -
- -
-
-
- - - -
- - -
- --
- - -
- - -
-

OS Services

- - - -
- --
- - - -

- - - - --
-- --
- - -- - - ---

233

x86 Instruction Set Architecture


- - -
- - -
-- - - -- -
- --
-- - -
- -
-

Direct IO Access

is

te

re

- -
- --
- -- - - - - - -
- - - - -- - - - - --
- -

U
nR
eg

- -
- --- -
- -
- -- - -

Application Memory Usage


- -- - -
- - - - - - -
- -

Task Initiation, Execution and Termination


-- -
- - - -
-
- -- - - - -
- -

234

Chapter 8: Real Mode (8086 Emulation)


- - - -

- -

re

te

Running Real Mode Applications Under a Protected Mode


OS

is

- - -

U
nR
eg

Real Mode Applications Arent Supported in IA-32e Mode


- -
- - -
-

Real Mode Register Set


Introduction

-- -

- -- --

- ---
- - -- -
-- -

235

x86 Instruction Set Architecture

U
nR
eg

re

te

- - - - -

- --
--
- - - -
-
- - --
- -- -
- -
-- - -
- - -- -
-
- -

- -
-- -
- -

--
- -

- --
-
- -- - -

is

236

Chapter 8: Real Mode (8086 Emulation)

--

--
--
--
--
-

--
-- -

-
-

te

--

is


--

- --

re

- -- -

U
nR
eg


--

Control Registers

-- --
- --
--

- - - - -

--
-- -
---

237

x86 Instruction Set Architecture


- -
-- -- --

- - - --

CR0
-- -

re

- - -
- - -- --

te

is

U
nR
eg


-

-


-
-
-
--

--
-

238

-

-- -
-- -

Chapter 8: Real Mode (8086 Emulation)


--

-- - -
- -
-- -

-
- - -
- -- -
- - -

- -- --
- - -
- - - - -
- -
- -
- -- -
- --
-
- -
-
-
-
- -- - - - - -
- - - - -
-
- -
- -
- ---

U
nR
eg

is

te

re

- -
-- - -

239

x86 Instruction Set Architecture


--

-
- -
-

-- -- --

- -
- --
--
-
-
-
-
-
-

- - --
- -
-
- -

U
nR
eg

is

te

re

240

- - -
---

- -

- - -

Chapter 8: Real Mode (8086 Emulation)


--

-
-
-- -
-

-- - --
-
- -- - -

-
- - -
- -- --
- - - -
-- -- - - - -- -
-

--
-- -- -
-
-

U
nR
eg

is

te

re

241

x86 Instruction Set Architecture


-

- -
- - -
- -- --
- - - -
-- -- - - - -- -
-

--
-- -- - -
- -

- - - - -
--
- - -
- - - -- - - -
- -- -
- --
-- -
-
--
--

--

-- --
- - - -
- --
-- -- -
- -
-
- - -
-

U
nR
eg

is

te

re

242

Chapter 8: Real Mode (8086 Emulation)


Address Translation (Paging) Control Registers
--
- -
- --
-- - -- -
-- -
- -- - -

re

te

--

-- -

U
nR
eg

is

- - - -- -
- -- - - -
- -- -- - --
- - -
- -- -
-- - -- - - - - -
-- - -
-- -
-- - -- - - - - -
- - -
-- -
-- -
- - -- -

-- - --
- - -- -

243

x86 Instruction Set Architecture

- --

-
-

-

re

CR4 (Feature Control Register)


-- -

is

te

- -
- - -- - -
- -- -- -

U
nR
eg

- --

- - - -

- -




- -- -
- - -

--

244

Chapter 8: Real Mode (8086 Emulation)

--

-
- -
- - -
--
-

- -
-- - - --
---

-
- - - --

-

U
nR
eg

is

te

re

- -
- -- -
-- -
- - -



-
-
-- -

245

x86 Instruction Set Architecture


--

-- -
-
- - - - -- - ---
- - - --
- -- -- - - -
-
-
- -
- - -
- - -
-
-
- -- -
-- -
-

246

U
nR
eg

is

te

re

- -
- - - -
- -
-

- -- - - -

-
-- - -- -
-
-
-- - - - -

-

Chapter 8: Real Mode (8086 Emulation)


--


- - -
- -
-

-


-
- - --
- - -
- - - --
-
-

-
-- -
- - -

-
--- -
-
-
--- -


-

U
nR
eg

is

te

re

247

x86 Instruction Set Architecture


--

- - -
- --
- --
- - - --

- -- - - -
- - -- -
-- - -
--

- --
- - -- -
- -
-- -
-- -
-- -

- -- -
- - - -
- - -
- -
--
- - -
- - --
-- - - -
- -
-- -
-
--
-- - --
-
-- -
-- -
-
--
--
- -- -

U
nR
eg

is

te

re

248

Chapter 8: Real Mode (8086 Emulation)


--

-
- --
-
-

-
-- -
- -

-

- -
---

- - -
- --

- - -
-
- -- -
-- -
- -- -
- - - -
- - --
- ---
- -
--

U
nR
eg

is

te

re

XCR0 (XFEM)

-- -

- - -- -
- -
-- - - -
- - --
-- - - - -
-- - -

249

x86 Instruction Set Architecture


- - - - -
- -- -
- - -- - -- -
- -
- - - - - - -
-- - - -- - - -
- -

re

- - -
- -
-- -
-

--

- --- -
- -

-- -
- -- --
- - -

is

U
nR
eg

te

- - -
- -

- -
- -

250

Chapter 8: Real Mode (8086 Emulation)


Flags Register
-- -
-- - -
- - - -
- - - - -
- - - - -

is

re

- - -- -- - - -
-- - - - - --
--
-
- -- - - --
--- -
-- -- -- -- -- -
-- - -- -- -
-- - -
-

te

U
nR
eg

- -

- -

-




-
- -









251

x86 Instruction Set Architecture

- - --
-

-
- -


- - - -
- -
- -


- - -

-

- - -

-
-
-


- -
-

-- - -
-
-


- - -
- -
- -
- - -
-

252

re

te

is

U
nR
eg

Chapter 8: Real Mode (8086 Emulation)


- - --
-

-
-

- --- -
-
-
- - --


-- -
-
- -
-

- - -
- --

-- - -- -- --
- - -- -
- - --
-- - -- -- --
- - -- -
- - --
-- - -

U
nR
eg

is

te

re


-
-
- -

- - -

- - -
-
- -
-
--
-

253

x86 Instruction Set Architecture


- - --

- -
--- - - -
-
-- - -

- -- -
- -

- - --
-
-
-

---
--
-
- -
--

254

U
nR
eg

is

te

re

- - -
--
- - - - - -
- -
- - -
-

- - - -

Chapter 8: Real Mode (8086 Emulation)


General Purpose Registers (GPRs)
-- -
-- --- - -
- - - -- -
- - -- --

A, B, C and D Registers
-- -

- - -- - -

re

- - -
-

te

is

-- -
- - - --
- --- --

U
nR
eg

-
-

- - --
- --
-


-
- - - -- -
-- - --
- --

- - -


- - --

- - - - --
-- - - --
-

255

x86 Instruction Set Architecture

te

re

-- - -
- - - -

-- - -
--
- - - -

- - - - -- -
- -
-- -- --
- - -- -
- -

- - - -- -

- - - - -

-- -

is

EBP Register: Stack Frame Address Register

U
nR
eg

- - -
--

256

- - -
-- -- - - - --
- - - - -- --
-- - -- -
- - -- -
-- - - - -
- -- -
- - -

--
-- - - - - -
- - - - -- - -
- - - --

Chapter 8: Real Mode (8086 Emulation)

U
nR
eg

is

te

re

-- - - - -
- - -
-- - -
-
- - -- -
-- - - -
- -- --
- - - - - --

-- -
- -- - - - -
-
- -- - -- -
- - --
- - - -
- - -
-- - -
- - -- - -
-
- -- -
-
- - -
-- - --
- -- -- - - --
-- - -
- --
- - - -- -
- - -
- - - -- --
-- - - - --
-- - - --

257

x86 Instruction Set Architecture


-

- -
-- - -
- -
-- -
-

-- -

re

- - -

Index Registers
-- -

is

te

- -
--
-- - - -
- - -

U
nR
eg

- -- -
--

258

- - -
- -- -
--
--
-- -
-
-- -
-
- -- - - - -- - -
- - -
-
- - -- -- - -
-
- - - - - -- - -
-

Chapter 8: Real Mode (8086 Emulation)


- - - - -
- - -- -
- - - - -

Stack Pointer (SP) Register


-- -

re

- - - - -- -
- - - - - --
- -

te

- -- -

is

U
nR
eg

Instruction Pointer Register


-- -
-- - - -- - -
- -- - -
- - --
- -
--

259

x86 Instruction Set Architecture


- -

Kernel Registers

is

re

- - -
-- -
-- -
- -- -
- - - - - --

- - - - - --

te

-- -

U
nR
eg

- -
--

--
- - - -

- - - -

-

-
- -

x87/MMX FPU Register Set


-- -
-- - - --
- - -

260

Chapter 8: Real Mode (8086 Emulation)


- - -- -
- - --
-- -
-
-

--

--

te

is

U
nR
eg

re

- -

261

x86 Instruction Set Architecture


SSE Register Set
-- -
-- - -
-- - - ---

--
- -

re

- -

te

U
nR
eg

is

--

Debug Address Breakpoint Register Set


General

-- -

--- --
- - - --- -- -- - --

262

Chapter 8: Real Mode (8086 Emulation)

re

- -
-- - -
--
- - -
-- - -
-- -- -
- - - - - -
- - - --
-
- --
- - -
- - -- -
- - - --

te

- - -
-- - --
-

U
nR
eg

is

- --- --
-- --- -- - -
---
- --- ---- -
-- - - -- -
-- - -
-- -
- - -- -

Defining Trigger Address Range


- --

- -- -- - - -- -
- - -- -
- - -- -
- - -- -
-- -
- - -- -
-- -

263

x86 Instruction Set Architecture


Defining Access Type
-- - - -

Defining Scope (Current Task or All Tasks)


- -- - -
- - -
--

re

U
nR
eg

is

- -
- -
- - -
- --- - -
- -- -
- - - -- -
- - - - -
-- - -

te

Special Notes

- -

- -- -- -

264

- -- --
- --
- -
- - --
- -
-
- --
-
- - - - - - --
-

Chapter 8: Real Mode (8086 Emulation)


- -

-
-
- --
- --
- - - - -
- --
- -- -- -
- -- --
- --
- -

- - --
- -

-
- --
-
- - - - - - --
-

U
nR
eg

is

te

re

-
- --
- --
- - - - -
- --

- -- -- -

- -- --
- --
- -
- - --
- -

265

x86 Instruction Set Architecture


- -

-
-
- --
-
- - - - - - --
-

-
- --
- --
- - - - -
- --

re

te

- -- -- -
- -- --
- --
- -

- - --
- -

266

U
nR
eg

is

-
- --
-
- - - - - - --
-

-
- --
- --
- - - - -
- --

Chapter 8: Real Mode (8086 Emulation)


- -

-
-
--- -
- -
- - -- --- -
-
--- - -
-

-
- --
-- - -
- - -
- - - -
-- -- --

is

te

re

U
nR
eg

--

- ---
- - - - - -
--- - -
--
-

267

x86 Instruction Set Architecture


- -- - --
-- - -- -- -

- -- - --
-- - -- -- -

- -- - --
-- - -- -- -

- - - --

- -- - --
-- - -- -- -

U
nR
eg

is

te

re

- - -

268

- - - -- --
--

- - - -- --
--

- - - -- --
--

- - - -- --
--

Chapter 8: Real Mode (8086 Emulation)


- - -
-

- - - - -
-- - - -- - - - -
-- -
-

- -- - - -- -
- - - --
-- -
- --- -- - -

- -- - - -
-- - - - - -
- - - -

is

te

re

U
nR
eg

- -

-
-

-
-
-
-

Local APIC Register Set


-- -
- - --
-- -- - -
- ---
- - - --

269

x86 Instruction Set Architecture


--- - - - --
- -
- - -- --
-- - - - --
- --

U
nR
eg

is

te

re

- - - - -
--- -
- - -
-- - - - -
-- - -
- - - - -
---
-

270

Chapter 8: Real Mode (8086 Emulation)

-
- --
-
-
-
-
-
-
-
-
-
-
-
-
-

-
-

re

-
-

te

- -

is

- -
-

U
nR
eg

-
-

-
-

-
-
-
-
-
-
-
-

- -

- -
- -
-
-
-- -
-
- -

-
- -
-

-
-
-
-

-- - - --

271

x86 Instruction Set Architecture


Architecturally-Defined MSRs
-- -

General

-- -- - -- -
-
- --
- -
- - - -

re

Determining MSR Support

is

Accessing the MSRs

te

- - - - -
--
--

U
nR
eg

- -- - --

272

- - - -
- - -
- -
- -
- - -
-

- - - -
- - -- -
- -
- - - -

Chapter 8: Real Mode (8086 Emulation)


- --

-
--
-- -
- --- --- - -
---
-- -
- - --

- - -
-

-
---
- - -- -
-- -- - -
--

- --
-
-- -
- - - -
- -
- --


- -
-- -
-
- - - -
- --
- - - --
- -
- - - - -
- - --

U
nR
eg

is

te

re

273

x86 Instruction Set Architecture


- -
--

-
- -- - - -
- -- ---
- - -
-

- - -

--

--- -
- - k- -
- --- -
--- -
--- -

-
- - - --
-- -
- -
- -- - -
-- - - - -
- -
-


U
nR
eg

is

te

re

- -
- -
-


--

- -
-


---

274

Chapter 8: Real Mode (8086 Emulation)


- -
-


--
-- -
-

-- -
-- -
-
---

-
-


-

- - -
-- - -
- - -
-

- -
- --
-- - -
- -
--- -

U
nR
eg

is

te

re

--

-- -
--- -
- -

-
-- - -
--- -

275

x86 Instruction Set Architecture


- -
--

-
--
-- - - - -
-- - -- - -
-
- - -

--

-- -
- -- -

--

- - -
- -
-
-

-

- - - - - -
-

-
--
- -

U
nR
eg

is

te

re

--

276

Chapter 8: Real Mode (8086 Emulation)


- -
-

- - --
--
- -
- -
-- - - -

-
- -

-
- -
- -
-
-

-

- - - -
- - - --
-
--- -

U
nR
eg

is

te

re

--

- - - - -
- -
- --

- - - - -
-- -- -

- -
-
-- - - -

- - -
- -

277

x86 Instruction Set Architecture


- -
--

-
-- - -
-- -
-

-- --
- -
-
-
-
-
-
-- -- -
-
- --

--

-- --
--- --
-

U
nR
eg

is

te

re

278

- -- - -
- - --
- - -
-- -
-
- -

Chapter 8: Real Mode (8086 Emulation)


- -
--

-
-
-- --- -
- - - -
-- - --
- -- -

- -
- - -
- - -

-
-- - -
-
-

- - -
- -

- -- -
- - -

- - -- -
-- -
- -- -
- -

- - -- -
-- -
- -- -
- -

U
nR
eg

is

te

re

--

279

x86 Instruction Set Architecture


- -
--

-
-
- -
-
-
- - -
- -
- -- - -
-
- - -
- -
--
-

- -
- --
- - -
- -
- -
- -
-
-
- --
- -
-- - --
--
--
-
- -
-
-- --- -
- - -
- -
--

U
nR
eg

is

te

re

280

Chapter 8: Real Mode (8086 Emulation)


IO Space versus Memory Space
-- -- -- --
- -- --- -- - -- - --


-
-
- -
- -- - -
- -
- - -- -
- - -- -
- --
- -- -- - - - -- - --- -
-- -
-- -
--- -
- ---

te

U
nR
eg

is

re

IO Operations

- -

-- - --- --
-- - --- -
-

IO Operations in IO Address Space


IN and OUT Instructions
-- - - ---
-- - -

281

x86 Instruction Set Architecture

-- -
-


-

--
-- -
- -- - -
- --
--

re

- --
-

is

te

--- -
- - - - --- - -

Block (String) IO Operations

U
nR
eg

- - - - - - -
- - -

- - - -

282

- - - -
-
- - - - --
- -- --- - -

-- -
- -
- - - -
-- -
-
- - -

Chapter 8: Real Mode (8086 Emulation)

- - -
--
-
- - -
- -- - -- - -
-
-
-- - -
- -- - -
-- --
- - - -
- - -

re

- - - -

U
nR
eg

te

- - - -
-
- - -
-- --- -
- -
-- -
- -
- - - -
-- -
-
-
--
- --
-
- -
-
- - -
- -- - -- - -
-
-
-- - -
- -- - -
-- --
- - -
-- - -

is

283

x86 Instruction Set Architecture


IO Space is Limited and Crowded

re

- --- -- - - -
- -- -
- -- - - -
- -
- -- - -
- - -- - -
-- -- -
- - - -- -- -
- - - - - -- -
-- - - --- - -

is

Introduction

te

Memory-Mapped IO (MMIO) Operations

U
nR
eg

- - - - - -- - - - --
-- - - -- -
- - - - -
- --

Know the Characteristics of Your Target


-- - -- -
- -- --
- -- - -

Why the Logical Processor Must Know the Memory Type


- -- - --
-- -- -
-- -
-- - - -- -
-- -- --
- - --
- -

284

Chapter 8: Real Mode (8086 Emulation)


- - - -
- -- - - --
- -- -- - -- -
- -

re

- - - -
- - -- - -
- - -
- - -
- - - -
- -
- - -
-

U
nR
eg

is

te

- - - - ---
- -- - -
- -- ----
- --
-
-

- - - --

- - - --
-- - -
- - - -
-- - -
- - -
-- - -- -- - -

Uncacheable (UC) Memory

- -- - - - - ---
-

- - - - -
-- -

285

x86 Instruction Set Architecture

- - - -
- -
- - - --- -
---

- - -
-

re

- -- -
- - - - -
- - ---
-
-

te

No IO Protection

U
nR
eg

is

-
-- - -
- - -- - --
-

Operand Size Selection

- --

- - -

- -
-

- - - -
- - - -
-- -- - -
-- - --- -
- -

286

- - - -
- - -- - -
-

Chapter 8: Real Mode (8086 Emulation)

- - -
-- - -

Address Size Selection


- --

te

- -
- - -- - -
- - - - - --- -
-
- -
- - -- - -

re

U
nR
eg

is

- - - -
- - - -
-- -- - -
-- - --- -
-- - -

- - - - -
- -- -- - - -
- - --
- - - - - -
- - - --
-- -- - - -
- -
-- - - -
- -- -

- -- - -
-- - -
- - - -- -
- -
-- - --
-
-

287

x86 Instruction Set Architecture


-- -

Real Mode Memory Addressing


No Address Translation

--- - -- -
--
- - - -- - - --
--

re

Introduction to Real Mode Segmentation

te

--- - - --

is

-- --- -
--

U
nR
eg

-- - -- - - - - -
- - - --
- --
- - - - - -
- -- --
- -- --
-- - -
- - - - -


-
- - - --

- - -- -
- --
- -- - --
- - - -- --
- -
-- - -
-

288

Chapter 8: Real Mode (8086 Emulation)


-- - -- -
--- - - -
- - -- -

--



-
-
-
-

te

re

is

U
nR
eg

-
-

-

289

x86 Instruction Set Architecture

- --

--

-
-

-
- -- -

--

-
-


-
--
-

290

-
--

te

--

-
-

is


-
--

U
nR
eg

re



- --
-
- --



- --
-
- --

-
- - - --


-
- --
-
- --

- -

Chapter 8: Real Mode (8086 Emulation)


- --

--

-
-

-
- -- -

--

-
-


-
-- -


-

re



-
- --
-
- --

U
nR
eg

is

te

-
-- -

- -

- - - -- -
-- - - -
-
- - - --
- - -
-
-- - ---
- --

291

x86 Instruction Set Architecture


- -

-
- - - --
- --
-
- - -
- - -- - - -
- - -
- - -- - --
-
-- --
- - - --
- - -
- - -
- - -
- -- -- -

- --
-- - - - --
- - - - -
- - - - --
-- -
- - -
-- -- -
- - -- -
- - - -
- - -
- -- -
- - - - --
-- -
- -- - -
- -- - -

U
nR
eg

is

te

re

All Segments are 64KB in Size


- -- - - - - -
- - -- -- - - -

292

Chapter 8: Real Mode (8086 Emulation)

-
-
-

-
-
-
- -

--- --
- - -
- - -- - -
-- -
-- - - --
-- - -
-- - - - -- -
- -- -- -
- -- -
- - - - -
-

re

U
nR
eg

is

te

- -- -- - -
- - -
- - --
-- - -
- - - --
- -- - -
- -

Memory Address Representation


--- - - -
-- -- - - -
- -

- --
- --
- --

Accessing the Code Segment


- -- - -
- --- -
- -
- -
- - -

293

x86 Instruction Set Architecture


-

Jumping Between Code Segments

- - -
-

re

Far Jumps and Calls

te

- -
-- - - -
-- - -
-

U
nR
eg

is

-
- -
- -- - -
- -- - -- - -
- - - -
-- - -
-- - - - -
-- - -- - -

-- - - -
- -
- -
- - -

294

Chapter 8: Real Mode (8086 Emulation)



te

U
nR
eg

is

-


-
-

re

Near Jumps and Calls

- -
- - - -

-- -- -
-- -
- - - -- -
- -- -

- - --
- - --
- - - - --
- - -

295

x86 Instruction Set Architecture

- -

- -- --
- -- - -
- - - - -
-- - - -
- - - -
- -

re

IP-Relative Branches

- - -

te

U
nR
eg

-- - -
-- - - - - - -
- - -
-- -
-- - -
-- - - - - -
- - -
-- -

is

Operations That Default to the Code Segment


- -

296

--- - - -
- - -
- - - - -- --
- -
- - -
-- -- - -
-
- - - -
--
- - - - -
-- - --
-- - - -

Chapter 8: Real Mode (8086 Emulation)

U
nR
eg

is

te

re

- -- --
- - --

-- - -
- - - -
-- -
- - --
- - -
- - -- - - -
- -- - -
- --

- -
-- -- - -
- -- -
- - - -
- - -
- --
- - -
- - -- -- -

Accessing the Stack Segment


Introduction

- - - - - - -
- -- - -
- - - -- -
-

- - - - --
- - - - -

- - - -
-- - - - -
- - - -

- - --
- - - - -
- - - - - -

297

x86 Instruction Set Architecture


- - - - - - - - - - - - - - - - -- -
-

Stack Characteristics
-- -

U
nR
eg

te

is

re

- - - --

- - - - - - -
- -
-
- -
- - -- - -- -- -
- - - -- -
- -- - -
-- -- -

-- - - --- - - - o

-- - - -
- -- - - - -
-- - - -
-

Pushing Data Onto the Stack



-- - - - - -
- - -- -
- - --
- - - -- -
- - -

298

- -- - -
- -
- - -
- -
- - - -
- -
-

Chapter 8: Real Mode (8086 Emulation)

-- - --
- - -- -

- - -
- - - - - -- -
-
-

is

- -
- -

te

- -
-

re

- -
-

U
nR
eg

299

x86 Instruction Set Architecture


Popping Data From the Stack
- - - -
- -- - -
- - - - - -
--

- -- --
- -
-
-- - - -

-- -- -- -
-
-
-- - -
- -

re

is

Stack Underflow/Overflow

te

- --- - - - -
- - -

U
nR
eg

- - - -
- - -- -
- - - -
- - - -
- - - -- - -




-- -


-- -

300

- -
- -

Chapter 8: Real Mode (8086 Emulation)


Processor Stack Usage
- - -
-- - - -- -- -
-- -- -

te

- - - --
-- - -

- -- --
- - -

- - -- --
- - -
- - - - -
- - -
-- - - --
- -

re

is

Accessing Parameters Passed on the Stack

U
nR
eg

-- - -
- - - - -
- - -

--
- -
- - - - - -
- -
-- -
-- - - -
- - - - -- -
- -

- - - --
-
- - -
-- -
- - -
-- - - - -
-

301

x86 Instruction Set Architecture


-- - - - - -- - -
- - - - - --
-- -- - -
- -- -- - -
--

Operations That Default To the Stack Segment


- -- - -

U
nR
eg

re

te

- - -- -- -
- -
- --- - --
-- - - - -- - -
- -- --
- - - -
- -
- -- --
- - -
- -
- - --
- - - - -
-
-- - -
-

- - -- - - --
- - - -
-
- -
-- -- - -
- -- -
- - - -
- - -
- - --
-- -

is

302

Chapter 8: Real Mode (8086 Emulation)


Accessing the DS Data Segment
General
- - -- - -- -- -
- - - - - --
- - - - - -
- - - - -
- -

re

is

te

- -- -
- - - - -

U
nR
eg

- -
- - - - - - - - - -- -
- - - -- --
- - -- --
- - - -- -
- - - - - -

Operations That Default to the DS Data Segment


- -

- -- - -
- - - -- -
- -

- - - - -
- -

303

x86 Instruction Set Architecture


-

is

-
-

-

te

re

U
nR
eg

Accessing the ES/FS/GS Data Segments


General

-- -- --

304

-
-
-

-
-
-
-

Chapter 8: Real Mode (8086 Emulation)


- - - - - - - - - -- - -
- -
- -- - - -
- - - - - -
- - -- -- - -
-
- - -
-

Operations That Default to the ES Data Segment

- -- - -
- - - -- -
-

te

re

- -

is

Segment Override Prefixes

U
nR
eg

Example Segment Register Initialization


-- - - --
--- - -
- --
-
-- -

-- --

--

-
--
-

305

x86 Instruction Set Architecture

-
-

-- - -
- -
- - - - - -
-- -- - - --
- - -
-- -- -- -- -
-- - -- - --

is

te

re

- --

U
nR
eg

306

Chapter 8: Real Mode (8086 Emulation)


Accessing Extended Memory in Real Mode
- -- -- -
-


-
- -

re

- -- -
-- -
- - -- -
- - - - -
-- - --

te

- --

U
nR
eg

is

- - - - --
-- - -- -
-- - -- - -
-- - - -
- -- - --
- -- -
-- -
- -

-


- -

- - --
- -- -
- - -- -
- - - - --
- --

-
- --

307

x86 Instruction Set Architecture


- - - - --
-- - -
- -
--
- - - -
-- -
- - - -
--- - --
- - - -

te

re

- - - -
-- - --- -- - --
--
-- - -- - -
-- -
--- -- -
- -- - - - -
-- -

U
nR
eg

is

- -
-- -
- --
- --
- - -
--- - --- - - - --

-- --
-- - - -
-- - -
- -
- --- --- -- - -
-- -- -- -- --
-
- - - -
- --
- - - --- -- --
- - -- -
- --- -
- --

308

Chapter 8: Real Mode (8086 Emulation)


- - -
-
- - -
- - - --
- - -
- -
-

is

te

re

- --
-- - -
--

U
nR
eg

309

x86 Instruction Set Architecture


Big Real Mode
--- -- --
- - - - -
- - - - - - -

U
nR
eg

is

te

re

- - -- -
- - - - - -
-- -
- - --
-- - - - --
- - - - -- - -
- -- - -
- - - -
- -- - - - - -- -
- --
- - - - - -- -
- - - -
--

-- - -
- - - -- -

-- - - - - -

-- - - -
-

- - - --
- - - -
- - - -
- - --- - -
- - - - -
- -
- -- - - -
- -- - - -- ---
- - -

310

Chapter 8: Real Mode (8086 Emulation)


286 DOS Extender Programs
Hot Reset and 286 DOS Extender Programs
- - -- - -
-- -- - - --
- -
--

re

- - -
- -
-- - - - --
-- - -

te

- -- -
- - -- - - --
--

U
nR
eg

is

-- - - - - -
-

- - -
- --
- - -- -
-- - --
- -
--
- --
-- - -
-- - -
- --
- -
--

- --
-

- - -

- --
- -- -- - --

311

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -
- - - -

- - -
-- - -
- -
-
- --
- - -
-- - - - -
- -
-- - - - -
- -- -
- - -- -- --
--
- -- - -
-
- - -
-- - - - - - -

-- -
- -
-- -

- -- - -
- -- - -
- -
- -- - - - - --- - -
-
-- - - - -
- -- -
-

Alternate (Fast) Hot Reset


- - -- -
-- --
- - - - -
-- - - - - - -
- - -- - -
-

312

Chapter 8: Real Mode (8086 Emulation)


- - - -
- - -
- - - - -
-- - - - - -- --

286 DOS Extenders on Post-286 Processors

- --
-- - - --
- - - - - - -- --- - -
-

is

te

- - -
- - -
--- - - -
-- -
-- - -
- -
-- -- - -- -
-- - - --
-- - - --

U
nR
eg

re

-- - - - -- -
- -- - -
--

- - -- - -
- - - - -
- - --
- -

- -
- -
- - -
- -

- - -- -

313

x86 Instruction Set Architecture


- -

- - - -
- -- - - - -
-- -

- -
-- -
- -- --
- - - --
--
--
- -
- - -- -- - -
- -
- - -- -
- - -
- -
- - --

314

U
nR
eg

is

te

re

- - -
--
- - -- -
- - --
- - - --
- -- -
-
-

- -
--
- -

Chapter 8: Real Mode (8086 Emulation)


String Operations
--

- -
- - -

- -- - - - -
- - -

re

-- - -
- -- - - -
- -
- - -
-- - --- -- -

is

te

--- -- -
- - - -
-
- -

U
nR
eg

- - --
- - - -- -
- - -
- - - - - -
- - -- --
-- - -
- - -
- - -
-- --- - -
--
- - - -
- - - -
- - - - - -- -

- - - - - -
- - -
- - -
- ---

315

x86 Instruction Set Architecture

- - -
- ---

- - -
- ---

-
- --- - -
-
-
- - - - -
-

U
nR
eg

te

- - -
- --
-
- -
- - - -
-
- -
- - - --
-
-
- -
- - -
- - -
- -
- - -
- -
-

is

re

--- - - - -

Real Mode Interrupt/Exception Handling


Events and Event Handlers
- - -
- - -

316

Chapter 8: Real Mode (8086 Emulation)


-- - - -
-

- - - -
- - -- -
- - - --
-
- - -
--

Events Are Recognized on an Instruction Boundary

is

te

re

- - -
- - - -
- - -
- - - - -
- - - -
- - -
- -

U
nR
eg

- - - -
- - --
- --
- -- -
- -- - - - -
- -

The IDT

Definition of the IDT


- -- -
- - - -- -
- -- - - -
-- - - -

317

x86 Instruction Set Architecture

U
nR
eg

-
-
-
-
-
-

is

te

re

- --

---

318


- -

Chapter 8: Real Mode (8086 Emulation)


---

- -
-- - -

- -

- - - - -
--- -- -

- --

- --

- -
- -
- -

re

te

is

U
nR
eg

- - - -
- - -
- - -


- - - - -
- -- -
- -

- -
- - -
- - -
-

319

x86 Instruction Set Architecture


---

-
- -
- -
- - -
- - - -
- --
- - - -- -
- -

-
--
- -
- -
- --
- - -
-- - - - -
-- -
- -
- -

320

U
nR
eg

is

te

re

--

- - -
- - - -
- - -
-
-- -
-- - - -
- -- -
- - -
-

Chapter 8: Real Mode (8086 Emulation)


---

-- - - -
--- -
- - -
---
- -
- --

- - -
- - -

- -
- - -
- -- -
- -
-

- --
-
- --
- -
- -
- -

- -
- -

U
nR
eg

is

te

re

321

x86 Instruction Set Architecture


---

-
- --
- - -
- -
- - -

- -

- -
-- -

- --

- -
- -
-- - -
-- -
- -- -
-- --
- -

-
-- - --

U
nR
eg

is

te

re

322


-
- -

Chapter 8: Real Mode (8086 Emulation)


---

-
- --
-- -
- -- -- --
-
- - --
- - -- -
- - -

- - -- -
-
-
- -
- -

-
- - - ---

- --- -
- - - - - -

- -


U
nR
eg

is

te

re

323

x86 Instruction Set Architecture


---


-- -
-
- - --
--- -- -
- --- -
-

-

- - - - -
- -

- - -
- -- ---

is

te

re

U
nR
eg

- -

IDT and IDTR Initialization

- - -

- -- -
- - -

- - - --
- - - -
-- -
-- - - --
- -- - -
- - - -- -
--- -- - --
- --
- - - - -

324

Chapter 8: Real Mode (8086 Emulation)


- -- --
- -- - - - -- - - - -
- - -- --
- -
- - - - - -

-
-

re

- - --
- -
- - -
- -
- -

U
nR
eg

is

te

- -
- - - - -
- -- - -
- -- -
- -
- -
- - -
- - -- - - -
- - -
- -
- - - --
-

Stack Initialization

- - -- --
- -
- - - - - -- - - -

325

x86 Instruction Set Architecture


Event (Interrupt and Exception) Handling
-- - --
- - -
- -- -
-- - -

re

te

-- - -


- -

is

-- -
-

U
nR
eg

- - -

- - -
- - -
-
-

--
-
-


-

-

326

Chapter 8: Real Mode (8086 Emulation)

-
-
-
- -

- -

- -

re

-
- -

-
- -

te

- - - - -
- - - -

- -- - - -


- - -
-- - - -

U
nR
eg

is

-- - -
- - - - - - -
-- - - - --
-- - -
- -
--

-- - - -
-
- - -

Software Event Types


Introduction

- - - -

- - --
-
-- - -
--

327

x86 Instruction Set Architecture


Software Exceptions
- - -
- - - --
- -

-
-

is

te

re

- - - --
-
-
- ---

- -
- ---

-- -
-- -

U
nR
eg

-- - -
-- -- -
- -
-- -- -
-
- - - -
- - - - -
- - --
-
-- - - - -- - -
-- -
- - - - -
- -- --
-- --
- - -

328

Chapter 8: Real Mode (8086 Emulation)

- - -
- -

- -

- -
- -
- -

- --

re

- -
- -

U
nR
eg

- -
-
---

is

-
--

te

- -


--
- -

--

--
--

329

x86 Instruction Set Architecture


- - - -
- -
- - - - -
-

- - --
-
- - -
- --
- - -
-- - - -
- - -- -
- -

- - - -
- -
- - -
- - -
-- -
-- -- -
- - - - -
- -- - - -
- -- -
-

U
nR
eg

is

te

re

- - - -- - -
- - --
-

Software Interrupt Instructions


--

- - -
-

330

Chapter 8: Real Mode (8086 Emulation)


-
-- ---
- -

U
nR
eg

re

te

- - -
- - - - -
- - -
- - - - - -
- - - -
-- - -
-- -- -
-- -
-- -
- - - - -
- --
-- -
- - -
- - - -
- - - - - -- -
- - -

- -- -
-

is

- - - -
-- -- -
- - - - - - -
- - - -- -
- -- --
-

- - - -
- - - -
- -- - -
--

- -
- - - - -
- - --
- - --

331

x86 Instruction Set Architecture


-
- - --
- --
- - --

Hardware Event Types


- - - -
- - -

- -

re

te

NMI

-- -

U
nR
eg

is

- - -
-- - - - -- -- - - --
- --
-- -
-- -
--- - - - -- - --
--- - - - -- --
-- ---
-- - -
--

- - --
- -
-- - -

-
-
- -
- - - -

332

Chapter 8: Real Mode (8086 Emulation)


-
- -
-
- - - - - -
-- - --

- - --
- -

U
nR
eg

re

te

- - - - -
- - -
- - - - -
- - - -
-- -- -
-- -
-- -
- - - -
- - -- -

- -

-- --
- - -

- -- -

is

- -
- - - - - - - -
- - -- -
- - - -
- - - --
- -- -- -- - - -
-- - - --
--
- - - - - -
-- --

333

x86 Instruction Set Architecture


-- - -
- - - - - - -
- -- - -

-- --
-

SMI
- -- - -
-
- -

-- -
--- - - - ---
---
--- - - --
-- -- -
-- ---
-- - - -
--- --

te

re

U
nR
eg

is

- - -
-- -- - - - - -
- - -- -
- -
-

Maskable Interrupts

- - -


- --
-- - - - - -
- - - - -
- - -
-

- -
- - --
- - -
- - - - - - -
- - -
- - -

334

Chapter 8: Real Mode (8086 Emulation)


- - - - -
- - -
-
--- - -
- - -
- - -
- - -
--- -
- - - -
- - -

- -- -

re

-- -

U
nR
eg

is

te

-- -
--- - - - -- ---
--- - - --
- -- -- -
---
---
-- - - -
--- --

- -- - - -
- - - -
--
- - -
- - -
- - -

- - -
- - -

335

x86 Instruction Set Architecture


-
-
-

- -

- - -

- -

re

- -

- --
-
-

is

te

- -
-

U
nR
eg

-
-



- --
- - -
- -

Machine Check Exception

- -
---
- -

- ---
-- -
-- -

--
- -

336

Chapter 8: Real Mode (8086 Emulation)


Summary of Real Mode Limitations

-
- -
- - - -- -
- -
- - -
- - - -
--
- - - -
- - - -
-

te

re

- - - - -

Transitioning to Protected Mode

U
nR
eg

is

- - -

337

U
nR
eg

is

te

re

x86 Instruction Set Architecture

338

re

The Previous Chapter

is


- -

-
-
-
--
-

--
--

-

U
nR
eg

te

- -
-

This Chapter

- - - -
-

-
-
-
-
--
-

339

re


-
-
-
-
- -
-
-

-
-
- -
-

-

x86 Instruction Set Architecture

The Next Chapter

is

-

- --- -
- -
-- -
-
- -- -
- --
- -
-
-- -

U
nR
eg

te

- -
- -

A Little History

-- ---
-
- -- --
- - --
- --
-- - - -
- - -

340

Chapter 9: Legacy x87 FP Support


- - -- --
--- -- -
- - - - -

x87 FP Instruction Format


- - - -

FPU-Related CR0 Bit Fields

re


- -

te

is

U
nR
eg


-

-


-
-
-
--

-- - -
-- -

-
- - - -
- - - -
-- - -
- -

341

x86 Instruction Set Architecture


-

- -- --
- - -
- - - -
- -
- -- -
- - --
-
- -
-
-
-
- -- - - - - -
- - -
- --
-
- -
- - -
- ---

342

U
nR
eg

is

te

re

---
- - - -
-- -
--
- -
-- - -

- -
- -

--
-
-- --
-
-- - -

Chapter 9: Legacy x87 FP Support


x87 FPU Register Set
- - - -
--
-
--

is

te

re

U
nR
eg

- -

The FP Data Registers

- --
- - - --
-- - -
- - -

343

x86 Instruction Set Architecture

-
- - - -

- - -
- - -

- - - - -
-

re

-
- --
- - -- -
-

te

x87 FPUs Native Data Operand Format

is

- - - -
- -
-- - - - -- -
- -

U
nR
eg

- - - - -

-
- -
--

- - - -

- - -
- - -
- -
-
- - - -
- -
- -

344

Chapter 9: Legacy x87 FP Support


- - -
- --
-
- -

-

--

te

re

is

U
nR
eg

--

- -- -

--

- -- -

345

x86 Instruction Set Architecture


32-bit SP FP Numeric Format
Background

U
nR
eg

A Brief IEEE FP Primer

is

te

re

-
- -
-
- - -
- - --
- - - -
- --
- -
- - -
- -

- -
- - -
- -

--- - - -
- -
- - - -- - --
- - - -

- - --
- -


- - - - - -
- - - - -

- -- - --

346

Chapter 9: Legacy x87 FP Support


-- - - - -
- - -- -
- -
-- --
- - -- - -
- - - -

-
- - - -
- - - -


- - -
- - -

re

- - -
- - -
- -
- - - - -
- - - - -
- -
- - -
- --- - -
- - -

U
nR
eg

is

te

- - --- - - - - -

The 32-bit SP FP Format

- - - - -

- - - - - -

- -
- - -- --
-
- - --
-

347

x86 Instruction Set Architecture


Representing Special Values
- - - -
-

--

re

is

te

- - -

-
- -

U
nR
eg

An Example

-- -- -- -

348

-
- - -
--


-
- -
-
- - -
- - - -

Chapter 9: Legacy x87 FP Support

-- - - -
-- - - - -- --
- -
-

--

--

is

Another Example

--
-

te

re

U
nR
eg

-- -- -- -

-
- -
- --


-
- -
-
- - -
- - - -
-- - - -
-- - - - -- --
- -

349

x86 Instruction Set Architecture

--


--
-

--

re

te

DP FP Number Representation

U
nR
eg

is

-
- - - -
- --
- - - -- -
- - -
-- -

FCW Register

- - --- - -
-
- -

- - -

-
- - -
-

350

Chapter 9: Legacy x87 FP Support


- -

-
-

- - - - -
-

-
- -

- -

U
nR
eg

is

te

re

- -
-
- - - --
- - - - - - - - -

- - --
- -
- - --
-- - -
- - --
- - -

- - - -

351

x86 Instruction Set Architecture

- -

- - -

re
te

FSW Register

-
- -
-
-
-
-
-

U
nR
eg

is

- - - --- - -
-

- -

-
-

352

Chapter 9: Legacy x87 FP Support


- -

-
-

- - -
- -
- -



- - - - -- - -
-

-- -
- - -
- -- - - -

- - - -- - - -
- - - - - -
- - - -
-

U
nR
eg

is

te

re

353

x86 Instruction Set Architecture


- -

-
- -- -
- - -
- -
- - -
- -
---

- - - - -
- - -
- -- -

- - --
---
- -
-- -
-- -
- - o
- - -

U
nR
eg

is

te

re

- - -
-

- -
- -

-
-

-




354

Chapter 9: Legacy x87 FP Support


FTW Register
- -
- - -- -
- - - - -

- -

re

is

te

U
nR
eg

Instruction Pointer Register

- - - - --

- -
- -- - - -
- -
- - - -

Data Pointer Register

- - - --
- -
- - - -
- - - -- -
- -- -
- - - -

355

x86 Instruction Set Architecture


Fopcode Register
General
- - -
-- - - - - -
- -
- - -
- -

te

Fopcode Compatibility Mode

re

- - - -
- - - - - - - - -
- -

- - -
- -
-
- - - -
- - -
- - -

U
nR
eg

is

- --

-
- - -
- -

356

Chapter 9: Legacy x87 FP Support


- -

- -

re

FP Error Reporting

te

Precise Error Reporting

U
nR
eg

is

- - -
- -
- - -- -
- - - -- - - --
- -
-- - -
- - - --
- -
- - - --
- -
- -

Imprecise (Deferred) Error Reporting


- -- - - -
-- -
- -- - --
- --
-
- -

-
-

357

x86 Instruction Set Architecture


- - -- -
- -
- -
- - -
-

Why Deferred Error Reporting Is Used

U
nR
eg

is

te

re

- - - -
-- - -
- -- -- -
- -
-- - -- -
- -
- --
-- -
- - - -
- -
-- -
- -
-- -

The WAIT/FWAIT Instruction


- - - - -
- - -
-- - --
- - -
-
- -- --

CR0[NE]
-
- - -
- -

358

Chapter 9: Legacy x87 FP Support


DOS-Compatible FP Error Reporting

te

re

- -
--
- -
-- - -
-- - -
-- --- -- -
- -
- - --
- - -- -- - --
-- - --
-
- - -
- -- -- --- -
- -

is

FP Error Reporting Via Exception 16

U
nR
eg

-- -
-
-

--

--

359

x86 Instruction Set Architecture


Ignoring FP Errors

-
-- --- -
- - - - - - --
- - - ---
-- -
--
- --

U
nR
eg

is

te

re

- - -- --
-- - --
- - -
-- -- --
- -
-- -- -
- -- -- -
-- - -- -
--
- - - - -

- -
-

--

- --
-- --

360

re

The Previous Chapter

is

-
-
-
-
--
-

-
-
-
-
- -
-
-

-
-
- -
-

-

U
nR
eg

te

- -
-

361

x86 Instruction Set Architecture


This Chapter
- - - -

-

- --- -
- -
-- -
-
- -- -
- --
- -
-
-- -

The Next Chapter

te

re

U
nR
eg

is

- - - - -

-

362

- - -

-
- --


-
-


-
- -

- -
-

Chapter 10: Introduction to Multitasking


Concept

te

re

- - - -- --
- - - --
- - -- --
- --- --
- -- -
- - - - -
- -- -
- - - -
-- - - -
-- --- -
- - - - - -
- -
- - - - -
-

U
nR
eg

is

- -- - ---
--- - --
- -
- --- - - - -
-- - - -
- -- - - - - -
-- - - - --
-- - - ---
- - --- -
--- -- - - -
-- - --
- -- - -
- -
--
-- - -- - - -
- - - - -
-
- - -- - - -
- - --
-- - -
- -- -- -- -
- -- -- -
- - -- - -

363

x86 Instruction Set Architecture


- - - --
- -- - - - - -

An ExampleTimeslicing
- - -

is

re

- -
-- --
-
- -- -- -
-
-- - --
- - -
- - -
-- -- -
- - - -
- - - -

te

U
nR
eg

Another ExampleAwaiting an Event


1. Task Issues Call to OS for Disk Read
- -
- - - -
- --- - -- -
- -
- -- -- -
- - -
- - - --

2. Device Driver Initiates Disk Read


--- -
- -

364

Chapter 10: Introduction to Multitasking


- -- --- -
- -

- --
- - --

te

3. OS Suspends Task

re

-- - - - -
- - --
-- - - - - - - -
- - - - -
- - - - -
- - -
- -- -

U
nR
eg

is

- - -- --- - - -
- - - - - - -
- - - - --
- - - - --

4. OS Makes Entry in Event Queue


- - - - -
-- - - --
-

5. OS Starts or Resumes Another Task


- - -- -

6. Disk-Generated Interrupt Causes Jump to OS


- - - -
-- - - -- --

365

x86 Instruction Set Architecture


- - - -
- - -

7. Interrupted Task Suspended


--- - -- - - -
-

8. Task Queue Checked

re

-- ---
- - -

te

9. OS Resumes Task

U
nR
eg

is

-- -- -- - -
- - --- --
-- -- -- -
- - - --- -

366

-
---

re

The Previous Chapter

is

-

- --- -
- -
-- -
-
- -- -
- --
- -
-
-- -

U
nR
eg

te

- -
-

This Chapter

- - - - -

- -

- - -

-

367

x86 Instruction Set Architecture

- --


-
-


-
- -

- -
-

re

The Next Chapter

te

-- - -- -
- -- -
--

is

Hardware-based Task Switching Is Slow!

U
nR
eg

- - -- -
- - - - -
- - - -- - --- - -
- --- - - --
- -- - - - - -
-- --
-- - -
-- - --
- - -- --
-- - - - ---
-- - -
- -- - ---
- - - - -- -
- - - - -- -- -
- - -
- - - - - - - -
- - - - - - - - -
- - - - -
--- - - -
- - - -
- - -

368

Chapter 11: Multitasking-Related Issues


Private (Local) and Global Memory

te

re

- -
- - - -
-- - --
- -- - -
- - - -- -
- -
- -
- - -- -
-- -
--- -
- --
- -- -- -
- - -

- - -
- -- - - --
- - -
- - -
-- - -
- -- - -

U
nR
eg

is

- -
- - - -

-- - -
--- - - -
- - - - -- - -

Preventing Unauthorized Use of OS Code


- -- - - - - - -
- - - -
-- -- - -- -- -

369

x86 Instruction Set Architecture


- - - --
- - -- - -
--- - -

- --
- - -
-- -- --
- -
-- - --
-
- -- -

is

te

re

- - - - - - - - -
- - - --
-- -
- - - -
- - -- - -

-
-
- --- -

U
nR
eg

With Privilege Comes Access

- -- --- -
- -- - -- -
- -- -- - - - -

Program Privilege Level


The CPL

-
- -- - -
-
- - - - ---

-- -- - --
-- - --

370

Chapter 11: Multitasking-Related Issues


Calling One of Your Equals
-- - - -
- - - -

Calling a Procedure to Act as Your Surrogate

-- - - -
- - -
- -- - -- -- -

U
nR
eg

is

te

re

- -- - -
- -

- -- -
- - - - - - --


-- --- - -

Data Segment Protection


Data Segment Privilege Level
- -- - - -
- ---
- -
- - --
-

Read-Only Data Areas

- -
- - -

-- - -
-- -

371

x86 Instruction Set Architecture


Some Code Segments Contain Data, Others Dont
- - - - -
- - - - - - -
- - -
- - -- -
- -
- - -
- - - -

U
nR
eg

is

te

re

372

Chapter 11: Multitasking-Related Issues

- -




- -

- - - --

- - --

re

U
nR
eg

is

--

te

- --

- --

373

x86 Instruction Set Architecture


IO Port Anarchy
-- - - - --

U
nR
eg

re

te

- - - - --
- -
- - -
-- - - -
-- -- - --
-- -- - - --
- -
-- - - - -
- -- -- - - -- - - -
- --- - -- -- -
- -- -
- - -- - -- - -
--- - - - - - - - - --
---
- -- - - -
- - - - - - --
- - -
- -- -

is

- --- - - -
- --
- - --
- --
- - - --
- - - -
- - --
-
-
-- - - - - -- -

374

Chapter 11: Multitasking-Related Issues


No Interrupts, Please!
- --
-- - - --
- -
- - - -
- - -
- - - - - -

U
nR
eg

is

te

re

- - - -
-- - - - -
-- - - -
- - - - --
-- - -- - - - -
-- - - - -
- - -
--- - -
- --- -
- -
- -- --
- - - -
- -
- -- -
--
- - -
--
- - - - - -
- -- - --
-- - -
- - - - - - -- -
- - -
- -
- - - - -
-- - -- - - - -
- - - - - --

375

x86 Instruction Set Architecture


- - - -
- --
- -- --
-

BIOS Calls
--
- -
-

is

re

- --
-
- --
- - --
-
-- - --
- -
- - -
- -- - - -

te

U
nR
eg

- - - --
- --
-- - -
- - -- -
-
- - --- - -

- - - -
-- -
- - -
- - - -
-

376

--

re

te

The Previous Chapter

U
nR
eg

is

- - - -

-

- - -

-
- --


-
-


-
- -

- -
-

377

x86 Instruction Set Architecture


This Chapter
- -- - -- - -
-- - --

The Next Chapter

te

re

-
- - --
- - -
-- -
- -
-

is

- - - -
- - -- - -
- - -
-

U
nR
eg

Protection-Related Mechanisms

- - - --- -
--
- - -
-
-- -
-- -- -
--- --
-- - -- -

378

Chapter 12: Summary of the Protection Mechanisms

-
-
- --
- -
- - - --

-
-

-
-
- -

- -- -
- - -

- -- -
- - -
- -
- -

U
nR
eg

is

te

re

--
-
-

--
-

- -- - - - -
- -- - -
-

- - - -
-- --

379

x86 Instruction Set Architecture


--

-
---

- -

-- - -
-
-
- -
-- -
- -
- -

-- -

-- -
- -
- - -

--
- -
-

- -
--

-
- - -- --
-- --
-- - -
- - -
- -

-- -
-
-- - -
--- -
--
- - - -
--
-

U
nR
eg

is

te

re

380

Chapter 12: Summary of the Protection Mechanisms


--
-


-
-

-- --
- -
-
- - -


- -
-
- -- --

-- - -
-- -


- -
- - - - --
- -

U
nR
eg

is

te

re


-- -

-

- - -
-- -
-- -

-
-
--


-

--

--


-

- --

381

x86 Instruction Set Architecture


--

-

- --

U
nR
eg

is

te

re

--

382

--

re

te

The Previous Chapter

is

- - - -- -
- -- -
--

U
nR
eg

This Chapter

- - - - - - -- - -
- - -
-

-
- - --
- - -
-- -
- -
-

The Next Chapter


- - --
-
-

383

x86 Instruction Set Architecture


-
--
-
-

--
-




-

Real Mode Segment Limitations

re

U
nR
eg

is

te

-- - - -
- -- - - -- - -
-- - -
- -- - -
-

-

- - - -- -
- -
- - - - -
-- - - -- -
- - --

384

- - -- - - -

- - -- - -
- -
- - -- -
- -
- - -

Chapter 13: Protected Mode Memory Addressing

re

- - - -
- - - - -
- - -
- - -
--
- - -- - -
-
- - - -
-
- -
-- - -
- - -
- -
- -- -

te

- -

U
nR
eg

is

- - --

An Important Reminder: Segment Base + Offset = Virtual


Address
- - -
- - --
- - - -- --
- - -- - - -- -
- - - - - -- - -- - -
-- - --
-- - -- - -
-
-- - - - --
- --
- - --- - -- -- -
- -- - -

385

x86 Instruction Set Architecture


Descriptor Contains Detailed Segment Description
- -
-- -

re

- -- --

- --
-
- -
- - -
- -
- --
-
- - - - -
--
- - -

te

U
nR
eg

is

- - - -
- -- -
- - -
- - - - -
-- - -- -- -
-- -- - - - -- -
- - - - - -
- -

Segment RegisterSelects Descriptor Table and Entry


-- -- -
- - - --
- -
- - --
- - -- -
- - - - - - -
- -- -

386

- - -

Chapter 13: Protected Mode Memory Addressing

- - - - -
- - - -
-
- - - -
- --

is

te

re

- - -
-- - - --
- - -
- - - - - - -- -
- -
- -- - - - -
-- - - -
- - - - -
- - -- - - -- -
- -- - - - -
- - -- -
- -- - - -
- - - -

U
nR
eg

-- - - -
- -
-
-

387

x86 Instruction Set Architecture


- -

- -

- -

- - - --

- - --

re

is

te

--

U
nR
eg

- --

388

- --

Chapter 13: Protected Mode Memory Addressing


-- - - -

-- -
-- -
- -

-- -

- --

- --
-
- -
- -

re

-

-

- - -
- -


- - - -

- - - -
- - -
- -- - -- - -
-

U
nR
eg

- - --

is

te

-- - - -

389

x86 Instruction Set Architecture


-- - - -

- - --
- - -
- -


- - - -

- - - - - - -
- - - -
- - -- - -- - -
-

- - -
- -


- - - -

- - - - - -
- -- - -- - -
- - -- -

U
nR
eg

is

te

re

Introduction to the Descriptor Tables


Segment Descriptors Reside in Memory
-
- - -
-- - -- -- -
- - -- - - - -
- - -
- - -- - - - - -- - -

390

Chapter 13: Protected Mode Memory Addressing


- - -
-
- - - - -
- -

- -

- - -
- --
- - - -
- - -- -
- - - -
- - - - -
-- - - - - -- --
-
- - - -
- -- - --
- - - - - - - -
- - - -
- -
- --- - - -
- - -
- - - -
- - -- --
- - --- -
- - - - -- --
- - -- - --
- - -

re

te

is

U
nR
eg

391

x86 Instruction Set Architecture


- -

-
- - -
- -- - -
- - -
- --
- - -
- - -
- - - -
-
- --- - - -
- - - -
- -- -
- - -- -- -
- -- ---
- - - - - --
-- - -- - -
- -

- -
- --
- --
- --
- - - - - - -
-- -
-- -

- --
- - - - - - - -
- --
- - -- -

- - --
- - - -
- - --- - - - -

U
nR
eg

is

te

re

392

Chapter 13: Protected Mode Memory Addressing


Global Descriptor Table (GDT)
GDT Description
- - -
- - - - -
- -- -

- -- -
- -
-
- --

U
nR
eg

re

te

- - -
- - -
-
- -- - -
- - - -
-- - - --
-- --
- - -- --
- - -

- - - - -- - -
--- - - - - - -
- -

is

Setting the GDT Base Address and Size


- --
- - --
- - - - -
- - - -
-- - - - -- -
- - - - - -
- -- ---

- - - - - - -
- - - - - -

393

x86 Instruction Set Architecture

-- -
- -- -- -
-- - -
- - - - - - - -
- - - -
-- -
- --

- - -
- - - -

GDT Entry 0

te

re

- - -- -
- - -
- -- -
- - - -- -
-

is

U
nR
eg

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- -

- --

- -

- --

--

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- -

- -
- -

394

- -

Chapter 13: Protected Mode Memory Addressing


Local Descriptor Tables (LDTs)
General
- -
- -- -- -
-- -
-- -

- - -- --
- -
- -
- - --
-
- - -
-

re

is

te

- -

U
nR
eg

- --

395

x86 Instruction Set Architecture


Creating and Selecting an LDT
-- - - - - -

U
nR
eg

is

te

re

- -
-- -- -- -
- - - -
- - -
- - -- -
- -- - - - - --
- - - - -
- -
- - -
- - -
-- - -- - -
-- - -
--
- - - -
-
- - - -
-
- - -
- - - -

- -- -
-- - -- - - -
- - -
- - -- - -
-- - - - - -- - - - -
-

396

Chapter 13: Protected Mode Memory Addressing


- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

re
- -- -- -- -- --

- --

- --

- --

- --

- --

is

-
- -

te

- --
- - -
- -

- --

U
nR
eg

- - - -

397

x86 Instruction Set Architecture


- -

- -

- - - --

re

-
-
-
- -- -
-

te

- - --

-
- - - -- -
- -
- -- - --

is

U
nR
eg

- - - -

- -
-

--

- - - -
- - -
- -

398

Chapter 13: Protected Mode Memory Addressing


General Segment Descriptor Format
-- - -
-- - -
- -
- - -

- -

te

re

- --

- --

is

- - --

U
nR
eg

-
- -
- -

- - - --
- - --
- -
-- - -
- - - -
- -
- -
-

-
- - -- -

- - - - -

- -- - - --
- -- -

Granularity Bit and the Segment Size


- -- -- - -

399

x86 Instruction Set Architecture

- - -- - - -
- - - - -

- - - -
-- - -
- -

Segment Base Address Field

re

- -- - - - - - --
-- - - --

Default/Big Bit

te

- - - -
- - -

is

In a Code Segment Descriptor, D/B = Default Bit

U
nR
eg

- - - - -
- - - - -
- -

- - - -
-- - - -
--
-- --- -
- -
- - -
- --- - -
- - - -
-- - - -
--
-- --- -
- -
- - -
--- - -

- - ---
-

400

Chapter 13: Protected Mode Memory Addressing


Override Prefixes
--- --- --
- - - --

-- - -- -- - - -
- -
-- - --
- - -- --
- - -

re

--- --
-- - - - --

- -

- -

is

U
nR
eg

te

- --

- --

- - --

- -

-
- - - -
-
-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

- - - -
- - -
- -
- - - -
-
- - - -
- - -
- -
- -
-



-
- -
- - -
- -

- -

-
- - - - - -
- --


-
-
-

- - - -

-- --
- - --

401

x86 Instruction Set Architecture


-

- -

- - - --

- - --

-
- -
- -


-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

- - - -
- --

U
nR
eg

- -
- -
-


-
- -
- - -
- -

- -


-
-
-

-- --
- - --

- - - -

re

te

is

In a Stack Segment Descriptor, D/B = Big Bit


- - - - - -
- - - - -
-
- - - -

- - - - -
- - - - -

- - - - -
- - - - -

- -- -
--

402

Chapter 13: Protected Mode Memory Addressing


Segment Type Field
Introduction to the Type Field
- - -
- - - - -- -
-

Non-System Segment Types

te

re

- - - -- -
- - - -

- - - - - -
- - - - -
- - -
- - - - -
- - -- -- - -- -

U
nR
eg

is

- --- - -
- - - -
-

- - - -

- - - - -

-
- - - - -
-- - --
-- - - - -
-- -- -
--
- -- -- -
-
-- -- - -
- - - - -
- -- -- -- -
-- - - -- - -- --

403

x86 Instruction Set Architecture


-
-

- -- -

--
- - - -

-- -
- - -

--
- - - -
-

--
- - - -
-

--
- - - -

404

re

te

is

U
nR
eg

-- -
- - -

--
- - - -
-

--
- - - -
-

Chapter 13: Protected Mode Memory Addressing


-
-

-- -- -

-- -- -

-- -- -
-

-- -- -
-

-- -- -

-- -- -

-- -- -
-

-- -- -
-

re

te

is

U
nR
eg

- -- -

405

x86 Instruction Set Architecture


-

-
- -
- -

- -

- - - - -

- - -
-

- -- -

- --

- -
- - -

- --

- - --

- - -- -
- - -

-
- -
- -

-
- - -

re

te

-
- -
-

is

-- --
- - --

U
nR
eg

Segment Present Bit

- - - - - -
-

- - - -
- - -- - -
- - - -
- - - - -
- -- - -- - -
- -

Descriptor Privilege Level (DPL) Field


- - -- -
-- - -- -
-- -

406

Chapter 13: Protected Mode Memory Addressing


- - -- -

--

System Bit

re

- - -

- - - -- - -
-- - --
-- - - -- -
-

te

- - -- --
-

U
nR
eg

is

- - -- --
-

- - -- --
-

- - --
-- -

- - --
-- -

- - -- --

- - -- --

407

x86 Instruction Set Architecture


- - -

-

- - -- --
-

- - -- --
- -

- - --
-- -
-

- - -- --
-

- - -- --
-

U
nR
eg

is

te

re

Available Bit

- - -- -
- - -

Goodbye to Segmentation
Introduction

- - - - -
--- - - -

408

Chapter 13: Protected Mode Memory Addressing


- - -
- - -
- - - - -
- - --
- - - - - - - --
- -

IA-32 Flat Memory Model

U
nR
eg

is

te

re

-- --
- - -
- - - -- - - --
-- -
- -- - --
- -- -
-- -- - - - -
-- - - - - --
- - -
- - --

- -- -
--
- --
-
-- - - -
- - -
- - - -

- -- -
--
- --
-
-- - - -
- - -
- - -
-

409

x86 Instruction Set Architecture

- - -- -
--
- --
-


- - - - -
- - -

- -

- - -
- -
- - --
- -

re

te

- - -

U
nR
eg

is

- - -
- - -
-- - - -
-- - - -- -
- -- - -- - --
- - -- -
- - -
- -

410

Chapter 13: Protected Mode Memory Addressing


U
nR
eg

is

te

re

-
- -- -


- -

--




- -
--- -

-
- -- --
-

--
-
- -- --
-
-- - -
- -
- -
- - -
-
-
- -- --
-
-- - -
- -
- -
- - -
-

411

x86 Instruction Set Architecture


No Protection? Paging Takes Care of It
- -
- - -- - -- -

- - -

- --

U
nR
eg

is

te

re

- -- - -- - -
- - - -- - -
- --- -
- --- --- -
- - -
-- - - - -- --
- - - - -
- -
--- - - - -
- -
-- - - - - -- -
--

A Reminder of Where We Are

- - -
-
-- - - -
-- - -- - - -- -
-- - - - -
- - -- - -- -
- -- -
-- -- -
- -
- -- - -
- -- - --

412

Chapter 13: Protected Mode Memory Addressing

U
nR
eg

is

te

re

- - ---
- ---- - -
- - -
-

413

U
nR
eg

is

te

re

x86 Instruction Set Architecture

414

-
-

re

The Previous Chapter

is

-
- - --
- - -
-- -
- -
-

U
nR
eg

te

- - - -
- -- - -
- -
-

This Chapter

- - - --
-
-


-
--
-
-

--
-

415

x86 Instruction Set Architecture

The Next Chapter

U
nR
eg

is

te

-

--

--




-

re

- - - -
-

Abbreviation Alert

-- - - -- -

Selecting the Active Code Segment


- -
-- - --
- - - -
- - -- -
- - --
- - -
-- -
- - - -
-

416

Chapter 14: Code, Calls and Privilege Checks


- - - -
-- -- --
-

- -

- - -
-

re

-- -- - -
- -
-

-
-

-- -- -
- - -
- --

-- -- -
- - -

-- -- -
- - -

-- -- -
- - -

U
nR
eg

is

te

-
-
--- -

- - ---
- - - - -
- - -- - - -- -
-- - - -

-- - - -
-

417

x86 Instruction Set Architecture


- -

-
-- - -
- -

-- -

- --

- --

-
- -
- -

is

te

-- -
- -

re

-- -

U
nR
eg

-

-

CS Descriptor

CS Descriptor Selector

- -

418

- - - -
--
--
- - -
-- - -
- -
- - - -

Chapter 14: Code, Calls and Privilege Checks


Calculating the Descriptors Memory Address
-- - - - - -
- - - - - -
- - -
-- - - - --
- - --
-

Descriptor Read and Privilege Checked

U
nR
eg

- - -

- --- -- -- -
- -

is

te

re

-- - - - -
- - - - -- - - -

CS Descriptor Format

-
- - -- -
- - -
-

- - - - - -
-
-
- - -
- -- - - -
-
- - -
- -- - - -

419

x86 Instruction Set Architecture


-

-
- - - -
- - - -
- -

-
- -
-- --
-
-

- -- - -
- - -
-- - -
-- - --
- - -
-- -- - - -- -
- - - -

- - -
- -

U
nR
eg

is

te

re

420

Chapter 14: Code, Calls and Privilege Checks

- -

- - - --

- - --

-
- -
- -


-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

U
nR
eg

- - - -
- --

- -
- -
-


-
- -
- - -
- -

- -


-
-
-

-- --
- - --

- - - -

re

te

is

421

x86 Instruction Set Architecture

- -

- -

- -

- - - --

- - --

- -

-
- - - -
-
-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

- -
- -
-


-
- -
- - -

U
nR
eg

is

- - - -
- - -
- -
- - - -
-
- - - -
- - -

te

re

422

- -

- -

-
- - - - - -
- --


-
-
-

- - - -

-- --
- - --

Chapter 14: Code, Calls and Privilege Checks


Accessing the Code Segment
-- -- - - - - -
- -- - -
- - -
-- --

In-Line Code Fetching

-- -- -
-
-- - --
-
- -
- -
-

-
- -
- - - -
- - - -

U
nR
eg

is

te

re

-- - -
-
-
-- - - - -
- - - - -
--- - -
-
- -
- --- - - --
- - -

Short and Near Branches (Jumps and Calls)


General
-- - -
- - - -

423

x86 Instruction Set Architecture


- - ---- - -- - -
- - -- - -
- - - -- -
-- - - --
--

Example Near Jump


- -

U
nR
eg

te

-- - - - -
- -- -
- - - -- - - - -
- - - -- - - - - - --
-- -
--

is

re

- - -
- - -- - --

Far Branches (Far Jumps and Calls)


General

-- - -
- - - - - --
- -

424

-- - - -

- -
- -

- -- -
- - - -
- - - -- -
-

Chapter 14: Code, Calls and Privilege Checks

-- - -
-- - - -
- - -- -

-- - - -- -
-- - -
-- --

Example Far Jump

- -

-- - - - -
- - -
- - - -
- - - -

- - - -
- - - - - -
- - - -
-
-- -- - - - -
- - - - -- -- - -
--

U
nR
eg

is

te

re

- - - -
-- - - -
-- - - -
- - - -
-
- - - - -
-
-- - -

425

x86 Instruction Set Architecture


-

- --



- -

- --

- - --

re

- --


- - - -

- - -
- ---
--

- -
- - -
-

U
nR
eg

- -- -

is

te

- - -- -
- - -
-

- -
- - - -

-- -- -
- - --

426

Chapter 14: Code, Calls and Privilege Checks


Short/Near Jumps
General
- - -
- --
- - -
- -
-

re

- - - --

te

No Privilege Check

U
nR
eg

is

- - -
- - -
-

Unconditional Short/Near Branches


- - -
- - -

- - -
-- -
- - --
- - - - - -
- -
-- -
- - --
- -
- -- -
- -

427

x86 Instruction Set Architecture

o - -
- -

o - -
- -

o - -
- -

o - -
- -


- - -
-


- - -
-

U
nR
eg

re

te

is

-- -
- - - -
-

Conditional Branches
General

- -- - - -- - - -

428

Chapter 14: Code, Calls and Privilege Checks

- - - -
- - --
- - -
-

re

- -- -
- -
- - -- - - - - - - -
- -- - -
- - - -
-

U
nR
eg

is

te

-- - -
- - - - -
- - - - - - -
- - - - -- -
-
- - - - -
- - - - - --
- -
- - - -
-

429

x86 Instruction Set Architecture


-

--

--

--

--

re

te

is

U
nR
eg

-- - -

-- - -

430

--

Chapter 14: Code, Calls and Privilege Checks


-

--
-- - -

- -
- - -
-

-- - -

-
-- - -

-
-- - -

U
nR
eg

is

re

te

Loop Instructions

-- -
- - -

- ---
- -

-



- - --
- - - -
- - -
- - -
- - -
- -

431

x86 Instruction Set Architecture

- - - - --
- -
- - -

- - - -

-

--

- - - -
- -
-- - o

- - -
-
- -
-- - o

- - -

te

U
nR
eg

is

re

- - -
-- - -- -
-- - -- -

432

- -
- -
-
- -
-- - o

- - -
-
- -
-- - o

- - -

Chapter 14: Code, Calls and Privilege Checks


- -

--

- -
- -
-
-
- -
-- - o

- - -
-
- -
-- - o

- - -

- -
- -
-
-
- -
-- - o

- - -
-
- -
-- - o

- - -

U
nR
eg

is

te

re

433

x86 Instruction Set Architecture


- -

--

- -
- -
-
-
- -
-- - o

- - -
-
- -
-- - o

- - -

- -
- -
-
-
- -
-- - o

- - -
-
- -
-- - o

- - -

U
nR
eg

is

te

re

Unconditional Far Jumps


The Privilege Check
- -
- - - -
-

434

Chapter 14: Code, Calls and Privilege Checks


Far Jump Targets
-- - -
-- - - --

U
nR
eg

is

te

re

- - - --
- --- -- - -
- - --
- - - - -
- -- - --
- - - - -- -
- - - - -
- - -
- - - -- --
- -- - - - -- - - -
- - - - -
- - - --
-- -- -- -- -
-- - --

Far Jump Forms

- - -
- -

- -- --
-- - -
- -
-- --
-- - -
- -

435

x86 Instruction Set Architecture

-
--
- -
- -
-

--
- -
- -

--
- -
-
- -

is

re

te

--
- -
-
-

U
nR
eg

-- -
- - - -
-

Privilege Checking

No Check on Near Calls or Near Jumps


- - -
- - -
-

436

Chapter 14: Code, Calls and Privilege Checks


General
- --
-- - --
- - --

Definitions

Definition of a Task

te


-
--
- - -
-

is

re

-- - -
- - - -
- - -

U
nR
eg

- - -- -- - - --
- - -
-- - -
- - - --
-- -- - -- - - - - -
--- -
- - - -
- - - -
--

Definition of a Procedure

- -
-

CPL Definition
- -
--
-

437

x86 Instruction Set Architecture


- - -- --
- - - --
--
- -
-

CS DPL Definition
- - -

-
- - -

-

re

te

- - -
- ---

is

Conforming and Non-Conforming Code Segments


--

U
nR
eg

-- -

-
---
- - - --
- -
- - -
- - - - -
-- --
-- - -
- - -
- - ---
- -
-

- -
---

438

Chapter 14: Code, Calls and Privilege Checks


-
-
-

- -
-

RPL Definition
- --- -

-- -- --

re

- -
- - -

te

- - - --

- -

U
nR
eg

is

- -
--
- -- -
--
-
-
--
-- -
- - ---
-

- - -- - -
- -
-- -

-
- -
- - - -
- --
- -

439

x86 Instruction Set Architecture


-
- -
-- -
- -

re

- - -
- -- - - - -
-
-- -- - -
- - - -
- -
-- - -

is

te

-
- - - -
-

U
nR
eg

Privilege Check on Far Call or Far Jmp


General

- -
- - -
-- - - -

Example

440

-- -
- - -
- --
- --
-
- - -
- - -
-
-
- -- -- --

Chapter 14: Code, Calls and Privilege Checks


- - -- -
-- - --

is

U
nR
eg

te


--

re

-
-



- -

Jumping from a Higher-to-Lesser Privileged Program


-- - -
- --
- - - - -
- - - - -
- - - - -
- - -
- -

- - -
- -- - - -
- - - - - -
- - --

441

x86 Instruction Set Architecture

- -
- - -
-
- -
- - - --
- - -
- - --
- - - - - -
-- -- - - -
- - - - -

te

Introduction

re

Direct Procedure Calls

U
nR
eg

is

- -- - -
-- - - - - - -
-- -- -
- - - -
- -

General

- - --

442

- - - -
- -
- -
-
- - - - --
- --
- -
-- -- --
- - - --
-

Chapter 14: Code, Calls and Privilege Checks


- --

-- - - -
- - - - - -- - --- - -
-
-- -
- - - - - -- -
- --- - -
- -

-- - - - - -

re

Near Calls/Returns

te

Description

- - -
- - -
-

U
nR
eg

is

- - - - - -
- --

-- - - - -
- - -
- - ---
- - - - -
- -
- - - - -
- - - - -
- - - - - -
-- -
-- - -
- -
-- -
-
- -
-- -- -
- - -

443

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- - - - -
- - - - - -- -
- - - - -
- - - - - -
-- -
-- - -
-- -
-
- -
-- -- -
-
- --- - - -
-- -- -
- - - - - -
- - -
- - -
- - - - -
- - - - - -
-- -
-- - -
-- -
-
- -
-- -- -
-
- - - - - -
- - -
- - -
- - - - -
- - - - - -
-- -
-- - -
- -
-- -
-
- -
-- -- -

444

Chapter 14: Code, Calls and Privilege Checks


- - -
- --- - - -
- - -
-

Call/Ret Operand Size Matching


- - - - -
- - - -
-
- - - -

Near Call/Return Forms

te

- - --
-- --
-

is

re

-- - - - - -

U
nR
eg

-- o
- - - -
- -
-
-- - -
---
-
-- o
- - - -
-
-- - -
---
-

445

x86 Instruction Set Architecture


-

-- -
- -
-
-
-- - -
---
-

is

te

-- -
- -

-- - -
---
-
- - -

re

446

- - -
- -

U
nR
eg

- - -


- - - -
-- - - - -
-
- - -
-- -


- - -
-- - - - -
-
- - -
-- -

Chapter 14: Code, Calls and Privilege Checks


-
-

-- -
- - - -
-

Far Calls

re

General

- --
-

U
nR
eg

Far Call Forms

is

te

- - - - -
- - --

-- - - -
- - -
-- --

-- - -

-- - -

- -

- -

-- -
-

447

x86 Instruction Set Architecture


-- - - -

-
- - -


-- - - -

-
- - -

is

te

re


-- - - -

-

U
nR
eg

448


-- - - -

-

Chapter 14: Code, Calls and Privilege Checks


-


-
- - -
-
--
- -
- - -
- -
- -

re

is

te


-
- - -
-
--
- -
- - -
- -
- -

U
nR
eg

449

x86 Instruction Set Architecture


-


-
- -
- -
-- - -
-
- -
--
- -
- - -
- -
- -
-- - -
-
- -

is


-
- -
- -
-- - -
-
- -
--
- -
- - -
- -
- -
-- - -
-
- -

U
nR
eg

te

re

-- -
- - - -
-

450

Chapter 14: Code, Calls and Privilege Checks


Far Call, Same Privilege Level
-- - -
- - -
- -
-- -- - --
- - - -- - -
- -- -- -
- -
- - - - -
--
-- -- -
- - - - --
- - -- -
-- - - -
- - -
-- - -
- -- - -
-
-- -
-
- -- - -
- --
-- - -
- -
- -

U
nR
eg

is

te

re

Far Call to a More-Privileged Procedure


-- --

-- -
-- - - - - --
- - - - -
- - - -
- -- - -
- - - -
- -

451

x86 Instruction Set Architecture


-- -
-- -
- - -
- -- -- -
-
-
- - - - -
-- - - -
- --
-- - -
-- - - - -
-

re

Far Call to a Procedure in a Different Task

is

te

--- - -
- - - - -
- - - - -
- - -
-

U
nR
eg

-- - -- - -
-- -- - -
- - -
-- -

Indirect Procedure Far Call Through a Call Gate


Example Scenario Defines the Problem
The Scenario

452

-- -
- - -- -
- - - - --
- -
- -
- -

Chapter 14: Code, Calls and Privilege Checks

- - - -
-- - -

- - --
-

The Problem

re

- - - -- -
- - - -

-
- --
-
- - -
- - - ---
- -

is

te

U
nR
eg

453

x86 Instruction Set Architecture


The SolutionDifferent Gateways
- - - - --
- - --
-- -
-- - -
- - -- - -
- - - -

-- - - - -
-- - - -
- -
-
- - - --
-

is

te

re

- - - -
- -
- - - - -
- -

U
nR
eg

- -
- -
-
- -
- - - -
- -
- -- - -

The Call Gate Descriptor

- - -
- - - - -- - -

454

Chapter 14: Code, Calls and Privilege Checks

-
-
- -
-
-
- - -


-- -
- -
- -
- -
- - -
- - - --
- - - -
---

U
nR
eg

is

te

re

- - - - - -

- - --
- - - -
- -
- - - - -

- - - -
-- -
--

- - -
- - -

455

x86 Instruction Set Architecture


-

- - --
- -
-

- - - -


- -

- -
- - - -

te

- -
- -- - -

re

-
-
- -

U
nR
eg

is

- - -
-

Call Gate Example


Execution Begins

-- - -




-- -
- - --
- - -- -
- - -
-- - --
- - -- -
- --

456

Chapter 14: Code, Calls and Privilege Checks


-
-

- --
- --

- --

re

Call Gate Descriptor Read

- - -- - -
- -

is

te

- -
-- - -
-

U
nR
eg

- - -
- -
- - -

- -

-
- - - - -
- -

- - - -- -
- -

457

x86 Instruction Set Architecture


- - -

- - - - -- -
- - -


- - -
- - - - -
--

-
- - - -
- -

-
-- - -

te

re

U
nR
eg

is

-
-
- - --
- -
-
- - -
- --
- - -

- -

- -
- - - -
- -
-
-
- -
-

- - -

Call Gate Contains Target Code Segment Selector


- -
- - -

458

Chapter 14: Code, Calls and Privilege Checks


-- - - - -
- -
- -


-
- -
- --

re

Target Code Segment Descriptor Read

is

te

-- - -
-- - -

U
nR
eg

- -- - -

-
-

- - -

- - - -

- -
- - -

- -
-

459

x86 Instruction Set Architecture


-

- - - -- -
- - -

- -
- -

- -
- -
-

- - -
- -

- -
-- - - - --

is

te

re

U
nR
eg

- -- -

- --

-
- -

- - -
- ---
--

- --


- --


- - --

- -
- - -
-
- - -- -
- - -
-

- -
-

-- --
- - - --

- -

460

- -- -

- --
-

Chapter 14: Code, Calls and Privilege Checks


The Big Picture
-- - -
- -
-

- -
--

-
-

re

- --

te


- --

U
nR
eg

is

The Call Gate Privilege Check


-
- -- --
- -
-- -
- -- --
- -
- - -

461

x86 Instruction Set Architecture


Automatic Stack Switch
Background
- - -- - -- -
-- - - - -
- -- -
-- - -- -
--

-
-

re

- -
-- - -- -

is

A Potential Problem

te

-- - -- -
- -
-- -

U
nR
eg

-
- -- -- -
-- - -
- - - -
- - -
- - -

The Solution: Pre-Allocated Stacks


-- --- - -
- - - --
- -
- -- - - - -
- -- -
-
-
-- -- - -
-
- - - - - --
- - -- - -
-- -

462

Chapter 14: Code, Calls and Privilege Checks


-- -
-

-- -- - -
- - --
- - -
- -
-- -- - - -
- -
-
- -
- -
- -- -
- --

U
nR
eg

is

te

re

463

x86 Instruction Set Architecture


-

U
nR
eg

is

-
-

464

-
-- -

re




--
-

--
--
--
--








- - - -
- --

-- -

te

--

-

Chapter 14: Code, Calls and Privilege Checks


--- -- -

- --

re

- - -

- -
-

U
nR
eg

is

- -
- -

te

- - -
- --
-
- --

- -

- -
- -
-
- -
- -
- -- -
- --
- -
- -

-
-

-
-

465

x86 Instruction Set Architecture


Far Call From 32-bit CS to 16-bit CS
General
- -

is

te


- -


-- -- -


-
- -
- -

re

U
nR
eg

Method 1: Far Call with Operand Size Override Prefix



- -
- - -
- -- --

- - -
- - - - -

- - - - -
- -

- - - -

466

Chapter 14: Code, Calls and Privilege Checks

re

- - -
- - -
- - - - -

-- - --- -
- -- -
-- -
- -

te

- - -

- -

is

- -
-- -
- -

U
nR
eg


--


- -

- - - -
- - -
- -



-- -
- -
--
-
- -
-

Method 2: Far Call Via 16-bit Call Gate


- - -- --
- -
- -

467

x86 Instruction Set Architecture


- --
-
- -

- -- -
- - - -
- -
- -
-
- -
- - - -

U
nR
eg

is

te

re

- - - -

468

Chapter 14: Code, Calls and Privilege Checks

- --

- - -

- -
-

U
nR
eg

is

- -
- -

te

re

- - -
-
--
-
--


-

-


-
- -

- -
-
-
- -
- -
- --
- --

- -
- -

-
-

-
-

469

x86 Instruction Set Architecture

-
-

- -
-

-



- -

--

- -
-

te

re

- -

is

- -
- -
-
- -
-

U
nR
eg

-
-

Method 3: Call 32-bit/16-bit Interface Procedure


- - -
-- - -
-
- -
--

470

- -
- - -- --
-
- - - - -
-- - -
- -

Chapter 14: Code, Calls and Privilege Checks

- - - -
- - -- - -
-- -
-

-
-

- - --
- -
-

- - - -


- -

- -

te

- -- - -

is

re

U
nR
eg

- -
- - - -

-
-
- -

- - -
-

Far Call From 16-bit CS to 32-bit CS


- -


- -


-- -- -

471

x86 Instruction Set Architecture


Method 1: Far Call With an Operand Size Prefix

- -
- - -
- -- -
- - -
- - - - -
- - -

te

re

is

U
nR
eg

-- - --- -
- -- -
-- -
- -

- - -
- - -
- - - - -

- -
-

- -
-

--
-


--

-
--



-

- -
- -

472

Chapter 14: Code, Calls and Privilege Checks


Method 2: Far Call Via a 32-bit Call Gate
- - -- --
- -
- -
- --
-

- - - -


- - --
- -
-

U
nR
eg

te

is

re

- -

- -- - -

- -

- -
- - - -

-
-
- -

- - -
-

473

x86 Instruction Set Architecture


-

- --

- - -

- -
-

U
nR
eg

- - -
-
-- -
-
-- -

is

te

- -
- -

re


-
- -

- -
- -
- -
- -
- -
- -- -
- -- -

-
- - -
- -- -
- -


- -
- -

-
-

-
-

474

Chapter 14: Code, Calls and Privilege Checks

- -

- -
-
- -

te

- -

re

- -
-
- -

U
nR
eg

is

- -
- -
- -

-
-

Far Returns

General

- -
-- -
- -
- --

-
- -- - - -
- - - - - - - -
- - -- -- -- - -

475

x86 Instruction Set Architecture

re

-- -- -
-
-- --
-
- - - - -
- - - -
- -- -
- - -
- - -
- - -
- - - -
- -
- --
- - -

te

Far Return Forms

-- - -

is

U
nR
eg

476

Chapter 14: Code, Calls and Privilege Checks

-
-
- -
- -
--
- -
- -
- -
- -
-
- - -
- - -
-
- - -
- -
- --
- - -- - -
- -- - -
- -

U
nR
eg

is

te

re

-
-
- -
--
- -
- -
-
- -
-
- - -
- - -
-
- - -
-
- --
- - -- - -
- -- - -
- -

477

x86 Instruction Set Architecture


-

- -
- - -
-- - - - -
- -
- -- -

U
nR
eg

is

te

re

- -
- - -
-- - - - -
- -
- -- -

478

re

The Previous Chapter

is


-
--
-
-

--
-




-

U
nR
eg

te

- - --
-
-

This Chapter

- - - - -
-- - -- -

-

--

479

x86 Instruction Set Architecture


--




-

The Next Chapter


- -

re

U
nR
eg

te

- - -- -
- --- -
-
- - - -
-- -
- - - -- -
-- -
- - - - -
- - - - -

-- --
--
-- -
-

-
-

is

A Note Regarding Stack Segments


- - -
- - - - - - -
-

480

Chapter 15: Data and Stack Segments


Data Segments
General
--- - -- - - -
- -- --

is

te

re

-- -- - -
- - - - -
- - -- -
- -- -
-- - -
-- - -
- - - - -

Two-Step Permission Check

U
nR
eg

--- -- - -
-- - - --

-
- - -
- - -- -
- - - - -
- - -
-- - -- -- -
- -- - -- -
- - - -
- - - -

481

x86 Instruction Set Architecture

- -
- --

-
- -
- --

is

te

re

U
nR
eg

- -
- -
- -

An Example

- - --- -

- -

-
-

- - -- -
-- ---
- - --
-

482

Chapter 15: Data and Stack Segments


-- - - -
-

-
-

-- - - --- - -
- - - -
- - - -

U
nR
eg

is

te

re

- - --
- - - -- - - -
- - - -
- - - -
- - -- -- - -- -- - -- - - - --
-- - -
- - -
- - -- -- - - - -
- - - -
- - - -- - --
--
- - -
- - - -
--- - - - -
--


-
-
-

- -

- -
- -

483

x86 Instruction Set Architecture


-

-
- -

- - - -
- -
- -

- --

- --


- - --

- -- -
- -
- - -

- - -- -
- - -
-
- -

U
nR
eg

re

- --

is

te

-
-

-
-

-- --
- - --

- --

- -- -
- -

Selecting and Accessing a Stack Segment


Introduction
- - - - - - - -
- - -- - - - - - - - -
-- - - - -

484

Chapter 15: Data and Stack Segments

- - - -
-- -

- - -
-

- - - --

Expand-Up Stack

-
- -
- -

-
-

te


--
-

is

re

--- - -- - -
-- -- -
-- -- -

U
nR
eg

- -- - - -
-- - - -

- - -
-- - - -
- - - - -
- --

- - - - -
- - -
-
-
- - - --
--
-
- - - - - -
- - - - - --
- - -- -

485

x86 Instruction Set Architecture


- --- --
- - - - - --
- - - - - - -
-
-
- - -

re

-- -
- -
- - - - -
-
- - - -
- - - -

-- - -
- -- - --
--
- -

te

-- - -
- -- - --
- -

-
-- - - - -

U
nR
eg

is

- -

486

Chapter 15: Data and Stack Segments


-

- - - --

- - -
- - -
-
- - -- -
- - - -

- -
- -

- -- - --
- -


- -- -

U
nR
eg

- -- -

- - --

- - - -
- -
-

-
- -

re

te

- --

is

- --

-- --
- - - --
- --
- -

Expand-Down Stack
The Problem

-- -- - -
- - - - - -
- - - -
-
-- - - - -
- --

487

x86 Instruction Set Architecture


- - - -
- - - - - -

te

- - -- - -
- - - -

re

-- - - - -
- - -- -
-
- - - - -
- - - - - -
- - - - -- -
- -- -
- -

is

- - - --

U
nR
eg

- -
- - - -

488

Chapter 15: Data and Stack Segments


- - -
- - - - -

te

re

is

U
nR
eg

- -
-

Expand-Down Stack Description


- - -- -
- - - - - -
- - - - - -

489

x86 Instruction Set Architecture


- - - - - - - - - - - -

- -
- -

An Example

re

- -- - -- --
- -
- - -
- -- - - --
- - - - --

- - -- -
-- - - - -
- - -

te

- -- - -- - --
- - -
- - - -
-
- - - - - -

- - - - - -
- -
- - - -
- - - - -

- - -
- - - -- - - -
-
- - -
- - -
-- - -

U
nR
eg

is

- -- - - - -
-- - -- - - - - - -

490

Chapter 15: Data and Stack Segments


Another Example
- -- - - - -
-- - -- - - -
- - - -

U
nR
eg

re

te

- -- - -- -
- - - -

- - - -
-
- - - - - -

- - - - - -
- -
- - - -
- - -
- - -
- - - -- - - -
-
- -
- - -
--- - -

is


-
-

- --

491

x86 Instruction Set Architecture

- - -

te

- --

U
nR
eg

is

- -

-- -- -
- -- - - - -

re

492

--
--

re

te

The Previous Chapter

-

--

--




-

U
nR
eg

is

- - -
- -
-

This Chapter
- - -

- - -- -
- --- -
-

493

x86 Instruction Set Architecture

The Next Chapter

re

- - - -
-- -
- - - -- -
-- -
- - - - -
- - - - -

-- --
--
-- -
-

-
-

te

U
nR
eg

is

-- -- - -
-
-- - - -
- -- --- --- -
- -

Three Generations

- -- - - -
- - - -
- - - ---
--

- -- - - - -
-- - - -
- - - -
- - -- - -
- - -

- - --

- - - -
- -- -

494

Chapter 16: IA-32 Address Translation Mechanisms


Demand Mode Paging Evolution
-- -
- -
- --- - --

- -- - -
-- - - -
--
- - - - -
- -- -
--

- -
-

te

re

U
nR
eg

is

--

-

- -
-
-
-
-
-
-
-

- - - -
- --
-
-

-
-

495

x86 Instruction Set Architecture



--

-- - - - - - -
-- -
-- -

- -
- --
-

-- -
-- - - - -
- --
- -- -
- -
-- - --

re

te

U
nR
eg

is

Background

Memory and Disk: Block-Oriented Devices


-- - - - - - -
- -- - - --
- - - -- - - - -

Definition of a Page
- -
- - -- -
- - -- - -

496

Chapter 16: IA-32 Address Translation Mechanisms


- - - - - -
- -- -

- - - -

- - -
- -

re

- -
- - - - - -
- - - - - - -

te

Example Scenario: Block Transfer from Disk to


Memory

U
nR
eg

is

- - - -
- - -- -- ---
- -- - -- - --

--- - -
--- - -
- - --
- - --
--- - -
- - -
- -

- - -

- -- -- --
- -
-- - -- --
- -- -
- - -
- - - -

497

x86 Instruction Set Architecture


- - -
- --
- -
- --
- - -- - -
- -- - -
- - -
- - - -
-- - - - ---
- -- ---
-
- -- - -

re

A Poor Memory Allocation Strategy

is

-- - - -
- - - -- -
- - -
-- -
- -
- -
- - -
- - -
-- -
- -
-- - - - -
---







U
nR
eg

te

498

Chapter 16: IA-32 Address Translation Mechanisms


- - - -
- --- - - - -

Applications Are Presented With a Simplified World-View


Introduction

- - - -- -
- --

re

- - - --
--

U
nR
eg

is

te

-- - - - -
- -- -
- -- - -
- --- -- - -
- - --

Life Without Paging Would Be Chaotic


-
- -- -
- - -
-
-

499

x86 Instruction Set Architecture

-- -

- --

- -
-

re

U
nR
eg

is

te

- --

The Virtual World Is a Simple One


-- - - -
- - - --- - -
-- - - ---
- -

500

Chapter 16: IA-32 Address Translation Mechanisms

-- -

- - -
-- - -

re

--

is

te

U
nR
eg

- -
-- -

--

- - --
- - - - - -- - -
-- - -- - -- - --- - - -
- -- -

501

x86 Instruction Set Architecture


-- - - --
--

- --

re

- --

U
nR
eg

--

is

te

502

Chapter 16: IA-32 Address Translation Mechanisms


-- - - --
--

- --

re

- --

U
nR
eg

--

is

te

503

x86 Instruction Set Architecture

-- - - --

--

- --

U
nR
eg

is

te

re

--

- --

- - -- -
- - - - -- - -
-- - -- - ---
- --- - - - -
-- -

504

Chapter 16: IA-32 Address Translation Mechanisms

-- - - --

--

- --

U
nR
eg

is

te

re

--

- --

505

x86 Instruction Set Architecture


-- - - --

--

- --

U
nR
eg

--

is

te

re

- --

Virtual Address Space Partitioning


--- -
- -- - - -
- - - - -
-

506

-- -
- -- --
-- -- -
- - - --
- - -
-- -
- -
-- --
-- --

Chapter 16: IA-32 Address Translation Mechanisms

- - - --
- - -- - --

-- - - --
-
- --

--

re

is

te

U
nR
eg

507

x86 Instruction Set Architecture


Example Virtual Buffer Allocation
- -
- - -
- - - -

U
nR
eg

is

re

- -
- - - - -

- - - - -
- ---
- -- - - -
- - - -

- - --
- - - -- - - - - - -- -
-- --- -
-- - - -
-- - -- -
-- --

te

508

Chapter 16: IA-32 Address Translation Mechanisms


-- -

- - -

--

re

- - - -- -- - -
-- -
- - -
- - -
- -
-- - -
-

U
nR
eg

--

te

is

Address Translation Advantages


Introduction

-- - - --
- - --
-- - - - --
-- - -

Simplifies Memory Management


- - -
- - -

509

x86 Instruction Set Architecture


- -
- - -
--- - ---
- -- -

Efficient Memory Usage


A Wasteful Approach
- -

U
nR
eg

is

te

- - -
- - - - -
- - -
- -
- -
- - - -
- - - -
- - - - - -
--
- --
- - - -- --
- -
- -

- -- - -
-
- - - -
- - - - -

re

- - -
- -
-
--- - --
- -
- --- - - - - -
---

510

Chapter 16: IA-32 Address Translation Mechanisms


A Better Approach: Load On Demand
- - -

-- -
- -

- - -

te

Attribute Assignment

re

- - -
-
- -
- -
- -

U
nR
eg

is

- - -
-
- -
- - - -
- - -
-- - - -
-- - - -- -
- -- - -
- -- - - -- -

- --


-- -
- -- - - -
- --
- - --

- - - -

511

x86 Instruction Set Architecture


Track Access History
- - - -- -
-- -- -- -

Allows DOS Applications to Co-Exist


Problem: Running Multiple DOS Programs

re

- - -
-- - -
- -
- - -
- -- - -- -
-

U
nR
eg

is

te

- -
- - -
- ---
- - -
- -
-

Solution: Address Redirection


- -
-

-
-
- -
--- - ---
-- -
-- - - -
--- -
-- -- -
- - -
-

- - - - - - ---

512

Chapter 16: IA-32 Address Translation Mechanisms


- -- - -
--
- --- -

- -

- -

re

te

U
nR
eg

is

First-Generation Paging

Definition of First Generation Paging


-- - - - -
-- - - -
- - -
- - - - --- - - - -
-

513

x86 Instruction Set Architecture


- - -

- -
- -
- -
- -

- - -
- - -- -

Paging Logics Interpretation of a Virtual Address

U
nR
eg

- - --
- --
- -
- -
--
- -- -
- -
--

is

te

re

-- ---
- -- -
- -

--

--

514

Chapter 16: IA-32 Address Translation Mechanisms


First-Generation Paging Overview
The Set-Up
-
- - -- -
-- -
- - --- - -

-
-
-
- -- - -
- - -- --
-
- - --
- - -
-- -- -
-- - - - -- -

-- - - -
- - -
- - -
- - - - --

- - - --
-
- - -
-- -
- -
-- -
- - - ---

U
nR
eg

is

te

re

- - - - - -- - -
- - - - - - -

515

x86 Instruction Set Architecture

is

te

re








- - -- -
- -
-- -- -- - - - -

-- -- ---
- - -

-
- - - -- -
- - --- - - -
-

U
nR
eg

Virtual-to-Physical Address Translation


-- - -
- - -
- -- --
- - - --
--- -- - -
-- -- - - -

-
-- - -
- --- - - -- -
- -
- - - - - --
-
--
-- --

516

Chapter 16: IA-32 Address Translation Mechanisms


-- -
-- --

-- - -- -
--

U
nR
eg

te

is

re

-
- - --
-- - --
-- - -- -
- --
- - - - --
- -
- - -- -

- - - --
- - -

-- - -- -
-
- - -- - -
- - - --
-
- - - - -
-- - - -- - - - - -- - - --
- -- -
-- - - - - --
-

517

x86 Instruction Set Architecture


---
--

518

d
re

is

U
nR
eg

-
--

te

- -

-
- - --
-- - --
-- - -- -
- --
- - - -
-- - -
- - -- -

- - - --
- - - -

-- - -- -
- - -
-- - -
- - - --
-

Chapter 16: IA-32 Address Translation Mechanisms

- - - - -
-- - - -- - - - - -- - - --
- -- -
-- - - - - --
-

---
--

is

te

re

U
nR
eg

-
--

- -


- - --
-- - --
-- - -- -
- --
- - - -
-- - -
- - --
-

519

x86 Instruction Set Architecture

te

re

- - - --
- - - -

-- - -- -
- - -
-- - -
- - - --
-
- - - - -
-- - - -- - - - - -- - - --
- -- -
-- - - - - --
-

is

---

--

U
nR
eg

-
--

- -

520

Chapter 16: IA-32 Address Translation Mechanisms

U
nR
eg

re

te


- - --
-- - --
-- - -- -
- --
- - - -
-- - -
- - --
-
- - - --
- - - -

-- - -- -
- - -
-- - -
- - - --
-
- - - - -
-- - - -- - - - - -- - - --
- -- -
-- - - - - --
-

is

521

x86 Instruction Set Architecture

---

--

is

U
nR
eg

-
--

te

re

- -

Two Overhead Memory Reads Take a Toll


-- -- -
- -- -
-
- - -- -- - -
- - -- - --- - -- - -- - -
- - - -
-- - - -
-- -- - - - -
--- - - -

522

Chapter 16: IA-32 Address Translation Mechanisms


- -- - - --- - -
- - - -
- - -

The TLBs
-- - - -
--- -

re

-- - - -
- - - -
- - - - -- - -
- -- - -
- - --
-- - - -

te

TLB Miss

U
nR
eg

is

-- -- - -
--- - - -
-
- -

- -- - -
- -- -
-- - - -- -
- -
- - --
- -
- -- - -
- - -

- --
- - -- -
-- -
-
-- --- - --
- -

523

x86 Instruction Set Architecture


TLB Hit
- -
- - -
- - - -- -
- - -- -
- -- - - --

is

te

U
nR
eg

re

- - --

TLB Maintenance

- -
-- -
-- -- --
--

- -
- -
- - -
- - - - -
- - - - - -
- - -- ---
- - -

524

Chapter 16: IA-32 Address Translation Mechanisms


- --
--- - -- -
- - - - --
-

TLBs Are Cleared on Task Switch or Page Directory Change

- - - - - --- - -
- - -- - - --
- - - -
- - - --
- - -
- -- -- -
-
- - - -
- - - - -
- - --
- -
- -

U
nR
eg

is

te

re

- - - --
-- --- - -
- -- - - - - - -
- - -- -
- - - -
- - --
- - -
--

Updating a Single Page Table Entry


- -
- - - -
- - - - -
- -
-- - - - - -
-
- -
- - --
-- -
- -

525

x86 Instruction Set Architecture


Global Pages
Problem

te

Global Page Feature

re

- - - - - --
-- - - -- - -- - - - --
- - -
-- - - -- - - -
--- - - -
- - - - -- - - -- - -
-
- -- -- -- -
- - -- -

U
nR
eg

is

- -
-- --- --- - -
-
- - -
- - - --
-

- - -

- -- -

- -

-

- - - - --
- -- - -
- - - - -
- -- -

- - - -- -
- -

526

Chapter 16: IA-32 Address Translation Mechanisms


---
- - - - - -
- -


- -- -

--

--

re

te

--

is

- - - --

U
nR
eg




-- --

--
-- -
-- -

- -
- - -

Enabling Paging

-
-

- -

- -

527

x86 Instruction Set Architecture


- - - --
- - - --
- - - -- -
- - -- --
- - -- -
-- - -
-

re

- - -
-
--- - - -- -

te

is

- --

U
nR
eg

-
-

-

- -

- -

- -

528

Chapter 16: IA-32 Address Translation Mechanisms

te

re


-
-
-
--


-

-

U
nR
eg

PDE Layout

is

Detailed Description of PDE and PTE

- -

- - -
- - -
--
- - - - -
- - -
- -
- -

-- -
- -

529

x86 Instruction Set Architecture

- - --

-
-
-- --

re

--
- -- -
- -- -
- -

te

- -
- - -

U
nR
eg

is

- -
- -- - -
-- - --


- --

- --

- - -


- -- --
- -
-
- -- --
-

530

Chapter 16: IA-32 Address Translation Mechanisms


- - - --
-

- -- - -
- --

- - -
- - -
--
- - - - -
- - -
- -
- -

- - -
- - -
-

U
nR
eg

is

te

re

- - - -- -
- - -
-- - - - -- - - -

PTE Layout

--
-

531

x86 Instruction Set Architecture

- - - --

-



-- --

re

--
-- -
-- -

te

- -
- - -

U
nR
eg

is

- -
- -- -
- -
-- - --


-
-
- - -


- -- -
- -- -

532

Chapter 16: IA-32 Address Translation Mechanisms


- - - --
- - -

- -- -
- --

- --
- -
-
-
-
-


- - -
- - -
-
- - -
- - - - - -

U
nR
eg

is

te

re

- - -
- - - -

- - - --
- - - - --
- - --

533

x86 Instruction Set Architecture

--
-
-

- -
- -

- -
-
--

is

U
nR
eg

534

- -
- -

re

te

Chapter 16: IA-32 Address Translation Mechanisms

-- --

-
-

-
-

- - - - -
-

- -
-- - - -
-

re

te

-- -
-

is

U
nR
eg

Checking Page Access Permission


-
-- - - - - -
-- - -- -
-- - -

The Privilege Check

Segment Privilege Check Takes Precedence Over Page Check


-- - - -
-
-- - - -
-- -- - -

535

x86 Instruction Set Architecture


-- - - - - - -
- --
- --
- --- - - -
- -
-- -- -
- -
- -- --
-- - --

is

te

re

-- - -- -
- - - -
-- -
- - -
- -- - --
- ---
- --- -- - -
--

U/S Bit in PDE and PTE Are Checked

U
nR
eg

- -
- -- -- -- - - - -- --
- - -- -
-

--

536

-- -
- -

Chapter 16: IA-32 Address Translation Mechanisms


Accesses with Special Privilege
-- - -- --

--- - -- -
-
--- -- -
- - -
-- -

re

The Read/Write Check

is

te

- - -- - - - - -
- -
- - --
-- -- - -
-

U
nR
eg

-- --- - -- -
- - -
--- -

-

---

- -
-- -
-

537

x86 Instruction Set Architecture


Missing Page or Page Table
Introduction
- -- - -- - - --

te

- -- --
- - - - -
- - - - - -
- - -
- - --
- -- - - -
- - - - - - -
- - - - -
- - --

re

U
nR
eg

is

-- - -
- - - - -
- -

Page Table Not Present

- - -- -- - -
- - - --
-- - --
-- - - -
- - -

- -
-
-- -

538

Chapter 16: IA-32 Address Translation Mechanisms


- -
- -

-- -

re

- -- - -

-
- -

te

-
- -

is

-
- --

U
nR
eg

- -
-

- --- -
-- -- -

- --
-

539

x86 Instruction Set Architecture

U
nR
eg

is

te

re

540

Chapter 16: IA-32 Address Translation Mechanisms


- - --

-- ---
- - -
-

- - - - - -

- --
-

re

---

te

--
- --
- -- -

-
-- -

U
nR
eg

is

- -
- -
-- -- --
- -
- - -

- - -
-- - -
- - - -
- - -
-- - -

--

541

x86 Instruction Set Architecture

- -- - --

Page Not Present

te

re

- -
- - -
-- - - - - -
-- -- -
-- -- - -
- -
- -

is

- -
- - -

U
nR
eg

- - -
-- -

542

Chapter 16: IA-32 Address Translation Mechanisms


- -
- -

re

- -- - -

-- -

te

-
-

-- -
-- -
-

is

-
- -
-

U
nR
eg

-
- --

- -
-

- --- -
-- -- -

- --
-

543

x86 Instruction Set Architecture


-
-
-

- --
- -

te

- - -
-

re

- -- - -

- -- -
- -

is

-
-
- --

U
nR
eg

544

Chapter 16: IA-32 Address Translation Mechanisms


- - --

-- ---
- - -
-

- - - - - -

- --
-

re

te

- - --
- --
-
-
-
-
--

---

is

- -
- -
-- -- --
- -
- - -

U
nR
eg

- - -
-- - -
- -
- - - -- - -

Page Faults

Page Fault Causes

- --

- - - -
-
- - - -

545

x86 Instruction Set Architecture


- -
- - -
-
- --
- -
- - - - - -

Page Fault During a Task Switch

re

- - --
- - -
- -
-- --

- -
- - --
--
- - -- -- -
- --
--- - - -
--
- - -

U
nR
eg

is

te

- - --- - - ---
- - - - - - - -
- - -- - --
--

- --- -
- - -
-- - - - - - -
- -
- -
- - -- - - - - - - -
- - - - -
- -
- - -
- --- - - -
- - - - - -

546

Chapter 16: IA-32 Address Translation Mechanisms


Page Fault while Changing to a Different Stack
- - - -
-
--
- -

- - - - -

- - - -
- - - -
- - -- - - -
- - -
- --

is

te

re

- - - - -- - - - -
- -- - - -
-- - -
- - - - -
- - -- - -
- - - -
- -

U
nR
eg

- - - - -
- - -

Page Fault Error Code

-- - - - - - -- -
- -
- - -
- -

Additional Page Fault Information



547

x86 Instruction Set Architecture

-
-

-- -
-- -
- - --
-

-- -- --
-- - --
- - --

- -
- - - -

- -
- -
- - - -

-

U
nR
eg

is

te

re

Access History
- - -- - -
- -- -
-- - --- -- --
- -

548

Chapter 16: IA-32 Address Translation Mechanisms


-- - --
- - - - --
- -- - -
- - - -- - - -
- - - - - - -- -

U
nR
eg

is

te

-- - -
-- -- - -
- - -
- - - --
- - -
- -
- - -
-- -- -
- - --
- - - -
- -
-
- -
-
- - -
-
- -
-
- - -
- - - -
- - - - -
- -
- - - -- -
-
-- -- - - -
- -- - -
- - -
- - - - -
- -- --

re

549

x86 Instruction Set Architecture


4MB Pages
Basic Concept
- - -- - - - - - -
- - - - - -

te

re

- - - -
-- - - -
- - -- - - - -
- - -
- -

U
nR
eg

is

- - -
-- - - --- --

Enabling the PSE Feature


- - -
- -
- - - -

Simplifies Housekeeping
-- - - -- -
- -- - - --
- - -- -
- -
- - - --
--
- -- -
- -- -

550

Chapter 16: IA-32 Address Translation Mechanisms


How To Set Up a 4MB Page
-- - - -
- -

- - -
- - -
-- --- -

te

re

- -
- - -
-- - - -
- - -- -
--- -
- - - -
- - - --
- - - -
- - -

U
nR
eg

is

- -- -
- -

-
--

- --

-
-- --

--
- -- -
- -- -
- -
- -
- - -

551

x86 Instruction Set Architecture


The Address Translation
-- - -
- - -- -
- - -
- -- -
--- - -

re

-- -

te

U
nR
eg

is

- --


- --

552

Chapter 16: IA-32 Address Translation Mechanisms


Second-Generation Paging
First-Gen Problem: 4GB Physical Memory

re

-- - -
-- - - - -- - - -- - -
- - -
- -
-- - --
- - - ---
-- -

U
nR
eg

is

te

---
- - - --
- -
- - - - --
- - -- -
- --- -- -- -

The Solution: PAE-36 Mode


- --
- - -- - -
-- - - --
-- --
-- - - - - -
--- - -
-
- - -

Enabling PAE-36 Mode


- - -
-- - -

553

x86 Instruction Set Architecture


CR4[PSE] Is Dont Care
- - -
- - -
-
- - - -

re

---

- - - - -

- -

is

te

- -

U
nR
eg




- -- -
- - -

--

Application Still Limited to a 4GB Virtual Address


Space
- -
-- - --
- - -
-- - -
- -- - - - -

554

Chapter 16: IA-32 Address Translation Mechanisms


Virtual Address Space Partitioning
First Generation Partitioning
- -
- -- - - -

re

- -- --
-- -
- --
--
- -

te

- --

--

is

U
nR
eg

555

x86 Instruction Set Architecture


Second Generation Partitioning
-
- - -
-- - - -

is

te

re

-- - - --
-- -- --
- - - - --
- -- -
- --
- -- -- - --
- - - - - --

-
-- - -- - - --

U
nR
eg

- -

556

Chapter 16: IA-32 Address Translation Mechanisms


--

--


--


--

re

te

is

U
nR
eg


--

Second Generation Uses 3-Level Lookup Mechanism


- - - -
- - --
- -
-

- - -
- -- - -
-- - - - -

- -
-

557

x86 Instruction Set Architecture

- -
- --
- - -
-
- -
--
--

U
nR
eg

is

te

re

- -
- - -
- -- -

CR3 Points to PDPT in Lower 4GB


- - - - -
-- -
-- - - -
- - -
-- - - - - - -- --- -- -

558

Chapter 16: IA-32 Address Translation Mechanisms


--
- -
-

-- - -
- -
-
-

-- - -
- -
-
-

-- - -
- -

U
nR
eg

is

te

re

- -- -

- - - -
- - - - -

Enlarged Physical Address Space


- - -
- - - - - - - -

559

x86 Instruction Set Architecture


- - - -
- -- - - -
-- - --
- - - -
-- - -- -
- - - -

- - - -- -
-
- - -
- - -
- -- -
- -- - - -
-- - -- -

re

is

Step 1: PDPT Lookup

te

The Translation

U
nR
eg


-- - --
- - - - -
- - --
-- - -

560

- - -
- -- --
- -
-
- - -
- - - - -- -
-
-- - - -- -
- --
- -- -

Chapter 16: IA-32 Address Translation Mechanisms

re

te

is

- -
- - -
- -- -

U
nR
eg

- -

-
- -
- -

- -

- - --

- -- - - --
-

-- - --
-

--

--

--
- -

- - - -- -
-
- - -
- ---
--

561

x86 Instruction Set Architecture


Step 2: Page Directory Lookup
-- - -
- - - - - --
--

re

- - -
- -- --

- - -
- - --
- -
--
- - --

te

-- - - - - --

U
nR
eg

is

- -
- - -
- -- -

-
- - -
- - -- -
- - --
- -

562

Chapter 16: IA-32 Address Translation Mechanisms


- -- - - -

- -

-
- -
- -

- - --

- -- - - --
-

- -

-- - --

--

--

--

re

- -

te

-- -- -
-
-
-

is

- -

U
nR
eg

- - - -- -
-
- - -
- ---
--

- -
- - - --
- - -
- -- - - -
-- - - - -
- - -
-- - - ---
- - - -- -
- -
- -- -
- -

563

x86 Instruction Set Architecture


-

re

is

te

U
nR
eg

- -

-
-

- - -
- --

- -

-
-
-
-
-

-
- --

-- - --

-- --
-- -
-- -

-
-
- -

- - - -- -
-
- - -
- ---
--

564

Chapter 16: IA-32 Address Translation Mechanisms


Step 3: Page Table Lookup
- - -
-
- - --
-- - - - - -- -
- - - -

- - -
-- - - ---
- - -- -

re

- -- - - - - -

is

te

- -- - -
-

U
nR
eg

- -
- - -
- -- -

565

x86 Instruction Set Architecture


- -
- - -
- -- -

te

re

U
nR
eg

is

- -

-
-
-
-
-

- -

- - --

-

-

-- --

--
-- -
-- -

- -
- - -

- - - -- -
-
- - -
- ---
--

566

Chapter 16: IA-32 Address Translation Mechanisms


Page Protection Mechanisms
General
- -
- ---

--

-
-

re

- -
- -

te

is

U
nR
eg

- -
- -

- -
-
--

567

x86 Instruction Set Architecture

-- --

-
-

- - - - -
-

-
-

- -
-- - - -
-

re

-- -
-

is

te

U
nR
eg

Write-Protection

-
- - -
- - - -

568

-- -
-- -

Chapter 16: IA-32 Address Translation Mechanisms


-

-

te

re


-
-
-
--

Example Usage: Unix Copy-on-Write Strategy

- - - -
- - - -
-
- - --
- -- -- - - - -- - - - -
- -- --- --
- - - - -- - -
- - -
- -
- -

U
nR
eg

is

- - -

569

x86 Instruction Set Architecture


--- -


-
--
- - -
- -
-- - - -

re


-
-

U
nR
eg

is

te


-
-

570

Chapter 16: IA-32 Address Translation Mechanisms

--- -

-
- - -
- -- -

re

U
nR
eg


-
-

is

te


-
-

3-Level LookupIncreased TLB Size


--- - -
- --
- - - -
- -
- - -
-- -

571

x86 Instruction Set Architecture


- - -- - -
- -- --- -
- - -
-
- --- -
- --- -
-

Microsoft PAE Support

te

re

- --- - -
- --- - - -- - - - -
- --- -
- --- -- - -
- - - -

U
nR
eg

is

- - -
- -- -
----

-
-

572

Chapter 16: IA-32 Address Translation Mechanisms


-
-
-

- - -
- -
- - -
-- - -
- - -
--

-
-

-

-

-
-
-
-- --
-

- - -
- -
- - -
-- - -
- - -
--

U
nR
eg

is

te

re

573

x86 Instruction Set Architecture


-
-
-

- - -
- -
- - -
-- - -
- - -
--

-
-

-
-

- - -
- -
- - -
-- - -
- - -
--

U
nR
eg

is

te

re

- -

Linux PAE Support

- - -
- - --
-

PSE-36 Mode (PAE-36 Modes Poor Cousin)


- -
- - -- --- - - -

574

Chapter 16: IA-32 Address Translation Mechanisms


PSE-36 Mode Background
-
- - -
- -- -
-- - - -- -

re

- - -
- --
- --
-- - - -- -
--
- - -
-- -
- -

U
nR
eg

is

te

-
-- -
- --
-- - - - -
-
- - - - - - -
- - - - -
- -

Detecting PSE-36 Mode Capability


-- --
- - -

Enabling PSE-36 Mode


- - -- --
--
- -
- -
-- - -
-

575

x86 Instruction Set Architecture



- - - - - -
- -


- -- -

--

re

--

te

--

Per Application Virtual Memory Space = 4GB

U
nR
eg

is

-
- ---
--- - - -
-- - -
-- - - -- --

First-Generation Lookup Mechanism


- -- - -
-- -- -
- - -
-- - --

Selected PDE Can Point to 4KB Page Table or a 4MB


Page
- -- - -
-
-- -- -

576

Chapter 16: IA-32 Address Translation Mechanisms

-
- -- -
- -- - -
-- - - --
- - - -
-
- -- -
-- -

Virtual Address Maps to a 4MB Page in 64GB Space

is

te

re

- - -
- --
- - -
- - -- -
- - -- -
- -
-- - -- -
- --

U
nR
eg

- -- -
- -- -
--

- -
-

-
- - - -

577

x86 Instruction Set Architecture

- --
- -- - - -
- -- - - -- --
- -- - --

re


-- -- --

is

-- - -

te

- -

U
nR
eg

- - -

Windows and PSE-36

- - -
- - -
- - --
- -- - -
- - --

- -
- -
-- --
-
-- --

-
--

578

Chapter 16: IA-32 Address Translation Mechanisms

- -

- -
--
--
- --


re

- - - - -
- - -
--- - - -

AMD Enhanced PSE-36 to PSE-40

U
nR
eg

is

te

--- -
- -
- -- - -
-- - -
- -- -

Execute Disable Feature

- - -- - - -

Problem: Malicious Code


The Overflow

- - -

-- - - -
-
- - --
- -
- - -- -

579

x86 Instruction Set Architecture

U
nR
eg

re

te

- - -- -
-
- - -
-- -- - -
-
- - -- -
- -

--
- - - -
- - -- - -
- -

-- -
- - -
- - --
- -
-- -
-
- - --
- - -
- - -
- - - - - -
- - -
- -
- - ---

is

- - - -
- -

- -
- - -
- - -
- - - -
- - --

- -
- - -
-- - - -- -
- - - -

580

Chapter 16: IA-32 Address Translation Mechanisms


- - -

-
-

-
-

re

te

is

U
nR
eg

- - -

- -
-- - -
- -
-- -
-

-- -

- -
--
-- - - -
- - -

The Exploit
--
- ---

--
-- - -

581

x86 Instruction Set Architecture

-- -- -
-

re

is

te

- - - - -
-- -
- - - --
- - - --
-- -
- -

U
nR
eg

The Fix: Intercept Code Fetches from Data Pages


---
- - -
- - - -
-
- -

Enabling the Execute-Disable Feature


-- - -
-
-- - - - -
- - -

582

Chapter 16: IA-32 Address Translation Mechanisms


- - - -
-- - - - --

- - -

- -
-


-- -

te


-- - -

re

-
-

is

- - --

Available in both IA-32 and IA-32e Mode

U
nR
eg

- -
- -

How It Works

- -


- - - - - -
-- - -
-
-- -
- - -- - -
- - -
- - - -

583

x86 Instruction Set Architecture



- -

- -

- -

-
- -
- -

- - --

- -- - - --
-
-- - --
-

--

--

--

-- -- -
-

re

-
-
- -

is

te

- - - -- -
-
- - -
- ---
--

U
nR
eg

- -

-
-

- - -
- --

- -

-
-
-
-
-

-
- --

-- - --

-- --
-- -
-- -

-
-
- -

- - - -- -
-
- - -
- ---
--

584

Chapter 16: IA-32 Address Translation Mechanisms


-

- -

- - --

-
-
-
-
-


-

-- --

--
-- -
-- -

- -

- -
- - -

Introduction

is

te

Defining a Pages Caching Rules

re

- - - -- -
-
- - -
- ---
--

U
nR
eg

- - -
- -- -
- -
- -

- -- - - -- - - -
--- - - - -

Translation Table Caching Rules


General
- --- -- -- -
-
- -
- - -- -
- -- -- -

585

x86 Instruction Set Architecture


-- -

- -
-

- -
-

- -
-

te

First-Generation Paging Tables

re

- -- -
-
- - -- - - -
- --- -
- -
-
- - -
--- - - - -

U
nR
eg

is

Second-Generation Paging Tables


-- -

586


- - - -- - -
- - --- -
- - -

- - - -- - - - --- -
- - -
-
- - -

Chapter 16: IA-32 Address Translation Mechanisms


--- - - - -

Page Caching Rules


- -
--- - - -
-
-- -

U
nR
eg

is

re

-- -

-- -

--

--
- - -
-
-
--

te

PAT Feature (Page Attribute Table)


Whats the Problem?

- - - -
- - --
--
-
- -- -
- - -- --
-- - - -- - -
-- - - - - -
- - --- -
- - - -
-- - -- - -
- --- - --

587

x86 Instruction Set Architecture


Detecting PAT Support
-- --
-
-- -- - -

PAT Allows More Memory Types

-- -- -
- - -
- -
- -

U
nR
eg

is

te

re

- -
- - - -
- - - -
- - - -- -
-
- -- -- - -- - -
- - -
- -- -
- -
- -
- - -

588

Chapter 16: IA-32 Address Translation Mechanisms


re

te

is

- - - --

U
nR
eg

Default Contents of IA32_CR_PAT MSR


-- -
-- - - -
-- - - - -

589

x86 Instruction Set Architecture

re

te

is

Memory Type When Page Definition and MTRR


Disagree

U
nR
eg

- -- --
-- - -
- - -
-- - -- -- -
- --
- -
-- ---
- - - -
- - - -
- - -
- - -

- -
-- - -
- - -
- -
- - -
- -
- - -

590

Chapter 16: IA-32 Address Translation Mechanisms

re

- -
- -

is

U
nR
eg

te

591

x86 Instruction Set Architecture


- - - - - -- -
- - -
- - -
- -
- --
- -
- - -- -
- - - - - - -
-

- - - - - -- -
- - -
- - -
- -
- --
- -
- - -- -
- - - - - - -
-

U
nR
eg

592

te

is

re

Chapter 16: IA-32 Address Translation Mechanisms


- - - - - -- -
- - -
- - -
- -
- --
- -
- - -- -
- - - - - - -
-

re

U
nR
eg

te

is

Altering IA32_CR_PAT MSR

- - -- -
-- - - -
- -
- -
--

Ensuring IA32_CR_PAT and MTRR Consistency


--
-

--
--
-

- -
-- - - -

593

x86 Instruction Set Architecture


--- -
--
-- -- -
-- --- --
--- - - --
--- - --

te

re

-- --- - -
-- - - -- - - ---
- - -
- - -- - - ---
- - --
- - - -
--- --- -
- - - - -
- - -- -

U
nR
eg

is

- --
-- - ---
- - -- - -
- - -
- -- - - - - --
-- --
- -- -- - --
--- - -- - -
-- -- -
-- -
- - - -
--
--- --
-- --

594

- -
-
--- - - -
-
- -
- -- - - -
- -- -- -- - - - - -

Chapter 16: IA-32 Address Translation Mechanisms

U
nR
eg

re

te

is

- - -- ---


-
- -- - - - - - - - - - -
- -

- --- --
- -
- - -
- - -
- -
-- -
- - -
- - -
- - - - -
- - - - - --
- - ---
- - -
-- ---
-
- -- -
--- - - -
-
-
-

Assigning Multiple Memory Types to a Single


Physical Page
-

-- - - -

-- -
- --
- - - - --
-

- - - - - -- -
- - - - --

595

x86 Instruction Set Architecture


- - -
- -- -
- -
- -- - -

te

re


-
- - - - - --
--- -
-
- - - --

- - --- -
- - -- -
-- --- - -- - - - - -
-

is

Compatibility with Earlier IA-32 Processors

U
nR
eg

-- - - - - - - -
-- - - -

- - - - -
- - -- -
-- - - -
---
- - --

- - - -
- - - --
- - -
- - - -
- --
--- - -

596

Chapter 16: IA-32 Address Translation Mechanisms

-
-

-
-

- -
-

re

te

Third Generation Paging

U
nR
eg

is

- - - -- -
-
- -- -

597

U
nR
eg

is

te

re

x86 Instruction Set Architecture

598

re

The Previous Chapter


- -

U
nR
eg

te

---
-
- -- -
- - - -- -
--
- -

- - - -
-- --
--
-- -
-

-
-

is

This Chapter

- -- -- - -
-
-- - - - -- --- --- -
- -

599

x86 Instruction Set Architecture


The Next Chapter

- - -
-
-
- -
-
- -
-
- -
- - -

- - -
-
- -- -

U
nR
eg

is

te

re

-- -- -- - -
- - - - -
- - - - -
-

Characteristics of Memory Targets


Introduction

-- - -- -
- --
- - -- - -

Example Problem: Caching from MMIO


- -- - --
-- -- -

600

Chapter 17: Memory Type Configuration


-- - -
- - - -- -
-- -- -- -
- - --
- -
- --
- - - - - --
- - -
-- -- --
- -- - - -
- - - -
- - -- -
- - -
- - -
- - - -
- -
-

is

te

re

U
nR
eg

Early Processors Implemented Primitive Mechanism


- - - - ---
- -
- -- --
--- ---- -
--
-
-
- - - - --

- - - --
-- - -
- - - -
-- - -
- - -
-- - - -
- -
-
--

601

x86 Instruction Set Architecture


Solution/Problem: Chipset Memory Type Registers

is

te

re


-- --- -
- - --
-- -- -
- - --
- - - - -
- -- -- - -
- -- - - -
-- - -
- - -- - - - - - -
- -- -- -
- --
- - - -- - - --
- -- -
- - - --

U
nR
eg

-- - - - -
- - -- - - -
-- - - - - -
- -
-- - - - -- -

Solution: Memory Type Register Set



- - - - - --
- - - - - - -- -
- -- -
-
--
- -
- - - -- - --

602

Chapter 17: Memory Type Configuration


MTRR Feature Determination
-- -- --
- - - -
--
- - - -

is

re

- - -
- -

- - -
- -
- -
- -
- -
-
- - - - -
--

te

U
nR
eg

-
- -
- -


-

-

- -

-
-- -

603

x86 Instruction Set Architecture


MTRRs Are Divided Into Four Categories
- -

MTRRDefType Register

re

- - -
- - - -
- - - -
-
- - - -
- - -
- -
- - --
--

te

U
nR
eg

is

- - -
- -
- - -
- - - - -
-
-

- - -

-
-
- -
-
- -
- -
- -
-
-

604

Chapter 17: Memory Type Configuration


State of the MTRRs after Reset

re

- -- - -
- - --
-- -- -
-
-- - - -
- - -- -
-- - -
- - - --- -
-

te

Fixed-Range MTRRs
The Problem: Legacy Issues

U
nR
eg

is

- - - -
- -
-- - -- - - -

- - - - --
- - -
- -
- --
- - - -
- -- -
- - -
- -- -- - -
--

Enabling the Fixed-Range MTRRs


- -
- -
- -

605

x86 Instruction Set Architecture


Defining Memory Types in Lower 1MB

re

- -
- --- -
--- - - -
- - - --
- -
-- - - - - - - -
- - -
-- -

606

is

U
nR
eg

te

Chapter 17: Memory Type Configuration


-

- -

- -

te

re

U
nR
eg

is

- -

Variable-Range MTRRs

How Many Variable-Range Register Pairs?


- - - -- -- - -

Variable-Range Register Pair Format


- --- - - -
- - -
- - ---

607

x86 Instruction Set Architecture


- -
-

--

--

--

--

te

MTRRPhysBasen Register

re

- - - -- -
-
- - -
- ---
--

- -

U
nR
eg

is

- - - - -- - -
-- - -
- - - - - -
- -- - -- -- - -- - -- -- --
- -

MTRRPhysMaskn Register

- - - - -
- -- -- -
- - -
-
- - -
- -- -
- - -
-- - - - --
- -

608

Chapter 17: Memory Type Configuration


Programming Variable-Range Register Pairs
- -

- - - --
- --
-
- - - --
- --
- -

re

- - -- -
-

te

Enabling Variable-Range Register Pairs

U
nR
eg

Memory Types

is

- - -- -
- -

Memory Type Defines Processor Aggressiveness


-- --- -- -- -
- - - -
-- - --
-
- --
--- - --
- - - --
-

609

x86 Instruction Set Architecture


Five Memory Types
- -
- -
- - ---- -
- -

re

te

- - -
-- --- - - - - - -

is

Uncacheable (UC) Memory

U
nR
eg

- -- - - - - - -

610

- - - -
- - - - - -
-- -- - - --
- -
- -
- - - --- -

- - ---
- -
- -
- -

Chapter 17: Memory Type Configuration


- -- -
- - - - -
- - ---
-
-

Uncacheable Write-Combining (WC) Memory


Description

- - -
- -

is

te

re

- - -
- -
- -
- - -
- - - - ---
- - - --

U
nR
eg

- -- - - - - - -

- - - -
- - - - - -
-- -- - - --
- -
- -
- - -

-
- - --
-
-- -- -- -
- - -
-- -
-

611

x86 Instruction Set Architecture

-
- - -
-- - -
- --
-
- -
- --
-- - -
-
--- -
- - -

U
nR
eg

is

- - -
-- -

- --
--
- - -
-
-- - --
- - -- -
-- - -
- - -- -
-- - -

te

re

- --
--

Weakly-Ordered Writes

- -
- - - - -
- - -
-- -

Cacheable Write-Protect (WP) Memory


- - - -
- - -

612

Chapter 17: Memory Type Configuration


- - - --
-
- - -
-- -
- -- -
- -- - - - - -
-
-
-- -- -
-
- - -
-- -
-- -- - -
--- - -
- --- - -
-
-
-
- - --- -
- - ---
--- -
- - - -
- - -

-
--

U
nR
eg

is

te

re

Cacheable Write-Through (WT) Memory


- -- - - - - -
-

-
-- -- -
-
- - -
-- -

613

x86 Instruction Set Architecture

te

re

-- -- - -
--- - -
- --- - -
-
-
- - - - -
--- -
- - ---
- -
- -
-
--
- -

- -
- - - -

is

Cacheable Write-Back (WB) Memory

U
nR
eg

- - -
- - - ---
- - - - -- -
- -
- -- - - - - -
-

614

-
-- -- -
- - -
- - --
- -
- - -
-- -
-- -- -
- - - - -- -
- - -
- ---

Chapter 17: Memory Type Configuration


- - -
- - -
- -
- - - --
-
- -- - -
- - -
-
- - - -
- - -- -
- -- - -- -
- - -- -
-
- - ---
- - -
-- -
- -

te

re

is

The Definition of a Speculatively Executed Load

U
nR
eg

-
-

-

--

-- - -

---
- --
- -
-- - - - - - -
- - - -
-- - - - - - -
-- - - -
- -
- -
- - -

615

x86 Instruction Set Architecture


--
- - - --
-

Rules as Defined by MTRRs

-- - -
-- - - --
- - - -

re

te

is

-- -
- -
--
-
-

-- -
- - -
--
- -

U
nR
eg

-- -
- - -
--
-
-

616

Chapter 17: Memory Type Configuration


- -

-
-
- -
-

- -
- -

-
- -
- -
-
- -
-
- -

-- -

is

te

re

- -
- --

-

-- -

- -


- -

U
nR
eg

-- -

- -

Memory Type Provided in Memory Transaction


-- - -
- - -
- - -
- - --

Paging Also Defines Memory Type


- -- - -
--- - - - - -- -- - -

617

x86 Instruction Set Architecture


--- - - -
- -- -- --
- - -
-
- -- --

In an MP System, MTRRs Must Be Synchronized

-- -- --
-- -- - - - --- - --

re

Posted-Write Related Issues

te

General

- ---
- -- - -

U
nR
eg

is

- -
- -- -

- --- -- - -
-- - - - -
- - - -
- -
- -
- - - - -
-- -

Synchronizing Events
- - - - -- - - - -
- -- -

618

Chapter 17: Memory Type Configuration

U
nR
eg

is

te

re

--

- -
- -
-- --


- - -- ---
-- - -
-- -
-- - -
-- --- - - --

- - - --
- --- -
- -
- -- -
-

- --
--


- -- - -- - - - -
- - -- --
- - -
-- - - --
- - --
-

PMWB and WCBs Arent Snooped


-- -- --
-- -- - - - -
- --- - --
-

- - -
-- - - -

619

x86 Instruction Set Architecture

-
- -
- - -
- - - -
- - - -- -
- -

-

-

-
-

re


- -

U
nR
eg

is

te

-

-
-

-

- -

- --- -

WCB Usage

An Example
-- -- -
- - -- - - - - - -
--- - - -- --
- - - - - -

620

Chapter 17: Memory Type Configuration

-- - -
- - - --
- -

- - --
--- - - - ---

te

re

--

--

U
nR
eg

is

- - - -

- -
- -- -
- - -- -
- -

621

x86 Instruction Set Architecture

--

te

re

is

- - - -

U
nR
eg

- -
- -
- - --
- - - --
- -

622

Chapter 17: Memory Type Configuration

--

te

re

U
nR
eg

is

- - -- -

623

x86 Instruction Set Architecture

te

re

--





is

- - - - -

U
nR
eg

-- - - -

- --- - -
- -
- - - -
-- - -- - ---
- - -
-

624

- - -
-
--
-

Chapter 17: Memory Type Configuration


te

re

--





U
nR
eg

is

- - -
- -- -

625

x86 Instruction Set Architecture


te

re

--





U
nR
eg

is

- - -- -

626

Chapter 17: Memory Type Configuration

is

te

re

--





U
nR
eg

-
-
- - - -
- - - - - -
- - -
- -

All WCBs in Use

- - -- - -
- -- - -
-- -- - - -
-

627

x86 Instruction Set Architecture


Draining the WCBs
-- - - - - - -
-- -- -
- - - -
-

U
nR
eg

is

te

re

-- - - - - -

- - - - -- -
-

628

The Previous Chapter

This Chapter

te

re

- - -- - -
-- - -
- - --- --- -
- -

U
nR
eg

is

- -- -- -- - -
- - -
- - - - -
-

- - -
-
-
- -
-
- -
-
- -
- - -

- - -
-
- -- -

629

x86 Instruction Set Architecture


The Next Chapter

re



-
-
- - -
-
- -
-


--
-

te

- -
- -

is

Hardware- vs. Software-Based Task Switching

U
nR
eg

-
- - - - - - - -
- --
- - -- - -
-- --
- - - -
- - - - -
- - - - -
- -- -
- - - -
- - - --
- - - - --
- - -- -

-
-

- - -
- -- - -- - -
- - - -

630

Chapter 18: Task Switching


A Condensed Conceptual Overview
- - - -

U
nR
eg

is

te

re

- -- -
- --- - - -
-
- -
- - - -- -
-
-- -- - - -

- -
- - -
--- - - -
- - - -- -
-- -- - - -
- - -
- - -
- --- - - -
-- - - - - - - --
-
-- - - - - -

A More Comprehensive Overview


- --- - - - --
- --- - - -
- - -

The Scheduler and the Task Queue


- - -

- - - - - --
- -
- - - - -

631

x86 Instruction Set Architecture

re

--
- -- - -- -
-- -- - -
- - -- -
-
-
- -- - - -
- --
- -
--- -
- - - - -
-- - -
-- - - -

Setting Up a Task

U
nR
eg

- -
- -
-
-- - -- -
-
-- -- -
- -

is

te

- - -

-- --
- --

The Task Data Structure

- - - -
- - - -
-

632

- - - -
- --- - - - - -
- - -
--- -- - -
-- - -- - -- -

Chapter 18: Task Switching


- - - - - - -
- - -
- - --

The LDT
- -
- - - -
-

is

The TSS

re

- --
-
- -- - -
- -- - - --
- - - -- -

te

U
nR
eg

- -- - -
- - - - -
- - - -
- -- --
- - -- -
- - - - - - -- -- -
- - - - -

633

x86 Instruction Set Architecture

- -

re

is

te

U
nR
eg

The Address Translation Tables


- -- -
- - -- - --
- -- - ---
- - --- - - - -- -- - -
- - -- - - - - - -- --

634

Chapter 18: Task Switching


- - - -- -

te

re

U
nR
eg

is

The GDT and GDTR Register


-- - - -
- - - -- -
- -

-- -- --
- -- -- -
- -- - --
- -- -- - - -
-
- -- - - --
- - - - -

635

x86 Instruction Set Architecture

re

is

te

U
nR
eg

The LDTR Register

- - - -
-- -- - - - -
- - -- - - - - --
- -- - -
- -- -- - - -- -
-- - - -

636

Chapter 18: Task Switching

- - -

re

U
nR
eg

is

te

The Task Register (TR)

- - - -
-- -- - - - -
- - -- - - - - --
- -- - - -
-- -- - - -- -
- -- - - -
- - -

637

x86 Instruction Set Architecture

- - -

re

U
nR
eg

is

te

Starting a Task

-- - --
- -- --
- --- --
- - - - -
--- - - -
- -- - -
- - - - -- - -- - -
- -- - -- -
- - -- - - - -
- - - -
- -

638

Chapter 18: Task Switching


-- -- - -- -
- - - - -

Suspend Task and Resume Scheduler


Execution

re

- - - - - -
-- - -- -
- - - -
-- - -- -
-
- - -- - -
- -- -- - --

- - -- -- -
- --
- -
- - -
-- - - - - -
-- - --
-- - -
-- - - -
--- -- -- - --
- - -
- -- - - - -
-
- --
- -- --- - --
- --- -- --
- - - - - - - - --

U
nR
eg

is

te

-- - - -- -- - --
- -- --
-

639

x86 Instruction Set Architecture

- - --

re

is

te

U
nR
eg

- -

640

Chapter 18: Task Switching

- -

re

is

te

U
nR
eg

- -

Hardware-Based Task Switching


Its Slow

- --
-- - - - -
- - - -
- - - - -
-- - - - -
- - - - -
- - - - - - -
-

641

x86 Instruction Set Architecture


Why Didnt OSs Use It?
- - - -
-- -
- --- - - - - -
- -

Why Wasnt It Improved?

- - -
-
- - --

U
nR
eg

is

Why Does It Still Exist?

te

re

- - - -
-
- - - - -

Introduction to the Key Elements


- -- - - -
- -

642

Chapter 18: Task Switching

- - - -

- - - - - - - -
-- - -
-
-

- -- - -
- -- -
- -- -
- -
- -- - -- --
-
- -

- ---
- - - -
- - - - -
-- - - -
- - - - --
- - - - - - --

U
nR
eg

is

te

re

643

x86 Instruction Set Architecture


- - - -
-

-
-

- - -
-
- -- - - -
- -
-
--
- -
- - - - - -
- - -
- - -
-- -
- -
- -
-- - -
-
-- - - -
- --

U
nR
eg

is

te

re

644

Chapter 18: Task Switching


- - - -

- - -- -
- -- -
-- - - - -- -
- -
- - - -
-- - -
- - - --
-- - -
- - - - --
-- ---
- -- -
-- -- -- -
- -- -
- - -
- - - - -
- -
-
- - -- - - -

- - -
- -

-- - -
--
- - --
-
- - - -
- -
- -- -
- -
- - - -
-- -- -
- -- - --
- - -

U
nR
eg

is

te

re

645

x86 Instruction Set Architecture


The Trigger Events
- - -- -- -
- - - - -
-- - -- -- - -
-

- - -
-



-- -- -

-
- -

-

- - - -
-
-
- -- -
-- - -
- -- -
- -- -

-- - -
- -- -
--
- - --
--- - -
-- --
-- -
-

- - -

U
nR
eg

is

te

re

646

Chapter 18: Task Switching


- - -
-


-- -
-

-- - -
- - - - -- --
- - --

- -- -

- --
- - -
- - --
- - -
- - - - - -- --
- - - --
-
- - -
- - - -
- - -
- - -

U
nR
eg

is

te

re

--
-

-- -
- - -
- - - -
-
- - - - - -
- - - - --
- - -
-

647

x86 Instruction Set Architecture


- - -

-
- -
--
- - -
- - -
- - - -- -
- - -
- - -- - -
- - -
- - -

--
-

- -
--
- -
- - - - -
-- - -
- - - - --
- -
-
- - -

U
nR
eg

is

te

re

- -


- -

--
-
-

The Descriptors
TSS Descriptor

- - - - -
- --
-- --

648

- -- -
- -

Chapter 18: Task Switching

- - -
- - - - - -- - --- - - -
-- - - -
- - - -
- - -- -
-- - - -

re

- - - -
- - -- - -
- - - --

-
- -
- -

- -

U
nR
eg

is

te

- --

- --

- -- -
-

-
- -- - -
- -
- - - -

- - --

- - - - --

- - - -

Task Gate Descriptor


-- - - - -- -
--
- - - - --
--- - --
-

649

x86 Instruction Set Architecture


-
-- - - -
- -
- - - -
-- - - - - - - -

- -
- -
- - - -
- - -
-

re

- - -- - -

is

te

-
-- - -- - -
- - -- -
-
- - -

U
nR
eg

- -
- --
- - -
- - - - - - - - - -
-

650

Chapter 18: Task Switching


-


-
-

- - -- -
- - -

- -
- - -
- - - --
- --

- - -

re

te

- - -
- -

is

U
nR
eg

- --
- - -- - -
- -
- -

- --

- -

- -
- -

651

x86 Instruction Set Architecture


The Task Register
General
-- -- - -
- -- -
- - - -
- - -
- -- - -
- - - - -- --
--- - -- - -- -
- -
- - -- - - - - -- -
-

te

re

U
nR
eg

is

-- --
- - -
- - - -
- - - - - - -
- - --
-- - - -
- -

TR Instruction Pair

- - - -- -
-
- - - --
-- -
--
- -

- --

- -
- -
-- -
- -
- - - --

652

Chapter 18: Task Switching


- -- - -- --

- - - -
- - - - - - -
- - -
- - - - -- - - - -
-- -
- - - -
- - -
- --

re

-
-
- - - - - -
-- - -

U
nR
eg

is

te

- - - -
- - -
- - - -
- -
- -- - - -
- - - - --
- - -

- -

- - -
- - -
- - --
- - -
- - -
- - - - -
- - - --

- - - - -
-- - - - - - -
- -
- - - - - - -
- -- -
- - - - - -

653

x86 Instruction Set Architecture

- -
-

re

te

- -

is

U
nR
eg

- - - -
- - -
- --
-

TSS Data Structure Format


General

-
- --- - - - ---
- -

654

---
- -
-- -- ---
- - -

Chapter 18: Task Switching


Required Fields
- -
- - --- - -

- - - - - - - -
- -
- - --
- - - -
-- - - --
- - - --
- - -
-- - -

re

Optional Fields

U
nR
eg

- -
- - - - - - - -
- - - -- - - -
-- - -
-
--- - - -
-
- -- -
-- -- -

-- -- -
- -- -- - --
- - -

is

te

--- -

-- -

655

x86 Instruction Set Architecture

U
nR
eg

-
-

re

-
-- -

te




--
-

--
--
--
--








- - - -
- --

-- -

is

--

-

Register Snapshot Area

- - - - -- --
- - - -- --
-- - --- -

656

-- - -- -
-
- -- -- - - -
- --

Chapter 18: Task Switching


-
-- - -
- - - -
- -- -
-- - - - -
- - - - -- - -

- - -- -

re

- -- - - -
- - - - - - - - - -
-- - - - - - - - - --
- - -- -

- - - -- -

is

te

-- - -
- - - - - -
- -- -- - - --
- --- -- -

- - --

U
nR
eg

- - - - - -
- - - -
- -- - -- -
- - - -- -
- - - -

- - - --
- - - - - -
- - - --- - - -- -- - --

- -
-- - -
- - -
-
- -

- - -- - - - - -

657

x86 Instruction Set Architecture


- - --
- - - - - -
- - - -
- - - -- - - - -
-

- --

- - - - - -
-
- - - --
--- - ---

re

- - -- -
- - --

U
nR
eg

is

te

- - - - -- - - - -- - -
-- ---
- - - -- - -
- - -
-- -- -- -
-- - --- -- - - - -- - - -

- - -- -

- --
-

-

658

Chapter 18: Task Switching


- -- -


- -- -

- - - -
- - - - -

Debug Trap Bit (T)

te

IO Port Access Protection

re

--
- - - - - -
- - - - -

- - -

is

-- -

U
nR
eg

- -
-- - -
-
- - -
- -
-- -
- - - - - -
-- --


-- - -- - - -
-- -- - - - -
- - - -
-- - - - -- - - -
- --- - -
- - - -
-
- - - -
- -- -
-- -- -- --

659

x86 Instruction Set Architecture

-
- -
-
- -
-
-

re

- -

- -
- - -
-- -
- - -- -
- - --

te

- -

U
nR
eg

is

-




-
- -









--
-- - -
-- - - -
- - -- -
-
-
- - - -
- - -

660

Chapter 18: Task Switching

re

- -
- - - - -
- - -
-- -- - -- -- --
- -
-- -- - - -
-- - -- -
- - -- - -
- - -
-
- - - - -
- -- -

te

-- - - --
---

-- --

U
nR
eg

is

- -
- -
- - -
- --

-- - -- --
- - - -- - - - -
-- - -
- - - -
-- - - -
-

IO Permission Bit Map


- - -

-- --
--
--

661

x86 Instruction Set Architecture


--
- --
- - -
--- -
- -
- - - -
- - -
-- -- -
-- -- -

- --

is

te

re

- - -
- -
- -- - - -
- - - -
-
- - -
- --
- -

U
nR
eg

- -
- - - -- -
-- --
- - - - -

-- - - -
- -- - --
- -- -- --
-- - - --
- - --
--
- -- -
-
- -- - -- - -
- -- - --
- -- -
-

662

Chapter 18: Task Switching


- -
- -- -
- -- - -- -
- - -- - -
- - - -
- -- - --- --
-- - - - -

-
- -
- -

te

re

- -- - -
--- -- -
- -- - --
- - -
-- - -
- - -

U
nR
eg

is

- - - --
- - - - -
- - - - -
- - --
- - -- -- -
--- - - -
-- - -- - -
- - - -- - - -
- -
-- - -
-

-- -
- - - - - -
-

-
- - - - - --
-
-- - - - -

663

x86 Instruction Set Architecture


Interrupt Redirection Bit Map
- - -
- -
- -- -- - -- - -- -
-

OS-Specific Data Structures

is

te

re

- - -- -
-- -- - - -- -
-- - -
- - -- - - - -
- - - ---
-- - -
- -
- - - - - - -
- - - -- - -- --

U
nR
eg

Privilege Level 0 - 2 Stack Definition Fields


- - -
- -
- - -- --
- - - -

- -
--
- - - - --

- - -
-

664

- - --
-
- - --
-

-
-
-
-

Chapter 18: Task Switching

- - -- -
- -
-

- -

Link Field (to Old TSS Selector)


- -

Comprehensive Task Switch Description

is

te

re


- -- --
- - -
- - - -

U
nR
eg

- - -- -
--
-
- - -

665

x86 Instruction Set Architecture


- -

- -- - -
-- -
-- - - -
- --
- - - --
- --
- -
-
- - - - - -- -
- - --
- - - -- -
--
- -
- --
- -

-
-

U
nR
eg

is

te

re

666

Chapter 18: Task Switching


- -

- - - -- -
- -
- -
- -- - - -
- - - - - - - -
- - - -

- --
- - - - - -
- -
- --
- - -
- -
- - - - -
-
- - -- - - - - -
- - - -
- - - -
- - - -
- -
-

U
nR
eg

is

te

re

-



-
-
- -- -- - - -
- - - -
- - - - -
-- -- -
- -

667

x86 Instruction Set Architecture


-

- - -
-- -
--
-- - -
- -
- -
- -

- - -

-
-
-

is

U
nR
eg


- -

--
-


- -

- - -- - - -

- -
-- - - -

668

-
-

te

re

-
-

Chapter 18: Task Switching


-

-

-

--
-

--
--

-

U
nR
eg

-- --
-
-
-

is

te

- -
-- ---
--
- --
-
--

-

re

--
-

-
-
- - -

-- - -

-
-

669

x86 Instruction Set Architecture


-

-- -

-

is

te

-- - -- - - --
- -
--
- - -
-
--

- -- -
--- -- - - -

-
- - --
- - -
- - -
-
- -

re

--
- -
-
-

-
-- - -
- - -
-
- -

U
nR
eg

Calling Another Task


An Overview

-- - - -- -
-- - - -
- -- -- - -
- - -
- - - - - - - -
-- -
- - - - -
--
- - - - - -

670

Chapter 18: Task Switching


-- - - - - --
- - - - -
-- - - - --
--
- -
- - - - -
-
- - -
- -

A Comprehensive Example

is

te

- - - -
- - - -
- - - -
- - - -
- - - -

U
nR
eg

re

671

x86 Instruction Set Architecture


-
- - -- - -
-
- - -
- - - -
- - - - -
- - -

- -

- -

- --

is


- -
- -

te

re

U
nR
eg

672

Chapter 18: Task Switching

- - -

- -

- -

re

- - - - --- - - - --
-- - - - -- - - -
- - - - - - -
- - - - - -
- - - - - - - -
- - -- - - -
- - - - - - --
- - - - - -
- - - - - - - - -
- - - -- - - - - -
- - - - - - - -

- - --

te

- -


- -
- -

- --

U
nR
eg

- --

is


- -
- -

- - -
- - - -

673

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- - -

674

Chapter 18: Task Switching

U
nR
eg

is

te

re

- -

675

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -

676

Chapter 18: Task Switching


LTR Instruction and the Busy Bit
- - - - --
- - -
- - - - -- -
- - - --
--

-- - -
- - - - -- --
--- - - -- - --
-- - - -- -
- -
- -- - - -
-

re

te

When Is Busy Cleared?

- - -
- - - -
- -
- - - - - -
- - -- -- -
- -
- - -- - -
- - - - --
- - - - -- -- -- -

U
nR
eg

is

-- - -- -
--

Critical Error: Switching to a Busy Task


-- - - - - - - - -- - - -
- - - - -
- - - - - - -
- -
-- -- - -

- - -

677

x86 Instruction Set Architecture


Busy Toggle Is a Locked Operation
-- --- -
--- - -
-- -- - --
--- -- -- - -
- - - - -

Linkage Modification

te

U
nR
eg

- - -
- - - -
- - - - -
- - - -
- - - -
-
-

is

re

- -
- - - - - -
- - - - - - -
-- - - -
- - - - - -

Task Switching and Address Translation


One GDT to Serve Them All

- - -
- - -- - -
-- - - - - - -- - - -- - - - -

- - -
- - - - - -- - - --
--
- - - -- -- -
--

678

Chapter 18: Task Switching

- - -- - -

- - -- - -

- -- - -

re

- - - - -
- --
- -- - - - -
--- - -- - -
- - -
- -- - -
- -

Each Task Can Have Different Virtual-to-Physical Mapping

is

te

- - - -- -
- - -- -- -- -
- ---
- - - - -
-- -

U
nR
eg

TSS Mapping Must Remain the Same for All Tasks


- --- --
-- - - -- - -
-- - - - -- - -
- - -

- -- - - - - - - - - - - - -
- - - - - - - -
- - - - - - -
-
- - -- - - -
- - - - -
-- - - - - - - - -- - - -
- - - - -

679

x86 Instruction Set Architecture


- - - - - - -
- - - - - - -
-- - - - -

Placement of a TSS Within a Page(s)


--
- - -- - - - -
- - -
-- - - --
- - - -- -
-- - - -
- -
- - - -
-

te

re

is

Switch from More-Privileged Code to Lower

U
nR
eg

- --
-
- -
- - -
- - - - - - - -
- - --

Software-Based Task Switching


- -- - - - - -

680

The Previous Chapter

is

- - -
-
-
- -
-
- -
-
- -
- - -

- - -
-
- -- -

U
nR
eg

te

re

- - -- -- -
- - -
- - - - -
-

This Chapter
- - -
- -

681

x86 Instruction Set Architecture

-
-
- - -
-
- -
-


--
-

re

- -
-

The Next Chapter

is


-
- --

-

-
-

-- --
-- -

U
nR
eg

te

- - - - - -

Handler vs. ISR

- - -
-- - - - -

682

Chapter 19: Protected Mode Interrupts and Exceptions


Real Mode Interrupt/Exception Handling
- - - - -
- -
-

re

- --

te

is

U
nR
eg

-- - -


- -

-- -
-

- - -

- - -
- - -
-
-
--
-
-


-

-

683

x86 Instruction Set Architecture

-
-
-
- -

- -

- -

re

-
- -

-
- -

te

- - - - -
- - - -

- -- - - -


- - -
-- - - -

U
nR
eg

is

-- - -
- - - - - - -
-- - - - --
-- - -
- -
--

-- - - -
-
- - -

The IDT

General

- -- -
- - - --
- - - - -
- - - - -- - --
- - -
- - - - -
-
- -

684

Chapter 19: Protected Mode Interrupts and Exceptions


-- - - -
-- - -
- -- - -
- -
- - - -- -
- - - -
-- - -- - -
- -

te

- -- -
- -- - - -
-
- -
-
--- -- - - -
-

re

is

Protected Mode IDT and the IDTR

U
nR
eg

-- -
- - - -- -
- - -

- - - -
- - -- -
--


- -
- - -
- -
- -

-- - - - -
- -- -
- - -
-- - -
- - -

685

x86 Instruction Set Architecture


- - -- - -
-- - - -
- - - - - - -- --
-- - -
-- -
-- - - -
-- - - - -

U
nR
eg

is

re

- --
- - - - - - -
-
- --
- - - - -
- - - - -
-
- - --
- - - - -- -- - - -
- - -
-- -- -- --
-

te

686

Chapter 19: Protected Mode Interrupts and Exceptions

- --

re

-
-
-
-
-

te

U
nR
eg

- -

is

- --
- - -- - -
- -
- -

- -
- -

687

x86 Instruction Set Architecture

- -

re

- --
-

U
nR
eg

Introduction

is

The Gates

te

- -

- -
- - -
- - - -
- -
- - - - - - -

- - - -
- - - -
-- -- - -
- - - -
-- - -

688

Chapter 19: Protected Mode Interrupts and Exceptions

--
- - - -
- -- --
-- - - - -
- - -

- - - - -
- -
-
-
-
- - --
-- - -
- - - - -
- - - -

U
nR
eg

is

te

re

-- -

689

x86 Instruction Set Architecture


-

-
- - - -
- -
-- -
-- --
-- - - - -
-
- - -
- - - -

-
-- - - - - - - - - -
-
-
-
- - --
-- - -
- -

U
nR
eg

is

te

re

-- -

690

Chapter 19: Protected Mode Interrupts and Exceptions


-

-
- - -
- - - -
- - -- -- -
- - -- -
-- --
-- - -
--- -- --
-
- - - -
-- -
-- - -
- - - - --
- - - -
- - - -- -
- -
- - - -
-- - -
- -
- - -
-- -- - --
- -
- - - - -
--
- - - -
- - -

U
nR
eg

is

te

re

-- -

Interrupt Gate

- -
-- -- - -
-
-- -
--

691

x86 Instruction Set Architecture

- -
-

- -
-

-
-

- - - - -
-- -

- - -
-

- - - - -
- - -- - -

-
- - - -
- - -
- -
- - -
-

U
nR
eg

is

te

re

692

-
- - -
-
- - -
- - - - - - -

- - - -
-

Chapter 19: Protected Mode Interrupts and Exceptions

- - -- -
- -

- - -
-

-
-

- -

- -
- -
-
- -

- - -
-
- -- -
-

te

re

Trap Gate

is

- --
-
- - -

U
nR
eg

-
-

--
- - - - - - -
- --
-
--
- - - - - - -
- - -
-- - -

- -

693

x86 Instruction Set Architecture

- - -- -
- -

- - -
-

- -
-
- -

-
- -

- - -
-
- -- -
-

te

- -

re

is

- --
-
- - -

U
nR
eg

Actions Taken When Interrupt or Trap Gate Selected


- - -
-
- - - - -
-
-- - -
- -

694

Chapter 19: Protected Mode Interrupts and Exceptions



-- - -


-
-- -
-

- -
-

te

-- -
- -

re

is

- - --
- -

- - -

U
nR
eg

- -

-- -
-

-

--

- -- - -
- - - -
- - -
-
-

- -

695

x86 Instruction Set Architecture


-- - -
- -

- - -
-- --
--
- -
- - - -

- - --
-

--
- -
- --
- -- - -
-
--

is

te

-
-

re

- -


--
- - --
-
- -- - -

U
nR
eg
-
- -

Actions Taken When Task Gate Selected


- - -
- - - - - -
- -
- - - -
- - - - - -
- -
- - -
- - -
- -- - -
- - - - - -- - - - - -

696

Chapter 19: Protected Mode Interrupts and Exceptions


- - -
-

re

- - -- -
- -- -- - - -- -- --
- - - - - - - - - -
- -- - -- -
-- - -
- - - -
- -- - - -
- - - -
- -- - - -
- - -

te

is

U
nR
eg

-
-
- - -- -
- - -
- - -
- -
- - -
- - - --
- --

- - -
- -

Interrupt/Exception Event Categories


- - -

- - - - -
- -
- - - -

697

x86 Instruction Set Architecture

is

U
nR
eg

te

re

- - - --

--- -
-
-- ---
-- ---
-

--

-
-- -- -
-- ---
-- --
-- --
---
--- - - -
-- - -
---
---
- - --
-
-
--- - - - ---
---
--- - - --
-- --
-- ---
- - --
-- - -
- -
- - -
- --- --
--
--- - - -
-- -- -
- -
-
- -
- - -
- -
- -

698

Chapter 19: Protected Mode Interrupts and Exceptions

-
-
- - - - -
- --
- --
--
- -- ---

General Event Handling

U
nR
eg

te

-
- -- ---
-
---
-
- - -- -
- -
--
-- -- -
- --
-
- -- -
- -- -
- --
- --
-- --

-- --
-
-- --

is

re

- - - -- - -- -
-- -

- - - -
--

699

x86 Instruction Set Architecture


- -- - - -
-- - -

re

-- -
- -
-
- -

-
- - -

te

U
nR
eg

is

-
-

- -
- -

- - -

700

Chapter 19: Protected Mode Interrupts and Exceptions

-- -
- -

- -
- -

te

--
- - -
- - --

re


- - - -
- - - -
- - -

- - -

- - - -
- - -
- - -

- - -

is

- -
- --
-
-
- -

U
nR
eg

701

x86 Instruction Set Architecture


- - -
- - -
--
-

re

te

- -

- -


- -

U
nR
eg

is

- - - - -
- -

- -
-

- - - - -
- -
- -

- -- - -
- - -
- -
- - -
-
-
-


- -
- --
-
-
- -

702

- -
- -

Chapter 19: Protected Mode Interrupts and Exceptions

-
-

re

- -

- -
-

is

te

- -
- --
-
-
- -

U
nR
eg


- - -
- - -
- - -
- - -
- - -
- -
- - -
- - -
- -

- -
- -
- -
- -
- -
- -
- - - -
- -
- -
- -- -
- - - -
---
-

-
-

-
-

703

x86 Instruction Set Architecture

-- -

--

re

-
- - - --
- - -
- - - - -
- - -

- - -
-
-- - -

- - -

is

te

State Saved on Stack (but which stack?)

U
nR
eg

-- -- - - - ---
-- -
--- - -- - -
- -
- - - -- -
-
-- - -
- -- -- - -
--- - -

704

Chapter 19: Protected Mode Interrupts and Exceptions

--

-
- - - -
- - - -
- -
-- - -
- - - - -
- - - --
- -

- - - - -
- -
- - - -
-- - -
- - - - -
- - - --
- -

- - - -
--
- -- --
- - -
- - -
- -
-

- - -

---
- - -- - -
-- -
- -

U
nR
eg

is

te

re

705

x86 Instruction Set Architecture


--
-

- - - -
- - -
- --
-
-- - - - -
- - -
- -
-


- - -

---
- - -- - -
-- - -

is

te

re

U
nR
eg

- --

706

--

--

Chapter 19: Protected Mode Interrupts and Exceptions



-

--

- --

--

re

U
nR
eg

- --

is

te

--

--

- --

--

707

x86 Instruction Set Architecture


-




--
-

U
nR
eg

is

te

re

-
-- -

--
--
--
--








- - - -
- --

-- -

--

-

-
-

Return to the Interrupted Program


General

- - - -
-

708

- -- -

- - - --
- - -

Chapter 19: Protected Mode Interrupts and Exceptions

- - -
-
--
- -
-

The IRET Instruction

U
nR
eg

is

re




-
-- - - - -
- -
- - - -
- - -- - --
- - --
-
- - - - -
- -



- -
- - - -

te

- -
--- - -
--

- - - --
-

- - - --
-

709

x86 Instruction Set Architecture

-
-
-


- - -
-- -
- - -

- -

-
-

-
- -
-

re

- -

--

- - - - - -
- - --


- - -



- -

te

-
-

-
-

is

--

- -

-
-

U
nR
eg

-
-

-
-

-
-

--
-- -
- -- - -

710

-
-

Chapter 19: Protected Mode Interrupts and Exceptions

- - -

- - -

-- -
- - -
-

-
- -- -
- -

re

- -

te

-
- -
- -- -
-- - -
- -
- -
-

U
nR
eg

is

- --

-
-
-
- -

-- - - -
- - - - --
-

-
-

-
- -
-

711

x86 Instruction Set Architecture

- -
- - - - -
- -

-
-
-
- -
- -

- - -

re

te



- -

is

- - -
-
-

-

U
nR
eg

- - -- - -
-

-
-

-
-

-
-

-

- - -
-

- -

712

Chapter 19: Protected Mode Interrupts and Exceptions


Maskable Hardware Interrupts
General
- - - - - -

- -
- -

re

te

- -- - -

U
nR
eg

is

- - --
- - - - - -
--- -
- -
-- - -
- -- -
- - - ---
- - - -
- -- - -
- -
- - - - - - --- -
-- - -
-- - - -
- -- -
--

Maskable Interrupt Vector Delivery


- - -
- -- - - -

713

x86 Instruction Set Architecture


- -
--- --- -- ---
- -
-
-- -
- --
---
-- -- - - - - --

-- - --
- - - - -

- - -- -
- -

te

re

is

PC-Compatible Vector Assignment

U
nR
eg


- -- -
--
- - -
- - -
- - -
-- - - - --
- -
- --
- - -
- -
- - - - -
- - - - -
- - - -
- - - -
- - - - - - -
-- -

714

Chapter 19: Protected Mode Interrupts and Exceptions

- - - -
- - -

--

- - - -
- - --
-
-- - -
- --
-- -
-
-- -

-
- - - -
- -
- -
- - -
- - -- -
- -- - - - --
- -
-

U
nR
eg

is

te

re

715

x86 Instruction Set Architecture


--

- - - --
- -
- - -
-- -

- -
- --
-- -
-
-- -
-
- - - -
-
- -
- - -
-

-- -

- - - -
-
- -
- - -
- -- -
-- - -
-
-- - -

- -
- - - -
- - -
- - - -
- - - -

716

U
nR
eg

is

te

re

Chapter 19: Protected Mode Interrupts and Exceptions


--

- - -
- -
- -
- -
- -- -
-- -
-
-- - -
- -
- - - -
- - -
- - - -
- - - -
- -

- - -

- - -- --
-
- -- -

- -
- - - -
- - -
- - -
- - -
-

U
nR
eg

is

te

re

717

x86 Instruction Set Architecture


--

- - -

-
- -
- -- --
-
- -- -

- -
- - - -
- - -
- - -
- - - - -

is

te

re

- -

718

- - -

- - -

- - -

U
nR
eg

Chapter 19: Protected Mode Interrupts and Exceptions


---
--

--

re

is

- -

U
nR
eg

te


--

-- -
-

Actions Performed by the Handler


-
- -

- - --
-
-- -- -
-

719

x86 Instruction Set Architecture

- -- - -
-
--
-
- - --
-- - - -
- --
- - -

-- --

re

General

Effect of CLI/STI Execution

-- -
-
-
- - -
-

- -
-
-- -
--
- - -
-
- -



- -
-

U
nR
eg

is

te

---
-- - -

- - - -
- --
- -

720

-
- - -

Chapter 19: Protected Mode Interrupts and Exceptions

- -

-
- --
--

---
- -
- -
-

te

re

U
nR
eg

is

- -

-

- -
--- -
- -


-
-

- --

-
- -

- - -
--

721

x86 Instruction Set Architecture


--

-
-

- -

- --- - -
-

-
- -
-
- --

te

re

U
nR
eg

is

- -
-

Other Events That Affect Interrupt Flag Bit


- - -

722

- - - - -
- - - -
- - - - - -
- - -
- - - --- -
- - - -
- -
- - - - - - -
- - - - -
-
- - - -
- -
-- -
- - - - -

Chapter 19: Protected Mode Interrupts and Exceptions


Protected Mode Virtual Interrupt Feature

-

Non-Maskable Interrupt (NMI) Requests


-- -- - - --
- -- -
--- -

te

--- - - -
---
--- - -
-- ---

re

is

PC-Compatible NMI Logic

U
nR
eg

- - -
- - - --
- -
- - -
- - - -
- - - - --
- -- - -
-- -
-- - - - -
- -

NMI Description
- - -- -- -
- -
-- --
- - -
- -

723

x86 Instruction Set Architecture


- -
- - - -- -

- - - -
- - -
- -- - - -
- - - - --
- -- -- -- -
- - -
-- -- --

re

More Detailed Coverage of Hardware Interrupt Handling

is

te

-
- - -
- - ---
-- -
-- - - - - -

U
nR
eg

Machine Check Exception

- - -
- - - -
- -- -
-- - - - -
-- - -
-

-- - -
- -
- ---
- - - ---
- --- - -

- -
- -

724

Chapter 19: Protected Mode Interrupts and Exceptions


SMI (System Management Interrupt)
- - -
---
- - - --- -- -
-- - - -
- --

- - - - -
- - -- - - - -
- --
- - -- -- -
- - - -- ---
-- --- -
- - - -
- - - - -
- - - - - - -
- --
- - -- -- -
- - - -- -
-- --- -
-- - -
- - -- -
-- - - -
- --
- - -- -- -
- - -
-- --- -- -
-

U
nR
eg

is

te

re

- -

Software Interrupts
- -
-- - - -

725

x86 Instruction Set Architecture


INT nn Instruction
- - -
- - -
- -
- - -- -- -

- -

U
nR
eg

is

re

-- -- -
- -
-- - - - -- - - -- - - - - -
- -
--- - -
- -
- - -
- - - -
- -
- - -
- -
- -- - - - --
-- --

te

- - - --

INTO Instruction

- - - -
-- - -
-
-- -- - -

726

- -- - -
- - -- -
- -
-

Chapter 19: Protected Mode Interrupts and Exceptions


BOUND Instruction
- - -
- - - -
-

INT3 (Breakpoint) Instruction

- -
-- - - -
- -
-- - -
- -

re

U
nR
eg

is

te

- - - --
-- -
-
- -
- - -
- - -
- -
- - - - -
-- - -
-- - -

-- - -
-

-
-- -
- - - -
-

727

x86 Instruction Set Architecture


Software Exceptions
General
- -

U
nR
eg

is

te

re

- - -
-
- -
- -
-- --
- -
- - -

- - -

-
- -
- -- --

Faults, Traps, and Aborts


-- - -
- -
- - - - - -
- -- - -
- -- -

- - - - - - - - -
- - -
- - - -

728

Chapter 19: Protected Mode Interrupts and Exceptions


- - -
- - -
- -- - - - - -- -
- -

- - -
- - -
- -
- - -
-- - -
-- --
- - - - -
- - -- -
- - - --
- -

- - -
-- - - - --
- --
- -

U
nR
eg

is

te

re


-
- -

729

x86 Instruction Set Architecture


-
-

- -
-- -

-
--

-
- - - -
--- -- -

- --

te

re

730

- -

- - - -
- - -
- -

-
- - - - -
--
- - -

- -
- - -
- -
-

is

U
nR
eg

- --
- - - - - -
-

Chapter 19: Protected Mode Interrupts and Exceptions

-
- -
- -
- - -
- - - -

- --
- - - -- -
- -

-
--
- -
- - -
- -
-
-
- -
- -- - -
- - --
- - -
- -

--

- -
- - - - -
- -
- --
-- - -- -
- - -
-

U
nR
eg

is

te

re

731

x86 Instruction Set Architecture


-
-

-- - -
- --- -
- -
-
--- -
- -
--

- - - -
- -

- - -
- - -
- - - -
- -

- --
-
- --
- -
- -
- -
- - -
-
- -


- - -
- -

732

U
nR
eg

is

te

re

Chapter 19: Protected Mode Interrupts and Exceptions


-
-

-
--
- -
- - -

- -
- -
- -

-
--
-

- --

- - -
- -
-- -
- -
- -
-- --
- -
- -
-- -


-
- -

U
nR
eg

is

te

re

733

x86 Instruction Set Architecture


-
-

- --

- -
- -- --
--
- - -
-- -
- -- - -
- -

- -- -
- -
-- - -
- -
- ---
- - - -
--
- --- -
-
- -
- -


--
-
-
- - -- -
-- -- -
- ---
-
- -

- - - - -
-

U
nR
eg

is

te

re

734

Chapter 19: Protected Mode Interrupts and Exceptions


-

- - -
-

- -

Instruction Restart After a Fault

te

re

-- - - --
- -- -
- -- - -
- - - - - -
- - -
-- -

U
nR
eg

is

-- --
- - -
-

-- - -

--
- - --
- - -
-

- - -- - --- -
- - - ---
--- -- -

Exception Error Codes


-- -- - - - - - -
- - - --
- - - - -
-

735

x86 Instruction Set Architecture

-
- - -
-
- --
- - - -
- - --

- -
- --
- -

re

- -

- -
-

- --

- - -
- - -
-
-
- - --

- -
- -

U
nR
eg

is

te

736

- - -
- - -
-
-
- --
-
-- -
- -
-
-
-

Chapter 19: Protected Mode Interrupts and Exceptions


- -

- -
-

-
-
- - - -
- - -

- - -
- -
- -
- -
- -
-
-
- - -

- -
- -
- - -
-
- - -
-

-
- -
-
- -
-

U
nR
eg

is

te

re

737

x86 Instruction Set Architecture


- -

- -
-
- - -
-
-- - -
- -
- -- -
- -
- - - -

- --
- - -

- -
-
-- -
- -

-


- -

- -
- -

-
- -
-- - -
-
--- --
- - -

U
nR
eg

is

te

re

738

- --

Chapter 19: Protected Mode Interrupts and Exceptions


re

Interrupt/Exception Priority

te

-- -
- - - -
- -- - -

U
nR
eg

is

-- - -- - - --- - -- - -
-- - - - - -- - - -- --
- -- - -
- - - -
- -

-
-

-- -

-
-

-- - -

- - -- - - --

--
-- -

739

x86 Instruction Set Architecture



--

-- - -

-- -
- -

- - -
- -
-

- - --- -
-- -
-
-- - -

re

te

- ---
- --
-- - -
- -

is

- --
-- -

U
nR
eg

- --
-- - - - - - -
-

-
-
-
- -
--
-- -
-

- -- -
--
--
-

-
-

- -
--

740

Chapter 19: Protected Mode Interrupts and Exceptions



--

-- - -

-- -

-
-- -
-

-
-

-
- -- -
-- - - -

- - - -

te

-

-

- -

is

- - - -
-

U
nR
eg

re

741

x86 Instruction Set Architecture



-
-

-- - -

-- -
-
-

- -
-
-
- -

re

- -
-- - -
- -

is

te

- -
- --
- -
- -
- -

U
nR
eg






-- - -



-

-- -

742

Chapter 19: Protected Mode Interrupts and Exceptions


Detailed Description of Software Exceptions
- - - -
- -

Divide-by-Zero Exception (0)


Processor Introduced In

re

- - - -- -
-- ---

Exception Class

te

- - -

Description

U
nR
eg

is

- - -
- - - -
- - -

Error Code

- - -

Saved Instruction Pointer

- - - - - -

Processor State

- - - - -

743

x86 Instruction Set Architecture


Debug Exception (1)
Processor Introduced In
- - - -- -
-- ---

Exception Class

- --
-
- - --

re

Description

te

- -
- - -

is

- --

U
nR
eg

--

- -

-
- - -
-

-- -
-

- -

- - - - -

744

Chapter 19: Protected Mode Interrupts and Exceptions


Error Code
- - -
-- -

Saved Instruction Pointer


- - -
-
- - -
-

Processor State

te

re

- -
- -
-- -

U
nR
eg

is

- -
- - - -
- - -

The Resume Flag Prevents Multiple Debug Exceptions


- - --
- - - - -
-- - - - -
- -
- -- -
-
--
- - - -
- - - - -
- -
- -
-- - - - - - -
- -- --
- - -
- - --

745

x86 Instruction Set Architecture


NMI (2)
Processor Introduced In
- - - -
-- - -- ---

Exception Class

re

- - - --
--- -- -
--- -
- -- --

te

Error Code
- - -

is

Saved Instruction Pointer

U
nR
eg

-- - - -
- - - - -

Processor State

- - -
-- -
-- -- --- -

Breakpoint Exception (3)


Processor Introduced In
- - - -- -
-- ---

746

Chapter 19: Protected Mode Interrupts and Exceptions


Exception Class
- - -

Description

- - -
- -- -
- -
- - - - -
- - - -
- - - -
-

te

re

--- --
- -- -
- - -

Error Code

is

- - -

U
nR
eg

- - -

Saved Instruction Pointer

- - - - -
-

Processor State

- - - - -
- - - --
- -
-
- --
-

747

x86 Instruction Set Architecture


Overflow Exception (4)
Processor Introduced In
- - - -- -
-- ---

Exception Class
- - -

Description

re

- - -
- -

is

Error Code

te

-- -
- - - -
- - -

U
nR
eg

- - -

Saved Instruction Pointer

- - - -
-

Processor State

- -- - - -
- - -- --

Array Bounds Check Exception (5)


Processor Introduced In
- - - - --
---

748

Chapter 19: Protected Mode Interrupts and Exceptions


Exception Class
- - -

Description
- -
- - -
- - - -
-

Error Code

re

Saved Instruction Pointer

- - -

te

- - - -

is

Processor State

U
nR
eg

- - - -
- -
-- -
-

Invalid OpCode Exception (6)


Processor Introduced In

- - - - --
---

Exception Class

- - -

Description
- - --

-
- -

749

x86 Instruction Set Architecture

U
nR
eg

re

te

is

- - -
- -
- --
- -
-


-

--


- -- --

- - - -
- - -

-
- -


-
-

--- - -
--- - - -
-
- - -
- --- -
-
-
- - -

Error Code
- - -

Saved Instruction Pointer


- - - -

750

Chapter 19: Protected Mode Interrupts and Exceptions


Processor State
-- - - - - -

Device Not Available (DNA) Exception (7)


Processor Introduced In

- - - - --
---

re

Exception Class

Description

te

- - -

- -

is

U
nR
eg

-- -

-- -
-- -
-- -

--

-- -- -- - -- -
- - -
- -
- - -

- --
- - - - - -
- - - - - - - -- -

751

x86 Instruction Set Architecture


- - -
-- -
- - -- -
-- --
-- - -- -
- -
-- - - -
- -
- - - -

- -

te

re

-- - -
--
- - - -
- - - - -
--- -
- ---

is

Error Code

- - -

U
nR
eg

Saved Instruction Pointer

- - - -
-

Processor State

-- - - - -
-

Double Fault Exception (8)


Processor Introduced In
- - - - --
---

Exception Class
- - -

752

Chapter 19: Protected Mode Interrupts and Exceptions


Description
- - --
-
- -- -- -
- - -
-
- - - --
-- - - -

re

- --- -
- - -
-- - - --- -

U
nR
eg

is

te

-
- - - -
- - - --
-- -- -- --

753

x86 Instruction Set Architecture


--

-
-

-- ---

--

- -

- -

U
nR
eg

is

te

re

--

754

- - -

-- ---
- - --

Chapter 19: Protected Mode Interrupts and Exceptions


- -
-

re

is

Shutdown Mode

te

-- -
- - - - -- -

U
nR
eg

-- -- --
-



-
-- ---
--

-- - --
- - - -
- - -- - -
-- - -


-- - - --
- - - - -
-
- - -- --
- - -- --
- - -- --

755

x86 Instruction Set Architecture


- - -- -
-- - --
--

Error Code
-- - -- -

Saved Instruction Pointer


- - -

Processor State

re

-- - -
- - - -

Processor Introduced In

te

Coprocessor Segment Overrun Exception (9)

U
nR
eg

is

- - - -
-- --
-- -- -- - -

Exception Class

- - -

Description

- - -
- -
-
-- -- - - -

Error Code
- - -

Saved Instruction Pointer


- - - -

756

Chapter 19: Protected Mode Interrupts and Exceptions


Processor State
-- - -- -
- - -
- - -
- -

Invalid TSS Exception (10)


Processor Introduced In

- - - - --
---

re

Exception Class
- - -

te

Description

-

--

U
nR
eg

is

- - - - -
- -- -
- -
- - -

- -

- -- -

- -

- -

- - - -

- -

- -

- -

- -

- -

757

x86 Instruction Set Architecture


-

- -

- - - -

- -

- -

- -

- -

- -

- - - -

- -

re

U
nR
eg

is

te

- -
- -- -
- -- -
- - -- - -
- - - - - - - - -
- - - - -
-- - -
- -
- -
- -
- - - - -
- - -- - --

Error Code

- - - -
- - - -
- - - -
- - -

- - - - -

758

Chapter 19: Protected Mode Interrupts and Exceptions


Saved Instruction Pointer
- - - -
- - - - - -
- - - -
- - - - -

Processor State
-
--

U
nR
eg

is

te

re

- - -
- - -- - - - -
- -- - --
-- - - - -
- -- - - -
-- - -- - - -
-- - - - -
-- -

- -- - - --
-- -
- - - -
-- - - - -
- - - --

Segment Not Present Exception (11)


Processor Introduced In
- - - - --
---

Exception Class
- - -

759

x86 Instruction Set Architecture


Description
- - - -
- - - - -

re

--
- -
--
- -
- - -
--
- - -
- - - -
- - - -

is

Error Code

te

- -
- -
-- -- -

U
nR
eg

- - - -
- - - -
- - - -
- - -
- -
- -

Saved Instruction Pointer

- - - -

-- - - -- - - --
- - - -
- -- -
- - - - - -
-- - --

760

Chapter 19: Protected Mode Interrupts and Exceptions


Processor State
- - - - -
-- - - - -
- - - --
- - - - -

- -- - --
- - - - -
- -
- -

is

te

re

- - -
- - -
-- - - -
-- - - --
- - -

- -- - --

U
nR
eg

- -- - - --
-- -
- - - - -
- - - - -
- - - --

Stack Exception (12)

Processor Introduced In

- - - - --
---

Exception Class
- - -

Description
- - -
- -

761

x86 Instruction Set Architecture

re

- -
- - - -
-- - - - - -
-
- - - - - -
-
- - -
- -
- -
-


-
- -

- -
-- - - -

U
nR
eg

Error Code

is

te

- -

- - - -
- -
- - - - - -
- - -
- - - - -

- - - -
- -

Saved Instruction Pointer

- - - -
- -
- - - -- -
- - - - - - - -

762

Chapter 19: Protected Mode Interrupts and Exceptions


Processor State
-- - -
- - - -
- -

- - - -
- - -- - - -
- -
- -

te

re

- -- - - --
-- -
- - - -
-- - - - -
- - - --

General Protection (GP) Exception (13)

is

Processor Introduced In

U
nR
eg

- - - - --
---

Exception Class

- - -

Description

- - --
- - -
- - -
- -

- -- -
-
- -
- - - -
- - - -

763

x86 Instruction Set Architecture

U
nR
eg

re

te

- -
-
- - -- - - - -
-
- -- -
--
- -
- -
- -
- - - -
-- - - -
-
- - --
- -
-
- - - - - -
-- -- -
- - -
- -
- - -

- - - -

-- -
-
--
- -
-
- - -
--- - -- ---
- -

- - -
---
-- - - -
-
-
- - -
-
- - - - -
-- -- -

is

764

Chapter 19: Protected Mode Interrupts and Exceptions

is

te

re

- -
- - - - - - -- -
- -
- - -
-- -
- - - --- - - - -
- -
- - - -- --- --

- - - -
- -
-- - -- -
- -
- - - - -
- -
- - --
-

U
nR
eg

- -
-
-
-

Error Code

- - -
- - -
- -
- - - - -

-
- - - -
- - -

Saved Instruction Pointer


- - - -

765

x86 Instruction Set Architecture


Processor State
-- - - -
- - -
- - - - -
- -

- - -
- - -
-- - - -
-- - - --
- -

te

re

- -- - - --
-- -
- - - -
-- - - - -
- - - --

is

Page Fault Exception (14)

U
nR
eg

Processor Introduced In

- - - - --
---

Exception Class

- - -

Description

- - --
- -
-- - --

766

- -
- - - - -
- - --
-- - -
- -

Chapter 19: Protected Mode Interrupts and Exceptions

-- - -
- - --
- - -
- - --
-
-
--
-
---
---
- --
-

-- - -
- -
-

re

U
nR
eg

Error Code

is

te

- - --
- - - ---
-- - - - -

- - - -
- - -


- -
- -- -
- - - -
- -- -
-
- -
- -

-
-
- - --
- - - - -
-

767

x86 Instruction Set Architecture

- - -
- -- - - --
---
- - - -
-- ---
- - -
- - -
-
-
- -
- -

re

CR2

is

te

U
nR
eg

- -- -
- -- -- -- - -

- - - - -
-

Saved Instruction Pointer

- - - -
- -
- - - -

Processor State
- -- - -
- -
- - -
-
-- -
-

768

Chapter 19: Protected Mode Interrupts and Exceptions


- - - -- -
- -
-

re

- --- - -
- - --
- -
-
- -
- -- -- - -
- - -
- - -
- - -

te

- -- - -
- - - - -
- - - - -
- - - -
-- - -

U
nR
eg

is

- - - -- - - -
- - -
- -- - - --
-- -
- - - -
-- - - -
- - - - -

Page Fault During a Stack Switch


--- -
-- - -


- -- - --
- -
- - - -
- - - - - -

769

x86 Instruction Set Architecture


- - -
- -- - - -
-- - -- - - - -

Vector (Exception) 15

is

FPU Exception (16)

te

- - ---

re

- -
- - - -
- - - - - -
- -- -
- - - -- - -
-
- - - - - - --

U
nR
eg

Processor Introduced In

- - - - -
- ---

Exception Class

- - -

Description

- - -
- - -

- - -

770

Chapter 19: Protected Mode Interrupts and Exceptions




- -

- - -- - -

- - - -

- -- - - -

- - - -
- -

re

Handling of Masked Errors

is

te

- - - -- -
-- - - - -
-- - - -
-- - - - -
-
- - - - -

U
nR
eg

- -

-- -- - -
- - - -
- -

-- -- - - -
- - -

771

x86 Instruction Set Architecture


- -

-
-- -- - - -
- - -- - -
-
- -
- - -
--
- -

-- -- - - -
- - -

-- -- - - -
-- - -
- -- --

- -

-
-- --
- - --
- -
- - -
-

U
nR
eg

is

te

re

Handling of Unmasked Errors


- - --- -
- - - -- - -
- - - - -
-- - - -

- - - -
- - - -
- -
-- - - - - --
-- - - -

772

Chapter 19: Protected Mode Interrupts and Exceptions


- - -
-- -
- - --

-- -
- --
-
-

Error Code

re

Saved Instruction Pointer

- - -

U
nR
eg

is

te

- - - -
- - - - --
- - - -
- - - --
- - -- - -
- -
- -

Processor State

-- - --
- -
- -
-- - - - -
-
- - - -- -
- - -
- -
-

773

x86 Instruction Set Architecture


Alignment Check Exception (17)
Processor Introduced In
- - - - --
---

Background: Misaligned Transfers Affect Performance

re

- - -
-- - -- -
-- -
-

- -
-

- -

U
nR
eg

is

te

- - -- --
- - -
- - - --
- --
- - --

- - -
- -
- -- - --
-- - -
-
- - - -
- -
-- - -

Alignment Is Important!
- - - - -
- - --
- -- --
-

774

Chapter 19: Protected Mode Interrupts and Exceptions

- -- - -
-- - --
- - - -
-- -- -- - -- -
-- - -

-
-
-- - --
-

Exception Class

re

- - -

te

Description

U
nR
eg

is

- - --
--
- - -- - -- --- -- --
-- - - -
--

-- - -

775

x86 Instruction Set Architecture


-

-- - -

- - -

te

re

U
nR
eg

is

- - - -
-- - - -- -
- -- -
-

- - - -
- - -
-
- -

Implicit Privilege Level 0 Accesses


--- - -
- - -
--

Storing GDTR, LDTR, IDTR or TR


- -
-
- -- - -
-- - -

776

Chapter 19: Protected Mode Interrupts and Exceptions


FP/MMX/SSE Save and Restore Accesses
-- - - -
- - - - -
- -- - - -
- -
-
-
-
- - -
- -
- -
-
-- - -- - -
- -- - -
-
-
-- -- - -
- - -- -

te

is

re

U
nR
eg

MOVUPS and MOVUPD Accesses


--
- - -
- -
- -

FSAVE and FRSTOR Accesses


- -- - -
-- - -
-- - -

Error Code
- - -

Saved Instruction Pointer


- - - -

777

x86 Instruction Set Architecture


Processor State
-- - - - -
- -

Machine Check Exception (18)


Processor Introduced In

- - - -
-- ---

re

Exception Class

Description

te

- - -

is

--- -
-

U
nR
eg

- - --
-- --
--
- -- -
--

-
-- -
-

-- -
- - - - --
-- - -
- - - - -

Error Code
- - - -
-

778

Chapter 19: Protected Mode Interrupts and Exceptions


Saved Instruction Pointer
--- -
-- - -- -

-- -
- - - --
-
- --

- -
--

re

Processor State

te

-- - - --

- - -

U
nR
eg

is

-
-- -- -

SIMD Floating-Point Exception (19)


Processor Introduced In

- - - -
-- ---

Exception Class

- - -

Description
- - -- -
- - - - --
- -
-

779

x86 Instruction Set Architecture


- --- -
-




- -

re

-
- -
- -
- - -

U
nR
eg

- - -
- - - -
-- - -
- - -- - -

is

te

- - -
- -
-- -

- - - -- -
-

- - - --

-- - - -
-

- - -- -
- - - -
- - -
- -
-
-
- - -
-

780

Chapter 19: Protected Mode Interrupts and Exceptions


- -
- - - -- -
- - -
-- -
- -
- --
-- - --
- - - -

re

-- -
- - -
- -- --

te

is

U
nR
eg

-
- -
--


- -
- -

- -
- -

- --
- - -
- -

781

x86 Instruction Set Architecture


Exception Error Code
- - -

Saved Instruction Pointer


- - - - -

Processor State

te

re

-- - - - -
- - --
- - - - -
- - -
-

is

Legacy Problem: 2-Step SS:ESP Update

U
nR
eg

Problem Description

-- - -
-
--
- - - - - -

-- -- - -
- - --
-- - - - -
- - - - - --
- -- -

The Solution
- ---
- - -
- - -
- - - - -
- - - -

782

The Previous Chapter

is

te



-
-
- - -
-
- -
-


--
-

U
nR
eg

re

- -
-

This Chapter

- - - - -
- - -


-
- --

-

-
-

783

x86 Instruction Set Architecture


-- --
-- -

The Next Chapter

- - -
- - -
- - - -
- - - - - -
- - -

re

A Special Note

is

te

- - - - -
- - -- -- - -
- -
-- -
- -

U
nR
eg

Real Mode Applications Are Dangerous


- ---
- - -
-

784

-- -- -
- -
-
- --
- - -
- -- -
- - -
- -
--- -
- - - -- -
---

Chapter 20: Virtual 8086 Mode


Solution: a Watchdog
- -- -- -
- - - --
- -
-- -- -
- - -- -
- -- -
-

re

U
nR
eg

te

-
-- -- - - - - --

- --
- -
- -
- - - -
- -
--
--

- -
- -
--
-- - - -

- - -
-
- - -

is

785

x86 Instruction Set Architecture


-




--
-

U
nR
eg

is

te

re

-
-- -

--
--
--
--








- - - -
- --

-- -

--

-

-
-

786

Chapter 20: Virtual 8086 Mode

- -

- -

is

te

re

-




-
- -









U
nR
eg

Real Mode Applications Run at Privilege Level 3



- -

Switching Between Protected Mode and VM86 Mode


Eflags[VM] = 1 Switches Processor into VM86 Mode
-- -
- - - -
- - - - -
- - - -
- - - - --
- - - --

787

x86 Instruction Set Architecture

- - - - -
- -- - -
- - - - -
- - - -- - --

But Software Cannot Directly Access Eflags[VM]


--
- - - -- --

is

re

- - - - -
- -
-- --

- - -
- - -
-
- -
- -
- --

te

U
nR
eg

-- - -- -- --

Scheduler Activates VM86 Mode


- - -
- - - -

788

- - - - -
- - - - - - -
- -
-
-- -- -
- - - -
- - --
- - -
- - - -- - -
- --
-- - - - - - - - - --
- - -- -

Chapter 20: Virtual 8086 Mode


-- -- - -
- - -
- - -
- -
-
- - - -
- - -
- - - -
-- - - -

re

Exiting VM86 Mode

te

U
nR
eg

- - - - -
-- -
-- - - -
-- - -
--
--
- -
-
-- -- - -
- - - -
-
- -

- - - --
-
-- -
- -
- - - --

is

Determining Interrupted Task Is a Real Mode Task



-

789

x86 Instruction Set Architecture


- - -
-

Returning to VM86 Mode from VMM

re

- -- -
- -
- - - -- - -
-- - - -- -
- --
-

te

VMM Passes Control to Real Mode Interrupt/Exception Handler

is

- - -- ---

U
nR
eg

Real Mode Applications World View


The DOS World

- - -
- - - -- -
- - - -
--
- - -

790

- - -
- - -
-
--

-
-
-- --

Chapter 20: Virtual 8086 Mode

re

- - -

-- - -

-
-
-
- -


- - -
-

U
nR
eg

is

te

-
-
-
-
-
-

- --

791

x86 Instruction Set Architecture


Memory Address Formation in VM86 Mode
-- - ---
- -
- - -
- - - -

-- - -

U
nR
eg

- -- -
- - - - - - -
- - - - --
- - -
- -- -
- - - - -- -- - -- - -

is

te

re

- - - -- -- - -
- - -

792

Chapter 20: Virtual 8086 Mode


-- -

- - --
- -- -
-
- -

re

U
nR
eg

is

te

Multiple DOS Domains in Separate 1MB Areas


-- -
- - - -
- -- - - -
- - - - - -- - - - - -
- - - -- -
- - - - - - -- - -- - - ---
- - - - - -
-- - - - - --
- -- - -
- - -- -

793

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- - - - --
- - - - -
-- - -

-

- -

-
- -
- -

- - - - - - -
-- - - -- - - - -- - - -- -
- - -- -
- -
-
- - - - - -
- - -- - - -- -
- - -- - - - --
- - - -- -
- -
-

794

Chapter 20: Virtual 8086 Mode


- - - ---

- -

- -

re

te

is

U
nR
eg

VMM Should Not Reside in the HMA


- - --- - -- - -- -
--- - ---
--

- - -
- -
--
- -- - -
--

795

x86 Instruction Set Architecture


Dealing with Segment Wraparound
8088/8086 Processor
--- -- - -
- ---
- - - - -- -

- - - --

U
nR
eg

is

te

re

- - -- -
- -
- -- - - - -- -
-- - - - -
- -
-- -
- - - -- -- - - --
- --
- - - -- -
-- -

286 and Later Processors

--- -- -
- - -
--- -- - - - -- - - -
-- -- - -
--

Solutions

- - -
-
--- -- -
-

796

- - -
- --- -
- - -- --

Chapter 20: Virtual 8086 Mode

- - - -- -- - - - --- -
-
-- -- -
- - -
- --- ---
-- - -- -- -
- - -- -- - - - -
--- - - -

Using the Address Size Override Prefix

- -- - -- -
-
-- -- - -- -

U
nR
eg

Sensitive Instructions

is

te

re

- - -- - -
-- -- - - -

Problematic Instructions
-- -
- --
- -- --
--
--

- -- - ---

797

x86 Instruction Set Architecture


CLI (Clear Interrupt Enable) Instruction

re

STI (Set Interrupt Enable) Instruction

- -
- - -
-- -- - ---

- - -
-- - -
- - - -
- -
-- - - - - -

U
nR
eg

is

te

- -
- - - -
-- -- - ---
-
- - - -
-
-- - - -- -
-

- -- -

798

-- -
- -

Chapter 20: Virtual 8086 Mode


PUSHF (Push Flags) Instruction
- - - - - - -
- - --
--

POPF (Pop Flags) Instruction

re

-
-- --
--
-
- --
-

te

- - - -
- - - -
- -

is

INT nn (Software Interrupt) Instruction

U
nR
eg

-
- - - - -
- - -
- - - -- -
-

IRET (Interrupt Return) Instruction


- - - -
- - - -
- - - -

-
-- --
--
-
- --
-

799

x86 Instruction Set Architecture


-- - -

- -

- - -

Solution: IOPL Sensitive Instructions

te

re

-- - - -- -
-- -- - -- -
- -

U
nR
eg

is

- - - -
-- -- - - -
- - --
- - -
-- -- - - - -- -- -

Handling Direct IO
The Problem

- - -
- - - - - ---
-

IO-Mapped IO
IO Permission in Protected Mode
-- -
- - -- -
-- --

800

Chapter 20: Virtual 8086 Mode


- -
-

te

re

- - - - -
- - -
- - - - - -- - -- -
- - -
- -- -- -
-- --- -
- - - - - - -- - - - -
- - -- -
- - - -

IO Permission in VM86 Mode

U
nR
eg

is

-- - -
- - --
- - -

- - - -
- -
-- - -- --
- -
- -- -- -
- - - -- -
- - - -
-
- - -- -
- - - -

801

x86 Instruction Set Architecture


-

--
--
--
--








- - - -
- --

-- -

re

--

-

--
- -

te

is

U
nR
eg

-
-

Memory-Mapped IO

-- - -
- - - - -
- - - -
- -- - -
- -- - -
-- - -
- - -- -

802

Chapter 20: Virtual 8086 Mode


- - -
- -- -

To Permit an Access
- - - - -- - - -
- -- - --
- -- -- - - -
---

To Deny an Access

re

-- - - --
- - -- -- - - -
-- -- - - --
-- - --
-- - - --
- - - - -- --
- - - -- --
- -- - --

te

U
nR
eg

is

- - -- -
-- - -- -- -
- - - --
--
-- --
- - - -

For Finer Control

-- -- -
-- - -

- --
--

Handling Video Frame Buffer Updates


- --- -
- - - - - -
-
- -
- ---
-- -- - - ---

803

x86 Instruction Set Architecture


-- - -
-

re

Handling Exceptions in VM86 Mode

- - - - -
- - - -
- --- - --
- - - - - -
-- -- -
- -- - - - - - --

Processor Actions

- - - - -
- -- --
- -
-
- -
- - -- -
-- - - - -- -
- -- -
- - -

- - - - -
- -- --
- - - - - - -

U
nR
eg

is

te

- - -- --
-
- -- -

--- --- - -
-- - -

804

- -- - --
- - -
-- -

Chapter 20: Virtual 8086 Mode

U
nR
eg

is

te

re

- -
-
-- - -
- -
- - - - -- - -
- -
- - - --
- -
-- --

- - - -

- - -- - -
- -
- - - - -
--- - -- - -
-- - --
- - --

-
-
- - -
-- -
- - - - -
-

- - -

Option 1. -
- - -
-
Option 2.
- --
- - - - - - -
---

Option 3. - - -
- - -
-

805

x86 Instruction Set Architecture


Option 1: Protected Mode Handler Services
Exception
- - - -
- - - -
- - - --
-
- - - -
-- -

- -

- -
- - - - -
-
- - - - -- -

- - -- - -
-- - -
- -- - -
- - --
-
-- -
-- -
- - --
- - -

U
nR
eg

te

is

re

- --
- - - - -

Option 2: Handler Passes Exception to VMM for


Servicing
- -
- - - -
- -
--- - - -

806

Chapter 20: Virtual 8086 Mode

-- -
- -
- -- - -
- -
- - - -- -

-- - - -
- - -
- -
-- - - -
- - -
- --
- - -
-
- - -
-- -
- - -
-- -
- -
- - -- -
- --
-- - -

- -- -
--
-
-- --
- - -
- - -
- - -- -
- --

U
nR
eg

is

te

re

- - -

- - --

-- -
- - -

807

x86 Instruction Set Architecture


Option 3: Exception Handled by Another Task

- --

is

te

- -

- -
- -

808

U
nR
eg

- --
- - -- - -
- -
- -

re

- - -
- - - - -
- - - - - --
- -- - - - - - - - - -
- - - - - -
- - -

Chapter 20: Virtual 8086 Mode


Hardware Interrupt Handling in VM86 Mode
NMI, SMI, and Maskable Interrupts

re

is

te

- - - - -
- -
-
--- - - -
-- -
--- - -
-- --
---
- -
-- --
- - - -- -

-
- -
- - -- -

- -- --
-
- -

U
nR
eg

- - - -
-
- - - - --

809

x86 Instruction Set Architecture


-

- -
- - --
-
-- -
- -
- - -
- - -
-- -
- --
---
-- - -
- -




-- - - -- - - -
- -

810

U
nR
eg

is

te

re

-
-

- - -
-- - -
-
-- --
- -
- -

- -- - --- -
-- ---
-
-- -
- - -
- --
-- ---

Chapter 20: Virtual 8086 Mode


Real Mode Applications Unreal Reality
- - - -- -
- - -
- - - -
- - -
- - - --

-- -
-
--
- - -
- - - -

U
nR
eg

is

te

re

-
- - -
-
- - - -
- - - - -
-
- - - - -
- -- -
- - -- - --
--
-- -
-

- -- -
--

- -
- - -
- - -
-- - -

811

x86 Instruction Set Architecture


- --- -
- - -
- -

VM86 Task Executes CLI When VME = 0


- - --- - -
- - -
-

te

re


- - - -
- - - - -
- -- -
-- - - - -
-- --

U
nR
eg

is

- - - -
- -
- -
- - --
- - -
- -
- - -
- - - - -
- -
- - - -
- - -
- -
-
- - -
- - - - -
- - -
- - -

CLI Handling
- - -
- - -- -- -
- -
- -

812

Chapter 20: Virtual 8086 Mode


-
- - - - -- -
-- - - -

-
-
- - - -
- - - --
- - -
- - -
- -

re

Subsequent High-Priority Interrupt Detected

U
nR
eg

is

te

- --
- - -
--- -
- - - -
- -
- - - - -
- - - -
- - - - --
- - -
- - - --
- -
- - -- -

Servicing of Lower-Priority Interrupt Deferred


- - -
-
- - -

-
- - -- - -

- - -- - - -
- -

813

x86 Instruction Set Architecture


- - -- -
- - - -
-
- - - - -
- - - - - -
-
- - - -
- - - -
- -- -
- -

is

te


- -
- -
-
- - - -
- -
-
-
- - -
-
- --
- -
- -
- - - -- -
-- -
- -
- -

U
nR
eg

re

- - - -

814

Chapter 20: Virtual 8086 Mode


- -

re

- -
-
- -
- -
- --- -

- -
- -
-

- -
-- -
-
-- - -
- -
- --
- - -
-- -
- -

- - -- -- -
--
- -
-

is

te

U
nR
eg

- - -

-- - -

-- - - -
-
-
- -
- - - -
- -- - - -

- - - -
-
-

815

x86 Instruction Set Architecture


STI/POPF/PUSHF/IRET Handling When VME = 0
--- -
- - - - -
- - -- --

Attempted Execution of STI Instruction (VME = 0)

re

- -
- -
--
- - -
- - ---

U
nR
eg

is

te

- - - -
- - - - --
- -
- - -
- - -
- - - -
- - -
- - -
- -
- -
- - -
- - - - - -
- - - --
- -
- -
- - -
-

Attempted Execution of PUSHF Instruction (VME = 0)


- -
- - - -
--
- - -
- -

816

Chapter 20: Virtual 8086 Mode


- - -
- -
- -
-- --
- - - -
-- - -
- --
- - -
- -
- - -

Attempted Execution of POPF Instruction (VME = 0)

te

re

- -
- - - - -
- -
- -

-
-- --
- - -- -
- - - - -
- ---
- - -
- -
- - - -

- ---
- -
- -
- - -

U
nR
eg

is

- - - -
- - -
- -

Attempted Execution of IRET Instruction (VME = 0)


- -- -- -
- - - - --
-

817

x86 Instruction Set Architecture


- - -- --
--- -
-
-- -
- -- -
- - -- --
--- -
--- -
- --

CLI/STI/POPF/PUSHF Handling When VME = 1

re

VM86 Extensions

- -
-- -
-
-- -
- - -

U
nR
eg

is

te

-- - -
- -
-- - - -- ---
- - - -
-

- - --- - -- --

818

Chapter 20: Virtual 8086 Mode



- - - - - -
- -

--

- -- -

--

re

Background

te

--

-

- - - --

U
nR
eg

is

- - - -
-- --

-- -- - - -
- - -
- -- -- - - -
- -
-- --- - -
- -- - -

When VME = 1 and IOPL = 3, Task Can Control Eflags[IF]


- - - -
- - - - -
- - - -
- - - -
- -

819

x86 Instruction Set Architecture


When VME = 1 and IOPL < 3, Task Controls VIF, Not IF
- - -
-- - -
- - -

- - - - - - -- -
- - -
- - -
-

Eflags[VIP] Is Controlled by the VMM

te

U
nR
eg

- - - -
- -
-
- - -

-- - - -
- -
-
- - -

is

re

- -
-- - -

Software Cannot Directly Access Eflags[VIP]



- - - - -
- - -
- - - - -
- - - - -
-- -- - -

CLI Followed by a Maskable Interrupt


-
- - -
- - -- - -

820

Chapter 20: Virtual 8086 Mode


- - - - -
--- - -
- - - - -- -
- - ---
- -

re

U
nR
eg

is

-- --
-- -

-- -
- -- - -
-- -- - -
-- - --
- - -- -
-- - -
-- -
-
- - -
-
- - -
-
- - ---
-
- -
- - - -
- - - - -
--- --
- -
- - -
- -
- -

te

--- - -
- - - -
- -- ---
- -- - -
- - -
- - - - -
- -- -

821

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -
- - -
-
--
- -
- - -
- - - --
-
-- -
- -
-
- - -
- -- -
-
- - -- --
-
- -
- - -
-- -
- --
- - - -
-- --
-- -
- - - -
- - - - -

-

Subsequent STI Effect Depends on Eflags[VIP]


- - -
- - - --
- -

822

- -
- -- - - - -
- - - -

- -
- --
- - - - - -

Chapter 20: Virtual 8086 Mode

re

-
-
-
- - -
- -

- -
- - -
- - -
- -
- -- --
- - --- -- -
--

te

- -

- -

is

-




-
- -










U
nR
eg

823

x86 Instruction Set Architecture



- -

is

te

re

- -

- - - -
- --- -

- - -
- -
- -

- - -
- -- - -
-- - -
- -
- --
- - -
- -- - -
- -- -
- - -
- -
-

U
nR
eg

- -

- -
--


--


--

824


--


--

Chapter 20: Virtual 8086 Mode


A Special Case
- -
- -- - -
- -
-

- - - -
- - - -
- - -
-

re

-
-

POPF/PUSHF Handling

U
nR
eg

is

te

- --
- - - -
- -
- - - - -

Software Interrupt Instruction Handling


- - -
- - --
-- - -
- - -
-- - -
--

Software Interrupt Handling in Protected Mode


--
- - - - -
-- -- - --
- -
- -- -

825

x86 Instruction Set Architecture


Software Interrupt Handling in VM86 Mode
-- -
- - -
-
--
- -
--
- - --
-

te

- - -- -

- - --

U
nR
eg

INT3 Is Special

is

re

- - -- -
- - - -
- - -

- - -
-

-- --

- - - - -

826

Chapter 20: Virtual 8086 Mode


-

-

-

-
- -- - - -- - -
- -
--
- - -
-
-- - --
- -
-- -
-- - - -
- - -
- - - -
- -
- - --
-
-

U
nR
eg

is

te

re

-- --

-

-


-- - --
- - -
-
- - - -- - -
- -
-
- -
-
-
-
- - -
- ---

827

x86 Instruction Set Architecture


-

-- --

- - -
-- -


- -
- -
- - - --
-
-
- - - --
- - - -
- - -

-
- - -
- -
- - - --
-
--

828

U
nR
eg

is

te

re

-
- - -
- -
- - - - -
- -
--
--
-- - -
- - - -
- - --
-- -
-

- - - -
- - -

Chapter 20: Virtual 8086 Mode


-

-
- - - --
-- -
- - --
- - -
-- -
--
-- - -
- -
-
- - - - -
-
- - -
- -
- - -
- - - - -
- - - --
-
-- -
-

- - - -
- - -

is

te

re

U
nR
eg

-- --

VMM Passes Control To Real Mode Handler


-
- -- - -
- -
- - -
-- - - -
-

829

x86 Instruction Set Architecture

-
- -
- -
- - - - - -
---

re



- ---
- -

--

is

te

--
-- -
- - - -
-- -
- --
-

U
nR
eg


- -
-

- - - - -
- - - - - -
- - -
- - -
- - - -

-- - -
- -- - -- - -
- -
-- - -
-

- -
-- - - -

830

Chapter 20: Virtual 8086 Mode


---

is

te

-
- -
-- - --
-
--

re

-- -

--

- - - - --
--
- - -
- - -
- - - - -- -

- - -
- - --

U
nR
eg

-- -- -
-
- - -

- - -
-

- -
-
- -

- -
- --- - -- - --
- - -
-
-

--
--
-

831

x86 Instruction Set Architecture


Halt Instruction in VM86 Mode

re

Protected Mode Virtual Interrupt Feature

- -
-- - -
- - -
- - -
-- --
-- - - -
- -- - -

te

General

is

- -
- - - -
- - - -- -

U
nR
eg

-- -

-- -
-
- -
- - -

- - - - -
- - -
-
- -
-- - --
-

832

- - - -
- -

- - -
- -

Chapter 20: Virtual 8086 Mode


1. Task executes CLI, Clears VIF
-
- - - -
- - - -
- - - -

2. Maskable Interrupt Occurs and Is deferred

U
nR
eg

te

-- - -
- - - -
- -
-
- -
-
-- - -
- -
-

is

re

- - -- -
- - - -

3. Task Executes STI

-
- - - -

- --

- - -
- - -
- - -
- -
-- - - ---
- - -
- -

833

x86 Instruction Set Architecture


Registers Accessible in Real/VM86 Mode
- --

-- -
- --
-
--
- -
--
- - -

re

- -
- - -

te

- - -

is

Instructions Usable in Real/VM86 Mode

U
nR
eg

- --
---
- - --

834

re

The Previous Chapter

is


-
- --

-

-
-

-- --
-- -

U
nR
eg

te

- - -
- - -

This Chapter

- - - - -
- -
- - - -
- - - - - - - -
-

The Next Chapter


-- - -- -
- - --

835

x86 Instruction Set Architecture


Introduction
- - - - -
-- --
-- - - - -
- --

- - -- -
- - -- -

re

- -
- -- -
--- -
-- -- -
-
- --

te

- - - -
- - - -
- -

U
nR
eg

is

-
-
-
-

-
-

-

-

-
-

-
-

-
-

-
-

- -- -
- - - --
- -- -
- - - -
- - -
-- -

836

Chapter 21: The MMX Facilities


Detecting MMX Capability
-- -- -
- -- -- - - - - -- --

The Basic Problem

Assumptions

U
nR
eg

- -- -
-- - -
- - - -- -
- - -
- - - -
-- - - - -
- - -
- --- -

is

te

re

- --
- - --
- -- --

The Operation

-- -

-
-
-
- - -

837

x86 Instruction Set Architecture


Example: Processing One Pixel Per Iteration
- -

re

-
- -

- - -

- -
- - --
- -

-
-- -

U
nR
eg

is

te

- - - - - - -
--- ---
- --- - --
--- -
-

-- -- --- - -
---
--
- -- -
- -- ---
-

Example: Processing Four Pixels Per Iteration


--- -

- -
- -
-
- - -

- - -- -

838

Chapter 21: The MMX Facilities


- - -
- - - -
-
-- - - -
- - - -
- - - - -- -
-

- -


- -

-- - --


-

-- --



-

- - --



-

- - --
-


-

U
nR
eg

is

te

re

- -


- -- --- -
- -
- - -
- --
--- - - - -
- - - - --
- - -

839

x86 Instruction Set Architecture


- -
- -
-

te

re

U
nR
eg

is

-
-
- - - -
-
--- - -

MMX SIMD Solution

-- - - - - --
- - - - - - - -
- - - -
- - -
- -
- - -
-- - ---
- -- - -- - -

840

Chapter 21: The MMX Facilities

--

te

Dealing with Unpacked Data

re

- -- -

U
nR
eg

is

- - - - -
-
- - - -
- - - - -

- - - --
- - --
- --

841

x86 Instruction Set Architecture

re

te

Dealing with Math Underflows and Overflows

- - - -- -
- - - -
- -- -
- -
- - - -
- - -
- - - - - - - -
- -
-
- - -- -
- - - - -
- -
- - - - - -

- - - - -
-- - -
- - -
- - --
--

U
nR
eg

is

- - -

842

Chapter 21: The MMX Facilities


- - -- -
- - --
- - - - -
- -
- --
- - - - -

re

U
nR
eg

is

te

Elimination of Conditional Branches


Introduction

- - -- -
--- -
-- --
- -- --
- - - -
- - - -

843

x86 Instruction Set Architecture


Non-MMX Chroma-Key/Blue Screen Compositing
Example
- - - - - -
-
- -
- - -
- - - -
-

-- -
- - -
- - -
- -- --

-- - - - -

- - -- -

U
nR
eg

is

te

re

- -
- - --
-
- - - -- -

- - - -- - - - - - - - - - -
- - -
- - --
- -
-
--- -
-


844

-
--
- -

Chapter 21: The MMX Facilities


MMX Chroma-Keying/Blue Screen Compositing
Example
--
- - -

-- - -
- - - -
-- - - -
-
- - -

U
nR
eg

is

- - - - -
-
-- -

-- - -- - - -
- -
- - ---
- - - -
- - -
- - - -

-
- - - - - - -
- - - -
- - - - - - - - - -
-
- - - - - - -
- - -
- - - -
- - -
- - -
-- - - - -

te

re

--- --

845

x86 Instruction Set Architecture

-
- - -
- -- - - -

- - -

re

te

is

-- -
- - -

U
nR
eg

-
- - -
- -- - - -

- - -

846

- -

Chapter 21: The MMX Facilities


-
- - -
- -- - - -

- -

re

te

- - - -
-

-
- - -
- -- - - -

U
nR
eg

is

- -

- -

- - - - -
-- -

Changes To the Programming Environment


- --
- - - -
-- - -

847

x86 Instruction Set Architecture

-- -- - --
-- - - --
- - - -
- - -- - -
- -- - -
- -- - - - -
-- -
-- - - -
- - - -
- -- -

re

Handling a Task Switch

MMX Instruction Set Syntax

te

- --

U
nR
eg

is

- - - -
- --
- - - - - -
- - - - -
- - - - -
- - - -
- - -- - - - -
-

848

Chapter 21: The MMX Facilities


-
-

re

U
nR
eg

is

te

849

x86 Instruction Set Architecture


-
-

--

- -

U
nR
eg

is

te

--

re

850

The Previous Chapter

te

re

- - -
- - -
- - - -
- - - - -
- - - -

This Chapter

U
nR
eg

is

- -- - -- - - -- - - ---

The Next Chapter

- -
-


--

-
-
---
- -- -
-- - -
- -
-
-
-
-

851

x86 Instruction Set Architecture



-
- -
- - - -

Chapter Objectives

-
-
-- - -
-- - --

re

- - - -
- -- -
- - -
-

SSE: MMX on Steroids

is

te

- - -

U
nR
eg

- - - -- -
- - - - - -
- - --
--
-- - ---

852

-- - -
- - -


--
-

Chapter 22: The SSE Facilities



-

-- -

-- - - - -
--
-

-
- -
- -
-
- --
- --

- -

- -
-
- - -

U
nR
eg

is

te

re

--
-
- -

- --

- -

-- - --
- -
--

- - -
- --
- -
-

853

x86 Instruction Set Architecture



-

--
- -
- -

--
--
-
-- --
- - -
--
--
- -
-
- --

- -
-
- - -
-

U
nR
eg

is

te

re

854

Chapter 22: The SSE Facilities



-

--
--
--- - -
- - -
- -- --

- --
-- - -
- - -
--

- - --
-
- -
-- -
- - -

-- -
- - -
- - --
-- -
-

re

te

is

U
nR
eg

855

x86 Instruction Set Architecture



-

-- -- --



-- -
- -
-- -
- -
-

-- --
--

-- -
--
- - -

-- -
-- -
-
-- - -
-

-- -
- --
-- - --
- - -
- --
- - -
-
- - - --
- -
--
- -
- -

U
nR
eg

is

te

re

856

Chapter 22: The SSE Facilities



-

-- - - -
- - --
-
-
- -

-- -
--

te

Streaming SIMD Extensions (SSE)

re

is

- --- - - -
- -

U
nR
eg

The Motivation Behind SSE

- -
- -

- - -
-
- -
-
-
-- - -
-
- - --
- - -
- -- - - --

- - -
- - -
-

857

x86 Instruction Set Architecture


Detecting SSE Support
-- -- -
- -- -
-

The SSE Elements

U
nR
eg

is

re

-- -- - -
- -
-- --
- - - - - -
- -- - - --
-- - - -

- - -
- -
- -- - - -
- -
--- -
-
-
-

te

- -
- --

-- -

858

-- --
- -
-- - - - - - - - -
- - - -
-
-- - -

--
- --

Chapter 22: The SSE Facilities

- -- - -
-
-

--

re

te

SSE Data Types

is

- -
-
- -
- -
- -

-- - - -
- -
-

- -

U
nR
eg

859

x86 Instruction Set Architecture


The MXCSR
MXCSR Description
- - -
- - -


- -

te

U
nR
eg

is

-

- -
-
-
-
-
-
- - -
-




860

re


- -

Chapter 22: The SSE Facilities


-

-

-- - -
- -






-
- - - - - -
- -
-
- -
-
-
- - -
- - - - -
- - - -
- - - - - -
-
- - -
- -
-
-
-- -
--
- -
- --

U
nR
eg

is

te

re

861

x86 Instruction Set Architecture


- -

- - -
-
- - -
- -
- - - -
- - -
-
- - -
- -

- - -
-- - - - - -
- - -
-
- -- -
-
- - --
-- - -
- -- -
- -

U
nR
eg

is

te

re


- -

862

Chapter 22: The SSE Facilities


- -

-
- - - -
-- - --
- -
- -- - - -
- - - -
- -
-
- - -
- --
- - - --
- - - -- -
- -
-
- -
-

U
nR
eg

is

te

re

- - - - -

Loading and Storing the MXCSR


-- - -
- - -

SIMD (Packed) Operations


- -
- --
- --
-
-- -
- -

863

x86 Instruction Set Architecture


- - - -
-
-

re

te

Scalar Operations

U
nR
eg

is

- - --
- -
-- - --
-- - - -- - -
- --

Cache-Related Instructions
- - - - -
- - -

864

Chapter 22: The SSE Facilities


-- -- -
- - -- -
- --

Overlapping Data Prefetch with Program Execution

te

re

-- -
- - -
- - -
- - - --
-- - -- -
- --
- - -
-- - -
- - - --
- --- -- - -
- -- - -

U
nR
eg

is

- -
- -

-- - - -
- -
- - --
- -
- - - -- - - -
- - -
- - - -
- - -

865

x86 Instruction Set Architecture


-- - -- -
- - --
-
- -
-

te

re

-
- -- -
-
-
- -
- -
- - -- -
-- -
- -
-
- -- -

U
nR
eg

is

- - - -
- -
- - --
- -- - - -
- - -

-
--
-
--

- - -- --
- -
- -
- -- - -
--- - -
-- -

866

- - -
--
- -- - -
- -- - -- -
- -- -

Chapter 22: The SSE Facilities

U
nR
eg

is

te

- - -
- - - --
- - - - -
- -

-
- - -
- - -- - - -
-- -
- - - - -
- -- -- -
- --
- -
- -- -
-- - --
- - - -

-
- - - - - - -
- -- - -
- - --
---
- - - - -
-- -
- - - -- -
- - -

re

-
-

867

x86 Instruction Set Architecture


-
-


-
-

-

-
--

-
--

re

U
nR
eg

is

te

- - - - --
---

Streaming Store Instructions


- - -
- --
- - - ---
- - -
-- -- --- -
-
- - --

868

Chapter 22: The SSE Facilities


- - -
-- - -
- - - -
- -
- - -
- -
-

- - -
- - -
- --
-

re

--
--

te

- --

- --

U
nR
eg

is

--- -
-

- - -- -
--- -

-

-
-
- -
-- -
- --- -

- - -- -
---
-

-
- - - - -
---

869

x86 Instruction Set Architecture


--- -

-- - -
-
-
-
- - - -
- -
-
-- -
- -
- -
- -
-
- - -
-- -
--
- - -

- -

- - -
--
- -
-

--
--

- -
-
--- - -- ---
--
-- - --
-
--- -
- -
-

-- -
- - -

- -
- -
- - -
- - -
-
- -
-
-- -

- -
-
-- -
- -
- -
-- -
-
-
--
-
- -
-- -
-
-- -

- -
-
--- - -- ---
--
-- - --
-
--- -
- -
-

U
nR
eg

is

te

- --

re

870

Chapter 22: The SSE Facilities


-
- -- - -
-- - - - -- -
- - - -- -
- -
- - --
- - - - -
-

U
nR
eg

is

te

re

- - - -
- -
-- - - -
- --
- -
-

-- - -
- --

-- - - -
- - -
-

- - -
- - - - - - - -- - -
- - -- - -
- - - -

871

x86 Instruction Set Architecture

- - - -
- --- - -
- -- - -

- -
-- - -
- --

-- - - -
- - -

is

te

re

U
nR
eg

- - -- - - -
- -
- - -
- - -

-- - -
-
- - - - -
- -
- - - - -
- --- - -
- -- - -

-
-- - -
- --

872

Chapter 22: The SSE Facilities


-- - - -
- - -
- -
-

- -

re

is

An Example Scenario

te

Ensuring Delivery of Writes Before Proceeding

U
nR
eg

- - ---

- - -- -
- -
-- -
- -- -
- - - --
- -- -
-
- - - -
- -
- -
- -- -
- - --
- - -
- - -

-- - -
- - - -

873

x86 Instruction Set Architecture


--
---
- - -
- - -
-
-- - -
- --
-

SFENCE Instruction

is

te

re

- - - -
-- - -
- --
-- -- -
--- - - -
---
- -
- - - - -

U
nR
eg

-- - -
--- --
-- -
-- -
- - - -
-- -- - - -
- - -

- - - -
- -- -
- - - -
- -- -
- - - -
-
- - --
- - -
-- - -
- -

874

Chapter 22: The SSE Facilities


- -- --

re

- - -
-- -- -
-
- - - -
-- - -
- - - --- - --
- - -
-- - -- -- -
--

-
-

- -

U
nR
eg

is

te

- - -

-
-

-
-

-
-

875

x86 Instruction Set Architecture


- -

-
-
-

-- -
- - -

-
-
-

-
-

re

-
-

te

U
nR
eg

is

- -- - -

-
-

-
-

-
-

-
- --
-
- - --
- -

876

Chapter 22: The SSE Facilities


-- - - - -

-
-
-
-
-
-
- -
- --
-- -
--
- -
- -

--
- -
--

-
-

re

-
-

te

U
nR
eg

Background

is

Elimination of Mispredicted Branches

- -- --
- - - -
- --
- - - - - -
- - - - --
- - --

SSE Misprediction Enhancements


-- -- - - -
- - - --
- - - - -
- -
- - -- - --
- -- -
- - - -
- - -- - -

877

x86 Instruction Set Architecture


- - -
-

re

-
- -
- - - - - -
- --
- - - - - - -
- -
- - -
- - -
- - -
- -
- -- -
- -
- -

U
nR
eg

is

te

- - - - -
- -
- - -
- - - -
-- -- --
-

Reciprocal and Reciprocal Square Root Operations


- - -
- -

- - -
- - -
- - -
- - -
- - -
-
- -

- -- --

878

Chapter 22: The SSE Facilities

re

MPEG-2 Motion Compensation

-- - - -- -
- -- - - -- --
-
- -- - - - --
- - - - -
- - -- - --
- - -
- - - - --
- - - --
- -

U
nR
eg

is

te

- -- - -
-- - -
- - -
--- -
- - -
--- -
- - - -
- -
- - - -
-- - - -
- - -- -
- -- -
- -
- - - -
- - - - --
-
-
- -- - - -
-- -
- - -
- - --
- - -
- -
- -

879

x86 Instruction Set Architecture


Optimizing 3D Rasterization Performance

- - -
- - -
- - - -
- - -
- - - -
- - -

re

Optimizing Motion-Estimation Performance

--
--

U
nR
eg

is

te

-- -
- - - - -
- - -- -
- - - -
-- - - - -
-- - --
- - - -

- -
- - -
- -
- - - -
- -- -
- - - - --
-- - - - -
- - - - -
- - - -
- -

Accuracy vs. Fast Real-Time 3D Processing (FTZ)


- -

880

Chapter 22: The SSE Facilities

-- -- --
-- - - - --
- - -
- - --
--

- - -
- - -
- - - - - --
- -- - -- -

SSE Alignment Checking

is

-- - -
-
- -
- - - -
-- -

te

re

-- --
-

U
nR
eg

The SIMD FP Exception

-
-
- -
- - --
--- -- - -
--- -
-

Saving and Restoring x87/MMX/SSE Registers


General
- - - - -
- -- - - - -
- - -- -

881

x86 Instruction Set Architecture


MXCSR Mask Field
- - - - -
- --- - - --
- - -- --
- - - - ---
- - - -
-- - - -- -
- -
- -- - -

-
- -
- - - - -
- - -

te

re

--
- - - --
- -
-- - -
-

U
nR
eg

is

- - - -

- -
-
- - - -
-
-
- - - - -
- - - - -
--- -

882

Chapter 22: The SSE Facilities


-

-
-
-
-
-
-
-
-

U
nR
eg

is

-
-
-
-
-
-
-
-
-
-
-

re

te

OS Support for SSE


General

-- - - -
-- -
- - --

883

x86 Instruction Set Architecture


- - -- -
- - - -
--- - - - -

Enable SSE Instruction Sets and Register Set Save/Restore


-

re

- - -- -
- - --
- -- - -
--

- - -
-- - -
-- -
- -
- -

U
nR
eg

is

te

- - -
- - - - --
-- -
--

-- -

Enable the SSE SIMD FP Exception


-
-
- --
- -- -
- -

884

Chapter 22: The SSE Facilities


-
- - - - - -
- -




- -- -

--

--

re

te

--

SSE Setup

- - - -
-
-

- -- -
-
- - - - -- - --

U
nR
eg

is

- -- -
- - --

Summary of the SSE Instruction Set


- - --
- - - - --

-- -
-
-
- -

885

x86 Instruction Set Architecture

--

--

--

---

--

--

--

--

--

--

---

is

U
nR
eg

---

--

--

---

--

---

--

-----

886

te

--

re

--

Chapter 22: The SSE Facilities


The SSE2 Instruction Set
General
- -
-- -- - -
- -
--
- -
- -
-- -
- -
-- - - -
- - --
- -- -
- -- -
- -
- --

re

te

is

U
nR
eg

DP FP Number Representation
- - -

- --
- - - -- - -
- - - -

887

x86 Instruction Set Architecture

-

-

--

- -- -

SSE2 Packed and Scalar DP FP Instructions

is

te

--
--
--
- --
--
- --

U
nR
eg

re

-- - -
- -

SSE2 64-Bit and 128-Bit SIMD Integer Instructions


-- -

888

-
-
-
- -
- - -
- - -
- - -
- - -
- -
- -
- -
- -

Chapter 22: The SSE Facilities

--
-
--
-

SSE2 128-Bit SIMD Integer Instruction Extensions

--
-
-- -- - -- -
- - - --

re

- - - -
- - -
- -

te

Your Choice: Accuracy or Speed (DAZ)

U
nR
eg

is

- - --
- - - - - -
-- -- -
- - -
-- - - -
- - - -
- - -- - -
- - - -

- - - -
- - - -

- - -
- - -

- - -- -
- - -
- - -
-- -- - -
-
- -

889

x86 Instruction Set Architecture


- --- -
- -
- --
- - - -
- -

- - -
- - -- -

- -
- - -
- - - --
-

re


- -

U
nR
eg

is

-

- -
-
-
-
-
-
- - -
-

te


- -

The Cache Line Flush Instruction


- - - --

890

-- -- -- -
- - - - - - - - -
- - --
- - - -
- - -

Chapter 22: The SSE Facilities

U
nR
eg

is

re

--- - - - -
- - - -
- - - -

- - - - -
- - -- -

- - -
- - - -
- - -
-- - - - -
- -
- - -
- -- -
- -
- -
-- - --
- - -
-- --
-

te

- -



--



--- -

Fence Instructions
MFENCE Instruction

- - - -
- -- - - - --
--- - -

891

x86 Instruction Set Architecture





---
-
--

re

-- - --
- - -- - - -
- - --
- - - -

U
nR
eg

is

te






- -

- -

- - - - -
- - - - -
-- -- -
--
-- - - - -- -
-
- - --
-- -
- - - - - -
- -- - -
- - - -
--
- - - -
- - - - -
- - --
-

892

Chapter 22: The SSE Facilities


LFENCE Instruction
-


re

- - - -
--- -
-
-- - -
-- - - - -
- -
--- - -

is

te

-
-

U
nR
eg

- -- - -
-- -
- -
- - -




- -

- -

- - - - -
- - - -
- -- --
- --
--
- - - -- - -
- - --

893

x86 Instruction Set Architecture


-- -
- - - -
-

- - -
-- --
- -- - - -
- -- -
- - --
- -- - -
-

re

- - --
-- - -
- -
-

te

SFENCE Instruction

is

- - - - -
- - -

U
nR
eg

Non-Temporal Store Instructions


Introduction

-- - -- - - -- - - -
- - --
- - - -
--

-
-
-
-

- --

MOVNTDQ Instruction
- - -
- - -

894

Chapter 22: The SSE Facilities


- - - - -
-- - - -
-
- -- - - - - -

te

- - - -
- --- - - -

- -- - -
-
-
-- - -
- --

-- - - -
- - -

re

is

-
-

U
nR
eg

MOVNTPD Instruction

- --
- - --
- - -
-- - -
- - - -- -
- -
- - -- - - - - -

895

x86 Instruction Set Architecture

- - - -
- - ---
- - -
- -- - -

- -
-- - -
- --

-- - - -
- - -

re

-
-

te

U
nR
eg

is

MOVNTI Instruction

- - --
- - - -
-- - - -
-
- -- - - - - -

896

- - -
- --- - - -

- -- - -
-
-
-- - -
- --

Chapter 22: The SSE Facilities

-- - - -
- - -

-
-
-

re

- -

MASKMOVDQU Instruction

te

- -

U
nR
eg

is

-- - - -
- -
- - - - -
- -

-- - -
-
- - - - -
- --- - -
- -- - -

- -
-- - -
- --

-- - - -
- - -
- -
- - -

897

x86 Instruction Set Architecture


- - - - ---
- - - - - - -

-
- -- -
-- - -
-
- -- -- -
- -
- - -
- - - - - - -

re

- -

U
nR
eg

is

te

- -- - - - -
- - - - -
- -
- -

PAUSE Instruction

- - --
- -- --- -
-

Thread Synchronization
- - -- -- - -
- - -
-
- -
- - -- -

898

Chapter 22: The SSE Facilities


-
- -
-
- - -

- -
-

The Problem

U
nR
eg

is

-- - -
- -
-- - -
- - - -

te

re

- - - - -
- -- -
-

- -
-- - - -
- ---
- -
- - - - - -
-- - -
- - - - - - --
- - - --
-- - - -
- - - -
-
-- - -
-- - -
- - -- --
- - -

-- -

899

x86 Instruction Set Architecture


The Fix
- -
- -- - -- - -
-- - --
- - - -
- - - -
- - - - -
- --

re

- -- -
- - --
- - - -
- - -
- -- --

te

- - -
- -

is

-
-

U
nR
eg

-
-

-

-
-


- -
- - -
- - -



-

- -
- - - -
-

900

Chapter 22: The SSE Facilities


-



-
-
-

When a Thread Is Idle

is

Spin-Lock Optimization

te

re

-
- -
- - -
- - -- - -
- --
---
--

U
nR
eg

- -
- -
-- - - -
- - - -

- - --- - - - -
-
- - -- -
- -
- -
- - - - - -
- -
- - - -

Branch Hints
- - - -
- -

901

x86 Instruction Set Architecture


- - - - - -
--- -- -
- - -
-- -

SSE3 Instruction Set

Introduction

U
nR
eg

is

- -
- -
-
--

-- --

-
- -

- --
--
-- -- -
- --
--
-

te

re

-- - -
-- --
-

-- - - --

Improved x87 FP-to-Integer Conversion Instruction


The Problem
-
-- -- - -
- --
-

902

Chapter 22: The SSE Facilities


- - -
- - -
--
-
- -
- --
-


-

re

- - - -
- - - -

te

The Solution

U
nR
eg

is

- - -
- -- - -
- - - - - -
-

-- - - -
--

New Complex Arithmetic Instructions


-- -
- -

-
- - -
--
- - -
- -

- --
- --

903

x86 Instruction Set Architecture

te

is

U
nR
eg

-
-

re

- -- - -
--

- - -

--

Improved Motion Estimation Performance


The Problem
- - -
- - -
-- - -
- - - - -

904

Chapter 22: The SSE Facilities

--
--
-- --- - - --

-
- - --
-
- - -
- -- ---
-

The Solution

te

re

- -
-- - - - -
- - -- - -
- - - - - - - - - - --
-

U
nR
eg

is

- - --

- - --

-- -- - --
-
- - - -

The Downside
- - - -
- --

905

x86 Instruction Set Architecture


Instructions to Improve Processing of a Vertex
Database
- - -- - -
- - - - -
-
-
-
- - -
- - -

- - - -
- - - -

te

re

- -- -

U
nR
eg

is

- -
- -- -- - -
- - --
- - -
- - - -- - - - - -- - -
- - -
-- -
-- - - - --
- --
---

906

Chapter 22: The SSE Facilities


- --
-

-
-

-

re

is

te

U
nR
eg

MONITOR/MWAIT Instruction Pair


- -- - -
-
- --
- - - -
- -

Background

- - - -
- - - -
- - - -
- -- -- -
--- -

-- - -
- -- - -

907

x86 Instruction Set Architecture


-- --
-- - - -
- - --
- - -
--- -
-- - - -
--

Monitor Instruction

- -- -
- -- - - -
- - -- - -
- -- -
-- - - --
---
-
-
-- -
- - -
- -
- - -

U
nR
eg

is

te

re

- - -

- --

-- -- - -
- --
- - -

-- -- - -
-

Mwait Instruction

- - -

908

- -
- - -
-- -
- - -

Chapter 22: The SSE Facilities


- --

-- - --
- -
- -- -- -- -

- -- - -
- --
- --
- -- - - -
- - - -

Example Code Usage

- -
- --
- -
- - -
-

- -
-
-

U
nR
eg

is

te

re

- - - - -

The Wake Up Call

- - -- -

- -- --
-- - -
-
- -- --

- -
-- --
- -

909

x86 Instruction Set Architecture

-- --
- -

-- --
-
-
-- --

-- --- -
-- --- -
- -- --
- --
-- --- -- --
- --

re

te

SSSE3, SSE 4.1, and 4.2

--
-
-

U
nR
eg

is

- - - -
-- - -
- -

- - - - - - -- -- - -- -
--- - -
- - - -
- -

910

re




The Previous Part

is

This Part

te

- --

U
nR
eg

- -
--- -


-- -

The Next Part

- - -

re

te

is

U
nR
eg
d

re

The Previous Chapter

This Chapter

te

- - - --
- - --

U
nR
eg

is

- - -
-


--

-
-
---
- -- -
-- - -
- -
-
-
-
-


-
- -
- - - -

913

x86 Instruction Set Architecture


The Next Chapter
- - -- -

The Big Picture

- -
- - - -

-- -- -
- -- -
- -- -
- -- -
-- - - -- --
-
- -- - -
- - -- --
-
-- - -
-
-- --
- -
- -- -
-- -- -
- - - -
- -
- - - - -
-
-
- -
--
- -
- - - --

U
nR
eg

is

te

re

-
- - --
-- --- -
- -

914

Chapter 23: IA-32e OS Environment


-- -- -
-
- - --- -
- - -
- --
-
- -
- -
- - -- -
- -- -- -

- - --
--- -
--- - - --

--- -

- - --
--- -

--- -
--- - --

- - -
- - - --
- --
- - - -
-

U
nR
eg

is

te

re

915

x86 Instruction Set Architecture

re

te

U
nR
eg

is

- -
- ---
-

Mode Switching Overview

Booting Into Protected Mode


- - - - -

916

-- - - - --
- - - -

- - - -- -- --- - - - -- -
-

Chapter 23: IA-32e OS Environment

- -
- - -- - -
- - - -
-- -- --
-
-- --
- -
-

re

- -

Initial Switch from IA-32 to IA-32e Mode


- - -

- - -- - -

- - -- -
- -

-- - -
-- -
- -
- - - -- -
-- - -
- -- - - - -
- -
- - - - -
-
--
- -

U
nR
eg

is

te

- -
- - - - - -
- - -
-- - -

917

x86 Instruction Set Architecture

- - -
--
-- -


- - -- - -
- -- -

-- -
-- -

is

te

re

- -- - - - - - - - - -
-- -- - -
- -
- -- - - -- - - --
- - -
-- - - - - -
-- - -- -
-

U
nR
eg

- -

918

Chapter 23: IA-32e OS Environment

U
nR
eg

is

te

re

919

x86 Instruction Set Architecture


CS D and L Bits Control IA-32e SubMode Selection
- - - - -- - -
- -

-
- - - --
-
- - - --

te

re

-- - -
- - - -
-- -
- -- --

- -
- -
- - -
- -
-- -

U
nR
eg

is

-- --
-

- -- - - -
- - - - - - - -
- -- -- -
- - - -
-- - - - - - - - -- - - -

920

-- - --
-- - --
-- -
- -- - - -
- - - -
-
-- - -- - -
-- -

Chapter 23: IA-32e OS Environment

-- -

- -
- --
- - - - -
- - -
- - -

--- - - - -
- -

re

- -


-- -- -
- - -- -
-- -


-- -- -
- - -- -
-- -

U
nR
eg

is

te


- - - -- - - -
- -
- - -
- -
- -
- - -
- -
- - -
-- -
-- - - -
- --
--- -

921

x86 Instruction Set Architecture

- - --


- -

- - --

- - --

- - - --

- -

- - -

- --


-
- -
- -
-
-- -
- -
- -- --
- -
-- - -


- -
-
-
- -

- -
- -
-



-
- -
- - -
- -

- -


-
- -
-
- -

--
- - - --
- --
- -

U
nR
eg

- - - --
- --

re

te

is

- --

- - - -

Old and New Applications Running Under a 64-bit OS


-- -
-- -
- -
-- - -
-- - --
-- - - -
-

922

Chapter 23: IA-32e OS Environment


Things You Lose In IA-32e Mode (hint: not much)
- -- -
-

U
nR
eg

re

te



- - - - -
-- -
-
-- -

- - -
- - - - --
-
-- - - -
-- - - -- -
- - - -
-- --
-- - -

- -- -
- -
- -- -
- --

is

Old Applications Live in an Expanded Universe


Old Legacy Universe = 4GB or 64GB

-- - - ---
- -- - - -

- - - -- -
- -- - - -

923

x86 Instruction Set Architecture

-- -- -
- -
- -- -
--
-- - - - --
-- - - -

- -
-
--- -
- -

re

is

- - -- -
- - -
- -- - - -
-- -
-- -
- - - - -- -
--
-- -

te

U
nR
eg

IA-32e Universe Is At Least 16 Times Larger


-
-

-- -
- - --
- -
- -- -
-- -
- --
-
-- - - -- - --
- --
- --

- - - ---
-- - -
- - - - -

924

Chapter 23: IA-32e OS Environment


-
- -- - -
-

-
- --
- -

Virtual Memory Addressing in IA-32e Mode

re

Virtual Address in Compatibility Mode

is

te

- - -- -
- - - -- --
-- -

--
--

U
nR
eg

- - - - - --
-- - -- -
-- - --

-- - --
--- -
- -- --
- - -

- - - - - --
-- - -- -
--
-- - --
--- -
- -- --
- - -

925

x86 Instruction Set Architecture


Virtual Address in 64-bit Mode
- - -- -
-- - -- - -
-- - - - -
- -- --
- - ---
--

--

re

--

- -- - -
-- --- -
-

--

- -- - -
-- --- -
-

U
nR
eg

is

te

--

- -- - - -
-- --- -
-

--

- -
- - -
- - -- - -
- - --
- - -
-

In Compatibility Mode, Segmentation Is Operative


- --- -
-
-- -

926

Chapter 23: IA-32e OS Environment


In 64-bit Mode, Hardware-Enforced Flat Model
General

re

- - - -
- -- --
- -
-- -- -
-- --
- -

New Segment Selector Causes Descriptor Read

- -- - -
-
--

is

te

- -- -

U
nR
eg

- - - -
-- - - -- - -
-- - - - - -
- - -- - - - -

Segment Register Usage in 64-bit Mode


- -- -
-

-- - - - - -- -
-
- - -- -
- -
-- -
- - - -- - -

927

x86 Instruction Set Architecture

re

- - - - -
- - --
- -
- -- - -- -
- - - -

- - - - - - -- -
-
- - -- -
- -
-
-- -- - -

U
nR
eg

is

te

-- - - - -- -

928

Chapter 23: IA-32e OS Environment

-
-

- -
- - --
- - - - - -
-
- - -- -
- -- - --
- - - - -- -- - -
- -- - - --
-- - --
-- -
- - - -
- - -
-
- - -
- - -
- - - -
- -
-
-
- - -
-
- - -- --
- -
- -
-
-- - --
- -- - -- -
- --

U
nR
eg

is

te

re

929

x86 Instruction Set Architecture


-

-- - -
- -- -
- - -
- - - - - - -
-
- - -
-- -- -- - -
-- - - - -
- - - -
- - - -
-
- - -- -
- -- - --
- - - - -- -- - -
- -- -
--
-- - --
- - - - - --
- -- - - -
-- - -
- - -
-
- -- - -
- -
- -- - -
- - -
-- - -

-- - -- -
- - - -
-- - --
- -- -
-- - - --
- -

U
nR
eg

is

te

re

930

Chapter 23: IA-32e OS Environment


-
-

- -- - - - --
-- - - - -- -
- - - - -
- - -
-- --- -
- -- --- -
- - -- - --
-- - - - -- -
- -
- -- - - -- - -
-- - - - -
- - -- -
- - - - --
- - -
- - - - --
- -- -
- -
- --
- -- -
- -- -
- -
- - -- --
- - -- - -
- - -- -
- - - - - - - - --
- - -
- - - --

re

te

is

U
nR
eg

931

x86 Instruction Set Architecture


-

U
nR
eg

is

te

re

-
- - -
- - --
- - -
-
- -
-- - -- -
- - -
--- - -
- -
- - -- -

932

Chapter 23: IA-32e OS Environment


-

-
- -
- -

- - -
-

- -

- --

- -- -
- -
- - -

- --

- - --

- - -- -
- - -

-
- -
- -

-
- - -

re

te

is

-- --
- - --

U
nR
eg

-
- -
-

- - - - - - -- -
- - - - - - -
- - -- - - - -- - -

933

x86 Instruction Set Architecture

-
- -
- -

- - -
-

- -

- - - --

- - --

- -
- - -
-

- - -- -
- - -
-
- -
- -

te

- -- -

re

U
nR
eg

is

-
- - -

-
- -
-

-- --
- - --

- - - - - - -- - - - - - - - - -- - - - -- - -
-- - -- - -- --
- - --

64-bit Mode: No Limit Checking = No Limits?


- -- ---
-- - --
-- -
-- - -
-- -
-- - - -- - - - --

934

Chapter 23: IA-32e OS Environment


-- -
- - -
- - -- --
- --

- -- - -- -
- -- -- -
- -
- -- - - -
- -- - -- -
- -- ---
- -- -
-- - - -- --
- -- -
-

U
nR
eg

is

te

re

- -- - -- -- - - -- --
-- -- - - -- --
- --
-
- --
---

Table Limit Checks Are Performed


-- - -- - - - -
-

Stack Management

Stack Management in Compatibility Mode


- --- - - -
- - -

-- -
-

935

x86 Instruction Set Architecture

- -
- - - - -
- - - -
- - - -
-
-- - - -
- -- - --
- - -
- - -

re

te

- - - -
-- - - - - -
-
-- - -
- -- -
--
- -

-
-
-- -

is

U
nR
eg

Stack Management in 64-bit Mode

- - - -
- - - - -
-
- -
- - - - -
--

-- - - - -
- -
-- - - -- - - -

936

-- - -
- - - - -- -- - -
- - -- - - -
- -- -- -
--

Chapter 23: IA-32e OS Environment

U
nR
eg

is

te

re

- - -
- - -
-- - - -
-- -- --- - - ---
- - - -- --
-- - --- - -
-- - -- - ---
- - - - -- --
-
- --
---
-- - -- -- --
- - -- - -
-- -
- - -- - -
- - - -- -
-- - --
---
-- - - -- -- - - - ---
-- -
-- -- -
- - - - - --
- -- - --
---
-- - --
-- - - - --
-- - -
- - -

Segment Override Prefixes Other Than FS/GS Are


Ignored
-- - --
-
- - - -- - -- - -
-- - -- - --

937

x86 Instruction Set Architecture


Protection Provided by Paging
- - - -
- - - - -
-- - - -- -
- - -- -
- - - -
- - -- - -

Segment Registers Preserved On Mode Switch

re

-
- - - -- - -
- - -
-
-

U
nR
eg

64-bit Instruction Pointer

is

te

Instruction Fetching

-- - - - -
- - - - - -
-

- -

- - - -

938

Chapter 23: IA-32e OS Environment


- -

- - - -

--
-- -
- - -
--
- -
- - -

RIP-Relative Data Accesses

re

U
nR
eg

is

te

-- -
- - -- -
- - - -
- -

- -

Changes To Kernel-Related Registers and Structures


Address Translation Mechanism
Basic Description
- -- - - - -

939

x86 Instruction Set Architecture

- - - --
-- -- - --
- --
-- -- -
--
- --
- -- - - - - - --
- --

Top-Level Directory Placement

U
nR
eg

Detailed Description

is

te

re

-- - -- -
-- - - - -
- -- -
- -- - -
- - - - -
- - -
- - - -
- - -- --

- -- - -
-- -

GDT/LDT Descriptor Changes


-
-- -- -

940

Chapter 23: IA-32e OS Environment

- -

- - - - - -
- - --
- - -
--

-- -
-- -
--
-- - -
- - - -
- -
--
--
- -
--- -- -- -
- -- - -
- - -
--- - - --

U
nR
eg

is

te

re

- -
- -- - -
--- -- -- -

--
-
- -- - - -
--- -- --

941

x86 Instruction Set Architecture


- -
-

- - -
- -


-- - -
- - -- --- -
- --
--
- -
-- -


--

- - -
- - -


- -- - -
- -
-- - ---
- - --
- - -
-- -

- -- -
-- -
- - -- - --
- - --

U
nR
eg

is

te

re

942

Chapter 23: IA-32e OS Environment


- -
-

- - - - - - - - - - - - -
- - - -
- - -

- - - - - - -
- - -- --- -
- --
--
- - -
-- -

is

te

re

U
nR
eg

- -


- -


- -

-
-

-
-

- -

943

x86 Instruction Set Architecture


- -


- -


- -

- -

-
-

- -

- -

te

re

U
nR
eg

is

944

Chapter 23: IA-32e OS Environment

- - --
- -
-

-
- - - -



- -

te

-
-
- -

- -- -
- - - -
--

U
nR
eg

- -
- -

is

-
- --
-
- - -

re

- - -
-

- -

945

x86 Instruction Set Architecture

- --

- --

- --

- --

- --

- --

- --

946

-
-

- - --
- -
-

- -

-
--

- --

---

- - - -
- -
-
-

- -- -
- - - -
--

U
nR
eg

re

te

is

- - -
-

- - -
-

- -

Chapter 23: IA-32e OS Environment

- --

- --

- --

- --

- --

- --

-
-

- - --
- -
-

- -

-
- - -

-
--

- --

---

- - - -
- -
-
-

- -- -
- - - -
--

U
nR
eg

- --

re

te

is

- - --

- - -
-

- -

GDT and GDTR Changes


GDT Descriptor Types

- - - -

947

x86 Instruction Set Architecture

- -

--

- - -- -
-

--

- - -- -

--

-
-

-- - - - -

-
- - -
- - - -- -
-- -
-
- --

U
nR
eg

is

te

re


-
--

--
- - - - -

-- -
- - -
- -


-
--

--
- - - - -

-- -
- - -
- - - --

948

Chapter 23: IA-32e OS Environment


- -
-

- - - - -
- - -
--
- - - - -

-- -
- - -
- -

re

is

te

- - - - - -
--

Executing LGDT in Compatibility Mode

U
nR
eg

- -
-- - - - -
- -- - - - -
- - -
- - - --
---

- - -
- - - - - - - -
- -
-- -
- -- -- -
-- - -
- - -
- - - - - - - -
- -
-- - - --

949

x86 Instruction Set Architecture


-
-
- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --

- --
- - - -

- --

re

is

te

- --

- -

U
nR
eg

- -
- -

Executing LGDT in 64-bit Mode


- -
-- - --
- -

950

Chapter 23: IA-32e OS Environment


-


- --

re

- -

te

Unaligned Accesses to GDT or LDT

U
nR
eg

is


- -- -- - -
- - - - --
-- - -- -
- - - - --
- - - -
- - -

-- -- - - - -
- - -
- - - - -
- - -
-- - - -
- - - --
- - - --

951

x86 Instruction Set Architecture


--

-
-

-
-
-

te

re

--

is

U
nR
eg

-
--

- --

- --

LDT and LDTR Changes


LDT Descriptor Types
- - - -

952

Chapter 23: IA-32e OS Environment

- -
-

--

- -


-
--

- - -


-
--

- - -

- -

is

te

re

U
nR
eg

- - - - - -
--

LDTR Contents in IA-32e Mode


- -
- - - -
- - - -- -
- -- -- - -
-
- - - -
- --
- - - - -
- -- -

Unaligned Accesses to LDT


---

953

x86 Instruction Set Architecture

- - -

- -

- - - --

- - --

te

re

-
-
-
- -- -
-

-
- - - -- -
- -
- -- - --

U
nR
eg

is

- - - -

954

Chapter 23: IA-32e OS Environment

- -
-

re

--

te

U
nR
eg

is

- - - -
- - -
- -

IDT/IDTR and Interrupt/Exception Changes


IDT Descriptor Types

- - -
- - - -
-- - -
- - -
--
- - - -

955

x86 Instruction Set Architecture

- -
-


-- -
-- -
- - -
- -- -
- -
- -



-
- -
- -
- -

-- -
--
- - -
- -
- -

U
nR
eg

is

te

re

- - - - - -
--

956

Chapter 23: IA-32e OS Environment

--

--

--

--

- -

-
-
- - --
- -
-
- -

-- -
-
-- -
- -
-- -- --
- - -
-
- -
- -

-
-
-

U
nR
eg

re

te

is


-- --

957

x86 Instruction Set Architecture

--

--

--

--

- -

-
-
- - --
- -
-
- -

-- -
-
-- -
- -
-- -- --
- - -
-
- -
- -

-
-
-

U
nR
eg

re

te

is


-- --

Interrupt/Trap Gate Operational Changes


- - - -- -
-- -- -
- - -- -
- --
- - - -
-
- -
- - - - --

958

Chapter 23: IA-32e OS Environment

re

- - -- - - - - - -
-
-- -
-- -- - -
- -
--
- - ---
-
- - -- -

- - - -


-

te

U
nR
eg

is

-- - --
-
-- --
-
- -- -
-
- - -

- -- -
- - - - -
- - - -- - --
- - -
- -

-- - - - -- -
- - -
- - - -
--
-
-- -- - - -
-- -

959

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-
-- - - - - - --
- - - - -
-
- - -

-
- - -
-- - -
- -
- -
-- -
- - -
-- -- - - -
- - --
- -- - -
- - - --
- - - - -
-
- - -

- -
- - - -- - -

- -
-
- - -
-- - - -
- -
- - -
- - - - -
- - -

-
- -- -
-- --

- - -
- - - -
-- - - -
- - - -

960

Chapter 23: IA-32e OS Environment


- - -
- - - - - - - -

is

te

re

U
nR
eg

- -

- - -
-
- -

961

x86 Instruction Set Architecture

re

-- -
- -
-

-
--
-


-

U
nR
eg

is

te

- --

-
-

- -


-
--

962

- - -
- - - - -

- - - -
- -

Chapter 23: IA-32e OS Environment


Executing LIDT in Compatibility Mode
- -
-- - - - - -
-- - - -
- - -- -
- - - -
- - - -
- -- ---
- - -
- - - - - -
- - -
- -
-- - -
-- -- -
-- - -
- - -
- - - - - - - -
- -
-- - - --

is

te

re

U
nR
eg

- --
-

- -

Executing LIDT in 64-bit Mode


- -
-- - --
- -

963

x86 Instruction Set Architecture


-


- --

re

- -

te

All Accesses to IDT Are Properly Aligned

U
nR
eg

is

- - - ---
- -- - -- -
--

IA-32e Call Gate Operation


General

- -
-

- - -
--

- -
- --

964

Chapter 23: IA-32e OS Environment


-

-
- - -

- -
-

- -

re

IA-32e Call Gate Detailed Operation

U
nR
eg

is

te

- -
- - - -

965

x86 Instruction Set Architecture

- -
-- - -- - -

- -
--

- -- -

- - - -

- -
-

is

- -

U
nR
eg

- - -
-
-- -
-
-- -

te

re


-
- -
-

- - -
- -
-
- -- -
- --

- -
- -

-
-

-
-

IA-32e Call Gate Stack Switch


- - - -
- - - - - -
- -
- - -
-

966

Chapter 23: IA-32e OS Environment

- -

- - -

- - - -

- -
-
- - -

- -
- -
- -
- - -

- -

-
-
- -

-
-

- - -

- -


--
-


-

-

-


- --
- -
-- -

U
nR
eg

is

te

re

967

x86 Instruction Set Architecture

- - --
- -
-

-
- - - -



- -

te
-

-

-

- -
- -

-
-
- -

is

- -- -
- - - -
--

U
nR
eg

-
- --
-
- - -

re

- - -
-

- -

TR and TSS Changes


Real World TSS Usage

-- - -
- - - - -
- - - --
- - - - -

968

Chapter 23: IA-32e OS Environment

--
- - -
- - - -
-

- - - -
-- -- -- -
-- --- -- - - --
-- -
-

U
nR
eg

is

te

- -
-
- -
-
- -- -
- - -- --
-
- --
- -
- - -- -
- - --
- - - - -

re

- - - - -
-- - -- --

- - - -- - -
-
- - -
- -- - -

969

x86 Instruction Set Architecture

- -

-
- -
- -
- -- -
-
-
- - -- -
- -
- - - - -

re

-
-
-
- -

- - - --

U
nR
eg

- --

is

te

-
- --

- - --

970

- --

-- - - -

Chapter 23: IA-32e OS Environment

- - - - -
- --
-

re

is

te

U
nR
eg

-
-

-
-- -

--
--
--
--

--

-

971

x86 Instruction Set Architecture

- --

- --

- --

- --

- -

- --

- --

972

- - --
- -
-

- -

-
- - -

-
--

- --

---

- - - -
- -
-
-

- -- -
- - - -
--

U
nR
eg

re

te

is

- - --

- - -
-

- -

Chapter 23: IA-32e OS Environment

re

te

U
nR
eg

is

- - - -
- - -
- --
- -

Illegal For Jump or Call To Select a TSS Descriptor


- - - - -
- --- - - - -
- - - - -

Executing LTR in Compatibility Mode


- -- - - -
- - - -
-
-- - - - -
- - - -

973

x86 Instruction Set Architecture


- -- -
- - -
- - - - --

- -

-
- -
- -

- -

- - - --

- - --

- -- -
-

-
- -- - -
- -

re

- - - -

te

is

- - - - --

U
nR
eg

- - - -

Executing LTR in 64-bit Mode


- - -- - - -
- - -- - -
-

Revised TSS Structure

-
- -

974

- - -
- - -- - - - -
-
-
- -
-

Chapter 23: IA-32e OS Environment

- -- - - -
- - - - -


- - - - -- - - - - -
- -
- - - - -

re

U
nR
eg

-
-- -

-
-

te




--
-

--
--
--
--








- - - -
- --

-- -

is

--

-

975

x86 Instruction Set Architecture


TSS Usage
-- --- -
- -
-
-

-

-

--

- - -
-

-
--

- -
-

te

re

is

U
nR
eg

-
- - - - -
- -
- - - - -
-- - - -- --
- - - -
- - - -
-

-
- - -
- -

Register Set Expansion (in 64-bit Mode)


-- - - - -- -- -

976

Chapter 23: IA-32e OS Environment

--
--
--
--

-- - - - - -
- -- -- -
- --
- -
- --

te

Switching to a 64-bit Task

re

Schedulers Software-Based Task Switching Mechanism

U
nR
eg

is

- - --
- -- -
- -
- - - - -

- - - - -
- - - - - - -
-
- - -- -
- - -- -- -
- - --- - - --- - ---

- -
- -
- -- - -
- - -- - -
- - - - - - - - - -
- -
- - - - -
--- - -
- -

977

x86 Instruction Set Architecture


- - - -
- - -
- -
- -
- --
- - - - - - -
-- - -

- -- - - --
- - -
- -- -
- - - - --
-- - - --
-- - - - - - -
-
-- - - --
- - - --
- -
- - -
-- - - - -
- - - - -
- -
- -
- - - - - ---
-
- -
- - - - - - -- - -

- - - -
- -
- -
- - - - - -
- - - - -
- - -
- -
- - - - - --
- - - - --- -
- - --

U
nR
eg

is

te

re

978

Chapter 23: IA-32e OS Environment

U
nR
eg

is

te

re

- -- - - - - -

- -
- -
-- -
-
- - -- -
- - - -
- - -
- -
- - - - - -
-
- -
- -- - - -
- - - -
-- -
-
-- - -

- -

--

--

- - - - -
- - - - -

- - - - -

- -
- - - - -

Switching to a Legacy Task


General
--- - -
- - - - -

979

x86 Instruction Set Architecture


-
- --
-- - -
- - - - -
- -

is

te

re

- - - -
- - - -
-
- - - -
- - -
- - - -
- - -

- - - -
-
- - - -

U
nR
eg

- -
- -- -- -
-

Data Segment Register Initialization


- - - - --
- - - - -- -
- -- -
- - -
-- - -- -
-

CS and Instruction Pointer Initialization


- - -
--- - -
- - --

980

- -
- - -

Chapter 23: IA-32e OS Environment



- -

- - - -
- -
- - -- - -
--
- - - -

The Switch

- -- -
-- - - - -
- - - -
-
- - - - - - -

- - - -

- -- --


-- --
-- --
- - - -
- -

re

te

is

U
nR
eg

-- -- --
- - - -

- -

- -
-

-
--

- - - -
- - - - -
- - - - -

- -

- - - - -

981

U
nR
eg

is

te

re

x86 Instruction Set Architecture

982

--

re

The Previous Chapter

is


--

-
-
---
- -- -
-- - -
- -
-
-
-
-


-
- -
- - - -

U
nR
eg

te

- -
-

This Chapter
- - - -- - - -
-

983

x86 Instruction Set Architecture

The Next Chapter

re

--
-
-
--
-- -





--


-
-

te



-
--
-

-
-
--

U
nR
eg

is

- -
- - -

Theoretical Address Space Size


-- - -
- - ---
- --- -
- - --

984

-- -- -- - -- -

Chapter 24: IA-32e Address Translation

- --
-- - -- -
-- -

Limitation Imposed by Current Implementations


- -
- -- -

-- - - -
- -- - -
- - -

re

is

te

- -- -
- - - -- - -
-- -- -
- - --

U
nR
eg

Four-Level Lookup Mechanism

Address Space Partitioning



-- - - -- - - -

- - -
- --
-- -- --
- - - -
-- -
- - --
- - - -
--
-- -- --
- - - -- -
- --
- - - -
-- --

985

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-- --
- -
- - --
- -
- - --
- - - -
-- --
-- -
- - - --
- -

986

Chapter 24: IA-32e Address Translation

U
nR
eg

is

te

re

-- - -

987

x86 Instruction Set Architecture


The Address Translation

Initializing CR3

- - - - - - - -- - - --
- - ---
- --- -
- - -- -

U
nR
eg

is

te

re

-- - - - - -
- - -- -
- -- -
- --
- - --
- -- - -
- -
-- - -
-- -
- - -- -

Step 1: PML4 Lookup

-- -- - - -
- -
- - --

988

Chapter 24: IA-32e Address Translation

U
nR
eg

is

te

re

-- -

989

x86 Instruction Set Architecture

- -

-
- -
- -

- - --

- -- - - --
-
-- - --
-

--

--

--

--

- -

-- -
-

re

-
-

- -

U
nR
eg

Step 2: PDPT Lookup

is

te

- - - -- -
-
- - -
- ---
--

-- -- -
- - - - --

990

Chapter 24: IA-32e Address Translation

U
nR
eg

is

te

re

-- -

991

x86 Instruction Set Architecture

- -

-
- -
- -

- - --

- -- - - --
-
-- - --
-

--

--

--

- -

-- -
-

re

-
-

- -

is

te

- - - -- -
-
- - -
- ---
--

Step 3: Page Directory Lookup

U
nR
eg

-- - -
- - - - - --

- -
- - -- --

- - -
- - --
- -
- - --

-- - - - - --

992

Chapter 24: IA-32e Address Translation

U
nR
eg

is

te

re

-- -

993

x86 Instruction Set Architecture


- -
- - - - - - --
- -
-
- -- - - -

- -

-
- -
- -

re

- - --

- -- - - --

te

- -

-
-- - --
-

--

--

--

is

- -

U
nR
eg

-- -- -
-
-
-
- -

- - - -- -
-
- - -
- ---
--

- -
- - -
- -- - - - -- - -
- -- - - -
- - - -
- - -- -

- - -- -

994

Chapter 24: IA-32e Address Translation


- - - -
- -
-
-- - - -

- -

-
-
-
-
-

-
- --

-
-- - --

is

-- --
-- -
-- -

-
-
- -

U
nR
eg

te

-
-

- - -
- --

re

- -

- - - -- -
-
- - -
- ---
--

995

x86 Instruction Set Architecture

U
nR
eg

is

te

re

996

Chapter 24: IA-32e Address Translation


Step 4: Page Table Lookup
- - -
-
-- -- - -
- - -
-- - - - -
-
- -- - - - -

re

- - -- - - --
- - -- -

te

- -- - -
- -

U
nR
eg

is

- -

-
-
-
-
-

- -

- - --


-

-- --

--
-- -
-- -

- -
- - -

- - - -- -
-
- - -
- ---
--

997

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-- -

998

Chapter 24: IA-32e Address Translation


Page Protection Mechanisms in IA-32e Mode
Page Protection in Compatibility Mode
-- - --- - - - - -
-- --

re

Page Protection in 64-bit Mode

-- - - -- -
- - -- - -- -- -
- -- -- -
-- - -

--
- -- -

is

te

-- - --- -
-- -

U
nR
eg

- - - -
- - -
-- - -

- - -
- -
- -- - -
-- - -
-- -- - - - - --
-- - -

-- -- -- -
- -- -- -
- - -- - - --
- - -- - -

999

x86 Instruction Set Architecture

- -- -- -- -
-- - - -- - --
- - - - -
-- - -- - -
--
- - - -
-- - - -- -
- -- -- -
-

te

re

-
- - ---
- ---
- --- - -
-

Dont Forget the Execute Disable Feature!

U
nR
eg

is

- -
- -

1000

Chapter 24: IA-32e Address Translation

--

-
-

-
- -
-

- -
-
--

- -
-
--

re

te

is

- -
-
--

U
nR
eg

1001

x86 Instruction Set Architecture

-- --

-
-

- - - -- - -

- -
-- - - -
-

re

-
- -

- -
-- - - -
-

U
nR
eg

- -
-- - - -
-

te

is

-- -
-

1002

Chapter 24: IA-32e Address Translation


--- -


-
--
- - -
- -
-- - - -


-
-

te

is

U
nR
eg

re


-
-

1003

x86 Instruction Set Architecture


--- -

-
- - -
- -- -


-
-

is

U
nR
eg

te

re


-
-

TLBs Are More Important Than Ever


- - -
-
- - - -
--- - - -
-

1004

Chapter 24: IA-32e Address Translation


No 4MB Page Support

U
nR
eg

is

te

re

-- - - - -
-

1005

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1006

re

The Previous Part

is

This Part

te

U
nR
eg

- - -
--

The Next Part

- - -

re

te

is

U
nR
eg
d

The Previous Chapter

te

--
-
-
--
-- -





--


-
-

U
nR
eg

is

re

- -
-- - - -
-

This Chapter

- - -
- - -



-
--
-

1009

x86 Instruction Set Architecture


-
-
--

The Next Chapter

te

re

-
- -
--
- -
-
--
-
--
-
-
-

is

U
nR
eg

Initial Entry to Compatibility Mode

- - -
- -

Switching Between Compatibility Mode and 64-bit Mode


-- - -
- - -
-- - -

--

1010

-
- - - -

Chapter 25: Compatibility Mode


Differences Between IA-32 Mode and Compatibility Mode
IA-32 Background
- - - --

Unsupported IA-32 Features

te

- - - - - -
-
- - - -- - -

-
-
-
-- - -
- -- - -

- - -
- -


- -- - --
-

U
nR
eg

is

re

- -
-

Changes to the OS Environment


- - - -

1011

x86 Instruction Set Architecture

-
- - -
-- ---

- - --
-- -

-- - --
--

-- -

- - -
-

- -- -
- - - - - -
-
- -
- - -
-

U
nR
eg

is

te

re

-- -

-- -

- - - -

- -

--

--- -
- -
--

- --

- - -
-- -

- - -- -
-

1012

Chapter 25: Compatibility Mode


-

-
- -- - -- -
- -- --

--
-- -
-

- --
--- -

--- -
--- -
--

- --
--- -
--- - -
--
--- -

U
nR
eg

is

te

re

Memory Addressing
Segmentation

-- - -
- - - -
-

-- -
-- -
- - -- - -- -
-- - - -
-- - - - - -

1013

x86 Instruction Set Architecture

-- -
-- -
- - -- - -- -
-- - - -
-- - - - - -

FS/GS Segments

Virtual Address

U
nR
eg

- --
- -- --
- --
- -- -- -

is

te

- -

re

- -- - - -
-- - -- -
- - -- -

Address Translation

-- - - -
-- - - - - --
- -
-- -- -- -
-- - - - ---
--- -- - -

1014

- -- - - -
-
- -- -

Chapter 25: Compatibility Mode


Register Set
Visible Registers

-- - - - -
-- -
-

--

- -

--
--
--
--
-

--
-- -

- --

- -- -

- --

- --

- --

- --

--

--

- --

U
nR
eg

-
-- -

--

is

te

re

-
-
-
- -
--
- -

- ---
--- -
--
- -

--

--

- -

1015

x86 Instruction Set Architecture


No Access to Additional or Extended Registers

-- --

re

--
-- --- -
- -- -
-
--
-- --
--
--
-
- -
--
--

te

is

Control Register Accesses

U
nR
eg

- --- - - - - --- -
-- ---
- - -- -
-

Debug Register Accesses


- --- - -
- - - --- -
--

Register Preservation Across Mode Switches


- - - -
-
- - - - -
- --

1016

Chapter 25: Compatibility Mode


- - -

- - -
-
- -
-

Exception and Interrupt Handling

U
nR
eg

re

te

- ---
--
- -- -
- - - - -
-- - - --
-- --
- -
- - -
- -
- -
- - -

- - - -
-- -- -
- --
- - --- -
- - - - - -
- - - - - -
- - - - - -

is

-
-

OS Kernel Calls
Call Gates
- - -
- -

1017

x86 Instruction Set Architecture

- -- - --
- - -- - --
- - --- -
- - - - - -
- - - - - -
- -
- - -
- --
- -

re

Kernel Call Instruction Usage


SysEnter Instruction

U
nR
eg

--- --

--- --
--- - --

is

te

- -
-

SysCall Instruction

- -
-

1018

--- --
--- - - --

--- --

Chapter 25: Compatibility Mode


Odds and Ends
IRET Changes
- - -
-- -

re

--

--


- - -

- -
- - - -
- -- -
- - - -- -
- - - - -
- -

U
nR
eg

is

te

- -

Segment Load Instructions


- - - -- -
- - -
-- - - - - -
- --

- - - - -
- - -

1019

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- - - -- - -
- - -

1020

The Previous Part

re

- -

te

This Part

-
- --
- -

U
nR
eg

is

- - -
--- -

The Next Part

- -

re

te

is

U
nR
eg
d

re

The Previous Chapter

- -
- -

is

te



-
--
-

-
-
--

U
nR
eg

This Chapter

- -

-
- -
--
- -
-
--
-
--
-
-
-

1023

x86 Instruction Set Architecture


The Next Chapter
-- -

-

--
--
--
-- -
--
- --
--
--
-
--

te

re

is

Overview of 64-bit Register Set

U
nR
eg

-- -- -
-- -
- -- - -
- - - -
-

1024

Chapter 26: 64-bit Register Overview

-- -

-
-- -

- -

--
--
--
--
-

--
-- -

--

--

--

--

- --

- --

- --

U
nR
eg

- --

- -

is

- -

te

re

--
--

--

- -

EFER (Extended Features Enable) Register


- -
- --
- -- -
-- -- --

1025

x86 Instruction Set Architecture


- -

- -
-

-
-

re


-- -


-- - -

te

- - --

is

- --

U
nR
eg

1026

- - -
-- - -
-- - - - -
- - --
- -- -
-
- - - --
-- - -
-
- - -

- -
-- - -
-- - -- - -- --
- - - --
-

Chapter 26: 64-bit Register Overview


- --

-
- -
-- -
-- - -

- --
- - - - - - - -
-- - - -
- - -
-
-

-
- --- -
--
- --

- - - -
- -
-- --
- - --

U
nR
eg

is

te

re

- - - -

Sixteen 64-bit Control Registers


-
- --
--- - -- - -
- - -
- - - -
- - -- -

- -- -- -
-

1027

x86 Instruction Set Architecture

- - - -
-- -
-- -- - --
- -- -- -

-- -- --
-- - -

--

- - -
- - -
- - -
- --

- -
-

is

te

re

-- -
-- -
-- -
-- - - - --
-
- --


-- -- - --
- -
-- - -
-- - -

- - -- -
-
- - -- -- -

-- - ---
- -- -

U
nR
eg

1028

-- -

Chapter 26: 64-bit Register Overview


-- -
-

- - -
- - -
- - -
- -
- --

-
- -
-- -

- - - - -
- - --
- -- --
- -
-

--- - -
-- -
-

-
- -- -
--

U
nR
eg

is

te

re

--

1029

x86 Instruction Set Architecture


-

-

te

re


-
-
-
--

U
nR
eg

is


-

-


-
-
-

--

--

1030

Chapter 26: 64-bit Register Overview

- -



- --

- - -
- -- -
--

re

- - -- - -

te

--

is

U
nR
eg

- --

1031

x86 Instruction Set Architecture

- - - - - -
- -

re

- -- -

--

--

te

is

--

U
nR
eg

- --

- - -

- -
- -




-- -
- - -

--

1032

Chapter 26: 64-bit Register Overview

- -

64-bit Rflags Register

te

re

- - - - - -
- - - -
- - - -
- - --

U
nR
eg

is

- -

-
-

Sixteen 64-bit GPRs

-- -

- -- -
-
-- --
--
--
-- - --
- - - - --
- --

1033

x86 Instruction Set Architecture

re

- -
-- -- - --
- -- -
- - -- --
- - - - --
- --
- -- --
- - - --
- - - -
- -
-- - -- --

te

--

is

U
nR
eg

-- - - -

--

- -

-- - - -
--
-- -- -

1034

Chapter 26: 64-bit Register Overview

--

is

te

re


-- - - - -
-- - --
- -
-- -- --
-- -- --
- -
- -

--
--
--

U
nR
eg

- - - -- -
-
- - - - - - -
- - -
- - - - - - -
- - -
- - - - - -
-- - - - - --

1035

x86 Instruction Set Architecture

- - -

re

is

te

U
nR
eg

Kernel Data Structure Registers in 64-bit Mode


- -- - - -

1036

- -

- -

- -

-
-

Chapter 26: 64-bit Register Overview


SSE Register Set Expanded in 64-bit Mode

-- - - - -
- -- - - -
-- - -
-- - - - - --
- --

re

- -

is

te

U
nR
eg

--

1037

x86 Instruction Set Architecture


Debug Breakpoint Registers
-- - - - - - -
- -

U
nR
eg

is

te

re

-- - - - - - -
- -
-- -

-

- -- -
- -- -

- - - - -

- - -- - -
-
- - - -
-
- -
-- - -- - -
--

- - --

- -
-
-

1038

Chapter 26: 64-bit Register Overview


Local APIC Register Set
- - --
-
-

x87 FPU/MMX Register Set

re

- - --
-

te

Architecturally-Defined MSRs

U
nR
eg

is

- - - -

1039

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1040

-
--

The Previous Chapter


-

is

te

re

-
- -
--
- -
-
--
-
--
-
-
-

U
nR
eg

This Chapter

- - -


-

--
--
--
-- -
--
- --
--
--
-
--

1041

x86 Instruction Set Architecture


The Next Chapter
-- -

--
--
--
-- --
--

-

- - -

re

te

Helpful Background

U
nR
eg

is

- - -
- - --
- - -

Switching to 64-bit Mode

- - -

The Defaults

-- - - -- -
- -
- - --- - - -

- -
-- - -

- - -- - -

1042

Chapter 27: 64-bit Operands and Addressing


The REX Prefix
Problem 1: Addressing New Registers
- -- - - - -

- - -
- - - - -

- -
- - - -
- -
- -- -

te

re

-
--
--
--

U
nR
eg

is

- - - - - -
- -- --
- -

- - - - -
- - - --
-- -- -

- - - - -
- -- - - -

- - -
- -

- - - -
- -- - - - - -

1043

x86 Instruction Set Architecture

- - -

- -


-
-

- - --
-
-- --

- - - -
-
- -- -- -- -
- -
- - -

te

re


- - - --
-
- - -
- - -
- -- -

U
nR
eg

is

- - -

- - - -







- -
-- -

1044

-
-- - -

Chapter 27: 64-bit Operands and Addressing


-

- -

te






-
-
-
-

re

is

Problem 2: Using 16- and 64-bit Operands

U
nR
eg

- - -
- - - -
- -- - - -
-- - - -- -
- - -
- -- - -
-
- - -
- - --

Solution: The Rex Prefix

- -- - - -
-- - - -- - - --
- -

1045

x86 Instruction Set Architecture


Making Room for REX
-- -- - - -
-

- --
-- - -
-- -
- --
-- - -
-- -

is

-
-
- -


-
- - -
- -
-
-
- -


-
- - -
- -

U
nR
eg

te

re

- -
-- - - - -
-- -
- - -- -
- --

REX Prefix Placement


- -
- -- - -

1046

Chapter 27: 64-bit Operands and Addressing


- - - - - -
- - -

- - -- -

- - - - - --

- -
-

re

- - - -

-- -

--

U
nR
eg

-
--

is

te


- -

-
--

--

- - - - -

- -

When You Need REX...

- --

-- - - - -

-- -

--
-

1047

x86 Instruction Set Architecture

--
--
--
- - -
- - - -

...and when you dont


- - --

is

te

- -
--
-- --
-
- -- -
- - - -
- -
-

re

--

U
nR
eg

1048

Chapter 27: 64-bit Operands and Addressing


--
--

te

re



-
-
- -
- -
- -
- -
- -
- -
- -
- - -
- - -
- -
--

U
nR
eg

is

- -
- -
- -
- -
-
-

- - - --
- -- - --
- - - - -
-- - - - -

Anatomy of a REX Prefix


General
--
- - -
- - - - -
- - - - -

1049

x86 Instruction Set Architecture


-
- -- -
- - -
- - -

U
nR
eg

is

te

re

- - - -

-

- - -
-
- - -

1050

Chapter 27: 64-bit Operands and Addressing

U
nR
eg

is

te

re

1051

x86 Instruction Set Architecture


The Width Bit

-- - -
-
- - - - -
- - - - -

te

-- - - - -

-- - -
- -

re

-
- --
-

U
nR
eg

is

1052

-
- -

Chapter 27: 64-bit Operands and Addressing


The Register Bit
- --
- -
- -
-- - - -
- - -

- - -
- - - -
-

re

- --

-- -

te

-- -

is

-- - -- -

U
nR
eg

- - -
-
- -
- -
- - -
-

1053

x86 Instruction Set Architecture


- -

-
-


-
- - --
-
-- --

- - - -
-
- -- -- -- -
- -
- - -

is

- -

- - -

U
nR
eg

te

re


- - - --
-
- - -
- - -
- -- -


- -

1054

Chapter 27: 64-bit Operands and Addressing



-

te

U
nR
eg

re

is


- -

The IndeX and Base Bits

- -
- - - --
- - - -
- -
- --
- - - -
- - -- -

- -- - -
-- -

1055

x86 Instruction Set Architecture

- -
- --

- - - - -

-- - - - --
- - -

-
-- -- - --
- - - -
- --

re

-- -
-- - - - - - -
- -

U
nR
eg

is

te

- - -
- - -- - - -

- -- - -
-- - -

-- -

- -
-
- -

1056

Chapter 27: 64-bit Operands and Addressing


-- -

re

te

is

U
nR
eg

- - -- -
-

--

-
-
-

- - -- -

1057

x86 Instruction Set Architecture


-- -
--
-- - - -
- - -
- -- -- - - --

-
- -- - - -
-

Addressing Registers Using REX[B] + Opcode[Reg]

is

te

re

-- --
- -
- -- -- -
-
- --
- - - - - - --
-- - - -

U
nR
eg

Addressing Registers Using REX[B] + ModRM[RM]


- -
- - -
- -
- - -
- - - - - - --
-- - - -

Byte-Register Addressing Limitations


-- --
- - - - -
- - -
-- - - - --
- -- - --

1058

Chapter 27: 64-bit Operands and Addressing


Sometimes, REX Fields Have No Effect
- --

-- -
- - -
- -- -
- -
-- - - - -
-
- -
- -- - - - - -
-- - -

is

te

Addressing Memory in 64-bit Mode

re

64-bit Mode Uses a Hardware-Enforced Flat Model

U
nR
eg

- -
-

CS, DS, ES, and SS Segments Start at Virtual Address 0


- -- -
-- - - -- - -
- -- - -- - - -- -
-- -

-
--

- --- - -
-- - --
- - --- - --

- - - -- - -- - -

1059

x86 Instruction Set Architecture

- -
- -- - - - -
-- -- -- -

CS/DS/ES/SS Segment Override Prefixes Ignored


- - -- - -- -
- - - - -

FS and GS Segments Can Start at Non-Zero Base Addresses

is

te

re

- - - -
-- -- -- - -
- - - - -
-- - -
-- - - - -- - --
- - -- -
-- -- -

U
nR
eg

-- - - - --
-- - - -
- -- - - --
--

- - - -
- - - -

--

-- - - -- - - - -- -

FS/GS Segment Override Prefixes Matter


- - -- - -- -
- - - - --

1060

Chapter 27: 64-bit Operands and Addressing


Default Virtual Address Size (and overriding it)
- - --- -- -
- - - -
- - -
-

- -
-- - -

re

- - - -
- - -
- -

U
nR
eg

is

te

-- - - -
- -- --- -

1061

x86 Instruction Set Architecture

- - --


- -

- - --

- - --

- - - --

- -

- - -


-
- -
- -
-
-- -
- -
- -- --
- -
-- - -

- --

U
nR
eg

- - - --
- --

- -
- -
-


re

-
- -
- - -

te

is


- -
-
-
- -

- -

- -


-
- -
-
- -

--
- - - --
- --
- -

- --

- - - -

Actual Address Size Support: Theory vs. Practice


1062

Chapter 27: 64-bit Operands and Addressing

-
--
- - -
--
- -- - - -
- -
--

-
- -- - --
-
- - --
-

re

U
nR
eg

General

is

Canonical Address

te

- - - -
---

- - - -- -
- - -- -
-- - - --- - - -- -
- - -- - --
- - - -
- -- -
-

- - - - -
- - - - -

--- - -
- -- - - - - -
- -
- - - ---
-
-- -- - -
--

1063

x86 Instruction Set Architecture


32- (and 16-) bit Addressing Limited to Lower 4GB
--
- -- - -
-- - - - - --

- -- - - -
- ---
-- - -
- -
- -

-- -

te

re

- ---
- - -
--- - -
--- -

U
nR
eg

is

-- - - -
-- - -- - -
- --
-- - -- - -
- - ---

-- - -
- -
- -

- -

1064

- ---

- -- --

Chapter 27: 64-bit Operands and Addressing

--

-- - - - - ---

re

--
-- - -

te

Memory-based Operand Address Computation

U
nR
eg

is

-- -
- - -
-- -
-- --- -

- - -- -
- - - -
- - --
-- -
--- -


- - - - -
- - - - -

-- -
- -- - -
- - --
-
-- -- -
- - - --
- -
-

1065

x86 Instruction Set Architecture


- - - -
- --
-
- - - -- -
- -

re

- - - -
- - -- - -
-

1066

--

is

-- - - -
- - - -
--

U
nR
eg

te

-- -

-- - - -
- - -- -
- --

-- o
- -

Chapter 27: 64-bit Operands and Addressing


-- -

--
-- -
-- -
-
-
- o
o
o

- - -- - --
-
-
- -
-
- - - - -
- - -

U
nR
eg

is

te

re

--

1067

x86 Instruction Set Architecture

- -
-

-
-


-
- - --
-
-- --

re

- - - -
-
- -- -- -- -
- -
- - -

is

te


- - - --
-
- - -
- - -
- -- -

U
nR
eg

--
-

1068

--
-

--
-

Chapter 27: 64-bit Operands and Addressing


-- -

-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-

-
-
-
-
-
-
-
-

re

-
-
-
-
-
-
-
-

te

is

U
nR
eg

- --

- -
- -
- - - -

RIP-relative Data Addressing


- - --
- -
-- -
- - -- - -- -
--
- - - -
- - - -
- -
- -
- - - -
-- -

1069

x86 Instruction Set Architecture

- - - -
- - - - - -- -
- --
-- -
- - - -- -
-- - --

re

- --
-- - -- -
- - - -
- -

U
nR
eg

is

te

-- - - -
-- - - - --
- - - -- -
- -- - - - -
- --

Near and Far Branch Addressing


- - -

1070

Chapter 27: 64-bit Operands and Addressing



-- - -
- - -
- - - -
-

-- - -
- - -
-- -


- -


-- -
- - -
- -

-- -
- - -
- -
-
-- - - -
-- -

U
nR
eg

is

te

re

1071

x86 Instruction Set Architecture


-


-
- -
-


- -
-


- - -
-


- -
-
- - -
-


- -


-- -
- - -
- -
-
-
-- - - -
-- -

U
nR
eg

is

te

re

1072

Chapter 27: 64-bit Operands and Addressing


-

-
- -
-


- -
-


- - -
-


- -
-
- - -
-

U
nR
eg

is

te

re

Immediate Data Values in 64-bit Mode


- -
- - - -- -
- - - -
- - - - - -

-
-
-

- - -
-

-
- -

1073

x86 Instruction Set Architecture


-- - -
- - - -

Displacements in 64-bit Mode


-- - -
--- - - - -
- - - -
- - -
- - --

U
nR
eg

is

te

re

- - -
-- - - -
- - - -
-- -- -
- - - - - -

1074

- -

- - -

te

re


-

--
--
--
-- -
--
- --
--
--
-
--

U
nR
eg

is

The Previous Chapter

This Chapter

- -- -

--
--
--
-- --
--

-

- - -

1075

x86 Instruction Set Architecture


The Next Chapter
-- -- -
-

- --
--
-

re

New Instructions
General

is

te

-- -- -

U
nR
eg

- --

SwapGS Instruction
The Problem

- - -
-- -- -
-- - - -
-- - --
- - -- -
- - - - - -- -
- - - --
- -

1076

-- -- - - - - - - -
-- -

Chapter 28: 64-bit Odds and Ends


- - - -
- - - - -
-

The SwapGS Solution


- - - - - -
-- -
--

re

- - - --
- - - --
- --
- - - -

U
nR
eg

is

te

- - -
-- -- - -
- - - -
-
- - - -

- -


- - - -
- --- - -

- - - -

- - - - -
- - - -- - --
- - -

- --

- - - - -

- -- - - -
- -- - -

-
- --
- -

1077

x86 Instruction Set Architecture


-- - -

- - -
- - -
-
-- - -
-- -- - - --
- -
- - - -
- --

re

MOVSXD Instruction: Stretch It Out

U
nR
eg

Enhanced Instructions

is

te

-
--
- - - - -- -
- - -
-- -

-- -- - -

--

-
-- -- --
- -- -

1078

Chapter 28: 64-bit Odds and Ends


--

-
- - - -
-
-

- --

--

re

- -
- -

- -
- -

is

- -- - -
-
- -
- -- -
-- -
-
- -

U
nR
eg

te

Invalid Instructions

-- - -- -
- -

1079

x86 Instruction Set Architecture

--

- -

re

te

is

U
nR
eg

- -

- - -

1080

Chapter 28: 64-bit Odds and Ends


--

--

re

Reassigned Instructions

te

- - --
-- -

U
nR
eg

is

-- --

- -
- - - - -

-- --
-- - - -- --
--
-

LAHF/SAHF Instruction Support


- -- - - --
-- -

1081

x86 Instruction Set Architecture


Instructions That Default to a 64-bit Operand Size
Stack Operations

re

-- -
-
- - -- - - -
-- - -- -- -
- - -

te

--
-

U
nR
eg

is

- -

- -

- - -

- -

- -

- - -

- - -

1082

Chapter 28: 64-bit Odds and Ends


--

- - - -

- - - -

- - - -

- - - -

te

re

- - - - -

is

Near Branches

U
nR
eg

Branching in 64-bit Mode

Short/Near Branches Default to 64-bit Operand Size


- -
-
--

- - -
- - -
-- -
-
- - -
- - -
- -

1083

x86 Instruction Set Architecture


- - -

-
--
-
--
--
-
-

Unconditional Jumps in 64-bit Mode

te

re

- - -
--

-
-

is

1084

U
nR
eg

-

- -

-- o
-
-
- -
o - -
-

-

- -

-- o
-

-
- -
o - -
-

Chapter 28: 64-bit Odds and Ends


-


-

- -

-
-- -- -
-
-

-
- -

- -
-- - -

- -

- -
-- - -

re

U
nR
eg

is

te


- -
-- - -

-
- -

-

1085

x86 Instruction Set Architecture


-

-
-
-- -
- -- - -
-

-
-
-- -
- -- - -
-


- -
-- -- -

U
nR
eg

is

te

re


- -
-- -- -

- -
- - -
- -

1086

Chapter 28: 64-bit Odds and Ends


Calls/Ret/Iret in 64-bit Mode
Instruction Forms in 64-bit Mode
-- -
-- -- -

-
-

re

-
-

o -
-
- - -

-
-

- -- -

- -- -

is

U
nR
eg

te

- --
- -
- -- -
- - -

- -
--

- -- - -
- -

1087

x86 Instruction Set Architecture


-


- - -

-
- - -
-
--
- - -
- -
- -
- -

1088

is


- - -
-- - - - -

- - -
-- -

-

- -

U
nR
eg

te

re


-
- -
- - --
- - -

- -
--
- - -
- - --
- - -

- - -
-
- -
- -

Chapter 28: 64-bit Odds and Ends


-

is

te

re


- -
-
- -
- -
- -


-


--
- -
- -

- - -
-
-
-

U
nR
eg

Example Call/Return Operations


- - -
-- --
-
- - -- -
- -

- -
-- -- -
- -- -

- - --
- - - - - - - -

1089

x86 Instruction Set Architecture


- - -- - -
-
- - -
-- - -
-- - - -
-

U
nR
eg

is

te

re

-- -
- -
- -- --
- -

--
-- -

- -- - -
-

-
-- -- - - -
--
- - - - -
-
- -

- - - -
-- - - - --
- -
- - -- -

- -- - - -
-
- - -
-
-- --
-
-
- --
-
-
-- - --

1090

Chapter 28: 64-bit Odds and Ends


- - - -
- - -- -

- -
-- -- -
-

- - -

U
nR
eg

is

te

re

-- -
- -
- -- --
- -

--
-- -

- -- - -
-

-- -- - -

-- - -
-- - -- -
--
- - -
-

-- -

-- - -
- -
-- -
- -
-
- - - --
- - -
-- -- --
-- - -
- - -
-

1091

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -- --
- - -- -
-- -
- - -- -
- -
-- -
-- - - --
- --
-- -
-
- -- - -- -
-
-- - -- -
- - - - -
-- -
-- - -
-
--
- - - - -
- -- -
- - -
-- -- - -
- -- - - -
- -- --

-- -- -
-
-- -- - -
-
- - -
- - - -- -

- -- -
-- - - -
-- - - - --
- -
-- -- - -- -

1092

Chapter 28: 64-bit Odds and Ends


-- -- -
-

- -

- - -

is

te

re

-- -
- --
-
- - -- -
- - - - - - - -

-
-- - - -
-
-- -- -
- -- -
- -
-- -

Conditional Branches in 64-bit Mode

U
nR
eg

-- - -
- -- -
-

- - -

- o - -
- - - -

- o - -
- - - -

1093

x86 Instruction Set Architecture


-
-

-

-

-- o -
- - -

-
-

- -
- -

-- o -
- -

re

U
nR
eg

is

te

1094

Chapter 28: 64-bit Odds and Ends


-
-

- -
- - - - -- -
-- - - -
- --
- - -- - -- -
- - - -
- - - -
-- - -

o
-
- -
-- - -

o
-
- -

is

te

re

U
nR
eg

-- - -

o
-
- -
-- - -

o
-
- -

1095

x86 Instruction Set Architecture


-
-

- - -- - -- -
-
- -
-
- -
-- o
-
- -

- - -- - -- -
-
- -
-
- -
-- o
-
- -

1096

U
nR
eg

is

te

re

- - -- - -- -
-
- -
-
- -
-- o
-
- -

- - -- - -- -
-
- -
-
- -
-- o
-
- -

Chapter 28: 64-bit Odds and Ends


NOP Instruction

re

-- - -
- --- --
- - - -
- - -
-- - -
- - -
-
- -- - -
- - -
- -

is

General

te

FXSAVE/FXRSTOR

U
nR
eg

-- -
-- -- -



- - -

-- - -
-

Fast FxSave/Restore Feature (AMD-only)


- - -
-
-- -- -
- -- -

1097

x86 Instruction Set Architecture

-
-
-
-
-
-
-
-

is

U
nR
eg
1098

-
-
-
-
-
-
-
-
-
-
-

te

re

Chapter 28: 64-bit Odds and Ends

-
-
-
-
-
-
-
-

te

U
nR
eg

is

-
-
-

re

1099

x86 Instruction Set Architecture

- -
-


-- -


-- - -

U
nR
eg

is

te

- - --

re

-
-

1100

Chapter 28: 64-bit Odds and Ends


U
nR
eg

is

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

re

-
-
-
-
-
-
-
-

te

The Nested Task Bit (Rflags[NT])


-- --
- - -- -
- - -
- - -- - - -
- - - - - --
-
-- -- -- - -

1101

x86 Instruction Set Architecture


-
- - - - - -
-- - - -
- - -
-- - -- - -
--

IA-32 Processor SM Save Area

SMM Save Area

is

- --
- -- - - --

-- - --
-- -- - - - -
- -
- --
- --
- - --
- -- -- -
- -
- --

U
nR
eg

te

re

-- -
-- - - -- - -
--- - -- - - --
-- - -- - -
--

- - - -
-- -
- - - -- -- -
- -
- -
-- -
-

1102

Chapter 28: 64-bit Odds and Ends


- - - - -- -
-- - -- -
- -- -- - - - -- - -
-- -
-- -
-

---

U
nR
eg

is

te

re

--

--
-- ---
-- ---

- --

--

1103

x86 Instruction Set Architecture

-- -

-
- -

is

te

re

- - - -
-- --
- -
-
-

U
nR
eg

1104

Chapter 28: 64-bit Odds and Ends


-- -

-
- -

- --
-
-- --
- -
-
-

- --
-
-- --
- -
-
-

- --
-
-- --
- -
-
-

is

te

re

U
nR
eg

- --
-
-- --
- -
-
-

1105

x86 Instruction Set Architecture


-- -

-
- -

- --
-
-- --
- -
-
-

- --
-
-- --
- -
-
-

is

te

re

--

- - -

- -

- - -

U
nR
eg

Intel 64 Processor SM Save Area


-- - -- - --
-- -- - - - - -
-

1106

Chapter 28: 64-bit Odds and Ends

- --
- --
- - --
- -- --
-- - -
- - --

re

-- - - -
-- -- -
- - - -- --
- - -
- -
-- -
-

is

U
nR
eg


-
- -

te

--

- -

- -

- -

1107

x86 Instruction Set Architecture


--

- -

- -

- -

- -

- -

--

U
nR
eg

te

re

is


-
- -

1108

Chapter 28: 64-bit Odds and Ends


--

-
- -

- -

is

te

re

- -
- -

U
nR
eg

1109

x86 Instruction Set Architecture


--

-
- -

- -
- -

- -
- -

U
nR
eg

is

te

re

- -
- -

- -
- -

- -
- -

1110

re

The Previous Part

is

This Part

te

- -

- -

- -
-
- -
-

U
nR
eg

The Next Part

- -- -


-

-

re

te

is

U
nR
eg
d

re

The Previous Chapter

- - -

is

te

--
--
--
-- --
--

-

- - -

U
nR
eg

This Chapter

- -- -- -
-

- --
--
-

The Next Chapter


-- -- -
--
-

1113

x86 Instruction Set Architecture


Real Mode Peculiarities That Affect the OS Boot Process
- -- -
- -- -- -

U
nR
eg

is

te

re

- -- --
- -- - - - -- -
- -
--
- --
- -
- -- - --
- - -
-
-- - - --
--
-- - -- -
- - --
- -- - - -
- -
--
--

- -- -- -
-- - - - --
- - - --
--
--

Example OS Characteristics
- --- - ---

1114

--
- - - --

Chapter 29: Transitioning to Protected Mode

- - -
--

- - -
- -- - -
- - -- - -
--- - - -
-
-
-

re

Flat Model With Paging

is

te

--- - --- --
- -- - - - - -
- - - -
- -- - -

U
nR
eg

Software-Based Task Switching


- - - -
-- - -
--
-- --- -
-
-- -
-- - - -
- -- - - -
- - - - -
-
-- - -
--- - - -
- - -
- - - -
--- - - -- - -
- - -

1115

x86 Instruction Set Architecture


Protected Mode Transition Primer
GDT Must Be In Place Before Switch to Protected
Mode

is

te

- - --
-- -
- - -
- -
-- - - - - -
- -- -
- -

re

- - -
- - - - --

U
nR
eg

- -
- - - - - -

1116

- - - -
- - -- -
-
- - --
- --
-

-- -
- - --
- -
-
- - --
- --
-

-- -
- - - -
-

Chapter 29: Transitioning to Protected Mode


- -- -
- - -- - - - - - -

re

- - -- - - -
-
- -
-
- -- - -
- - -
- -
-- -
- - --
- -- -
-
- --
- --

is

te

- -- - -
-

U
nR
eg

--

-
- -- --
- -

-- -

-
- -- --
- -
- -
-- -

- --- -

1117

x86 Instruction Set Architecture

- --

- --
- --

-
- -
- -


-
- - --
--- - -- - - -
-
- - --
--- - -- - - -

1118

U
nR
eg

- - - -
- --

-
- -
- - -
- -

- -


-
-
-

-- --
- - --

- - - -

- -
- -
-


te

is

re

- - --

Chapter 29: Transitioning to Protected Mode

- --

- --

- --

- - --

- - - - -

- - -
-
- -- -
- -
- - -
-

- - -- -
- - -

-
- -
- -

-
- - -

-
- -
-

is

-
- -
- -

re

te

-- --
- - --

U
nR
eg

- -- - --

No Interrupts or Exceptions During Mode Switch


- - -- -
- -- - - -

- - - -
- - -
- - -
-- - -
- - -

-
- - --
- - - --
- - -

1119

x86 Instruction Set Architecture


Creation of Protected Mode IDT

re

- - - - -
-- - - --
- --
-
- - -
- - - - -
-- - - -
- - - -
- - -
- -
- - - - -
- --

U
nR
eg

is

te

-
-
- - --- -
- - - - - --
- -

-
- -
- - -
- -
- - - - --
- - -

- - -- - -
- - - - -

-- - - - - - -- -
- -
-- - --

1120

Chapter 29: Transitioning to Protected Mode

- --

re

-
-
-
-

te

U
nR
eg

- -

is

- --
- - -- - -
- -
- -

- -
- -

Other Protected Mode Structures


TSS

- -
- - -- -
- -- - -
- -
-- - -
-- - -
- - - - - -
--


- - --

1121

x86 Instruction Set Architecture

Address Translation Mechanism

re

- - -
-

- -
-- - -
- -

- - - - -
- --

- - - -
--
- --- --

te

- - -- -

is

- - -
-- -

U
nR
eg

- -- -
- -
- -- - - -

- - -
-- -
- - -- -
- - - -
- -- - -
-
- - ---
-- - --- -
- - -- - --
---

- -
- --
- -- -
-- - - --
-- - - -
- -- - - - --

1122

Chapter 29: Transitioning to Protected Mode


- ---
- - -
- - - - - --
-- - -- - -
- - - -
- - -

- -

- -- - - - -
- -
- -

U
nR
eg

is

te

re

- - - -
- - - -- -
-- - -
- - - --
- -
- - - -- -
- -
-- - - -
- - --


-

-


-
-
-
--

1123

x86 Instruction Set Architecture


Optional Structure: LDT
-

U
nR
eg

is

te

re

- - - -
- -- -
- -- - - - -- - - - - --
- - - - - - -
- - - - - - - - -
- - -- - -

- - -
-- -
- - - - - -- - - -
- - - --
-
-- -
-

- --- - - -
- - - -
- - -
- - -- --
- - - --- - - - - --
- -- - -

-- - - - -
- - - -- - --
- -
-

1124

- - -
- -
-

- --- - - -
- - - -

Chapter 29: Transitioning to Protected Mode


-- -- -
- - -- -- -
- -- --- -
- - - - -- - --
- - -
-

Enable A20 Gate

re

- - --
--
-- --- -

Load Initial Code and Handlers Into Memory

U
nR
eg

is

te

-
-
-
- -
--
-

The Switch to Protected Mode


- --
- -- --
- -

Loading Segment Registers With GDT Descriptors


- - - - - - - - -
-
-- - - --
- -
- -- -- -
-- - - - -- - -
- -

1125

x86 Instruction Set Architecture

-- -
-- -- - - - - -
- - -
- - -
- - -
- -
- -- - -
-
- - -
- - -
- - -
- -- - -- - - -
- - - -
- - -
- - - -
-- -
- --

-- - -
--

U
nR
eg

is

te

re

1126

-- - ---
- - - - -- - -
- - - - - - - - -
-- - - - - - -
-

Chapter 29: Transitioning to Protected Mode


-

Load TSS Descriptor Into TR

- - -
-- - -
- - - --
- -
- -- - -
- -
- - -

re

is

- - -
-- -- - - - --
- - - - - -
-
- - -- - -
- - -- - -- - -
- -- - - -

- -

U
nR
eg

te

- - - - -
-- - - - -

Enable Interrupts

- -
-- - - - - - -
- -- - - -- - -
- -

- -
-

1127

x86 Instruction Set Architecture

-
-

- -

Load Application Into Memory

- -
- - -- - -
-- -

re

Create Tasks Address Translation Tables

is

te

-- -
- - -- - -
- - --- -
- --- -- -
- - - -
- - -- -- -

U
nR
eg

Switching From OS Scheduler to First Task


- - - - -
- -
- - --
- --
- - - -
- -- - - - --
- - -
- -- - - -
- - - -
--
- - - -

Example: Linux Startup


- - -- - -
- - --- -
- -

1128

Chapter 29: Transitioning to Protected Mode

-
-
--

1. Bootsect
- - - -
- -
-

re

U
nR
eg

te

-- - - - -

- - - -
- -
- --
- - - -
- - -

-
- -- - -

- -- - -

- -

is

2. Setup

- -
- -

-- - - -
--
- - -- -- -

- - -
- -
- -

- - -
-- - -
- - - - -

1129

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -
-
- - -
- - -
- -
- --
- --
- - - -
- - -
- --
- - -

-
- -
- -
- - -
- -
- - -
- -
- - - - -
-- -

-- - -
--- - -
- -
- - --
---
-- - -
-
-
-
- -

- - - -

1130

Chapter 29: Transitioning to Protected Mode



- --

- -

- - -
- - -
-

-
--


- --

- -

- - -
- - -
-
- - - - -
-
-
--

U
nR
eg

is

te

re

3a. Startup_32 in boot/compressed/head.s


- -

- - -
- - - -
- - -- -
-
- -
- - - - --

-- -

1131

x86 Instruction Set Architecture

- --
- -

3b. Startup_32 in kernel/head.s


-
-
-- -
--

U
nR
eg

is

- - -
- - -- -
-
- - -
- - -
- - -
-
- -
-- - - ---
- -
- - - -
- -
- -
-- --
- ---
-
- -
- - - --
-- - --
- - - --
-- - --
- -
- - -
-

te

re

- -

1132

Chapter 29: Transitioning to Protected Mode

U
nR
eg

is

te

- - - --
- -
- -
- -- -
- - - -
- -
-
- -

- - --
- -
- -
- -- - --
-
-
- - - -
-- - -- - - -
- - -

- - -- - - -
- - -
- - -
- - - - -

- - -
-
-- -

re

- - - -

1133

x86 Instruction Set Architecture



- - -
- - -
- - -
-

-
-- - -
- --

- -


-
--


- - -
- - -
- - -
-
- --

- -
- -


- - - - -
-
-
--

U
nR
eg

is

te

re

1134

Chapter 29: Transitioning to Protected Mode


-
- - -
- - -
- - -
-
-
-- - -

- -
- --



-
--

-
- - -
- - -
- - -
-
- -


- -
- --

- - - -
-
-
--

U
nR
eg

is

te

re

- - - -

- - - -

1135

x86 Instruction Set Architecture


- -
- - - --- - -

- - -
- - -
- - -
- - -
-
- -


- --
- - -
- - - - -
-
-
--


- - -
- - -
- - -
- - -
-
-
-- - -



-
--

1136

U
nR
eg

is

te

re

Chapter 29: Transitioning to Protected Mode



- - -
- - -
- --
- - -
- - -
-
-
-- - -



-
--

- -
- - -
- - -
- --
- - -
- - -
-
- -


- - - - -
-
-
--

U
nR
eg

is

te

re

- --

1137

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1138

re

The Previous Chapter

is

- --
--
-

U
nR
eg

te

- - -- -
-

This Chapter

- -- -- -
-- -

The Next Chapter

- -
- -

-
-
--




-
--

1139

x86 Instruction Set Architecture


-
-
- --
- -
- ---

No Need to Linger in Protected Mode

- --- - - --
-

re

Entering Compatibility Mode

-
- - -
-
- -- -
- -
- - -- - -

- --- --- -- -
-
-- -- -

U
nR
eg

is

te

-
- - - - - -

1140

- - -

- - -
- - -
- - - -
-

-
- -
--
- - - -- -
- -

Chapter 30: Transitioning to IA-32e Mode



-- - - - --
- -- -
- -
- - - -- -

-
- - -

- - --
- -
- -
-- -
- -
-

- - --
-- -
- -


-- - - - - -
- -- - - -
- -
- - -
- -

- -
-
- --



- - -- - - -
- -

-- -
-- -

U
nR
eg

is

te

re

1141

x86 Instruction Set Architecture

U
nR
eg

is

te

re


- -- - - - - - - - - -
-- -- - -
- -- - -
- -- -
- - -- - - - --
- - -
-- - - - - - - - -- - --

- -
- --
- -
- --
- -
- - --
-- - - -

- -
- -
-- -- - - -

Switch to 64-bit Mode

1142

-
-- -- -
-
-- - - -
- -- --

- - -
-- -
- -- - -- -
- -- - -
- -- - - -
-- -
- - -

Chapter 30: Transitioning to IA-32e Mode

U
nR
eg

is

te

re

- -
-
-- -

- -
-
- --
-- - - - - -
-
- -- - -
-- -
- --
-

--
- -- - -
--- - -
--- -- -
- --- --
- - -
-- -- - -
- --
-- -- -
- -- -- -
-- - - -
-
- - - - -
-- - - - - --

1143

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1144

The Previous Part



This Part

te

re


-

-

U
nR
eg

is

- -- -

re

te

is

U
nR
eg
d

re

te

The Previous Chapter

U
nR
eg

This Chapter

is

- - -- -
-
-

- - -
- -

-
-
--




-
--

-
-
- --
- -
- ---

1147

x86 Instruction Set Architecture


The Next Chapter
- - -
- -

te

re

- -
--
- -
- -

-- - - - -





- - -

U
nR
eg

Just an Introduction?

is

- - - - --
- -
- - - - - -

Detailed Coverage of Virtualization


- -- -
-- -

1148

-
- -- -
- -- -
-
- --
- --

Chapter 31: Introduction to Virtualization Technology

--

-
- -- -
- -- -

- ---
- -

The Intel Model

te

OS: I Am the God of All Things!

re

- - -
- - - --

-
-- -
--- -

- - -
- - -
- - - - -
-
-- - --
- - - --
- -
- -
-
-

-- -
- - -
- -
- -
-

U
nR
eg

is

- - -
--- -

1149

x86 Instruction Set Architecture


-
-- - -
-
-
- - - -
- - - --

-
- - -- --
-

re

- - - -- - -
-- - - -

Virtualization Supervisor: Sure You Are (:<)

U
nR
eg

is

te

---
- -- - - -
-
- - - - - - -
-
- - - --
-- - -
- --

Root versus Non-Root Mode

-- -
- - - - -
- - -

1150

Chapter 31: Introduction to Virtualization Technology

--

-- -


-- -
- -
-

-
--


--
- - -
-

te

re

- - -
- -

-- -

is

-- -

U
nR
eg

- - -
--
-- -
- - -- --
- -- - -
- - - -
-
- -
- -
-- -
- - - - -
- - - - - --- - - -
- -

Detecting VMX Capability

--- - - - -
--- -
-

1151

x86 Instruction Set Architecture

- -
-

- -- -
-- -
--
- -
- --- --- - --
- --- - -
-- --
-- - --

re

-- - -- -
-- - -

- - - ---
-
-- - -
-- -

is

Entering/Exiting VMX Mode

te

U
nR
eg

Entering VMX Mode


- --

- - -
- -
- -

-- -

Exiting VMX Mode


- --

1152

-
-
- -

Chapter 31: Introduction to Virtualization Technology


Virtualization Elements/Terminology
- -- -

U
nR
eg

is

te

re

-- --
- - - -

- - -
- - - -
-- --- - - -
- - - - - -
- -- - - - -
- --
- -- -
- -
-
- -
-- -- -
- -
- - --
- - -- -
- - - - -
--
- - - - -
- -
- - - - -
- - - - -
-
- -- -
- - - -- -
- -
- - - - -
- - - -- --
-

1153

x86 Instruction Set Architecture


Introduction to the VT Instructions
- - - -
-

-- -
--

- -- --
- - --

- -- --
- - --

-
-- - - -
- - -
- -- -

U
nR
eg

is

te

re

-- -- -
-- -

- - -- -
- - -
- -
- - - - --
- --- - -
-- -
- - -
- - - --

1154

Chapter 31: Introduction to Virtualization Technology


--
-

- -
-- - --
-- - -
- -- - --
-- - - -- - - - - --
- - -
- -- -- -
-- --
-- -- - -
-
-- - - -
- - -- --
--
-- - - -

- -- - - -

U
nR
eg

is

te

re

-- -- -
- -- -

1155

x86 Instruction Set Architecture


--
-

-- - --
-- -
- - --- -
- - - -- -
-- - -
- - -
- - -
- -
- -
- - - -
- -
- -- -
-
- -

is

te

re

- -

U
nR
eg

- - -
- -

- -- --
- --

Introduction to the VMCS Data Structure


- - -
- - - - - -
- - - --
- - - - -- -
-- ---

1156

-
- - -
- - -

Chapter 31: Introduction to Virtualization Technology

- - --
- -

- - - -- -- -
- - --
-
- -
-- - - - --
-- - --
-
-- -- --
- - -
- -- -
- - -
- --
-
- -- -
-- - - -

U
nR
eg

is

te

re

-
-

- -

- -

- - --
- - -
-- - -- -
- - -
- -

1157

x86 Instruction Set Architecture


-

- -
-- -- - -
-
- - -

--- - -- - -
- - - -
- - - -
- -
- -- -- ---
- -
--- - ---
-
- - - -

- -
--- - -
--- -
- - -
--- -
-- -- -
-- -
- - -
- -
- --
-- -

-- -
-
-- -

U
nR
eg

is

te

re

- -

1158

Chapter 31: Introduction to Virtualization Technology


-
- -

- - -
- -
-
- -


-
--
-- -

-
-
-

-

- - -

- - -
-
-
-
-
-
-

-



- -

- -
- - -

U
nR
eg

is

te

re

1159

x86 Instruction Set Architecture


-

- -
-
-
- -- --


-
- - - -
-

te

Preparing to Launch a Guest OS

re

- -

-
-
--- -
- - -- - -
-
- -- -

- -- -
- - - -
- --
- - -
- -
- - - -- -
- - --
--
- - --
- - -
-
-- - - - -- ---
-- - - - --
--

U
nR
eg

is

- - - -

1160

Chapter 31: Introduction to Virtualization Technology

U
nR
eg

is

te

re

- - --
--- --
- - -
-- - - -
- - -
-
- - --
-- - - -
- - - -- -

-- - - - - - - - --- -
-- - - - - -
- - --
-
-- --
- - -
- - - - - --- -
- - - -
-
- - - - -
-- - --
-- - - -
- - - - --
-- - - - - - - - --- -
-- - - - -
- -
- - - -

Launching a Guest OS

- -

- - -
- -
- - -
-- -- - -
-- - - -

1161

x86 Instruction Set Architecture

U
nR
eg

te

is

re

--
-- - - - - -
- -
- - -
- - - - -

- --- - -
- - -
- - --
--- --
- - - - - -

- -
-
-- - -
-
- -- - -- - -
-- - - - -

- -- - - --
- -
- -

Guest OS Suspension

- - ---
- -- --
--

- - --
-- - - -- - -
- - -- -
- -
-
-

- -- -- - -

1162

Chapter 31: Introduction to Virtualization Technology

-- - -- - -
- -
-- -

- -- - - -

--
-- -

Handling Timeslice Expiration

te

re

- --- - - - --
- --- -- - --
-- - - --- - -
-

Handling a Sensitive Operation or a VMCALL

U
nR
eg

is

- --
- - - --
- - --
-- -- - -
- -
-- - -
- - --
- -

Resuming a Guest OS

- - --- -
--

- - - -- - -
- - - - --
- - -
- - - ---
- - - -
- -

1163

x86 Instruction Set Architecture


- - -- --
- - -
-- - - - - --
- --- -
- --- - - ---
-

U
nR
eg

re

te

- -- - - - - - -
- - - - -

- -
-
- - - - - - -- -- -
-
-- --- - - - -
---
- - -
-- -
-- -
- -
-- - - - -
- -
-- - -- -
- -
- - -

- - -- -
- --- --
-- - - - - -
-- - -

-- - -
-
- -- - -- - -
-- -- -
- -- - - -
-- - --
- -
-

is

1164

Chapter 31: Introduction to Virtualization Technology


Some Warnings Regarding VMCS Accesses
- -- - - -
- - --
- - - - - --
- -- - --
- - --

U
nR
eg

is

te

re

-- - - - -
- -
-

1165

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1166

re

The Previous Chapter

is

-
-
--




-
--

-
-
- --
- -
- ---

U
nR
eg

te

- -
-

This Chapter
- - - -
- -

- -
--

1167

x86 Instruction Set Architecture


- -
- -

-- - - - -





- - -

re

The Next Chapter

is

-
--
- -


-

U
nR
eg

te

- -

What Falls Under the Heading of System Management?


- - -
---
- - - --- -- -
-- - - -
- --

1168

- - - - -
- - -- - - - -
- - --
- - -- -
- - - - - -

Chapter 32: System Management Mode (SMM)

is

The Genesis of SMM

te

re

- --- -- ---
- - -
- -
- - - - -
- - - - - - -
- --
- - -- -- -
- - - -- -
-- --- -
-- - -
- - -- -
-- - - -
- --
- - -- -- -
- - -
-- --- -- -
-

U
nR
eg

- -- -
- - - - - --
--- - -
-- - -
-- -- ---
- - --
-
- -- -
-- -- -- -
- - - --
- - ---
-- -
- - - -
- -- -- -
-
--- -- --
-- - - - -

1169

x86 Instruction Set Architecture


SMM Has Its Own Private Memory Space
-- - -
--- -- --

-- -- -
-- --- --
- - -

-- -- - -- ---
-- --

re

- -

The Basic Elements of SMM

is

---
--
--- --

-- --
-- - -- --

- - - - - -


--- - -- -

- --
- --
-- - --
-
--- -- - -
-- - -- - --
-- ---
- - --- --
-- -- - --
- -- -

U
nR
eg

te

- - - - --

1170

Chapter 32: System Management Mode (SMM)


A Very Simple Example Scenario
-- - --
- - -
- -
- - -- - --
- - - - - --- -
- - -- -- - -- -- -

U
nR
eg

is

te

re

-- - -
---
-- - - -
- -- -
- -- -- --

-- - -- - - - -- --
- - - --
- -

-- -
- - - - -
-- -- --
-- - - - -

-- - - -
- -- -
- ---
--

How the Processor Knows the SM Memory Start Address


-
- -
- - -

1171

x86 Instruction Set Architecture


- -- -
- - -
-- - -
- -- - --
-- -

Normal Operation, (Including Paging) Is Disabled

re

- - - -
- -- - - ---
- - - -
- - ---

is

General

te

The Organization of SM RAM

U
nR
eg

-
-- -- - -
--- - -- - - --
- -- - -
--

1172

- --
- -- - - --

-- - --
-- -- - - - - -
-
- --
- --
-- - -
- --
-- - -
- --
- -- -- -
- -
- --

Chapter 32: System Management Mode (SMM)


- -- - - -- - - -- -- -- - - - -- - --
- -- -
- -- -- - -
--

IA-32 Processor SM State Save Area

U
nR
eg

is

te

re

-- - -- - -
- -
-- - - -
-- - -
-
-- -
-- -- -

1173

x86 Instruction Set Architecture

re

--

is

te

U
nR
eg

--
-- ---
-- ---

- --

--


-
- -

1174

Chapter 32: System Management Mode (SMM)


-

- - - -
-- --
- -
-
-

- --
-
-- --
- -
-
-

U
nR
eg

te

re

is


-
- -

1175

x86 Instruction Set Architecture


-

-
- -

- --
-
-- --
- -
-
-

- --
-
-- --
- -
-
-

- --
-
-- --
- -
-
-

- --
-
-- --
- -
-
-

is

te

re

U
nR
eg

1176

Chapter 32: System Management Mode (SMM)


-

-
- -

- --
-
-- --
- -
-
-

-
- - --

--
-- - -

- - -

-
-

U
nR
eg

is

te

re

- -
- -

-
-

-
- --

- - -

1177

x86 Instruction Set Architecture


Intel 64 Processor SM Save Area
-- - -- - --
-- -- - - - -
- - - --
- --
- --
- - --
- -- --
-- - -
- - --

is

te

re

--
-- - - - -- -
- - - -- -- -
- -
- -
-- -
-- -- -

U
nR
eg

--


-
- -

- -

1178

Chapter 32: System Management Mode (SMM)


--

- -

- -

- -

- -

- -

- -

- -

U
nR
eg

is

te

re


-
- -

-
- - --

--
-- - -

1179

x86 Instruction Set Architecture


--

-
- -

is

te

re

-
-

- -
- -

-
-


- --

U
nR
eg

1180

Chapter 32: System Management Mode (SMM)


--

-
- -

- -
- -

U
nR
eg

is

te

re

- -
- -

- -
- -

1181

x86 Instruction Set Architecture


--

-
- -

- -
- -

- -
- -

- -
- -

te

re

is

Protecting Access to SM Memory

U
nR
eg

-- -- - -
-- - - -
- -- -- -
- --
- -
- - -
- -- -
- - -- --
-- -- - - -
-- -
-- - - -

-- - -- - -
- -- -
-- - - -
-- -- -- - -

- - -- -- - -
-

1182

Chapter 32: System Management Mode (SMM)


-
- -
- -


-

-

re

- -

te

-
-- -

--

--

U
nR
eg

- --

is

--

--

- -

Entering SMM

The SMI Interrupt Is Generated


- -- -- -
-- - -

No Interruptions Please
General
- -- -- - - -
--
- - - - - - -- -

1183

x86 Instruction Set Architecture

- - - ---
-
---

- - - -- -
- - - -
- --- - -
--
--
--- - -
- --- -
-- - -

--
-- -- - - -
-- -

re

te

Exceptions and Software Interrupts Permitted but Not


Recommended

U
nR
eg

is

- - -
- - - -
- - -
-- - - -
- - - -
- --
-
-- - - - -
- - - -
- - --

Servicing Maskable Interrupts While in the Handler


- - - -

- - - -- -
- - - -
-

Single-Stepping through the SM Handler


-- - -
- - --

1184

Chapter 32: System Management Mode (SMM)


- -- - -
-

If Interrupts/Exceptions Permitted, Build an IDT


-- - - - -
- - -
- - -

re

- -

- - - -
- - ---
- --

is

te

- -- - -- -
- - - -
-
-

SMM Uses Real Mode Address Formation

U
nR
eg

-- - -- -
-- - - -

- -
- - - - --
- - - -
-- - - --
--
-- - - --
- - - -

- - - - - - -

- --
- - -- - - -
- -- - - -
- -
-
- -

1185

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -- --
- -- -
- - -
-- -
-
- - --

- -- -
- - - -
- --
- -- -
-- - -- - -
- -- - --
-- - -- -
-- -
-- - - -- - -- - - -
- - -
- -- -
--
-- - -

NMI Handling While in SMM

--- -
- - ---
- -- - -

- - - - -
--
- - - --- - -
- - -
- -


-
- -

1186

Chapter 32: System Management Mode (SMM)


- -
- - -- -
- - - ---
- - -
- -
- -

- -

U
nR
eg

is

te

re

-- -
- - -- -
--
--
-- --
-
-- -
- - --
-- -- - -
- - - - -

- - -
- ---
- -
- -
- - - -
- - - - -- -
-

- - -
- --- - -
- -
--- - - -
- - -
- -- --

- -- -
-
- - - -
- -
- - -
-

1187

x86 Instruction Set Architecture



- -
- - - --
-

Informing the Chipset SM Mode Has Been Entered

- - - - -- -
--
- - - -

re

General

te

-- - -
- - --
- - --
- --- -- -

is

A Note Concerning Memory-Mapped IO Ports

U
nR
eg

- - - -- --- - - -
- - - -
--- - -
-
-- --
- - - ---
-

The Context Save


General

- -- - --
-- - - - - -
-

1188

Chapter 32: System Management Mode (SMM)


Although Saved, Some Register Images Are Forbidden
Territory
-- -- -
-

- - -

- --- - -- -
-- -

Special Actions Required on a Request for Power Down

is

--
- -
-

- -- ---
--- -- - --
-
- -
- - -
-

U
nR
eg

te

re

- --- -- --
- -
- - - -
- - -
-

- - - -- -
- - -
-- - - - - - - --- -
- - -- - - -
- -

- -
- - - -
- - -
- - -- - - -
- - -
- - - -

1189

x86 Instruction Set Architecture


The Register Settings on Initiation of the SM Handler
- --- - - -
--- -- - -

-
-- -
- - -

-- -- - - -
- - - --
-- - - - -
-- -- - - -- -
- --
- --- --
-

te

re

is

- - -
-- - -- -

U
nR
eg

-- - - -- -
- -
- - - -
- - -- -- -
-- - -- - -

- -

--

1190


- --
-
- -

Chapter 32: System Management Mode (SMM)


- -
--

- -
-- --
- -

- -

- - -
- - - --

--


- - -
- - - --

te

re

-
-

U
nR
eg

- - -
- - -

is

- - -
-

- --
-- -

The SMM Revision ID

-- - - - - -
- -- -

- - - -
-
- - - - - -
-
- - - -
- - - - --

1191

x86 Instruction Set Architecture


- -
- -

- - - - -
--
- - - --
-- - - - - -

- - --
-- - - -
--

is

- - -
- - - -

te

re

U
nR
eg

The Body of the Handler

--- - - - - -
-- -

Exiting SMM

The Resume Instruction

- - - - -
- -- -- - - -
-
-

-- - - - -
- - -
- -

1192

Chapter 32: System Management Mode (SMM)

- - -
- -
-
-- - -
-- - -

- -

Informing the Chipset That SMM Has Been Exited

te

re

-- - - - - -
- - -
- -- - - --
- -- -- -

is

- -- --- -
- - -
- -

U
nR
eg

The Auto Halt Restart Feature

-- - -
- -
-- -
- -
- - -
-- - - - -

- - -
-- -
- -- -
- -
-- -
- -

- --
- - - -

1193

x86 Instruction Set Architecture

-- -

-- --
-

--- -

-- --
-
-

-- --
-

is

te

re

Executing the HLT Instruction in the SM Handler

U
nR
eg

- - -- -
-- - - -
- - - -
-- - - -
- - -

-
-- -
-- -

1194

Chapter 32: System Management Mode (SMM)


The IO Instruction Restart Feature
Introduction

- - - -
-- --
-- - - - -
-- - -
- - -

An Example Scenario

U
nR
eg

is

te

re

- -
- - - - - --
-- - -- - -
-- - - -- -- -
- - - --
-
- - - --- -

The Detail

- - -
- -
- - -
-

- - - - -
-- --
- -
- - -
-
---
- - - -
-- --
- - -
-- - -
- -- --

1195

x86 Instruction Set Architecture


-- - - - -
- - -
-
-
- - -
- - - -
- -

Back-to-Back SMIs During IO Instruction Restart

U
nR
eg

is

te

re

-- - -
- - -
- - -
-- - -
-
- - -
- - - -
- - -
- -- - -
- - - -
- -
- - - - - -- -
-

Multiprocessor System Presents a Problem


- - - - - -
-- - -- -
- - -
-- -- -- - -
- ---
- - - --
--
- -- - -
- -
-

1196

- -
- -
- - -
- - --
-- - -

Chapter 32: System Management Mode (SMM)

-- - -- -
-- -
- -
- -
-- - -
- -
-- - -
-- -

is

te

re

- - - --
- -- - - -
-- -
-- --- - -
-- - -
- - - -
-- -
- -- -- -

U
nR
eg

--

- --
- - - -
-
-
-

-
-
-
-
-
-
-

1197

x86 Instruction Set Architecture


Caching from SM Memory
Background

U
nR
eg

is

-- - -
- --
--
-- - -
- -- -
-- -
-
- -
- -

te

re

- --- - -- -
-- - ---
-- -- - - - - - -- -- -
- -- -- -
-- -

- -

1198

-- - --
-- -

-- -
-
-- - - -
- - --
-- - --
-- - - - -
- -- - - -
-- - - -

- - -- -
-- -

Chapter 32: System Management Mode (SMM)


- -
-- - - -
- - - - -
- --
- - -- ---

The Physical Mapping of SM RAM Accesses

re

te

U
nR
eg

-
--- -- -
- - -
- -
- - - - - -
- --
-
--- - - -
- - - -- -
- -- - - - - --- -- --
- - - - -
-
- --
-- - -- - -
- - - -
- - -
- --
-- - -- - - -
- - -
-- - - - - --
- -
-
-
- - -
--- -
-- - -
- - -
- - -

is

-- - -- -
- - - -- -- - -

1199

x86 Instruction Set Architecture


-- - - - -
- - -
- - - -
-
- -
- - - -
- -

re


--

--

-

is

--

te

--

U
nR
eg

--- -
-- --
- -

1200

--

-
-

Chapter 32: System Management Mode (SMM)


--

--

--

U
nR
eg

is

te

--- -
- -
- - - - -
- - -

re

--
-
-
-


--

- - -
- - -
-

--

--

- - -
-
-

--- -
- -
- - - - - -

1201

x86 Instruction Set Architecture

- - -
- -
- -
-


--

--

--

re

- - -
-
-

is

te

--- -
- -
- - - - -
-

U
nR
eg


--

--

-
--
-
-

--

--

--

-
-

-- - -
- -- - -
-
- -- - -
-
-
- - --
-
- - -

1202

Chapter 32: System Management Mode (SMM)


FLUSH# and SMI#
- --- - - -
--- -
-

re

-- - - --
- - - - - --
- - -
-- - - -

-- - - --
-

-- -- -
- -- -

-- --- -- -
- - -

U
nR
eg

is

te

- - - - --
-- - -
-- -- -- --
- - - -
-- -
--

-
- -

Setting Up the SMI Handler in SM Memory


-- -- - - -
-- - -
- - -- -- -
-- -
-- - - - - -
- - --
-- -

1203

x86 Instruction Set Architecture


Relocating the SM RAM Base Address
Description

re

-- - - -- -
- - -- - -
- -- --
- -- -
- - - - - - -

- - - -
- - --

U
nR
eg

is

te

-- --
- -- - -
- - - -
-- - - -- --
- --
- --
-- - - - - -- - - - - - -
--
--- -- - - --
- - -- - - --
-- - - --
- - - --

In an MP System, Each Processor Must Have a


Separate State Save Area
-- - - - - -
-- -- - -
---

1204

Chapter 32: System Management Mode (SMM)


Accessing SM Memory Above the First MB
- - -- --
- -- - -
- - - -- -
- - - -- -
-

- -- - -
-- - -- -
-- -- - -
-- -
- - -
--

re

-
--

te

- -- -- -

is

SMM in an MP System

U
nR
eg

- - -- ---

-- -- -
---
- - -- - -
- - -- -
- -
- - ---
- -- - - --
- -- -- -
- --
--- - -
---
- - ---
--- -

SM Mode and Virtualization


- - - -

1205

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1206

re

The Previous Chapter

is

- -
--
- -
- -

-- - - - -





- - -

U
nR
eg

te

- - -
-

This Chapter
- - -

-
--

1207

x86 Instruction Set Architecture

- -


-

The Next Chapter


- - -
-

te

re

- -

-- - -
---
-
-

-
--- --
--
--
--
-
- -
--
-

- --
-
-- -

-- ---
-
-





-

-

U
nR
eg

is

1208

Chapter 33: Machine Check Architecture (MCA)

-
--
- -

Why This Subject Is Included

re

- ---
- - ---
---
-- --- -
- -
- - -

MCA = Hardware Error Logging Capability

- --
-

U
nR
eg

is

te

--- - -
- ---
-- -
- - - -

- - -
- -- - -
- - -- -
--- - -
- - - - - - -
- -
-- - - - - -
-
-
- - - -
-- - - - -
- -

1209

x86 Instruction Set Architecture


The MCA Elements
-
-- -- -

--- -
- - -
- -
-

The Machine Check Exception

is

te

re

- -- -----

- --- - -
-- -- - -
- --
- - -
-

U
nR
eg

--- - -
- ---
- - -
-

- --

- - - -

- -




- -- -
- - -

--

1210

Chapter 33: Machine Check Architecture (MCA)


The MCA Register Set
- - - - -
- --

-- - --
---
- -- --
--

- -- ---

-
-

re

-- - - -- -
-

-- - --
- - -- -
- - -
- - - - -
- -- - -- - - -- -
--

U
nR
eg

is

te

-- - - -- -
-- ---
- - - - ---

- --

- - - ---
- - -- - -

1211

x86 Instruction Set Architecture


The Global Registers
Introduction
-- - -
-- - -
- - -- ---

te

- - -
- -
- - - - - -

- -
-

re

is

The Global Count and Present Register

U
nR
eg

- -
- - -

1212

- - -
-- - ---
- --
- - -
-- -
-- - - -
- - - -- -
-
- - -- -
- --
-
-
-
-- - -

Chapter 33: Machine Check Architecture (MCA)

- -

- - - -
-- -- -

- -- -

-- -
- -

te

re

- - --
- -

is

The Global Status Register

U
nR
eg

-- - - -- -

-- - -
-- -
- - - - - -
-- -
- -
- - - -- - - -

- -- -- - -
-
- - - -
- - - --
- - - -
- - - - -
- - ---
- -
- --- - -

1213

x86 Instruction Set Architecture

- -


-
--

-

re

The Global Control Register

is

- - - --
- -
- - - -
-

U
nR
eg

te

-- - - -
- - -
-

The Extended MC State MSRs


- -- -
- - - - -
-- -
- - - -
--
- -- - --
- - -

-- - --
--
-- - --
--

- -- -
- - -
- -

1214

Chapter 33: Machine Check Architecture (MCA)

--- - -

te

is

re

- -

- --- -
- - --
-

U
nR
eg

- - -- - - -
--- - -
- - - - - --
- - ---
- - -
- -
--
-- - - - - - -
- -
--

1215

x86 Instruction Set Architecture

--- -

is

te

U
nR
eg
1216

- -

re

Chapter 33: Machine Check Architecture (MCA)


--- -
- -

- --- -
- - --
-

re

The Composition of a Register Bank

te

Overview

U
nR
eg

is

- - -- -
-- -- - -- -
- -- - - -- -- -
- --- -
-

-
- -
-- -
-- -
- - - -
-

- - -- --

The Bank Control Register


General
- - -
- - - --
- - -
-

1217

x86 Instruction Set Architecture


-- - -
-- - - - - - - - - -
- - - -
- - -

-- -- -
- -
- -

re

- - - - - --
- - - - --
-

te

P6 and Core Processors

U
nR
eg

is

--- --- -
---
- - - -- -
-
- - -
- -- -
- -

The Bank Status Register


General
- --
- - - - -

1218

Chapter 33: Machine Check Architecture (MCA)


- -
- - -
-- - - - -
- -
- - - -- -

U
nR
eg

re

te





-- - -- -

-- - -- -

-- --







-

- -

is

--- - - - -

1219

x86 Instruction Set Architecture

- -

- --


--
-
-
-


-

is

re

te

U
nR
eg

- - -
- - -

Error Valid Bit

- - -
- - - - -- - -

- -

- - -
- - --

Overflow Bit
- - - -- -
- -
- -
-

1220

Chapter 33: Machine Check Architecture (MCA)

-
- -
- -
- - -

- - -

Uncorrectable Error Bit

-- -- - -
-
-

re

Error Enabled Bit

is

te

- - - -
- - - - -
- - - -
-

Miscellaneous Register Valid Bit

U
nR
eg

- -- -
-
- - -- -
- -

- - - -
- - - -
--
- - -- -
- - -

Address Register Valid Bit


- --
-- -- - - -- -
- - - - -
- - -- -
- -- --

1221

x86 Instruction Set Architecture


-- - - -
-- - --
- -

Processor Context Corrupt Bit


- - - --- - -

- -
-- -
--- -

te

Other Information

re

MCA Error Code and Model Specific Error Code

is

- - -
- - -
-- - - -

U
nR
eg

The Bank Address Register

-- -

The Bank Miscellaneous Register


-- -

Control 2 Register

1222

Chapter 33: Machine Check Architecture (MCA)


The Error Code
The Error Code Fields
-
- -
- -
- ---
- - -
- -

-- --
- - - -
- -
- - - ---
-
- - -
- -

U
nR
eg

is

te

re

Simple MCA Error Codes


-
-- - -
-

-
-
--

--

- - --

---

1223

x86 Instruction Set Architecture


-
-

--
-- - --


--
- -
-
-

--

te

re

is

--
- -
- - -

U
nR
eg

Compound MCA Error Codes


General

- - - - - -
-- -- -
- -
- - -
- - - -
-
- -
- - - -
-- - -

- - - - - - - -
-- -
-

1224

Chapter 33: Machine Check Architecture (MCA)


-

re

te

U
nR
eg

is

- -
--
--- - - -

Correction Report Filtering Bit



--- - - -
- -- - - --
- -- --- -
- - - -- -
- - - -

1225

x86 Instruction Set Architecture


-
-

- -

re

- - -
- - - --
--- - --
-

is

te

U
nR
eg

-
- - -
- - --

-

1226

Chapter 33: Machine Check Architecture (MCA)


-

re

U
nR
eg

is

te

- -- -
- - - --
-
--
- - -
- -- -
-- - - -
-

- -

--
- -
- -- -

-
-- -
-

-- -
-

1227

x86 Instruction Set Architecture


- -

-
-
-
--

--

re

is

te

- ---
- - --- - ---
- -- --
-- - - --
-

U
nR
eg

--

1228

Chapter 33: Machine Check Architecture (MCA)


-

- --
- -

Example External Interface Error Interpretation

te

re

-
- -
- -
- - -

-

is

U
nR
eg

- - -

- -

- -
- - -
-

1229

x86 Instruction Set Architecture


-

r - - -

-

-
-- - -
-
-
-
- -- -
-
-
- -
-

-

- - -
-

-
- --- - - - - - -- -
--
-
-
--
-


-
-
--

--

-





--

1230

U
nR
eg

is

te

re

- -


-- -
-
-
-- - -

Chapter 33: Machine Check Architecture (MCA)


-

-- - --

-- - --

- --

-- --

-- --

k -
- - -
- --

k -

- --

-
- -

- -- - --

-- - - --

- -- -
- - -
- -

- -

- -

- -
- - -
-- - -
--

U
nR
eg

is

te

re

1231

x86 Instruction Set Architecture


Cache Error Reporting
Green/Yellow Cache Health Indicator
Background

U
nR
eg

is

te

re

- --
-
- - -- -
-- - -- -
- -- - -
- -
- - - - - -
- - -
- - - - - -
- - - -
- - -
- - --
- - -

TES (Threshold Error Status) Feature


--- -
- - -
-- - - - -
- - - -

1232

- - - -
-
- -
- - -
-
- -

Chapter 33: Machine Check Architecture (MCA)


-- - -
- -
-- - - - - - -
- -- - -- -
-- - -

-- -
-

- -
- - - - -

- -
- -
- - - -
- -
- -- -

U
nR
eg

is

te

re

-- - - -

Interrupt On Soft Error Threshold Match


Before CMCI, Soft Error Logging Required Periodic Scan

- - -
- - -
-
- -- -
- - - - -
- - -
- -

1233

x86 Instruction Set Architecture


CMCI Eliminates MC Register Scan
-
- -
- - - -

te

re

- - - -
- - -
- - -
- - -
-
--

- - -
-- -
- -

U
nR
eg

is

- - -
- --
- - -
- - - -
- -
- - -
- - -
- -

-- -- - -

-- - -
- - -

1234

- - -
- -
- -
- - -
- - -
-

Chapter 33: Machine Check Architecture (MCA)


Determining Processors CMCI Support
-- - -
--
- - - -

Determining a Banks CMCI Support

re

- -
- -- - - - -
- - - -
- -
-

CMCI Interrupt Is Separate and Distinct From MC Exception

te

- - - -
- - - -
- - -

is

CMC Interrupt May Affect Multiple Cores/Logical Processors

U
nR
eg

- - ---
-
- -- -
- - - -
- - - --- --
-

CMC Interrupt Should Only Be Serviced Once


- -
-- - - - - -
- - - -
- -

- - - -
-- -
-- - -
- --
-- --
-
--- -

1235

x86 Instruction Set Architecture

U
nR
eg

is

te

re

-
- - -- -
-
- -
-- - --
-
-- - -
- - - -
-- -
-
- -
- - - - --
- - -- - --
-- - - --
- -
-
- -
- - - -
-

- - - --- - --
- - -


- - -
- - -
- - - -
-- -

-
-- - - -

MC Exception Is Generally Not Recoverable


- --
-
-
--- -
- ---
- -

1236

Chapter 33: Machine Check Architecture (MCA)

-
- - - - -
- -

Machine Check and BINIT#

te

Additional Error Logging Notes

re

---
-- -- - ---
- --- - - -
- --- -
-

is

Error Buffering Capability

U
nR
eg

- --
- - --- - -
--- - -
- - - - --- - - - -
- - - -
- - - -
-- -
-- - --

Additional Information for Each Log Entry


- - -
-

--- -
- -
-- --- -
-

1237

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1238

The Previous Chapter

is

te

-
--
- -


-

U
nR
eg

re

- -

This Chapter

- - - -
-

- -

-- - -
---
-
-

-
--- --
--
--
--
-
- -

1239

x86 Instruction Set Architecture


--
-

- --
-
-- -

-- ---
-
-





-

-
-
--
- -

is

te

re

U
nR
eg

APIC and the IA-32 Architecture

- - -
- - -
-
- - - -
--- -- -
- ---
- - - --
- -- - -
--
- - - - -- - - -

- -- - - -
- -
- - -

1240

Chapter 34: The Local and IO APICs


Definition of IO and Local APICs
- - -

Hardware Context Is Essential

re

--
- - -- - -
- - -
-- -- -
-

te

A Short History of the APICs Evolution

APIC Introduction

is

- - -

U
nR
eg

- - - - -
- - -

Pentium Pro APIC Enhancements


-


-
-
- - - - -
- -- --
- - - - -
-- -
- -
- - -- -
-- - -- -
-- - -- -

1241

x86 Instruction Set Architecture

is

te

re

- ---
- - -
- -- -
-
- - - -
- -- - - - -- -- - --
-
--
-- -
- --- -
- -- - - ---
- - --

- -- - - -
- -
--
-- -- -

U
nR
eg

The Pentium II and Pentium III


-
---

Pentium 4 APIC Enhancements: xAPIC


-
- -
- -
- -
-

1242

- - -

- - - -
--- - -
- -
--- --

Chapter 34: The Local and IO APICs

is

te

re

- ---
--
- - - -

- - - -
- -
-- -- -- -
--
- - -
- - -- -- -
- -
-- - -

- --
--- -- --
-- -
--- - -

The x2APIC Architecture

U
nR
eg

- -
-- - -
- -

- --
- - - -
- -
- -
- -- - - - - -
- -- -
-- --
- -
- - -
-- ---
-
- - -
- -
-- - -
- --- --

1243

x86 Instruction Set Architecture

- - - -
- - -
- - - --
- - - -

Before the APIC

te

- -- - -
-- --

re

- -- -- -
-- - --- --
-- -- ---
---

U
nR
eg

is

-- -
-- - - -
- - --
- -
-- -- - - --
-
--- - - -
-- - - - ---
- -- - -- --
-

1244

-- - -
- - --
-
-
-- -
-- -
-- - -

-- - - -
-
--

Chapter 34: The Local and IO APICs


- --
- -
- --
-- - -
- -
--
-- - - - - --
- -
-- -
- -
- -
-- - -- -

re

te

- -
-

is

---

U
nR
eg

1245

x86 Instruction Set Architecture


-

--

--

re

is

- -

U
nR
eg

te


--

-- -
-

MP Systems Need a Better Interrupt Distribution


Mechanism
Legacy Interrupt Delivery System Is Inefficient
- - - - -
-- -- --- - -- -

1246

Chapter 34: The Local and IO APICs


- -
- -
-- - -

- -
- ---
-- -- -
- --
-
-- -
- - -
-- - --
--
- -- ---
-- -- -
- -

- -- --
--- -
- --
- -- --
-- - --

U
nR
eg

is

te

re

--
--
-

- --

- -
--
-- - -
-
- -- -
- -- -

-
-

--

- -
-- -
---

1247

x86 Instruction Set Architecture


-
-

- - -
- - -- --
-
-- --
-- -

re

te

U
nR
eg

is

The APIC Interrupt Distribution Mechanism


Introduction

-
- ---
-
-
-- - -- -
-- - -
- -- - -
- --- -- - -
-

1248

Chapter 34: The Local and IO APICs


-

--

--

te

re

is

U
nR
eg

- -

Message Types

-- ---
- --- -
--- - --
- - --
--- - - - - -

--- - -
- -
-- - --
---

-- -
-
-- - --

1249

x86 Instruction Set Architecture


Message Transfer Mechanism Prior to the Pentium 4
--- -
-- - --- - - --
- - --
- --- -
- - - --
- -

Message Transfer Mechanism Starting with the Pentium 4

is

te

re

- -
- - - -- ---
- - -
- -- -
--- - - --
-- - -- - -
-- - --
--- - - -

U
nR
eg

--

--

- -

1250

Chapter 34: The Local and IO APICs


Message Transfer Mechanism in Intel QPI-based Systems

--- ---

--- - - -- - --
- - - -- ---
- - -
- - -- - - -
- -
- - -

re

- - --

te

is

U
nR
eg

1251

x86 Instruction Set Architecture


- - --

U
nR
eg

1252

te

is

re

Chapter 34: The Local and IO APICs


- - ---

re

te

is

U
nR
eg

Processors Reside in Clusters


-- -- ---

--- - - - - - --
-- -- - - -- - --
-- -- --- - -- -
- --
--- -
-- - --

1253

x86 Instruction Set Architecture

- --
-
-- - - -- -
--
- -- -
-

--

re

is

te

U
nR
eg

Each Core/Logical Processor Has a Dedicated Local APIC


-- - - -
- --
- -- -- -
-- - --
- - -- - - -
-- - - -- -
-
--

Introduction to the Message Addressing Modes


-- - -
- -- -
--- -

1254

-- - - --
-
-

Chapter 34: The Local and IO APICs


-- -
- - -- - - -
-- -
- - - - -
- - -- -
- --
-- - -
- -

-- -
- -
-- - --
--
-
- - - - -
-- ---
-- - - -- -
-
- -- - -
- - -- - -

U
nR
eg

is

te

re

Detecting Presence/Version/Capabilities of Local APIC


Presence

-- --
-
---

Version
-- - -
- -
- -

- -

1255

x86 Instruction Set Architecture

-
- - -
- -- - - -
-

x2APIC Capability Verification

-- -
-- -
-



- -

te

re

- -

is

- -
-- --

---

U
nR
eg

- -

- -

Local APICs Initial State

- - -- -
--

1256

- -

- -
- - - -- - - -
-- -- - - - -
- - -
-- - - -
- - - - -
-

Chapter 34: The Local and IO APICs

te

- - - - - -
-
- - - - --

-- - - - -

- -- - - -
- - --
- -- - - - - --
-- -
- - --
- - - - - -

- - -
-- -
- -

re

U
nR
eg

General

is

Enabling/Disabling the Local APIC

--- -
- -- - -
- - -
- --- ---
-- -- -
-- - -

Disabling Local APIC for Remainder of Power-Up


Session
-
- - -
- -
- --
- - - - - -

1257

x86 Instruction Set Architecture


- - -
- - - -
- -- - - -

- -- -
- -- -
-- - - -
--
-- - - -

- -

U
nR
eg

is

te

re

-- - - - --

--

- -
--- - - -
--- - - - -

Dynamically Enabling/Disabling Local APIC


-- -
- - -
- - -
- - - -
- -- -

1258

Chapter 34: The Local and IO APICs


- - -
- - - - -
- -- - -

U
nR
eg

is

re

-- -
-- ---
- -- - -
- --- ---

- - - -
-
- - - -
-- -- ---
--- - --
- - -- --- -
- - -
- - -- -
- -
-- - - -
--- -
- --- -
- - -
-

te

- - -
--- --
--

- -

- -

-
-

-
-

1259

x86 Instruction Set Architecture


Mode Selection
- - - -
-

-
- - - -
- - - -
-

re

- - - - -
- - - -

1260

is

- -
--- -

U
nR
eg

te

- - -
- - - - -
- -
- - - -
- -- - - -

- - - -
- - -
- - - -
- - -- - -- -
--

Chapter 34: The Local and IO APICs


The Local APIC Register Set
Register Access in xAPIC Mode: MMIO
General

re

- - - -
- - -
- - -- -
-- - - -
- -- - -- -
-- - - -

te

Local and IO APIC xAPIC Register Areas Are Uncacheable

is

- - --
- - - -- - -
- - - -

U
nR
eg

xAPIC Register Access Alignment


-- - -- - --

-- -- - -
-- -- -
--
- - - - -
- --

- --
- - -
- -
- - --
-- - -- -
-- -

1261

x86 Instruction Set Architecture


Register Access in x2APIC Mode: MSR
- -
- - - - - -
- -- -- - - --
-- - - - - -
-- --

te

- -
-- -
- - - -
- -- --
- - - - -- -
-
- - -
- -
-- -
- - -
- -- -
- - - - -
- -

U
nR
eg

is

re

- - - -- -
--- - - -- -
- - --
-- - - - - -

Introduction to the Local APICs Register Set


-- - - - - --- -
- - --
- -- - -
-- - -
- - - -
- --

1262

Chapter 34: The Local and IO APICs


-- - - - - - - - - - - - -
-- -- - -
-- - - --
- - - -

U
nR
eg

is

te

re

- -
-- - - --
-- -

1263

x86 Instruction Set Architecture

-
- --
-
-
-
-
-

-
-
-
-
-
-
-
-
-
-

re

-
-

te

- -

- -
-

U
nR
eg

is

-
-

-
-

-
-
-
-
-
-
-
-

- -

- -
- -
-
-
-- -
-
- -

-
- -
-

-
-
-
-

-- - - --

1264

Chapter 34: The Local and IO APICs

- --
-
--

-
--
-- - --
- --
- - - --
--
-
- - - -
-
--- --

te

re

U
nR
eg

is


- -

- -
-
- -
- -
-
--
-

1265

x86 Instruction Set Architecture


- --
-
-
--

is

te

re

U
nR
eg

1266

Chapter 34: The Local and IO APICs


- --

-
-
--

-
- - - -
- -
-
-
-- -
- --
-- -
- - --
- - - -
-
-- --
- -
-
- -- -
--
- - -
-
--
-- -
--

U
nR
eg

is

te

re

-
-

1267

x86 Instruction Set Architecture


- --

-
-
--

-
- - -

--- -
-
- -
-- -
- -
- -
-
-
-
-
- -
--

-- -

U
nR
eg

is

te

re

--

1268

-
--
--
-- -

-

--

--
-- - -

-- -
--

Chapter 34: The Local and IO APICs


- --

-
-
--

-



-- - -
- -

-
-
-

- -
-
- --
- - - - -
- --
-
--
-- -
- - -

- --
-



-

-
-

U
nR
eg

is

te

re

- -

1269

x86 Instruction Set Architecture


- --

-
-
--

-
-

-- - -
- - -
-- -
-- --
-
--
-
-

- -
- --
-

U
nR
eg

is

te

re

-
-

1270

-
- -
--- -
-
-- -
- -
--
-- - -
-
-- -

Chapter 34: The Local and IO APICs


- --

-
-
--

-
- - -
-
-
- - -
-
-
-

-
- -
- - -
- -- -
-
- -
- - -

- - -
- -
-

U
nR
eg

is

te

re

- -

- -
- - -
-
-- -
-

1271

x86 Instruction Set Architecture


- --
-
-
--

- -
- - -
-
-
- --

--
-

-
-

- -
- - -
-
--
-
--
-
-

U
nR
eg

is

te

re

1272

-
-- -
- --

-
- -
-
- - -
-
-
-

Chapter 34: The Local and IO APICs


- --
-
-
--

te

re

is

U
nR
eg

1273

x86 Instruction Set Architecture


- --

-
- - ---
- -
--
- - -
--
- -
- -
-


- -
--

--

is

te

-
-
--

re

U
nR
eg

1274

Chapter 34: The Local and IO APICs


- --

-
-

-
-
--

-
-


- -

- --


-


--

U
nR
eg

is

te

re

--

- - - - -
- -

--
-
-

1275

x86 Instruction Set Architecture


- --
-
-
--

- - - - -



-
--
--- - --

te

re

-
--
--- - --

U
nR
eg

is

-
--
-
-


- - -

--

- - - -


1276

Chapter 34: The Local and IO APICs


- --

-
-
--

re

- - - --
--

- --
- - - --

te

Local APIC ID Assignments and Addressing


ID Assignment in xAPIC Mode

is

Introduction

U
nR
eg

- - - -- -- -
- -- -- - -

-
- -- - - --
- - --
-- - -- --
- --- --
- - - - -- -
-- - -
- - -- -
-- - - -- - - - -

---
- -- - - ---

Cluster ID Assignment
- - - --- - --
- - - - --

1277

x86 Instruction Set Architecture


-- - -- - - -
- - -

-
-
-
-
- --

--

re

is

te

U
nR
eg

--- -

-
- - - ---

Physical/Logical Processor and Local APIC ID Assignment


- -
-- ---
--- - - - -
- -- --
- - - - -- - --- -
- - - -
-
- --- - -
- -- ---
--- - - - -- -
- -- ---

1278

Chapter 34: The Local and IO APICs

- -

-
--

re

te

-- -
- --- - - -- --- - -

is

-
--

U
nR
eg


--
-


--
-

-- -
-- -- - -- - - -
-- --- -

1279

x86 Instruction Set Architecture

-- -

--
-


--
-

-
--

-- -

re

- -- -- ---

te

-- - - --
-- - - -
--- -

U
nR
eg

is

- -- - - -
-- -- -
--- - -- -

-- -

- --

1280

Chapter 34: The Local and IO APICs


-- -- -

- --

xAPIC ID Register

U
nR
eg

is

-- --
-

--- -
--
-

--

te

re

-- - - -
- - -- -

-
-


--

--
-

--

-
--

--

1281

x86 Instruction Set Architecture


BIOS/OS Reassignment of xAPIC ID

- -- - - -
-
-- -- -
- - -- -
- -
-- -- - - -

Logical xAPIC Address Assignment

te

re

--- -
-- - -- - -
-- --
-- -

U
nR
eg

is

- -



--



--- -

Maximum Number of xAPICs


- - --
- - - - -
- - - -- -
---
-
- - - - - - -
- - - - --
--- - - -- --
- -
- - -

1282

Chapter 34: The Local and IO APICs


- --- --
- - -- -

ID Assignment in x2APIC Mode


Two Hardware-Assigned Local APIC IDs
- --
- --

re

U
nR
eg

is

- - -
- - -
- -
- - -- - - - --

- -
- -
- -
-- - -
- -- - - -- -
--

te

-- -

x2APIC ID (Physical Local APIC ID)




- - - - - -

- - -- --
- -
- - - -- --
- --- -
- --
--

-
- -- - - --

--

1283

x86 Instruction Set Architecture


- -- - -- - -
-
- -
- - - - --
--
- - - -- -- --- --
- -
- - - --- -
-- -- -

- -- - -

re

U
nR
eg

is

te

--- - -
- -
- - -
- - -- ---
-
--- - -
- -
- - -
-- - -
-- - -
-- - --
--
- -- -
-
--

--
- - -
- - -
- -
-
- -
- -
-

1284

Chapter 34: The Local and IO APICs


- -
-- -- -
-- - - -
- - -- - -

re

- -

- -
-
- - - - - -

te

Logical x2APIC ID

-- - - -

U
nR
eg

is

-- -- -
- -- - - -- -
- - --
--- -- - -- - --
--- - -
-- -
-- -
- - - -
- - -
- - - - - -- - -
- - -- -- -

--- -- -
- -- -
- - -- --
-- - -- -
---

1285

x86 Instruction Set Architecture

- -


- - - -
- --
- -
-

--

is

te

re

- - - -
- --
- - - -
- - -
-
- - - -

U
nR
eg

---
- -- -
--- - -
- --- -
-- - - - -
-- -- --
- -
-- -
- - -
-- - --
--
- -- - - -
- - - - -
-

1286

Chapter 34: The Local and IO APICs

-- -

- -

re

--
-- - -

te

- --

U
nR
eg

is

-- - -- -- - - - - -- -- -
-- - -- - - -

--- -- -
- - -- -
- -
- - -
- - -

--

Local APIC Addressing

Physical Addressing: Single Target


-- - - -- -
-- -- - -

--
--

1287

x86 Instruction Set Architecture


-- - -
- --

Logical Addressing: Multiple Targets


--

-- --

-- - --

re

- -- - --
-
-- --
-- --

te

-- - -- -
-

U
nR
eg

is

- --- -- -
-- - -
- -- -

- - -- - -
-

- --- -- - -

- - -
- - -
- - -- - - - - -

1288

Chapter 34: The Local and IO APICs

--

- -

-
-
-

re

- -

- --

- --

te

- - - -

is

U
nR
eg

- --- -- - - -
-- - - -
--- - -
- --- --
- - - -
- - - -
- - -
-- -

- - -
- - -
- - -
- - -
- - -
- - -
- - -
- - -

-- - -- --
--- --
- -
--- --

1289

x86 Instruction Set Architecture


- - - -
- - - - -
-
-- -- -
- -
- -- -- -
- - -

- - -- - - -

te

re

--- - - - --
-
- --- -- -
- - - -
- - -- - - - - - - - - -
- --

U
nR
eg

is

-- -
- --- -- -
- - -
-- - - - ---
-- - -
- - - --
- -- - --
- -- - -
- - -
- - --- - -
- -- - - - -
--- -- --
- --

1290

Chapter 34: The Local and IO APICs

-- - -

- -

-
- -
- -

re

- - -

- --

te

- - - -

is

- - - --

U
nR
eg

- - - - - -- -
--- -
- - -
- -
-- - - - - -
- --- - - -
- -
- -
- -- - -
-- -- - --
-- - -
- - - -- --
-- -
- --- -- -
- - -
-- - - - ---
-- - -
- - - --

1291

x86 Instruction Set Architecture

- -


- - - -
- --
- -
-

te

re

- -

- -

is

U
nR
eg

- -

Message Addressing Summary


-- - --
-

--

--

1292

--

--- - --
- -
-- - - - --
-
-

Chapter 34: The Local and IO APICs


--
--

-
- -
-- -
- - -
--
- - -
---
- --- -
-- -
- - --
- - --
- -- -- - -
- - - - - - -
-
- ---
--
--- -
- - --
- -
-- - -- -- - - - - - - -
- - -
-
-- -- -
- --

U
nR
eg

is

te

re

--

--- - --
-
-- - - - --
-

1293

x86 Instruction Set Architecture


--
--

--

- -
-- -
- - --
-
--- -
--- -
- -
-- - -
-- - -- -- - - - - - - -
- - -
-
-- -- -
- --

---

--- -
-- -
-- - - - --
-

---

U
nR
eg

is

te

re


- -- - -
-- - -- - -
- -- - --
- -
-- - - - --
- --

Lowest-Priority Delivery Mode


- - --
--- - -- -
-- - -- --- -
-- - -
-- - - -

1294

Chapter 34: The Local and IO APICs


-- - - -

General
- - - -- -- - -

-
- -
- -

U
nR
eg

is

-- - - --
--- -- - -
- - - -
--- - --
-- -
- - -

te

re

- -- -

- -

-- - -
-- -

Warnings Related to Lowest-Priority Delivery Mode

--- -
- - -- - - -
- -
- -- - --- - --
- - -- -
-- - -
-- - - -
- -
- ---
- -
- - - - -
-

1295

x86 Instruction Set Architecture

- --- -
- - - --
-
- - -
-- - -
- - -
--
- - - - - --- - --
- -

Chipset-Assisted Lowest-Priority Delivery

te

re

- - - - -
- -- - -
-- - -
- - --- -

- - --
-- - --
- - - - -
-- - -
-
- -- - --
- - -- - -- --
- - -
- - - --
-- - - -
- - ---
- -- - -
- - - ---
- -- -
- -- -
-- - - --

U
nR
eg

is

-- --- - - -
-

- --- - -- - - -
- --- --
--- -- - --
- -- - - -

1296

Chapter 34: The Local and IO APICs


--- - --
-

- -- -
-- - - - --
- - -
- - - -- - --

re

- - - - --
-- - - -- - -
--

-- --
-- - --

is

te

Local APIC IDs Are Stored in the MP and ACPI Tables

U
nR
eg

-- - - - - -
- - -
-- - - --
--
- - -
-- - -- - - -
- - -
- - - - - -
-- - -- -- -
- --- --
- -- -
--- --
- ---
--

1297

x86 Instruction Set Architecture


Accessing the Local APIC ID
-- - -

te

- -
- -
-
-
-- -
- -

-- -- -
--- -- - -
-- - -

-- -- -
- -

re

is

An Introduction to the Interrupt Sources

U
nR
eg

-- - - -
-- -- - - -
--

Local Interrupts

- - --- -
--- - --

1298

- - -
-- - -
- -
- -- -
-- -
--
- -- --
--- --
- - -
-- - - --

Chapter 34: The Local and IO APICs

te

re

-
-- -
-

--
- --- -
-
- --- -

--
---

- - -

- - -

is

U
nR
eg

--

--

--

Remote Interrupt Sources


--- - -
--- - - --

- -- --- -- --- -
-

1299

x86 Instruction Set Architecture

--- -- - -
--
-

---
-- -- -

--- - -- - -
-- - --- --

re

Introduction to Interrupt Priority

te

General

U
nR
eg

is

- -- --
- - - -
- -- -- --
- -
-- - -

1300

Chapter 34: The Local and IO APICs


--

--

- - ---
- --
- -
-

- ---
- --
- -
- -

- --
-- -

- --
-- - - - - -
-

- -- -
--
--

-- -

U
nR
eg

is

te

re

-- - -

Definition of a User-Defined Interrupt


- - - - -
-
- - - -
- - - --
- - - --
- ---
-

1301

x86 Instruction Set Architecture


-- - -
--
- - - -
- - -- -
- --
- - -

- -

re

is

te

- -- -


-
- -
- -
- - -
- - -

U
nR
eg

User-Defined Interrupt Priority


- - -
- -- - -
- - - - -
- - - -
-- -
- --- - - ---
- - - -
- - - - - -
- -
-- - - -
-- - -
- --
-- -
- - - - - -- -
- - --- -
- - -

1302

Chapter 34: The Local and IO APICs


- - - - - - -
-


-- -


-
-
- - -
- -

-- -
- - -
- -

re

--

U
nR
eg

is

te

- -- -
- -
-
-
- - -
-
-- -
-
- -
-

- - -
--
- -

- -- -
- -
-

- -- -
- -
-

- -- -
- -
-

- -- -
- -
-

1303

x86 Instruction Set Architecture


-
--

- -- -
- -
-

- -- -
- -
-

- -- -
- -
-

re

- -- -
- -
-

te

is
U
nR
eg

- -- -
- -
-

- -- -
- -
-

- -- -
- -
-

- -- -
- -
-

- -- -
- -
-

- -
- -- -

- -- -
- -
-

1304

Chapter 34: The Local and IO APICs


Definition of Fixed Interrupts
- - - -
-- - - - -- -
- -- - -
- -

re

Masking User-Defined Interrupts

-- - --
-- -
--

U
nR
eg

is

te

- -- -
- - - - - -
-
- -- -- - -
- -- -

Task and Processor Priority


Introduction

-- - - -
- - --

- -
--
-
-- - - - -

- - -

-
-
- - -

1305

x86 Instruction Set Architecture


--- -- -
-

The Task Priority Register (TPR)


- - - -
- --- --
- -- - --
- - - -
- -

te

re

-- -- - - -
- - - - -
- -- --
-- -
-

U
nR
eg

is

- - - -- - - -
-
-
- - -- - -
-- - - -
-- -
-

- -

--

--

The Processor Priority Register (PPR)


-- -
-
- - -

1306

Chapter 34: The Local and IO APICs

-- - -
-
-
-- - --
- - -
-- - -

The User-Defined Interrupt Eligibility Test

-
- - - -- -

is

te

re

- - - - - -
- - -- -
-- - -
- --
- - - -
--
--

U
nR
eg

-- - -

- -- -
- - - --
- - -
- -- - -
-- - -
-- -- -- -
- -
- -
-
-
- - -
- - -- -
-- - -
-- -
- - -- --

1307

x86 Instruction Set Architecture


-- -

--

--

--

--

CR8 (Alternative TPR)

- -- - - - -
-- - -- -
- - -
-- -

U
nR
eg

is

te

re

- -
- - - - -- -
-
-
-
-- -
-- - - -- -

--- - -
-- - -

-
--
- -
- -
-- - -
---

1308

Chapter 34: The Local and IO APICs


Interrupt Message Format
- - ---
- - -
-- - - -

te

- - -- -- --
- - --
- -
-
- - - -
-

re

is

-- -
-

U
nR
eg

-- --
-

- -- - -
-- - - -
-

- -

1309

x86 Instruction Set Architecture


-- --
-

--- - -
- - - -
-- -- - - -- - -
- - -- -- -
-- -- - - - -
- -- - -
-
-

- - -
--- -
-

- -
- -
---
- -
-- - -- -- -
- - - ---- -
- -- -
- -
- --
- - --- -
---
- - - -- ---

1310

U
nR
eg

is

te

re

- - - -
- -
-
- -
-

Chapter 34: The Local and IO APICs


--
-

-
-

-
- - - - -
- - -- - - -

--
--

is

te

U
nR
eg

re

1311

x86 Instruction Set Architecture


--
-

- - - - - -
-- -
- -
- - -
--
- --
- - --- -
--
- - -
-
- - -
- - --
- -
- - - - - - --
- -
-
- -- -
- - - -
- - - - --- -
-- --- -
--- -
-

1312

U
nR
eg

is

te

re

- - - -
- - - -
- - -

Chapter 34: The Local and IO APICs


IO/Local APICs Cooperate on Interrupt Handling
The Purpose of the IO APIC
--- - -- - -- -
-- - -
-
- -- -

U
nR
eg

- --- - -

--- -

- --- -

is

te

re

- - - -
- -- -- - -
--- -- ---
- - - --
-- ---

- - --
- -
- - - -

-- --
- - - - -
- - -
-
-- - -- -
---

- - - - - - -
- - - - -
- -
- - -

1313

x86 Instruction Set Architecture

U
nR
eg

is

te

re

- -- -
- -
- -
- - - -- - - -
- - - -
-
- -- - --
- ---
---
- -
- -- - ---
- - - --
--- - - -
-- -
- - -
- - --
- - -- - -- -
---
- --- -
--- ---

--- -

- -

1314

Chapter 34: The Local and IO APICs


---

re

- -

te

- ---

U
nR
eg

is

1315

x86 Instruction Set Architecture


Overview of Edge-Triggered Interrupt Handling
Assumptions
- - ---

is

U
nR
eg

te

re

- -
-
- - -
- -- - - --
--- -
- - -
- - -
- -
-
-- - - -
- --
-- -- -

- --- -- - - ---
-

Description

1316

--- -
- - -
- -
-- - - -
-- -
--- - - -
- -
- -- -
- --- - -
-- - - --
- -- - - -
-- - -
-
- --
- -- --
- -

Chapter 34: The Local and IO APICs

- - -
--
--- - -
-- --
- --
- --- -- -- - -
- -
-- - --

- -

is

te

U
nR
eg

re

- -
-
-

1317

x86 Instruction Set Architecture

U
nR
eg

is

te

re

1318

Chapter 34: The Local and IO APICs

-
-

re

U
nR
eg

is

te

- -
-
-


- -

-- -
- - - - -
-- - --
- -
--
-- - -
-- -- -
-
- --
- - -
-- - - -
-- -
-- --- -- ---

1319

x86 Instruction Set Architecture


- - -

- -
--

- -
-
-

te

re

is

U
nR
eg

-
-

- -
-
-

--
-- - -- -
- - -
- - - - -

1320

Chapter 34: The Local and IO APICs

---

- -
-
-

d
re

te

U
nR
eg

is

- -
-
- - - --
- - -
- -
- -

Overview of Level-Sensitive Interrupt Handling


Assumptions
- - ---

- -
-

1321

x86 Instruction Set Architecture

- - -
- -- - - --
--- -
- -
-
- - - -
- --
- - -
-- - - -
- --
-- -- -

- --- -- - - ---
-

re

Description

U
nR
eg

is

--- - -
-
--
- - -
-
- - --
- - - -

- - - -
- - --- -
- -
- -
- -- -
- --- - -
-- - - --
- -- - - -
-- - -
-
- --

- -- --
- -

- - --
--

te

1322

Chapter 34: The Local and IO APICs

--- - -
-- --
-
- --- -- -- - -
- -
-- - --

--
-

-
-

re

te

U
nR
eg

is

- -
-
-


- - -
-

-- - -
- -- - - - - -
--
-- -- - --
- - -
-- -- -
-
- --

1323

x86 Instruction Set Architecture

- - - -- -
- -
-- -
-- --- -- ---

- - -
- -- -
-
-- -
- -- -
- -
- -

re

--

is

U
nR
eg

te

- -
-
-

-
-

- -
-
-

--- -
- - -- - -
- - - - - -

1324

Chapter 34: The Local and IO APICs

---

- -
-
-

re

U
nR
eg


- - -
-
-- - -
- - -

- -

te

- -
-
-
-

is

- -

- -
-
- - - --

- - -
- -- - - -
- - - - - -- - -
- -
- - - - - - - - - -
- --
--
- --

1325

x86 Instruction Set Architecture


- - -
- - --
- - - -
- - - - -
--
-
-

Higher-Priority Fixed Interrupt Preempts Handler

te

re

-- -- --
- -

is

U
nR
eg

- -
-
-

-
-

1326

Chapter 34: The Local and IO APICs


- -
-- - -
-

- --

re

te

U
nR
eg

is

- -
-
-

- --- --- - -
- - -
-- -
- - - - - -
- --
- -- -
- - - -- - -
-- - -
- --- --- -
- - -
-

1327

x86 Instruction Set Architecture

- -
-
-

-
-
-
- -
- -

re

te

U
nR
eg

is

- --
-
-

1328

Chapter 34: The Local and IO APICs

- -
-
-

re

te

U
nR
eg

is

- - -
- - - - -
- -
- -- - -- -- - - -
- -- - - --
- -
-

1329

x86 Instruction Set Architecture

---

- -
-
-

d
re

-
- - -
- -

te

U
nR
eg

is

-
- - - - -
- - - - -
- - - -
- -- - -
-- -- --

1330

Chapter 34: The Local and IO APICs

---

- -
-
-

-
- - -
- -

re

te

U
nR
eg

is

-
- - - - - -
- - - - -
- - - -
-- - -
-- -- --

IO APIC Register Set


IO APIC Register Set Base Address
- -- - - - - - --
- - - -

1331

x86 Instruction Set Architecture


- -- - - - -- - --

IO APIC Register Set Description

re

- - - --- -- -
- -
-- - - --
-- -- -- -
- - - -
- - -- - -- - -

--

te

U
nR
eg

is

-- -

--
-- --
- - -
- - -
- -- - -
--
- ---
- -

-
-

--
-

- - -
-
-
-
--
- --
-

1332

Chapter 34: The Local and IO APICs


-


- - -
- - -
- --
-
-
--
-- -
-
-
- --

- --
-
-
- --
--- -
- - -


--
-
- -

-
-
- - -

U
nR
eg

is

te

re

--

-- ---- - -- - ---

- - --

-

1333

x86 Instruction Set Architecture


-

--

- -

- -
-

- -
--
-
-- -
- -- -

- -

te

re

is

- -
-
- - - --

-

- -
-
- --

- -

- --
- -
--

U
nR
eg

1334

Chapter 34: The Local and IO APICs


-

--

-
-

IRQ Pin Assertion Register

is

te

re

- - - - - -
-
-- - -
- - - - -
-- -
- - -
- - -
- - - -

U
nR
eg

- - -- -
-- - -- --
--- - -
-
-- - - - -

-- -


- - -

1335

x86 Instruction Set Architecture


IO APIC EOI Register and Shared Interrupts
- -
- -- - -
- - -
- - - -
- - - - - - -
- - -
- -

- -

te

re

-- - -
- -
- - -- -
-- - -
- -

U
nR
eg

is

- - -
- - -
- - -
- - --
-- -- -
- -- -
-

- - -- -
- - -
- -- - - -
- -
- - - - -- --
-- - - -
- - --
- -
- - -- -
- - -
- - -
- -- -
- -
- - - - -

1336

Chapter 34: The Local and IO APICs


-

te

re

- -- - -
- - - - --
- -
-- -
- - - -
- - - --
-- -- --
--- -- --
-- - --
-
-- - - - -
- - -- - -
- - --
- -- -
- - - - -

U
nR
eg

is

- - - - - - -
-
- - - --
- - -
- - - -
-- - - -
- -
- - - -
- - -
- -
- -
- -
- -- - - -
- - - -
- --

- - -- - - --
-- - -- - - -- -
-- - -- -

1337

x86 Instruction Set Architecture


- --
- - - -
- - - -- --
- - - --
- - - ---
- -
- -- - --- -
-- - -
- -- -
- -

re

- -- --- - - - ---
- -
-- - - --
- -

U
nR
eg

is

te

- - - -
- - -
- - - -
- - - - - -
- - - -

- - - -
-- -
- -
-

- -

- - -

1338

Chapter 34: The Local and IO APICs

re

te

is

U
nR
eg

- -


- -

- -
-- --

---

- -

- -

1339

x86 Instruction Set Architecture

- -

- -

-
-

re

-
-

te

IO APIC ID Register

is

- --
-- - - -
-- - - -

U
nR
eg

IO APIC Version Register

- - -

-
- - -
- -
-- -
-
- - -

-
-- -
-

1340

Chapter 34: The Local and IO APICs


IO APIC Redirection Table (RT) Register Set
- - -
-
- - -- - - - - -
- - - - -
-

U
nR
eg

is

te

re

- - --
- - - -- - -
--- -- - - -
- -

1341

x86 Instruction Set Architecture

U
nR
eg

is

te

re

1342

Chapter 34: The Local and IO APICs

-
-

-
-
- -- - - - -

-- -- --- - --
- -
-- -- --- - -
-
- -- - - -
- - -- -
--- -- -
-
-- - -

- - -
- - - -
- -

is

U
nR
eg

te

re

-
-
- -
- - -
- -- -- -
- - - -- -
- - --
- - -
- - -

--

1343

x86 Instruction Set Architecture


-
-

-
- - - -
-- - - -
-
- -- -

-- - - -

- - - -
- -- -- - -

- - -- -
-
-- -
-

- - - -
- - - -
- -- - - --

- -
- -- - - - -
-- -

re

te

is

U
nR
eg

-
- - - -
- - -- -
-

IO APIC Interrupt Delivery Order Is Rotational


- -
--- -- -

1344

Chapter 34: The Local and IO APICs


- --- -
-- - -- -
- - - - -- -- -- -
---

Message Signaled Interrupts (MSI)


General

U
nR
eg

te

-- --
- --
- -

-- - --

-

is

re

- -
-

- - - --
- -
--

-- -
-
-

- -
--

-
-- -- -
- -

- - -
- -- -- -
-- -- - --
- - - - - -

1345

x86 Instruction Set Architecture


-- - -
-- -- - -
-
-- - -
- - -
-- - -- - --
- - -- -
- - -

re

- --- - - - -
-- -- - - --
-

Using the IO APIC as a Surrogate Message Sender

te

- - - -- -

is

Direct-Delivery of an MSI

U
nR
eg

- - - -- -
- --
- -- -
- - --
-- - ---
-- - -- - -- --- -
- -- - - - --
- - -
-- ---
--
--- --
-- - - -
---- - -

-- -- -- -
--- - -

1346

Chapter 34: The Local and IO APICs


- - - -
- - --
-- - - -
- - - -
--
- - - - -
-- - -- -
-

re

Memory Already Syncd When Interrupt Handler


Entered
The Problem

U
nR
eg

is

te

-- - --
-- -
-- - -
- -- - --
- - - -- - - - - -
- - -- - -
-- -
--- - - -
-- - - - -
- -- --
- -- --- - -- - --

Old Solution

- -
- --
- - - - -
- -- -
- - - - - -
- - - -
- - - -

1347

x86 Instruction Set Architecture


- -- -
- -

How MSI Solves the Problem

U
nR
eg

is

te

re

-- -
-- -- -
-- - - -
- -- -
-- - -
- - --
- - - - - - -- -- -
-- -- - - -- - - --
- - - - - -
-
- - - - - - -
- -
-- - -- -
- - --
- -
-- - --
-- -
- -- --- -
- -
- - -

Interrupt Delivery from Legacy 8259a Interrupt Controller


- -
- -

-
-

Virtual Wire Mode A


- -
- -
-- -

1348

Chapter 34: The Local and IO APICs

- --
- - --
- - ---
- - --
- ---
-

-- --

te

- - --
- - -
-
-- -
-- -
-- - --
- -

re

U
nR
eg

is

1349

x86 Instruction Set Architecture


Virtual Wire Mode B
-
-

- -
-
- -- - -

-- -

U
nR
eg

te

- -- -

-- --- - -
-- - -
- --
- - -
-
-- -
-- -
-- - --
- -
-

is

re

-- --

1350

Chapter 34: The Local and IO APICs

U
nR
eg

is

te

re

SW-Initiated Interrupt Message Transmission


Introduction

--- - -

-- --- -
-- -- - - - -
---
-- ---
--- -- --- -
--

- - -
-- -- --
-

1351

x86 Instruction Set Architecture

is

U
nR
eg

te

re

-- --
- - - - -- -
--- -- -- --
- - -

-- -
- - -- - -
--- - -- -
-- - -
-- -- --
- - -
-
-- - -
- --- -
- -- -
--
-- - -
-- ---

--- -
- -
-- - -
- --
-- ---
-- -
-- -- - -
-- - -
-
--- - -- -
--- - --
-
--
- - - -- -

--- - -
- -- - - -
--- ---


1352

Chapter 34: The Local and IO APICs


Sending a Message From the Local APIC
-- - -
- -- - - -

ICR in xAPIC Mode

te

- - - -

- - - -- -
- --

re

- - - -
- - - - -
- --- -
-

U
nR
eg

is

-- - - -
- -
- -
- - -
- -

ICR in x2APIC Mode

- - - -
-

- - - -
- --
- -
- -- --- - -
- - - -

- - - --
- ---
- - -- -- -
--

1353

x86 Instruction Set Architecture


- -

-


-
-



-

-



-

re



--

--
--

- - -

-


-

is

te

-
-

U
nR
eg

- -

-


-
-


--

--
--



-

-



-
-
-

- - -
-

-

1354

Chapter 34: The Local and IO APICs

--

-
- - - - -- -
--

- -
-
-
- --- - - - - - -
-
- -
-- - -
-- - --

-- - -
-
--
-- - --
- - --
-- - -- -
--
-- --
- --
- --
-- -

U
nR
eg

is

te

re

1355

x86 Instruction Set Architecture


--

-
- - -
- - - -
- -- -
- -
- --
- -
- - - -
-
-- -
- - - --
- -
- -- --
-- -
--
- - ---
-- -- -
-- -- -
--
--- -
-
- - ---
-- -- -
-- -- -- -
- - -
--
--- - -
---
- - - - - -
--
-- - -

U
nR
eg

is

te

re

1356

- -- - -

--
- - - -
--- - -

Chapter 34: The Local and IO APICs


--

-- - - -
- - - - -
--- - -

- - -
- -
- - - ---
- - - -
- ---
- - - -
- --- -
- - -- ---

-
- - - -- -
- -
- - -- -
- - --
-

U
nR
eg

is

te

re

1357

x86 Instruction Set Architecture


--

-
- - -- - -
- -
- - -
- ---
- - -
- -- -
- --- - -
- - - ---
- - - - - -
-
- ---
-
-
- ---
-
- - - - -
--- -

-- -
- - -- -- - -
- - -- -
- - -
- - - - -
-- -- -
- - --
-- - -- -
- - -- - - -

- - - - -
- - --
- - -
- - ---
- -- -- -
-

U
nR
eg

is

te

re

1358

- - - - -
-
---

Chapter 34: The Local and IO APICs


x2APIC Modes Self IPI Feature
-- - -
- - -- -- -

is

te

re

- -
--
--
-- -- --- -
-
-
-- - - - -


- --- -

- -

-
-
- - -

U
nR
eg

-- - -
-- -

-- -
-- -
-
- - -

- - -
- - -
- - -

1359

x86 Instruction Set Architecture


Locally Generated Interrupts
Introduction

--

- ---
- ---

--- -
--- -
---
-

re

is

te

-- -
--

U
nR
eg

--

--

--

The Local Vector Table


- - - - - -- -
-
- -- --

1360

Chapter 34: The Local and IO APICs


-
- - - - ---

The Pentium Familys LVT


-- - -- --

-
-
--
-

The P6 Familys LVT

te

-
-
--
-
-

is

re

-- - -- --

The Pentium 4 Familys LVT

U
nR
eg

-- - --- --

-
-
--
-
-
- -

Core Processors LVT

-- -- -- - ---
--

-
-
--
-
-
- -
-

1361

x86 Instruction Set Architecture


LVT Register State After Reset, INIT, or Software
Disable
- - - ---
--
-
- -
- --

re

- - - -
- -
- -

U
nR
eg

- - - -
-
- -

te

--

is

Local Interrupt 0 (LINT0)

--
--

The Mask Bit

-- - -

The Trigger Mode and the Input Pin Polarity


-- - - - -
- -

1362

Chapter 34: The Local and IO APICs

- --
- - -
- - -- -
- - - -
- - -

- - --
- -

- - -
- - -
- - - --

re

The Delivery Mode

is

te

- - - -
-- - -
-- -

U
nR
eg

-- -

- - -
-- - - - -
- -
-

- - -
-- --
- - -
-

1363

x86 Instruction Set Architecture


-- - -

- - -
-- --
-
-- -

- - - - -- --
-
-- -
-

-

-- -
-- -- -
- - --
--- - -
-
-
- -
- --
-- -- -
- --

te

U
nR
eg

is

re

The Vector Field

- -
- - - - - -
- - - -

1364

Chapter 34: The Local and IO APICs


The Remote IRR Bit
- - - - -
- - -
- - - ---
- - -

The Delivery Status

is

- -
-
- - --
-
- - -
-- -

te

re

- - -- -
--

U
nR
eg

Local Interrupt 1 (LINT1)

- - - -
- -

1365

x86 Instruction Set Architecture


-

-
-
-



-

-


-



--

re

is

U
nR
eg

te


-
- - - -
- - -
-
-

The Local APIC Timer


General

-
-
-- - - - - -
- --- -

- --
-- - - - - - -
- -
- -
- - - -
-

1366

Chapter 34: The Local and IO APICs


The Divide Configuration Register
- -
- - - - -

One Shot Mode

- - - -
- -
- -
- - -
- -

re

Periodic Mode

U
nR
eg

is

te

- -
- - -
- -
- - -- -
- -

1367

x86 Instruction Set Architecture


-

re

te

is

-
-
-

U
nR
eg

The Performance Counter Overflow Interrupt


-- -
-
- - - --
--- - - --
-- - - -
- -- -
-- - - -

1368

- ---
- ---

Chapter 34: The Local and IO APICs

- -
-
-

- - - - -

re

- - -
- -
-
-
- -
-
- - - - --

U
nR
eg

is

te

- - -
-
-- -- - - - -
- -
- - - - -

- --



- -
- -
-

- -
- -
-- -
-
- - -
--

1369

x86 Instruction Set Architecture

- --

-
-
-
-

re
te



-

-


-

is

The Thermal Sensor Interrupt

U
nR
eg

- -
- -- -
- - - -
- -
- - - - -
-- -
- -
- -- - - -
- - -
- - -
-
- - - --

1370

-
-
-

Chapter 34: The Local and IO APICs

-
-
- - - -
-- - - - -
- - - -
- - - - - - -
-
- - - -
-- - -
- - -
--- -

re

te

is

U
nR
eg


- -- - -
- - -

- - -
-
- -
--
- --
---

- -- -

-

- - -

- - - -

1371

x86 Instruction Set Architecture


- -
-- -
-
- - -
--
- -

re

te

is

Correctable Machine Check (CMC) Interrupt

U
nR
eg

- --

1372

- - - -
- - -
- - -
- - -
-
--

- - -
- -
-- -
-
- - -
--

Chapter 34: The Local and IO APICs


The Local APICs Error Interrupt
Local APIC Error LVT Register
- - - -
- -
---

is

re

- - - -
- - -
- - - -
-
- - - -
-- - --
- - -
--
- -
- --
-

te

U
nR
eg

- - - -

Error Status Register (ESR) Operation in xAPIC Mode


- -
- -
- - - --
- - - - - - -
- - - - -
- -
- - - -

Error Status Register Operation in x2APIC Mode


- -
-- - --
- -- -
- -
-- -

1373

x86 Instruction Set Architecture

re

- -
- --
-
- -- - -
--
- -
-- -

- - - -- - -
- --
- - --

- -
-- -

te

U
nR
eg

-
-
-

is

- -

- -- -


-
- -
- -
- - -
- - -

1374

Chapter 34: The Local and IO APICs

- -

re

- -- -



-

te

- -

-
--

-

-- --

-

-- - -
-

- - - -
- -- -
-

is

U
nR
eg

--
-- -
-
-- - -

1375

x86 Instruction Set Architecture


- -

-
-- -

- -

-
-- - -
-

-
- --
-

te

re

U
nR
eg

is

-
- --
- -

The Spurious Interrupt Vector


The Problem

-- - - - -
- -- - - --
- - - --
- -- --- - - -
-
-- -
- -- - -
- - -

Solution
- - -
- - - -

1376

Chapter 34: The Local and IO APICs


- -- -
-- -
- - -

-- - -
- - - - -

-- -- --- -
-

re

- - - - - -
- -- - -
- -- - -

te

Additional Spurious Vector Register Features

- -
- -
-
- - - -
- - - - - - -- - - - -
- --
- -- - - -- - - -
- - - --- -
--- - -- --
-- - --
---

U
nR
eg

is

- - -
- - -

1377

x86 Instruction Set Architecture


- - -

- -
- --


-
-
-

re

-
-

Boot Strap Processor (BSP) Selection

U
nR
eg

is

te

--- -- -- -
-- -- -- --
- - - --- ---
-- - --
--- --
-
- - -- - - --
-- - --

Introduction

-- - - --- -
--- - - - -- -
-- -
- -- - -
-- - - -
-- - --- -
- -- -
-- - - -
- --

1378

Chapter 34: The Local and IO APICs


The BSP Selection Process
Pre-QPI BSP Selection Process
- --
--- - - -
--
- -
--

re

-- - - - -

-- -- - - -
-- -- -
-- - -

te

- --- - -- -
- - ---
- -

U
nR
eg

is

- --- --- -
- --- - - - -- --
- --- ---
- -- - -

-- -- --- --- -- - -
- - -
-- -
- - - ---
- -- - - --
-- - - -
-- - - - -- --
--
-- - -- -
- -- - - -- - --- - -
- - -

1379

x86 Instruction Set Architecture

- --- - - --
- -- - -- - -
- -
-- - -
- -- - - - -
-- - - -- -- -
- - - -
-- - -- -
- -- - -

re

- -- - -
- - --
- --- - - -

te

--

-- -

is

--
--

---
- -

U
nR
eg

--- -

- -

-- --- -
-- - --
--
-- - -- - -
-

-- -
-- ---
- ---
- -
- -
-

-

-

1380

Chapter 34: The Local and IO APICs

- -

-- - - - --

re

--

te

is

- -
--- - - -
--- - - - -

U
nR
eg

Intel QPI BSP Selection Process

-- ---
--
- -
- --- - -
--

- -
- - - -
--
--- -
-
--

How the APs are Discovered and Configured


-- -
- - -- - -- - ---

1381

x86 Instruction Set Architecture


- - -- -
--
-
-- - - -
--- -

AP Detection and Configuration

re

-- - --
- - -
- - - -
---
- ---

Introduction

U
nR
eg

is

te

- -- --
-- - -
- -- - -- -
- -- - --
- - -- - - -
- -- - --
- ---
-- - - -
- -
-- - - -
- --- - - - -
- -
-- - -
--- --- -

BIOS AP Discovery Procedure


- - -

1382

-- -- -
-
-
- - -
- -- -- ---
- - -
- -

Chapter 34: The Local and IO APICs

U
nR
eg

re

te

- - -
- - -- --
--
- --
- - -- -
- - -
--
- - - -- - -
-- -- -- - - -
- --
- - - - --
- --
- - -- -
-- - --

- - - -
-
- - - --
-- -- -
-

- -
-
-
--- - - -
- - -- -
-
-- - - -
- - - - - --
- --
--
- - - --
- - --- - - -- - --
-
--
- --
--
- - - -
- - - - --- -
-- -

is

1383

x86 Instruction Set Architecture


- - -
- - - -
- - -- - - -
- -
- -- - -- - --
- - --- -

te

Uni-Processor OS and the APs

re

- - --
-- - --
- -
--- -

U
nR
eg

MP OS and the APs

is

- -
- - - -
-

- -- -

1384

- - -
- - -- -
--
- - - -- ---
--- - -
-

Chapter 34: The Local and IO APICs


- -

--

te

- -
-- --
-

re

-
-
-

is

-- -

U
nR
eg

- - -

--
-
--

- - - --
-
--

1385

x86 Instruction Set Architecture


- -

-
- --
-
--
- --

-
- -
-

re

te

- -

-

U
nR
eg

is

-

--- -
- -

- -
-- - - -
--- - -- - -- -

1386

- -


- -

Chapter 34: The Local and IO APICs


- - -

- -
- --


-

re

-
-

-
-

te

The FindAndInitAllCPUs Routine

U
nR
eg

is

- -- -- -
- --
- - -
- - -

- - - - -
- - - -
-- - -- -- -
-
- - - - -
- - - -
-- --
- - --
--- -
-- -- -

-
-
-
-

- -

-
- -

1387

x86 Instruction Set Architecture

--- - - - - - -
- -
-- -- --

-- - --
- - - -- -
- - -
- - -
- - -- --
--
- --

-- - - -- - -
-- -- -- - - -
- --
- - - - -
- --

- - - - -

-- - - --
-- -- -
-

- -
- - -- -

-
- - -
- -
- -

U
nR
eg

is

te

re

-
-

- - -
- -
- -
- - -
-

1388

Chapter 34: The Local and IO APICs


- -
--- - -- -
-
-

re

--- - - -
- - -
-

- --
- -- -

--

te

-

--

is

- -
- -- -

U
nR
eg

- -

- -
-

- -
--

--

- - -
- - -
--

-

1389

x86 Instruction Set Architecture


- - -
- - -

re

- -

- -
--

te

- -
-
-

U
nR
eg

is

- -
-
- - -

1390

Glossary of Terms

-
-- -
-
- --
-


- -
-
---

- - -- -
- -- -

--
-

-- -
- -
- --

-- -
- - --

-

- - - -


-- --
- --

-- -
-

U
nR
eg

is

te

re

1391

x86 Instruction Set Architecture

-
- - -- -
- --
- -- - -
--
- -
-- -- - -
- - -- - -
- -

- -
--
--
- -
-
--
- -
-

U
nR
eg

is

te

re

- --

- -
-- --
- -

--

- - -
-- -
- - --

-- - -

- - --
-- - --

-- - - -
- -
- - - -- - -- -
--
-

1392

Glossary of Terms

- -
-
- -

- - --
-
--- -

- - - -

-
-
-

- - -
- - -
- -
- - -
-
- - -
- -
-- ---
-- - -- -- -
- -- -
-
- - -

U
nR
eg

is

te

re

-
- - --
- -
-
- -

1393

x86 Instruction Set Architecture

-
--


--
-
- -- --
- ---
-

--

- --
-- - -
- -- --


--- -
--- -
-

U
nR
eg

is

te

re

- - -
- - -
-
-- - -
- - -
- -
--- -
- -
- -
- - --

--

1394

Glossary of Terms

-
- --
- -
-- - -
- - --
- - -
- -- -- --
- -- -
- - --
-
-
- -- - - -
- --

--

-- - -
--
--- - -
-- -
-- -

- -- -
-

U
nR
eg

is

te

re

- -

1395

x86 Instruction Set Architecture

-
- -
-
- - - - -
- ---
-
-
- -

-
- --
--

- --
--
--

- -
-

U
nR
eg

is

te

re

-
- - -
-- -
-
- -
- - --
- - -
- -
- -
- - - - -
- - -
--
-
- - -

--

1396

Glossary of Terms

-
- -
- -
- -

- --
- -- -
-

- -
-

--

--- -
-- - -- -
- --
-- - -
- -
- --

U
nR
eg

is

te

re

-
-
- - -
- -
-
- -
-
- -
- -

-
-
- - -
- -
- -
-

1397

x86 Instruction Set Architecture

-
-

-
- -
- - -
- -
-
-

- -

- --

--- -
- - --

U
nR
eg

is

te

re

-
- --

-
--
- --

-
-- -

-- -
-
- -- - -
-

1398

Glossary of Terms

-
-- - -
-- -
- --- - -
- -
-
- - - -
-

- - - -
- -

-

-- - -
- -
- -
- -- - --
--
-

U
nR
eg

is

te

re

--

- -
- - - --

1399

x86 Instruction Set Architecture

-
- --
- --
-- -- - - -
- - - - - -- ---
-- - -
- -
- -- -
-
- - -
- -

- -

- -- -
-
--- --
- -- -
-
- --- -
-- - --

U
nR
eg

is

te

re

1400

Glossary of Terms


-
- -
- -
-
-
- --
- -
-
- -
- -
-
-
-
- - --
-
- - -
- - -
-
- -
- -

U
nR
eg

is

te

re

- - -
--- -
- -
-

- -- - - - - - -

-
- -
-

1401

x86 Instruction Set Architecture

-
-
- -- -
-
-
- - - -
---

- - -
-

--

--

--

- -
-

- - -
- - -

- - -
- - - - -
- - -
- -

U
nR
eg

is

te

re

-- - -
-

- - - -
--
- -
- -

1402

Glossary of Terms

-
- -

-
- - -
-- - - -
- -
- --
-- -
- -
-

- -

- -

- -
- -
--- - -
-- -
- - - --

U
nR
eg

is

te

re

---

-- - --
- - -- -
- - - --
- --
-

- -
- -- - --
-- -- -
- -- -
- - --
- -- - --

- -

1403

x86 Instruction Set Architecture

-
- --

- - --
-
- --
- - --
- -
- - - -
- - - -
-
-- - -
-

- -
-
--

- -
--
-
- --
- -
- - -
- - -
--

U
nR
eg

is

te

re

--

1404

Glossary of Terms

-
- -
- -
- -
-
- -
-

- -
- -
-
-
-
- -
- --
-

- -

is

U
nR
eg

te

re

-
-

- - -
- -- -

- -

- -


- -

- -

1405

x86 Instruction Set Architecture

-
-- - -
-- -

- -
-- --
- -

- -

- - -
- -
- - -- -- - -
-- - -
- - -
--
--
- - - -
- --
- -- - -- ---
-
-- -- --
---
-- -
-- - -- -- -- -

U
nR
eg

is

te

re

--

- -
- -
-- -
-- - - --
- - -- -
-

- - -
- - -- -

-
--

1406

Glossary of Terms

-
- -
- - - -
-- - - -
- -
-- -
- --
-- -
- --
--

- - -
-

- -
-
- --

- -
-
-
-
-
- -
- -

U
nR
eg

is

te

re

- -

- -- -

- - -
-

- -

1407

x86 Instruction Set Architecture

-
- - - -- -

- - -
-
-

- - - -
-
- -
--

- - -
- -- -


- - - -- - - - --
- -
-

U
nR
eg

is

te

re

---
- -
- -
- -
-
-

- - - - - - -
- - - -
- - - - - -
- - -
-
- - -

1408

Glossary of Terms

-
- - - -
- - - -
- - -
- - -
- - - -
- - --
- - -

-
-

- - - -

--

- - -
- - -
-- - -
- - -
-

U
nR
eg

is

te

re

-- -
- -- - -

- -
- - - -
- -- -
-
- -

1409

x86 Instruction Set Architecture

-
- -- -
-- -- -
--

- --
- -
- --

- -
- -

-- -- -
- -

- -

- - - -
- - --

U
nR
eg

is

te

re

- -
-- -
--- -- - - -
-- - -
--- - -
- ---
--

-
- - - -
- - - -- -

1410

Glossary of Terms

-
-
- - -
-- -
- -
-

-
-- - - -
- - -

- -
- -

- - - ---
-

- -

re

te

is

U
nR
eg

- -

- - - --
-
- - -

1411

x86 Instruction Set Architecture

- -
- - --
- -
- - - -
-- -
--
- - - - - - -
-
- - - -
- --
- -
- - --
-
- - - -- -
- - -
- -
-
- ---
- - - -
- - -
- -

U
nR
eg

is

te

re

- - - -
-- -

-- -
-
- - --
-- - -

- - --
-
- - -

- -- --

1412

Glossary of Terms

-
- - -
-- -- -
-
- -
- -

- -
- --
- - -
-- --

- -

- -

-
--- -- -
- - --
- -

U
nR
eg

is

te

re

-
- --

- - -- --
-- - -
- - - --
-
-- --

- -
- -

-
--- --

1413

x86 Instruction Set Architecture

-
-- -
-- - --
- -
--
- -- - -
- --
- - --

---
- -

- --
--

-- - -

-- -

-

re

te

is

U
nR
eg

- -

-
-

- - -- --
-

- -- -
-- - -
-

1414

Glossary of Terms

-
- -
-- -
-
- -
-

- -

-
- --
- --
- --
-

-
-
-


-
- -
-- - -

- -
- -
- -
-

U
nR
eg

is

te

re

--

-
-- - -
- -- - - -
- - -

--
-- - - - - -

1415

x86 Instruction Set Architecture

-
- - -
- -
-- --
- - -

-- -- --
- -
- -

- -
- --
-
-- -- -- -

- --
-- - -

- - --
- --
- --

U
nR
eg

is

te

re

1416

-
- --- -
- -

Glossary of Terms

-
-
- -- - -
--- -
- -
--
-
-- - --
- - -
-
- --
- - -
- -

- -- -

- -
-- - -
-
--

-- - -
-

-- -- -
- - - -
- - -
-

U
nR
eg

is

te

re

- -

- -- -
-- -
- -
--

1417

x86 Instruction Set Architecture

-
- -
- -
-

- - -
-- - -
-
- -
- - -
- -
- - -
- -
-

- -
-- ---
-
- -- - - -
- --
- --
-
- -- -
- -- -
- -- -
--

1418

U
nR
eg

is

te

re

- -
---

Glossary of Terms


-
- - -
- -
-
- - - -
- -
- - --
--
-- --
-- --
-
-- -- - -
- -- - -
- - -- -
- - - -

- --

-- - --
--
- --
-- - -
- - --
- -
- - -
-

U
nR
eg

is

te

re

--

- ---
---
- -

-

1419

x86 Instruction Set Architecture

--

-- --


-- - - -
- - --
- -

-- -

-
- -
-
--
- -
-- -- -
-- -
---

- -

U
nR
eg

is

te

re

1420

- - - -
-
-
-
-

- - -
-- - - - -

Glossary of Terms

-
-- - --
- --
- - - - -- -
- -
-- - -- -
- - - - -- -
- -
-- - -- -
--

- -

- -
-- --
- - --
- -
-

U
nR
eg

is

te

re

--

- -

-
- - - -

--
-
--
- - - --
- --
-
--

1421

x86 Instruction Set Architecture

-
--
-
--
- - - --
- --
-
--

-- -
- ---
-
- -- -
---
-- -
-
- -
- - -- --

U
nR
eg

is

te

re

-
-

- - - - -
- - - - -
- -- -
- - -- -
- -- -
-

-- -- -- --
-
- - --
--

1422

Glossary of Terms

-
- -
-
-
-- --
- -
-

-- -- -
--
-

- -

- - - - - --

-
- -- - -
-- -
- -- - - - -

U
nR
eg

is

te

re

- - -
-- - --
---
---
- -
- - - -


--

- -
-
--- - -
-

1423

x86 Instruction Set Architecture

-
-
- -
---
-

- --- -
--

- -

- - - - -
--

- -

--


- - -

- -- -
- -

re

te

is

U
nR
eg

--

- -

- -

- -

- -
---
--

1424

Glossary of Terms

-
-- - -
- -
- - - - -
--
- -
- - - -- - -
-

- --
- -- - -

-

-- - --





-
-

U
nR
eg

is

te

re

- --
- -- -
- -- --

1425

x86 Instruction Set Architecture

-
--

- -
- -
-
- --
-
- - - --
- -- -
- -

- -- -
-- -
- - - -

-- - - -
- -

U
nR
eg

is

te

re

-- - --

-- - - -

--

- -
-
-
-- -
-

- -
-
-

1426

Glossary of Terms

-
- -
-- - -
-
- --
- - -
-
- --
- -
--- - --
-

- -
-- - - -
-
- --
- -

U
nR
eg

is

te

re

- --
-- -

-- - - -
- - -
- -- - -
-- -

--

--

- --
- - --
--

1427

x86 Instruction Set Architecture

-
- - - - -
- --
-

- - - -
- --
-- -- -

- -- -
- - -


- -

- - -
-- -
-

U
nR
eg

is

te

re

- - -
-- --
-
- - -

--
- - -
- - ---
-

--

-
-

- -

1428

Glossary of Terms

-
--
-
-
- -- -
-

-- -

-- -- - - -- -
--- - -- - - -
-- -
- -- - - -
- -
- -
- -
- - -
- -- - -
-- -
---
- -

U
nR
eg

is

te

re

-- -

--

1429

x86 Instruction Set Architecture

-
- - - -
-
-
- -
- -
- -
- - -
- --
- - -
- -
-
-
- - -
--- - -
- -

-- -
--
- - -- -
- -
-- ---
-- --

U
nR
eg

is

te

re

- - -
- - -

- - -
- - - - -
- -

1430

Glossary of Terms

-
-- --
- - -
-
-- -
- -- -
- -
-
-- - -
- -- --
- -

-- - -
- - -
- -

- - -- -
- - - --
-- - - - - --

-- -
- -

- - - -
- - -
--
-- - -

- --

- -
- - -
- - -
-

U
nR
eg

is

te

re

- -

1431

x86 Instruction Set Architecture

-
-- ---
-- -
-
-
- - - - - --
-- - -
-- -
- - - -- -
- -- ---
- ---

- - - -
-- --
-- - - -

U
nR
eg

is

te

re

--

- -
- - - -

-
-
---

-
- - -
- - -
-

- -
-

- - -
-- - -
- --
-

1432

Glossary of Terms

-
-
- -
- - -
- -
-
--
-
-
- -
- - -
- -
-
--

- - -

- --
- - --
-
-- -
-- -

- - - - - -
- -
- -

U
nR
eg

is

te

re

-
-
--
-
-

-
-- -
- -

1433

x86 Instruction Set Architecture

-
- - -
- -- -
--
-
- --
- - - -
- - - -
- ---
- -
--

- -- - -
-
-
-- -
-- - -
-
-- -
-- - -

-

U
nR
eg

is

te

re

-
--

1434

-
-- --
- - - -
- -
- --- -

Glossary of Terms

-

- -
- -- -

- -- -

- -- -

-- -
-
- -
- - -
- -
- -

-
-
- -
--
-
- --

- - -

U
nR
eg

is

te

re

- -- -
- - -- -
- -- -

-
- -- -

- -
-- - - -

1435

x86 Instruction Set Architecture

-
- - -
-- -

-- -
- - -
- - -
-- - -
-

- --
-
--- -

-
- -- -
-- -
- -



1436

U
nR
eg

is

te

re

-
-- -
- -
-
-
--- -
-

-
--- -


-

Glossary of Terms

-
- -- - - - - --
-- - - -
- -
-- -


--

-

- -- -

--
-

- --
- -
- -

- - --
- -
- - --- - ---

U
nR
eg

is

te

re

- -
- -
-
-

- --- - -- -

1437

x86 Instruction Set Architecture

-
--

- -- -

- -

-- -- -
-- - -

-
-- -

- - - -
-- -

U
nR
eg

is

te

re

- --

- - -

-
-

- - --
-

- --
- -
-- -

-- -

- -

-

1438

Glossary of Terms

-


- -

--
- -
- -
-
-

--

-

- - --

- -
- --
-- --
-
- --
- -
- -- - -

--

- - -
--
- ---

-- -

--
-- - - -
- -
-- -
-

U
nR
eg

is

te

re

1439

x86 Instruction Set Architecture

-


- -
- - -
--


- - --
- - --

- -
-- -
- --
-
-- -
- - -
-
- - - - - - - -

U
nR
eg

is

te

re

- - -

- -
- - - -

--
- -

1440

Glossary of Terms

-
-
--- -- -
-- ---

- -

-
- - -

- -- --
-
-
- -
- ---

- - -
-- -
-
- - - - -
-

U
nR
eg

is

te

re

- - -
-
-
-

- - -

- -

--- -- - - - - -
- - -
- - -- -

1441

x86 Instruction Set Architecture

-

- -
-- --

--

- - - - --
- - -

-
- -
--
-- - -
-

- - - - - - - -
- --- - -
- -
- - -
- - - -
- - - --
- -
- - - -

U
nR
eg

is

te

re

1442

Glossary of Terms

-
- - -
- - - --
- - --
- - -
-
- - - - -

- - -- --
-
- -
- --
- - -- - -

- -

U
nR
eg

is

te

re

-- -
-
- -
- - -

-
- - --
- -
- - -
-
- -

1443

x86 Instruction Set Architecture

-
- ---
-
-- -- --
- -
-
- - -
- -
--

- --
-
- -- --
-- --

- -
-

- - -
- - - -
--
- - --

- - -

U
nR
eg

is

te

re

- -

- - - -

- - -

--

-- -
- -

-
- -
- -
- -
- -

1444

Glossary of Terms

-
-

-
-
- - --
- - --

-- -
- -
-

- -
-

U
nR
eg

is

te

re

--

--

1445

x86 Instruction Set Architecture

-
- - - -
--
- -
- -
-
- - --
- - - -
- -
- -
- - -
- - -
- - - - -
--
- -
- - -
- --
--

- - - -
- - -
-
-
- - - -
-

-- -
- -

-
- - -- -- -
--

- -
- -
--
- - -- - - -
- - --

U
nR
eg

is

te

re

1446

Glossary of Terms

-
- - - -


- -- -
-
-

--
- - - --
-
-- -
--- -- -
- - -
-- -

- - - -

U
nR
eg

is

te

re

- -
- -
- -- - --

-
- -
- - --
- -
- - --
- -

-- --
-

1447

x86 Instruction Set Architecture

-
-
- -
-- - -
-
-


--
- - -

- - -
- - -
- -
-

- - -
- --
- -
- -- - - -- -
--
-
-- -
-
-- - - --
- - -
- - --

U
nR
eg

is

te

re

--

-- -- - --
- -

1448

Glossary of Terms

-
- -



- --
-

--
--

- - -
- - - - - -
- - - -
-- - - - -
- -
- - -
-- -
- --
- - --
-- - -
---


-- -
- --
-- -
--

U
nR
eg

is

te

re

1449

x86 Instruction Set Architecture

-
- -
-

-
- -
- -
-
- - - -
- --
-
- - -
- -

- -

-- ---
-- -
-- -- -

--
- -- --

-
- - -
- - -

- - -
-
-
- -
--
- --
-- - -- --

U
nR
eg

is

te

re

1450

Glossary of Terms

--- -
- -
-- --
-
- --
-
- --
-
- -
-
-
- - -
-- - -
-- - -
-- -
-
- - -
- -
-
-- -

- -
- -
- -

--- -
- --
- - -
- - - -

U
nR
eg

is

te

re

- -- -
- - - -
- - - - -- - -

1451

x86 Instruction Set Architecture

-
- - - - -

-- - - -

-- -- -
- - -
- - - -
-

--

--

--

--

-- -

U
nR
eg

is

te

re

- - -
- - --

- -
- - - -
-


-
- -
--- - -
-
- -
-

-
- - - -
-

1452

Glossary of Terms

--

- -
--
--- - -- -
- - -

- - - -
-
--- -
-- --- - -
- -

- -
-- - -

U
nR
eg

is

te

re

-
- -
---
- --

- --

- -

- - - -- -
- -- -

1453

x86 Instruction Set Architecture

-
- - -
-
- -
-
-
-
-

-- -
- - -
--- -
- - -


-- - -
- --- -
- - - -
-- --- - --
- -
-
--
-

U
nR
eg

is

te

re

- --

- -

1454

- - - -
- -
- -
-- - -
-- -- -
- - --
- - - - -
- -
-- -- -
- -- -
-- - -
- - --
-
--

Glossary of Terms

-
- -
- - -
- - --

- -

- - - -
--
- - - -
- -- - -
- -

- - - -

- - -
- -


-- - -

re

te

is

U
nR
eg

- - - -
--
- -- - - -
- - -- -- - - - -
- - -
- -

-- --
-
- -
- - -

- -

1455

x86 Instruction Set Architecture

-

- - --
-
- -

- -
- --

- -

- -
- - -
--
-- - -
--

--
-

U
nR
eg

is

te

re

- -

- -

- -

-- - -
- - - -
- -- --
-- -
-- - -
- -
--
--

1456

Glossary of Terms

-
- -
- - - -
-
- -
-
-- - -
-- --
- - - - -
- -
-- - - -
- -- -
-

-- --
- - - -
- -

U
nR
eg

is

te

re

1457

x86 Instruction Set Architecture

- -
-
- - - - -
- -
- - --
- - --
- - -
-

-- -
- - -
- --
-- --
- - --
- -
-
- -
- -
-
- - -
-

1458

U
nR
eg

is

te

re


-
-- -
-- -
- - -



-
-
-- -

Glossary of Terms

-
-
- - - - - - -
-
--


- --
- --

-- -
- - - -
-- - -

- - -
- --

- -

U
nR
eg

is

te

re

-- -
-
-
-
- -
-
--- -- -
- -- -

--

-- --
-
--

1459

x86 Instruction Set Architecture

- -
- -
- - -
- -

--
-- --
-
-

- -
- - -
-- -

-- - -
- -
-
- - - - - --- -

- -
- -
- -
-
-- -
-
- -
- -

U
nR
eg

is

te

re

1460

Glossary of Terms

-
- -
- -
-- - -
- - -
- -
-
-
- -
-
-- - -
- -
-
-
- -
-

--

--
- - -
- --
- --- --- -- -- - - -
--
-- -

--- -
- -
- - ---- - --
- --
-- - --
-

U
nR
eg

is

te

re

- -- -
-
- -

1461

x86 Instruction Set Architecture

-
- -
- - -- -
- - - --
- -

- - -
- - - -
-

- - - -
-
- -
- -
-- -
-
- ---
- - - -

U
nR
eg

is

te

re

-- - -
- -
- --
--- -

-- - -
- - -
-
-- --
--

-
- -- -
- -

1462

Glossary of Terms

-
- --
- - - -
-- -
- -
-- --
- - --
-
-

-- -
-
- -
- - -
-
- -
-
-
--

-- - -
- -

U
nR
eg

is

te

re

--
- - - --
- -

-
-

1463

x86 Instruction Set Architecture

-
- --
-
-- - - -
- - -
- - -

- -

- -
- - -
- --
-
-
-
-

U
nR
eg

is

te

re

- -
- -
-- - - -
- -
-- -
- -
- -
- - - -
-

1464

Glossary of Terms

-
- -

-- - -
- -
-
-
- -
--
-- - - -
- - - -- --

-
--
- - --- --

- --
--

- -
- - -
-
- --
-- - - --
- -
-
-
- -
--
- - -
-- - - -- -
--

U
nR
eg

is

te

re

1465

x86 Instruction Set Architecture

-
-

- -

- -
--
--
-- - - - -

-- - - - -
- -
- -
-- -
- -
-- - -- - -

-- - - - -
- - --
- - -- - -
- -

U
nR
eg

is

te

re

1466

- -
-
-
-
-
-- -
-
-
-- -
-- - - -
-
-

Glossary of Terms

-
-- - -
-- -
--
-- -

- - -
- - -
- -
-

U
nR
eg

is

te

re

--

1467

U
nR
eg

is

te

re

x86 Instruction Set Architecture

1468

re

te

U
nR
eg

is

-
-
--
--


- -
--

-

--

--
-
-

-- -

- --
-
-
-
--
--
-- -
-
--

-
--
-
-
--
--
-- --
--
-
--


--
--
--

--
- -
--
-
-

- -
-
--
-
- -
-
--
-
-
--






--
--

--



-


- --

te

re

- -



-

-
-




--

---
-
--
-
-


-- - --

--
- -

--


-
-
- -



-

--
--- -
-
--
-

U
nR
eg

is

-- -
-- --
-- -
--

-- -
-- -
-- -

-- - -
-- -
-- - -
-- -
-- -

-- - -
-- - -
-- -

-- -
-- -
-- -
-- -
--
-- -
-- --
--

--
--

-
-







--



- -
- -- -

te

re


-

- -


-

-



- -
-
-
-

-
-
--
--


-




-
-

U
nR
eg

is


- --
-
-
- -




-
-

--

- -
-
--
- --
--

-
-
-
-
-





-

-




-

te

re

--
--
--
--
--

--





--


- -





-
-
-
-

-
-
-
-
-
- -



-

-

U
nR
eg

is

- --
-
-



-
-

-
- -
-
-
-

- -

- -


-
-



--

- -
-


-
-
- -


-

- ---

te

re

-
-
- -


-

-

--
--




-
--
-




-
-

-


-

-
-

-
-
- -
-

U
nR
eg

is




-
-
--

-
- --
- --

-

-- -

--

-

--
-
- ---

--
- -
-

-
--
-- -

-
-



-
- --
- -
- -
-

re

-
- -
-





- -

--


-

te




-

-
-

-
-

-
-
- -
-
-
- -

- -

-

--


-

U
nR
eg

is


-

--
- -


-
-





-

-
-

-



- -
--
--








-
-





te

re



- --

-
- -

-
- -


- -



--
-

- - -- -

-
-
-
- -
- ---
-
-- -- -

U
nR
eg

is

-
-
- -




-


-
--

-


--
- - -- -

- -

-

-
-

-
-



- -- -
- -

---
-

-
-
-


-
-

-
-
-
- -

re

te

U
nR
eg

is




--
--
-





























-- -




- -
-
-




- --

- -

-

-


-



-

-
-
- -


--


-

te

re





--
-
-



-
-
-
--

-







-
- -
-

- -

--





-
-
-

-
-

U
nR
eg

is

-
-
- -
-
- -
- -
- - -
- - -
- -
-- --

--
-
-
-
-
-


--
-- --

-
-
- -
--



- -


--
--
- -


-

-

te

re

---
-

-
-

- -



















U
nR
eg

is


-
-

-

-
-
-


-- -
--

-

--

-

--


- -


- -

--
-
- -
--






-- --
-
-
--

- --


--
-


-
-

te

re


-

-
-
-
-
-
-
--
-
- --
-
- --

- --


-





-
-

-
-
- -

-
-
-

-

-
-


- -

U
nR
eg

is

-

-
-

---
-
- -


-

-

-
-
-

--


--
--
-
-
-



-


-

-
- --

- -

- -

te

re


-
--
-
--
- --
-
- -


-

-
- -

--


-
-- --


-
- - -
--

-
- -
-
-

-
--
- -

U
nR
eg

is


- -

--

-
-
--

- --
- --

-

-


-
-- --
--
--

--

--
-
-- -
--
-

-- --- -


- -
--
-
-
-


-

te

re

-


-
- ---
-
-
-

- -



-



-


-
--



- --
-
- -- -
--
--
-
- -

-
--




--
-
-

U
nR
eg

is

-
- - -
-- -- -



-

-

-
-
- --
-
-- -


- --
-
-



--

- -

- -

--
--
- -

-
-
- -

-


-
-

-
-
-

U
nR
eg

is

te

re

-- -

--


--
-
- -

-

--
- -
-

- -
-
-
-
- -

-- -
-
-
-- -
-- -
-


-
- -
- --
--


--

-

--

--
--
-
--

-







- --


--

-
-


- -
-- -

-


-

- -
- -
- - -
-


- ---
-
-
-

te

re



-

--




- -
--
- -
- -
- -
--




-


--
-
--




-



U
nR
eg

is

-


-- -

-
-
-
-
-
-
-
-
-
-
-
-
-


-
-- -
-
-

---
-- -- -



-
-

--
-
- - -
-
-
--
-

re

te

U
nR
eg

is





- -
-
-
-
-
-
-

-
-

-

- -
-- -

-
- -

-

-

--



-
-




-
- -

-- -
-- --
---

-
- --
-









--

- -


--





--






-
-

te

re

-
-

-
-
-
-


-
- ---
-
- -
-
-

-
-- -


-
-
- -
-
-
- --

--




--
--
---
-


U
nR
eg

is


-
--
-
-- -
-- -





- --
- -- -

-
- --
- -
-

te

re

-
-




-
-
-
--
-

- -
-


-
- --
- - -

- -
- -
- -
- -
- --
--
--

-
-
-
-
- -
- -
-
--
-

-
-

U
nR
eg

is


-




-
--

-






-

-


-
-








-
-
-

te

re

- - --
- -
- -
-

-
- -

-
-
- -

- -

- - -
- --
- --
-
- -
- - --
-
-
-
-
--
-

-

-
- -
-
-



-
- -
-

U
nR
eg

is


-


-


-






- -
-
--








-
-
-
-



-
-
-
- -
-
-

-

te

re


-
- -
- -
-
-
- --
-- - -
- -
- - --
-


-
-
-
-
-
-


-





- -
- - -
--
--
-
-
--

--
- -
- -
-
- -
--
--

U
nR
eg

is

-
-
-- -
--

- --

- --
--




- --


--
- -








--



- --
-
--
-
-



- -
- --


-
--
-
-
-

te

re

- --
- -
-

-
- -
-
- -
- -
-
- -
- -
- --
- - -
- -
- - -

- - --
-
-




- -



-
- -
- -
-
-

U
nR
eg

is

--

-
- -- -
-
-
-

- -

-
- -
- - -

- -
- -
- -

-
-

-- --


- -
-

- --
- -- -
-

-
- --
- -
---
---
-
-

-
-
--

te

re


-



-
-
- --
-
- - -
- -
- -

-
-
-
-

U
nR
eg

is


- -


-
-

-








-
-
- -










--

- -
-
-
- -
- -



--






---

-




- -
--
-

- --


te

re







-

-

-
-
-

---
- --

- -

- -

-
--
-



-
-
-
-
-

-
-
-
-
-


-
-

U
nR
eg

is



--
--
--

--
-- - -

-- -

-- -





--
-




-

--

-- -



-

-- --
-
-
-


--
--





--

--

-

-

--

re

te

U
nR
eg



--


--
-
--
-
-

-
--

is



-


-

-
-
-








-


-

Live Training Courses on the x86 Architecture


Comprehensive x86 Architecture (32/64-bit)
This lecture-based course describes the en re x86 architecture; everything from Real Mode
addressing to 64-bit Mode interrupt handling. This course focuses on the architectural elements
of x86, like segmenta on, interrupt/excep on handling, paging, etc. A er comple ng this course,
you will have a much deeper understanding of the x86 architecture.

re
te

Instruc on Set
Register Sets
Opera ng Modes
Segmenta on
Task Management
Interrupts and Excep ons
Paging
Memory Types
Virtualiza on

is

Topics covered in this course:

U
nR
eg

System Programming for the x86 Architecture


This course teaches the x86 architecture (both 32-bit and 64-bit) through a mix of lectures and
hands-on programming labs. All topics are explained in lecture format rst and then the students
are given programming labs in assembly to reinforce the concepts and to get hands-on experience
working with x86 processors at a very low level. This course focuses mainly on the behavior of
legacy Protected Mode, Compa bility Mode and 64-bit Mode as these are the modes most
commonly used in modern opera ng systems.
The lab exercises range from prin ng to the screen using the at memory model in legacy
Protected Mode to se ng up an interrupt driven, mul tasking 64-bit Mode environment, with
paging turned on.

You Will Learn:

- x86 programming basics like an overview of the instruc on set, register set and opera ng
modes
- The behavior of segmenta on, how it was originally intended to be used and how it is
actually used by opera ng systems today
- How to setup system calls using mul ple methods (and benets / side-e ects of each)
- How to setup interrupt service rou nes for both so ware and hardware interrupts and
implement a rudimentary scheduler
- How to implement paging in both the 32-bit environments as well as the 64-bit
environments including using various page sizes
www.mindshare.com

eLearning Course on the x86 Architecture


Intro to 32/64-bit x86 Architecture
MindShare's Intro to x86 eLearning course provides a great overview of the x86 instruc on
set architecture. It describes the concepts and implementa on of the major architectural
elements of x86 (paging, interrupt handling, protec on, register set, address spaces,
opera ng modes, virtualiza on, etc.).

You Will Learn:

The di erent groupings of x86 instruc ons and basic instruc on formats
The di erent address spaces available in x86 and how each can be accessed
The registers dened in x86 and how they have grown over me
All the opera ng modes that x86-based processors can run in and
characteris cs of each
- The concepts of paging and its base implementa on in x86
- How interrupts and excep ons are handled inside the core
- What virtualiza on is and about the hardware extensions that companies like
Intel are adding their processors

U
nR
eg

What's Included:

is

te

re

- Unlimited access to the x86 eLearning modules for 90 days


- PDF of the course slides (yours to keep, does not expire)
- Q&A capability with the instructor

Benets of MindShare eLearning:


- Cost E ec ve - Get the same informa on delivered in a live MindShare
class at a frac on of the cost
- Available 24/7 - MindShare eLearning courses are available when and
where you need them
- Learn at Your Pace - MindShare eLearning courses are self-paced, so you
can proceed when you're ready
- Access to the Instructor - Ask ques ons to the MindShare instructor that
taught the course
www.mindshare.com

Vous aimerez peut-être aussi