AMD X86-64 Architecture Programmer's Manual, Volume 2
Total Page:16
File Type:pdf, Size:1020Kb
AMD 64-Bit Technology AMD x86-64 Architecture Programmer’s Manual Volume 2: System Programming Publication No. Revision Date 24593 3.07 September 2002 AMD 64-Bit Technology 24593—Rev. 3.07—September 2002 © 2002 Advanced Micro Devices, Inc. All rights reserved. The contents of this document are provided in connection with Advanced Micro Devices, Inc. (“AMD”) products. AMD makes no representations or warranties with respect to the accuracy or completeness of the contents of this publication and reserves the right to make changes to specifications and product descriptions at any time without notice. No license, whether express, implied, arising by estoppel or otherwise, to any intellectual property rights is granted by this publication. Except as set forth in AMD’s Standard Terms and Conditions of Sale, AMD assumes no liability whatsoever, and disclaims any express or implied warranty, relating to its products including, but not limited to, the implied warranty of merchantability, fitness for a particular pur- pose, or infringement of any intellectual property right. AMD’s products are not designed, intended, authorized or warranted for use as components in systems intended for surgical implant into the body, or in other applications intended to support or sustain life, or in any other application in which the failure of AMD’s product could create a situation where personal injury, death, or severe property or environmental damage may occur. AMD reserves the right to discontinue or make changes to its products at any time without notice. Trademarks AMD, the AMD arrow logo, AMD Athlon, AMD Duron, and combinations thereof, and 3DNow! are trademarks, and Am486, Am5x86, and AMD-K6 are registered trademarks of Advanced Micro Devices, Inc. MMX is a trademark and Pentium is a registered trademark of Intel Corporation. Windows NT is a registered trademark of Microsoft Corp. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. 24593—Rev. 3.07—September 2002 AMD 64-Bit Technology Contents Preface . .xxiii About This Book . .xxiii Audience . .xxiii Organization . .xxiv Definitions. xxv Related Documents . xxxvi 1 System-Programming Overview . 1 1.1 Memory Model. 1 Memory Addressing. 2 Memory Organization . 4 Canonical Address Form. 5 1.2 Memory Management . 6 Segmentation . 6 Paging . 8 Mixing Segmentation and Paging . 10 Real Addressing. 11 1.3 Operating Modes . 12 Long Mode . 14 64-Bit Mode . 15 Compatibility Mode . 15 Legacy Modes. 16 System Management Mode (SMM) . 17 1.4 System Registers . 17 1.5 System-Data Structures . 20 1.6 Interrupts . 22 1.7 Additional System-Programming Facilities . 24 Hardware Multitasking . 24 Machine Check . 25 Software Debugging . 26 Performance Monitoring. 26 2 x86 and x86-64 Architecture Differences . 29 2.1 Operating Modes . 29 Long Mode . 29 Legacy Mode . 30 System-Management Mode . 30 2.2 Memory Model. 31 Memory Addressing. 31 Page Translation . 31 Segmentation . 33 2.3 Protection Checks . 35 2.4 Registers. 35 General-Purpose Registers . 35 Contents iii AMD 64-Bit Technology 24593—Rev. 3.07—September 2002 128-Bit Media Registers . 36 Flags Register . 36 Instruction Pointer . 36 Stack Pointer . 36 Control Registers. 36 Debug Registers. 36 Extended Feature Register (EFER) . 37 Memory Type Range Registers (MTRRs) . 37 Other Model-Specific Registers (MSRs) . 37 2.5 Instruction Set . 37 REX Prefixes . 37 Segment-Override Prefixes in 64-Bit Mode. 38 Operands and Results . 38 Address Calculations. 38 Instructions that Reference RSP . 39 Branches . 40 NOP Instruction. 43 Single-Byte INC and DEC Instructions . 43 MOVSXD Instruction . 43 Invalid Instructions . 44 FXSAVE and FXRSTOR Instructions . 45 2.6 Interrupts and Exceptions . 46 Interrupt Descriptor Table . 46 Stack Frame Pushes . 46 Stack Switching . 46 IRET Instruction . 47 Task-Priority Register (CR8) . 48 New Exception Conditions . 48 2.7 Hardware Task Switching . 48 2.8 Long-Mode vs. Legacy-Mode Differences . 49 3 System Resources. 51 3.1 System-Control Registers . 51 CR0 Register . 53 CR2 and CR3 Registers. 57 CR4 Register . 58 CR1 and CR5–CR7 Registers . 62 64-Bit-Mode Extended Control Registers . 62 CR8 (Task Priority Register, TPR). 62 RFLAGS Register . 62 Extended Feature Enable Register (EFER) . 67 3.2 Model-Specific Registers (MSRs) . 69 System Configuration Register (SYSCFG) . 70 System-Linkage Registers . 72 Memory-Typing Registers . 72 Debug-Extension Registers . 73 Performance-Monitoring Registers . 73 Machine-Check Registers . 74 iv Contents 24593—Rev. 3.07—September 2002 AMD 64-Bit Technology 3.3 Processor Feature Identification . 75 4 Segmented Virtual Memory . 77 4.1 Real Mode Segmentation . 78 4.2 Virtual-8086 Mode Segmentation . 78 4.3 Protected Mode Segmented-Memory Models. 79 Multi-Segmented Model . ..