Microprocessor system architectures– IA32 debugging and performance monitoring Jakub Yaghob.

Slides:



Advertisements
Similar presentations
Intermediate x86 Part 4 Xeno Kovah – 2010 xkovah at gmail.
Advertisements

Intermediate x86 Part 3 Xeno Kovah – 2010 xkovah at gmail.
CPU Structure and Function
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
Chapter 12: Interrupts. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. The Intel Microprocessors:
I/O Unit.
Computer Organization and Architecture
Computer Organization and Architecture
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
Microprocessors system architectures – IA32 real and virtual-8086 mode Jakub Yaghob.
Facilities for x86 debugging
Interrupts (contd..) Multiple I/O devices may be connected to the processor and the memory via a bus. Some or all of these devices may be capable of generating.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Facilities for x86 debugging Introduction to Pentium features that can assist programmers in their debugging of software.
Linux Operating System
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Introduction to Interrupts
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Intel IA32 OS Support -Refresh
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
80386DX.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Microprocessor system architectures – IA32 segmentation Jakub Yaghob.
Multitasking Mr. Mahendra B. Salunke Asst. Prof. Dept. of Computer Engg., STES SITS, Narhe, Pune-41 STES Sinhgad Institute of Tech. & Science Dept. of.
Interrupt.
Microprocessors 1 MCS-51 Interrupts.
Interrupts Useful in dealing with: The interface: Random processes;
System Address Registers/Memory Management Registers Four memory management registers are used to specify the locations of data structures which control.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Modes of transfer in computer
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
Dec Hex Bin 14 E ORG ; FOURTEEN Interrupts In x86 PC.
Microprocessor system architectures – IA32 tasks Jakub Yaghob.
80386DX. Programming Model The basic programming model consists of the following aspects: – Registers – Instruction Set – Addressing Modes – Data Types.
AMD K-6 Processor Evaluation. Registers AMD-K6 Registers General purpose registers Segment registers Floating point registers MMX registers EFLAGS register.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
Information Security - 2. Other Registers EFLAGS – 32 Bit Register CFPFAFZFSFTFIFDFOFIO PL IO PL NTRFVM Bits 1,3,5,15,22-31 are RESERVED. 18: AC, 19:VIF,
بسم الله الرحمن الرحيم MEMORY AND I/O.
Microprocessor system architectures – IA32 security
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Interrupts ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Protection in Virtual Mode
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
An Interrupt is either a Hardware generated CALL (externally derived from a hardware signal) OR A Software-generated CALL (internally derived from.
Interrupts and exceptions
Interrupts and interrupt responses
MICROPROCESSOR BASED SYSTEM DESIGN
Microprocessor and Assembly Language
Microprocessor Systems Design I
Anton Burtsev February, 2017
Interrupts In 8085 and 8086.
Basic Microprocessor Architecture
Computer System Overview
Architectural Support for OS
Computer Architecture
Computer System Overview
Architectural Support for OS
COMP3221: Microprocessors and Embedded Systems
Presentation transcript:

Microprocessor system architectures– IA32 debugging and performance monitoring Jakub Yaghob

Overview of debugging support Debug exception #DB Nearly all debug events Breakpoint exception #BP Exception invoked by INT3 Debug registers DR0 - DR3, DR6, DR7 T flag in TSS During attempt to switch task EFLAGS [ RF ] Resume Flag – disables multiple exceptions to the instruction EFLAGS [ TF ] Trap Flag – generates #DB after every execution of an instruction Breakpoint instruction INT3 Last branch recording Only P6+

Conditions for invoking the debugger Task switch Execution of breakpoint instruction Execution of any instruction Execution of an instruction at a specified address Read or write of B, W, D at a specified memory address Write to B, W, D at a specified memory address Input of B, W, D at a specified I/O address (Pentium+) Output to B, W, D at a specified I/O address (Pentium+) Attempt to change the contents of a debug register

Program tracing Tracing enabled by EFLAGS [ TF ]=1 Exception #DB invoked after every instruction execution with TF set before the instruction execution It is a TRAP An instruction, which sets TF, does not invoke the exception An instruction, which clears TF, invokes the exception TF cleared before calling the exception/interrupt handler TF does not change its state during CPL changes Concurrent occurrence of single-step and an external interrupt #DB invoked TF cleared The external interrupt handler invoked before the first instruction of #DB handler

Task switching TSS [ T ] set for a target task Invoked after the task is switched before the first instruction of the target task is executed #DB should not be handled by a task with T flag set CPU in loop

Breakpoint instruction Instruction INT3 Encoded as 1B instruction Suitable for inserting into the code to any address Using Write the INT3 instruction to the breakpoint and remember previous contents #BP invokes debugger Before returning from #BP the EFLAGS [ TF ] is set on the stack and original contents is written back to the breakpoint Return from the exception #DB for single-step invoked after the instruction on the breakpoint is executed Clear the TF and write back INT3 to the breakpoint

Debug registers – I

Debug registers – II Status register DR6 Bn – condition n detected BD – debug registers access detected with DR7 [ GD ] BS – single step BT – task switch Control register DR7 Ln – local breakpoint enabled Gn – global breakpoint enabled GD – general detect enable R/Wn – breakpoint condition LENn – size of memory location 00Instruction execution 01Write 10 I/O ( CR4 [ DE ]=1), undefined ( CR4 [ DE ]=0) 11Read and write 001B 012B 10Undefined (8B for newer CPUs) 114B

Breakpoint recognition Address The address must be aligned to the size Data and I/O breakpoint Any accessed byte inside the range Instruction breakpoint Must have size 1B Only the first byte of an instruction

Breakpoint conditions

Instruction breakpoint It is FAULT We need to avoid endless loop on the breakpoint High priority Invoked before other exceptions Not invoked on an instruction after the POP SS/MOV SS instruction How to avoid the endless loop The flag EFLAGS [ RF ] Automatically set before any FAULT exception is invoked, except of instruction breakpoint Cleared after successful execution of an instruction, except of task switch ( JMP, CALL, INT, IRET ) It can be explicitly set only by reading EFLAGS from the stack/TSS returning from interrupt handler Using as a breakpoint Set the RF in the EFLAGS image on the stack/v TSS

Last branch recording Introduced in the Pentium Pro Depends tightly on model and MSRs Branches, interrupts, exceptions Branches: JMP, Jcc, LOOP, CALL / RET

Performance monitoring Introduced in the Pentium Time-stamp counter Architectural performance monitoring Behaves consistently across microarchitectures Performance monitoring depending on a microarchitecture MSRs

Time-stamp counter Support TSC flag Availability check in CPUID.1:EDX.TSC IA32_TIME_STAMP_COUNTER MSR MSR used as a counter 64-bit RDTSC instruction TSD flag Enable/disable TSC (CR4[TSD]) Behavior Older CPUs Increments with every internal clock cycle Newer CPUs Increments at a constant rate