Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table.

Slides:



Advertisements
Similar presentations
Dr. Rabie A. Ramadan Al-Azhar University Lecture 3
Advertisements

Using VMX within Linux We explore the feasibility of executing ROM-BIOS code within the Linux x86_64 kernel.
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
Computer Organization and Assembly Languages Yung-Yu Chuang
Intel MP.
Computer Organization and Architecture
Computer Organization and Architecture
Multiprocessor Initialization
Introduction to 8086 emulation Using ‘Virtual-8086’ mode to execute real-mode procedures in a protected-mode environment.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Linux Memory Issues An introduction to some low-level and some high-level memory management concepts.
IA32 Paging Scheme Introduction to the Pentium’s support for “virtual” memory.
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
IA-32 Processor Architecture
The x86 Feature Flags On using the CPUID instruction for processor identification and feature determination.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Deferred segment-loading An exercise on implementing the concept of ‘load-on-demand’ for the program-segments in an ELF executable file.
1 Hardware and Software Architecture Chapter 2 n The Intel Processor Architecture n History of PC Memory Usage (Real Mode)
Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table.
1 ICS 51 Introductory Computer Organization Fall 2006 updated: Oct. 2, 2006.
CE6105 Linux 作業系統 Linux Operating System 許 富 皓. Chapter 2 Memory Addressing.
Multiprocessor Initialization
Microprocessors Introduction to ia32 Architecture Jan 31st, 2002.
Introduction to the Intel x86’s support for “virtual” memory
Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 2: 80386DX Internal Architecture & Data Organization.
Advanced Programmable Interrupt Controllers Multiprocessor-systems require enhanced circuitry for signaling of external interrupt-requests.
8086 emulation Using Virtual-8086 mode to execute real-mode procedures in a protected-mode environment.
Unit-1 PREPARED BY: PROF. HARISH I RATHOD COMPUTER ENGINEERING DEPARTMENT GUJARAT POWER ENGINEERING & RESEARCH INSTITUTE Advance Processor.
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
Intel
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
Intel MP (32-bit microprocessor) Designed to overcome the limits of its predecessor while maintaining the software compatibility with the.
Windows Kernel Internals Traps, Interrupts, Exceptions
The Pentium Processor.
The Pentium Processor Chapter 3 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
The Pentium Processor Chapter 3 S. Dandamudi.
1 Fundamental of Computer Suthida Chaichomchuen : SCC
The ISA Level The Instruction Set Architecture (ISA) is positioned between the microarchtecture level and the operating system level.  Historically, this.
Lecture 3. APIC ID Prof. Taeweon Suh Computer Science Education Korea University COM509 Computer Systems.
1 Linux Operating System 許 富 皓. 2 Memory Addressing.
Interrupts in the guest VM A look at the steps needed to “reflect” hardware interrupts back into the ROM-BIOS for servicing.
Computer Organization - 1. INPUT PROCESS OUTPUT List different input devices Compare the use of voice recognition as opposed to the entry of data via.
Virtual 8086 Mode  The supports execution of one or more 8086, 8088, 80186, or programs in an protected-mode environment.  An 8086.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
Different Microprocessors Tamanna Haque Nipa Lecturer Dept. of Computer Science Stamford University Bangladesh.
10. Epilogue ENGI 3655 Lab Sessions.  We took control of the computer as early as possible, right after the end of the BIOS  Our multi-stage bootloader.
MODULE 5 INTEL TODAY WE ARE GOING TO DISCUSS ABOUT, FEATURES OF 8086 LOGICAL PIN DIAGRAM INTERNAL ARCHITECTURE REGISTERS AND FLAGS OPERATING MODES.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Computer Organization 1
The Microprocessor & Its Architecture A Course in Microprocessor Electrical Engineering Department Universitas 17 Agustus 1945 Jakarta.
x86 Processor Architecture
Homework Reading Machine Projects Labs
Anton Burtsev February, 2017
Anton Burtsev February, 2017
Interrupts In 8085 and 8086.
Basic Microprocessor Architecture
contains 8086 processor and several additional functional chips: clock generator 2 independent DMA channels PIC 3 programmable 16-bit timers.
Homework Reading Continue work on mp1
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
Introduction to Intel IA-32 and IA-64 Instruction Set Architectures
CS 301 Fall 2002 Computer Organization
The Microprocessor & Its Architecture
Computer Operation 6/22/2019.
Computer Architecture and System Programming Laboratory
Presentation transcript:

Prelude to Multiprocessing Detecting cpu and system-board capabilities with CPUID and the MP Configuration Table

CPUID Recent Intel processors provide a ‘cpuid’ instruction (opcode 0x0F, 0xA2) to assist software in detecting a CPU’s capabilities If it’s implemented, this instruction can be executed in any of the processor modes, and at any of its four privilege levels But this ‘cpuid’ instruction might not be implemented (e.g., 8086, 80286, 80386)

Intel x86 EFLAGS register IDID VIPVIP VIFVIF ACAC VMVM RFRF 0 NTNT IOPL OFOF DFDF IFIF TFTF SFSF ZFZF 0 AFAF 0 PFPF 1 CFCF Software can ‘toggle’ the ID-bit (bit #21) in the 32-bit EFLAGS register if the processor is capable of executing the ‘cpuid’ instruction

But what if there’s no EFLAGS? The early Intel processors (8086, 80286) did not implement any 32-bit registers The FLAGS register was only 16-bits wide So there was no ID-bit that software could try to ‘toggle’ (to see if ‘cpuid’ existed) How can software be sure that the 32-bit EFLAGS register exists within the CPU?

Detecting 32-bit processors There’s a subtle difference in the way the logical shift/rotate instructions work when register CL contains the ‘shift-factor’ On the 32-bit processors (e.g., ) the value in CL is truncated to 5-bits, but not so on the 16-bit CPUs (8086, 80286) Software can exploit this distinction, in order to tell if EFLAGS is implemented

Detecting EFLAGS # Here’s a test for the presence of EFLAGS mov $-1, %ax# a nonzero value mov $32, %cl# shift-factor of 32 shl %cl, %ax# do logical shift or %ax, %ax# test result in AX jnz is32bit# EFLAGS present jmp is16bit# EFLAGS absent

Testing for ID-bit ‘toggle’ # Here’s a test for the presence of the CPUID instruction pushfl# copy EFLAGS contents pop%eax# to accumulator register mov%eax, %edx# save a duplicate image btc$21, %eax# toggle the ID-bit (bit 21) push%eax# copy revised contents popfl# back into EFLAGS pushfl# copy EFLAGS contents pop%eax# back into accumulator xor%edx, %eax# do XOR with prior value bt$21, %eax# did ID-bit get toggled? jcy_cpuid# yes, can execute ‘cpuid’ jmpn_cpuid# else ‘cpuid’ unimplemented

How does CPUID work? Step 1: load value 0 into register EAX Step 2: execute ‘cpuid’ instruction Step 3: Verify ‘GenuineIntel’ character- string in registers (EBX,EDX,ECX) Step 4: Find maximum CPUID input-value in the EAX register

load 1 into EAX and execute CPUID Processor model and stepping information is returned in register EAX Version and Features Extended Family ID Extended Model ID Type Family ID Model Stepping ID

Some Feature Flags in EDX HTTHTT PGEPGE APICAPIC PSEPSE DEDE VMEVME FPUFPU HTT = HyperThreading Technology (1 = yes, 0 = no) PGE = Page Global Entries (1=yes, 0=no) APIC = Advanced Programmable Interrupt Controller on-chip (1 = yes,0 = no) PSE = Page-Size Extensions (1 = yes, 0 = no) DE = Debugging Extensions (1=yes, 0=no) VME = Virtual-8086 Mode Enhancements (1 = yes, 0 = no) FPU = Floating-Point Unit on-chil (1=yes, 0=no) 12013

Some Feature Flags in ECX VMXVMX 5 VMX = Virtual Machine Extensions (1 = yes, 0 = no)

Multiprocessor Specification It’s an industry standard, allowing OS software to use multiple processors in a uniform way OS software searches in three regions of the physical address-space below 1-megabyte for a “paragraph-aligned” data-structure of length 16- bytes called the MP Floating Pointer Structure: –Search in lowest KB of Extended Bios Data Area –Search in topmost KB of conventional 640K RAM –Search in the 128KB ROM-BIOS (0xE0000-0xFFFFF)

MP Floating Pointer Structure This structure may contain an ID-number for one a small number of standard SMP system architectures, or may contain the memory address for a more extensive MP Configuration Table having entries that specify a “customized” system architecture The machines in our classroom employ the latter of these two options

An example record The MP Configuration Table will contain a record for each logical processor CPU Flags BP (bit 1), EN (bit 0) Local-APIC version Local-APIC ID Entry Type 0 CPU signature (stepping, model, family) Feature Flags reserved (=0) BP = Bootstrap Processor (1=yes, 0=no), EN = Enabled (1=yes, 0=no)

Our ‘mpinfo.cpp’ utility We created a Linux utility that will display the system-information contained in the MP Configuration Table (in hex format) You can refer to the ‘MP Specification 1.4’ document (online) to interpret this display This utility needs a device-driver ‘dram.c’ to be pre-installed (in order that it be able to directly access the system’s memory)

A processor’s Local-APIC The purpose of each processor’s APIC is to allow the CPUs in a multiprocessor system to send messages to one another and to manage the delivery of the interrupt-requests from the various peripheral devices to one (or more) of the CPUs in a dynamically programmable way Each processor’s Local-APIC has a variety of registers, all ‘memory mapped’ to paragraph- aligned addresses within the 4KB page at physical-address 0xFEE00000

Local-APIC’s register-space APIC 0xFEE GB physical address-space 0x RAM

Analogies with the PIC Among the registers in a Local-APIC are these (which had analogues in the older 8259 PIC’s design: –IRR: Interrupt Request Register (256-bits) –ISR: In-Service Register (256-bits) –TMR: Trigger-Mode Register (256-bits) For each of these, its 256-bits are divided among eight 32-bit register addresses

New way to do ‘EOI’ Instead of using a special End-Of-Interrupt command-byte, the Local-APIC contains a dedicated ‘write-only’ register (named the EOI Register) which an Interrupt Handler writes to when it is ready to signal an EOI # issuing EOI to the Local-APIC mov$0xFEE00000, %ebx# address of the cpu’s Local-APIC movl$0, %fs:0xB0(%ebx)# write any value into EOI register # Here we assume segment-register FS holds the selector for a segment-descriptor # for a ‘writable’ 4GB-size expand-up data-segment whose base-address equals 0

Each CPU has its own timer! Four of the Local-APIC registers are used to implement a programmable timer It can privately deliver a periodic interrupt (or one-shot interrupt) just to its own CPU –0xFEE00320: Timer Vector register –0xFEE00380: Initial Count register –0xFEE00390: Current Count register –0xFEE003E0: Divider Configuration register

Timer’s Local Vector Table Interrupt ID-number MODEMODE MASKMASK BUSYBUSY xFEE00320 MODE: 0=one-shot 1=periodic MASK: 0=unmasked 1=masked BUSY: 0=not busy 1=busy

Timer’s ‘Divide-Configuration’ reserved (=0) xFEE003E0 0 Divider-Value field (bits 3, 1, and 0) 000 = divide by = divide by = divide by = divide by = divide by = divide by = divide by = divide by 1

Initial and Current Counts Initial Count Register (read/write) 0xFEE00380 Current Count Register (read-only) 0xFEE00390 When the timer is programmed for ‘periodic’ mode, the Current Count is automatically reloaded from the Initial Count register, then counts down with each CPU bus-cycle, generating an interrupt when it reaches zero

Using the timer’s interrupts Setup your desired Initial Count value Select your desired Divide Configuration Setup the APIC-timer’s LVT register with your desired interrupt-ID number and counting mode (‘periodic’ or ‘one-shot’), and clear the LVT register’s ‘Mask’ bit to initiate the automatic countdown operation

In-class exercise #1 Run the ‘cpuid.cpp’ Linux application (on our course website) to see if the CPUs in our classroom implement HyperThreading (i.e., multiple logical processors in a cpu) Then run the ‘mpinfo.cpp’ application, to see if the MP Base Configuration Table has entries for more than one processor If both results hold true, then we can write our own multiprocessing software in H235!

In-class exercise #2 Run the ‘apictick.s’ demo (on our CS 630 website) to observe the APIC’s ‘periodic’ interrupt-handler drawing ‘T’s onscreen It executes for ten-milliseconds (the 8254 is used here to create that timed delay) Try reprogramming the APIC’s Divider Configuration register, to cut the interrupt frequency in half (or perhaps to double it)