Getting Ready to Enter x86 Protected Mode Survival tactics for enabling Protected-Mode with a minimum of supporting infrastructure.

Slides:



Advertisements
Similar presentations
There are two types of addressing schemes:
Advertisements

Dept. of ECE, GMU ECE Registers and Memory Access Dr. Qiang Lin.
Crafting a ‘boot time’ program How we can utilize some standard ‘real-mode’ routines that reside in the PC’s ROM-BIOS firmware.
Intel MP.
Microprocessors system architectures – IA32 real and virtual-8086 mode Jakub Yaghob.
Using data conversions
Lect 3: Instruction Set and Addressing Modes. 386 Instruction Set (3.4) –Basic Instruction Set : 8086/8088 instruction set –Extended Instruction Set :
Azir ALIU 1 What is an assembly language?. Azir ALIU 2 Inside the CPU.
Data Movement Instructions
Lecture 6 Machine Code: How the CPU is programmed.
Lab6 – Debug Assembly Language Lab
Facilities for x86 debugging Introduction to x86 CPU features that can assist programmers in the debugging of their software.
Task-Switching How the x86 processor assists with context-switching among multiple program-threads.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Viewing 8086 memory-areas A peek into the video display memory, the real-mode Interrupt Vector Table, and the ROM-BIOS DATA AREA.
Page-Faults in Linux How can we study the handling of page-fault exceptions?
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
The various x86 ‘modes’ On understanding key differences among the processor’s several execution-architectures.
Defining protected-mode segment-descriptors An example of a protected-mode bootsector application that draws a message to the video display.
Deferred segment-loading An exercise on implementing the concept of ‘load-on-demand’ for the program-segments in an ELF executable file.
Venturing into protected-mode A first look at the CPU registers and instructions which provide the essential supporting infrastructure.
Timeout for some demos An instructive look at how the Linux Operating System sets up system data-structures.
X86 segmentation, page tables, and interrupts 3/17/08 Frans Kaashoek MIT
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 2 The Microprocessor and its Architecture.
Task-Switching How the x86 processor assists with context-switching among multiple program-threads.
Executing an ELF executable
Executing an ELF executable How to load an executable ELF file for execution in ‘extended’ physical memory.
Understanding POST and ROM-BIOS service functions Numerous low-level services are available to real-mode programs (include boot-loaders)
Segment-registers’ hidden bits A look at how segmentation attributes are cached within the CPU’s segment-registers.
Deferred segment-loading An exercise on implementing the concept of ‘load-on-demand’
Venturing into protected-mode
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 4 Data Movement Instructions by.
Special segment-registers
A ‘protected-mode’ exploration A look at the steps needed to build segment-descriptors for displaying a message while in protected-mode.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
80x86 Processor Architecture
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2013 Lecture 4: 80386DX memory, addressing.
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
Venturing into protected-mode A first look at the CPU registers and instructions which provide the essential supporting infrastructure.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
Lect 13-1 Lect 13: and Pentium. Lect Microprocessor Family  Microprocessor  Introduced in 1989  High Integration  On-chip 8K.
Lecture 18 Last Lecture Today’s Topic Instruction formats
UNIT 2 Memory Management Unit and Segment Description and Paging
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
Multitasking Mr. Mahendra B. Salunke Asst. Prof. Dept. of Computer Engg., STES SITS, Narhe, Pune-41 STES Sinhgad Institute of Tech. & Science Dept. of.
Programming the Microprocessor A Course in Microprocessor Electrical Engineering Dept. University of Indonesia.
INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
UHD:CS2401: A. Berrached1 The Intel x86 Hardware Organization.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
Addressing Modes of 8086 Processor Ammar Anwar Khan Electrical Engineer King Saud University Riyadh Saudi Arabia.
ECE291 Computer Engineering II Lecture 3 Josh Potts University of Illinois at Urbana- Champaign.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
Information Security - 2. Descriptor Tables There are two descriptor tables – Global Descriptor Tables – Local Descriptor Tables The global descriptor.
Internal Programming Architecture or Model
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
Chapter 2 Instruction Addressing and Execution. Lesson plan Review some concepts in the first week First assembly program with EMU8086 Related concepts.
Stack Operations Dr. Hadi AL Saadi.
Instruction set Architecture
Microprocessor Systems Design I
CSE 120 Principles of Operating
BYTE AND STRING MANIPULATON
Assembly Language Programming Part 3
x86 segmentation, page tables, and interrupts
Data Addressing Modes • MOV AX,BX; This instruction transfers the word contents of the source-register(BX) into the destination register(AX). • The source.
3.6 Data transfer Instructions
8086 MICROPROCESSOR PROGRAMMING – INTEGER INSTRUCTIONS AND COMPUTATIONS Amar Saraswat.
The Microprocessor & Its Architecture
Presentation transcript:

Getting Ready to Enter x86 Protected Mode Survival tactics for enabling Protected-Mode with a minimum of supporting infrastructure

Diagnostics Upon entering protected-mode, the “rules” change regarding the allowed CPU actions Memory-addresses are computed using a different set of circuitry within the CPU Restrictions are enforced by generating a variety of “exceptions” which interrupt the CPU’s normal fetch-execute cycle We will need to “diagnose” their causes

Hexadecimal Display To display values in registers or memory locations, we need to convert from binary numbers to character-strings that consist of ascii-codes for hexadecimal numerals Why? Because hexadecimal values are easy for human programmers to convert into the actual bit-patterns represented, allowing us to “see” inside the computer

Conversion Algorithm The easiest algorithm to understand uses a “lookup table” for converting ‘nybbles’ to ascii numerals: 0000→ ‘0’ (=0x30) 1010→ ‘A’ (=0x41) 0001→ ‘1’ (=0x31) 1011→ ‘B’ (=0x42) 0010→ ‘2’ (=0x32) 1011→ ‘C’ (=0x43) 1001→ ‘9’ (=0x39) 1111→ ‘F’ (=0x46)

Lookup-Table Algorithm hexlist:.ASCII “ ABCDEF” ; ; Algorithm assumes DS already is setup lea bx, hexlist ; point DS:BX to table and al, #0x0F ; isolate nybble in AL xlat ; replace AL from table

Alternative to avoid data-table ; Clever machine-algorithm (by Tim Lopez) and al, #0x0F ; isolate nybble in AL cmp al, #10 ; set carry-flag for SBB sbb al, #0x69 ; subtract-with-borrow das ; adjustment to result ; no lookup-table is needed here, just some ; “immediate data” within instruction-stream

In-Class Exercise #1 Try replacing use of the ‘xlat’ instruction by the three Lopez-Algorithm instructions, in our bootsector demo-program ‘regdump.s’ Then the array of hexadecimal numerals, and the instruction setup for register BX, can be removed from the program source Question: How many bytes are saved?

Protected-Mode Addresses Segment-selector Logical Address: Segment-offset Operand’s effective address Physical Address: descriptor Segment Descriptor Table + Segment Base-address (also Segment-Limit and Access Rights) Validity is checked by CPU

Segment Descriptor Format Base[31..24]GD RSVRSV AVLAVL Limit [19..16] P DPLDPL SX C/DC/D R/WR/W ABase[23..16] Base[15..0]Limit[15..0]

“Hidden” part of Segment Registers selectorSegment baseSegment limit Access rights The programmer-visible part of a segment-register The “invisible” parts of a segment-register

Segment-Register “cache” The hidden portions of segment-registers are modified whenever any instruction modifies a segment-register’s visible part Examples: mov ds, ax pop es lss esp, tos jmpf #main, #0x07C0 iret

Observation If we can enter protected-mode, but NOT do anything to alter any segment-register, then we won’t need to construct Tables of Segment-Descriptors The left-over real-mode descriptor-values will still be in the segment-registers’ cache We will pursue this idea in a future lesson

Project #1 To get us ready for diagnosing the causes of protected-mode “exceptions”, we build a program that displays the contents of CPU registers (in hexadecimal format) similar to the ‘regdump.s’ demo (from our website) Two more segment-registers: FS and GS Also four special control-registers: CR0, CR2, CR3, CR4

In-Class Exercise #2 Modify the ‘regdump.s’ bootsector demo so that it also displays the contents in the new segment-registers: FS and GS Test your changes by reassembling you modified program text, installing it on the floppy diskette in your workstation, then rebooting (use the diskette’s menu-item) Try rebooting from a diskette “image-file”