Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ......

38
Introduction to the x86 Architecture September 29, 2015 Camiel Vanderhoeven

Transcript of Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ......

Page 1: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Introduction to the x86 Architecture

September 29, 2015

Camiel Vanderhoeven

Page 2: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Introduction to the x86 Architecture This information contains forward looking statements and is provided solely for your convenience. While the information herein is based on our current best estimates, such information is subject to change without notice.

Page 3: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 4: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Development Timeline

Page 5: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

New Designs vs Extensions

32-bit

VAX

64-bit Alpha

64-bit Itanium

16-bit

8086

286 PM

32-bit i386

AMD 64-bit

Page 6: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Nomenclature Architecture Sub-arch. First in Other implementations x86 (16-bit) 8086 8086 8088, V20, V30, 80186

i286 80286 IA-32 (32-bit) i386 80386 Am386

i486 80486 Am486 i586 Pentium Pentium MMX, K5, K6 i686 Pentium Pro Pentium II, Pentium III, Pentium 4,

Athlon x86-64 (64-bit) AMD64 Opteron Athlon 64, Turion, Sempron,

Phenom Intel 64 Xeon Pentium 4 “F”, Celeron, Core

Page 7: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x64

Confusion

AMD64 x86-64

Intel64 IA-32e EM64T

iAMD64

AMD

Intel

Others (Microsoft, Sun, UEFI)

Joke

Page 8: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x64

Confusion

AMD64 X86-64

Intel64 IA-32e EM64T

iAMD64

AMD

Intel

Others (Microsoft, Sun, UEFI)

Joke

Page 9: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Chip brand names and generations •  Intel64 brands − Xeon − Core − Pentium − Celeron − Atom − Quark

•  AMD64 brands − Opteron − Athlon − Sempron − FX − A-Series

•  Intel64 microarchitectures − Core, Penryn − Nehalem, Westmere − Sandy Bridge, Ivy Bridge − Haswell, Broadwell − Skylake

•  AMD64 microarchitectures − K8 Hammer, K10, Fusion − Bobcat, Jaguar, Puma − Bulldozer, Piledriver,

Steamroller, Excavator − Zen

Page 10: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

ISA Extensions Name First in Function x87 8086+8087 (1980) Floating Point Co-processor PM 80286 (1982) Protected Mode: Virtual Memory IA-32 80386 (1985) 32-bit PAE Pentium Pro (1995) Physical Address Extension MMX Pentium MMX (1997) MultiMedia Extension (Integer SIMD) 3Dnow! AMD K6-2 (1998) 3D Graphics (Floating Point SIMD) SSE(n) Pentium III (1999) Streaming SIMD Extensions (FP SIMD) x86-64 Opteron (2003) 64-bit VT-x Pentium 4 (2005) Virtualization support AMD-V Athlon 64 (2006) Virtualization support AES-NI Westmere (2010) Advanced Encryption Standard AVX(n) Sandy Bridge (2011) Advanced Vector Extensions (FP SIMD) TSX Haswell (2013) Transactional Synchronization Extension MPX Skylake (2015) Memory Protection Extensions

Page 11: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 12: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Some Numbers

VAX Alpha Itanium2 x86 Word size 32 64 64 64 Architecture CISC RISC EPIC CISC* Manufacturer DEC DEC Intel Intel AMD VIA GP Registers 16 32+32(FP) 128+128(FP) 16+8(MMX)+16(XMM) Orthogonality YES YES - - Instructions ~460 ~135 ~150 >600** Addr. Modes 24 4 6 10 Instr. size 8-400 bits 32 bits 41b (3/128b) 8-120 bits transistors 1.3M (NVAX) 130M (EV7) 3.1B (Poulson***) 5.6B (E7-v3****)

* With an underlying RISC-Like core ** Depending on how you count them *** 8 cores **** 15 cores

Page 13: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 14: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Traditional CISC Architecture (VAX) •  Complex Instruction Set Computer •  Complex instructions, mixing computation and

memory access •  Microcoded implementations •  Makes optimizing code execution by the

processor difficult

Page 15: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

RISC Architecture (Alpha) •  Reduced Instruction Set Computer •  Simple instructions, separating computation and

memory access •  Hardwired •  Relatively easily optimized by processor (parallel

execution, re-ordering, pipelining, branch prediction, but…

•  Optimization hardware becoming increasingly complex

Page 16: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

EPIC Architecture (Itanium) •  Explicitly Parallel Instruction Set Computer •  Simple instructions, separating computation and

memory access •  Parallel execution of instruction groups,

separated by compiler-inserted stops. •  Predication instead of conditional branching •  Mostly hardwired •  Burden of optimization shifted to compiler (though

Poulson fixes that by doing some reordering)

Page 17: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Modern CISC Architecture (x86) •  Complex instructions are translated into RISC-like

micro-ops •  Partly hardwired •  Extensive optimization performed by processor

(parallel execution, re-ordering, pipelining, branch prediction) after translation to micro-ops

Page 18: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 19: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

VAX Register Set R0 R1 R2 R3 R4 R5 R6 R7 R8 R9

R10 R11

AP/R12 FP/R13 SP/R14 PC/R15

PSL IPR’s

Page 20: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Alpha Register Set R0 R1 R2 R3 R4 R5 R6 R7 R8 R9

R10 R11 R12 R13 R14 R15

PC PS

IPR’s

R16 R17 R18 R19 R20 R21 R22 R23 R24

AI/R25 RA/R26 PV/R27

R28 FP/R29 SP/R30 RZ/R31

F0 F1 F2 F3 F4 F5 F6 F7 F8 F9

F10 F11 F12 F13 F14 F15

F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31

Page 21: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Itanium Register Set RZ/GR0

GR1 GR2 GR3 GR4 GR5 GR6 GR7 GR8 GR9

GR10 GR11 GR12 GR13 GR14 GR15

IP UM

IPR’s

GR16 GR17 GR18 GR19 GR20 GR21 GR22 GR23 GR24 GR25 GR26 GR27 GR28 GR29 GR30 GR31

F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30

FR127

GR32-GR127 Reg. Stack

FR0 FR1 FR2 FR3 FR4 FR5 FR6 FR7 FR8 FR9

FR10 FR11 FR12 FR13 FR14 FR15

Pr127

Pr0 Pr1 Pr2 Pr3 Pr4 Pr5 Pr6 Pr7 Pr8 Pr9

Pr10 Pr11 Pr12 Pr13 Pr14 Pr15

BR0 BR1 BR2 BR3 BR4 BR5 BR6 BR7

Page 22: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Register Set RAX RCX RDX RBX RSP RBP RSI RDI R8 R9

R10 R11 R12 R13 R14 R15

RIP RFLAGS

IPR’s

MMX0/FPR0 MMX1/FPR1 MMX2/FPR2 MMX3/FPR3 MMX4/FPR4 MMX5/FPR5 MMX6/FPR6 MMX7/FPR7

XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 XMM9

XMM10 XMM11 XMM12 XMM13 XMM15 XMM16

Page 23: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 register Part naming RAX

ALAH

AX

EAX

63 31 015 7

R8

R8B

R8W

R8D

63 31 015 7

Page 24: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 25: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

VAX Instruction encoding O

pcod

e 1 or 2 bytes, 1 opcode per operation

[Ope

rand

1] 1 byte

containing addressing mode and register number, up to 4 bytes of displacement, immediate data, or address [O

pera

nd 2

… n

] same

Page 26: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Alpha Instruction Encoding O

pcod

e 6 bits, one opcode per operation

Ope

rand

s 26 bits, encoding up to 3 registers, up to 21-bit displacement, 8-bit literal value, up to 16-bit function specifier

Page 27: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Itanium Instruction Encoding Syllable 41 bits

Opcode 4 bits

Operands 31 bits, typically 10-bit

function and 3 registers

Predicate 6 bits

Syll.

Opcode

Operands

Predicate

Syll.

Opcode

Operands

Predicate

Template 5 bits

Page 28: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Intel x86 Instruction Encoding [P

refix

es] 1-6 bytes

specifying address and operand size override, extended register set, extended instruction set, locking, repetition, segment, branch hints

Opc

ode 1-3 bytes

Multiple opcodes per operation

[Mod

-R/M

] 1 byte specifying addressing mode and either 2 registers or 1 register + 3 bits opcode extension

[SIB

] 1 byte specifying scale factor, index and base registers for indexed addressing

[Dis

plac

emen

t] 1-8 bytes specifying a displacement or offset

[Imm

edia

te] 1-8 bytes

specifying an immediate value

Page 29: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 30: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Memory Specs VAX Alpha Itanium x86

Address size 32 64 64 64 Page size 512 8K/64K/512K/4M 4K-4G 4K/2M/1G Split VA Space no yes yes yes PT Levels 2 3 3 4 PTE Cache no no VHPT PDE cache Virt. Addr. Size 32 48 54 48 Phys. Addr. Size 32 44 50 52 (48) Segmentation no no no yes (kind of) Prot. Bits in TLB 4 enc[KESU][RW] 11 [KESU][RW],

FO[RWE] 7 enc[KESU], enc[RWX] 3 R/W, U/S, XD

Page 31: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 32: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Hardware/Software Boundaries

OS

CPU ConsoleQUEUEetc.

VAX

OS

CPUQUEUEetc. Console

MicroVAX

OS

CPU SRMPALCODE

Alpha

OS

CPU UEFISWIS

Itaniumandx86-64

Hardware

Firmware

OS

Page 33: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 34: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

RAS Features in Itanium and Xeon Feature Itanium Xeon Cache ECC Coverage ✓ ✓ Single-bit Memory Error Correction ✓ ✓ Double-bit Memory Error Detection & Retry ✓ ✓ ECC on Data Bus ✓ ✓ Internal Logic Soft Error Checking ✓ Skylake-EX Bad Data Containment ✓ ✓ Intel Cache Safe ✓ ✓ Memory Sparing ✓ ✓ Memory Mirroring ✓ ✓ Hot-Plug I/O ✓ ✓ Memory Hot-Swap ✓ ✓ Processor Lock-Step ✓ ✓

Page 35: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

x86 Heritage Comparison at a Glance CPU Design Strategy Register Set Instruction Encoding Memory Layout VMS RAS Features Proliferation of x86

Page 36: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

Lifespans of different architectures

1974 1979 1984 1989 1994 1999 2004 2009 2014

POWER

MIPS

SPARC

X86

Itanium

Alpha

VAX

Pre Dev Life VMS Sales Post

Page 37: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

2013 Server Market Revenue

X86 (30.7B) Itanium (1B) RISC (4.8B) Other (5.6B)

Units

X86 (9.8M) Itanium (21K) RISC (90K) Other (10K)

0

100

200

300

400

500

600

K$/Unit

Page 38: Introduction to the x86 Architecture - · PDF fileIntroduction to the x86 Architecture ... Comparison at a Glance ... V30, 80186 i286 80286 IA-32 (32-bit) i386 80386 Am386 i486 80486

For more information, please contact us at:

[email protected]

VMS Software, Inc. • 580 Main Street • Bolton MA 01740 • +1 978 451 0110