Advanced x86: BIOS and System Management Mode Internals SMM & Caching Xeno Kovah && Corey Kallenberg LegbaCore, LLC.

Slides:



Advertisements
Similar presentations
Computer-System Structures Er.Harsimran Singh
Advertisements

CPU Structure and Function
CMSC 611: Advanced Computer Architecture Cache Some material adapted from Mohamed Younis, UMBC CMSC 611 Spr 2003 course slides Some material adapted from.
Crucial Security Programs Ring -1 vs. Ring -2: Containerizing Malicious SMM Interrupt Handlers on AMD-V Pete Markowsky Senior Security Researcher
OS2-1 Chapter 2 Computer System Structures. OS2-2 Outlines Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 2: Managing Hardware Devices.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
Group 5 Alain J. Percial Paula A. Ortiz Francis X. Ruiz.
Computer Architecture and Organization
Part 1.  Intel x86/Pentium family  32-bit CISC processor  SUN SPARC and UltraSPARC  32- and 64-bit RISC processors  Java  C  C++  Java  Why Java?
Parallelism Processing more than one instruction at a time. Pipelining
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 2: Managing Hardware Devices.
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
CMPE 421 Parallel Computer Architecture
Computer Architecture and Organization Introduction.
CHAPTER 2: COMPUTER-SYSTEM STRUCTURES Computer system operation Computer system operation I/O structure I/O structure Storage structure Storage structure.
Chapter 2: Computer-System Structures
Chapter 1 Introduction. Architecture & Organization 1 Architecture is those attributes visible to the programmer —Instruction set, number of bits used.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
A Framework for Using Processor Cache as RAM (CAR) Eswaramoorthi Nallusamy University of New Mexico October 10, 2005.
Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage Structure Storage Hierarchy Hardware Protection Network Structure.
Part 1.  Intel x86/Pentium family  32-bit CISC processor  SUN SPARC and UltraSPARC  32- and 64-bit RISC processors  Java  C  C++  Java  Why Java?
Module : Algorithmic state machines. Machine language Machine language is built up from discrete statements or instructions. On the processing architecture,
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
Hyper Threading Technology. Introduction Hyper-threading is a technology developed by Intel Corporation for it’s Xeon processors with a 533 MHz system.
1 Some Real Problem  What if a program needs more memory than the machine has? —even if individual programs fit in memory, how can we run multiple programs?
Advanced x86: BIOS and System Management Mode Internals SPI Flash Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
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.
Advanced x86: BIOS and System Management Mode Internals Input/Output
Advanced x86: BIOS and System Management Mode Internals Conclusion Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Advanced x86: BIOS and System Management Mode Internals System Management Mode (SMM) Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals SMRAM (System Management RAM) Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals Introduction
Advanced x86: BIOS and System Management Mode Internals SPI Flash Protection Mechanisms Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals Memory Map Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Advanced x86: BIOS and System Management Mode Internals Boot Process Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Xeno Kovah && Corey Kallenberg
Advanced x86: BIOS and System Management Mode Internals Flash Descriptor Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Xeno Kovah && Corey Kallenberg
1 Copyright © 2010, Elsevier Inc. All rights Reserved Chapter 2 Parallel Hardware and Parallel Software An Introduction to Parallel Programming Peter Pacheco.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Cache Memory Chapter 17 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Advanced x86: BIOS and System Management Mode Internals SMI Suppression Xeno Kovah && Corey Kallenberg LegbaCore, LLC.
Chapter 11 System Performance Enhancement. Basic Operation of a Computer l Program is loaded into memory l Instruction is fetched from memory l Operands.
The University of Adelaide, School of Computer Science
Translation Lookaside Buffer
Muen Policy & Toolchain
Chapter 2: Computer-System Structures(Hardware)
Chapter 2: Computer-System Structures
Memory COMPUTER ARCHITECTURE
Computer Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 2: Computer-System Structures Computer System Operation I/O Structure Storage.
Xeno Kovah && Corey Kallenberg LegbaCore, LLC
ECEG-3202 Computer Architecture and Organization
Computer-System Architecture
Module 2: Computer-System Structures
Introduction to Intel x86-64 Assembly, Architecture, Applications, & Alliteration Xeno Kovah – 2014 xkovah at gmail.
ECEG-3202 Computer Architecture and Organization
Miss Rate versus Block Size
Module 2: Computer-System Structures
Chapter 2: Computer-System Structures
Chapter 2: Computer-System Structures
Module 2: Computer-System Structures
Module 2: Computer-System Structures
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

Advanced x86: BIOS and System Management Mode Internals SMM & Caching Xeno Kovah && Corey Kallenberg LegbaCore, LLC

All materials are licensed under a Creative Commons “Share Alike” license. 2 Attribution condition: You must indicate that derivative work "Is derived from John Butterworth & Xeno Kovah’s ’Advanced Intel x86: BIOS and SMM’ class posted at

SMRAM and Caching 3

Cache Basics Temporary storage located on the CPU Accesses to data/instructions in cache are much faster than those to physical memory Caching is available in all operating modes, including SMM Caching type for a physical memory range is defined in Memory-Type Range Registers (MTRRs) MTRRs are a type of MSR (Model-Specific Register) that can be set to specify the type of CPU caching for ranges of physical memory Typically configured by BIOS but can also be configured by the operating system as needed 4 From Intel Vol. 3. Ch. "Memory Cache Control"

Physical memory ranges can be defined as having one of these types of caching properties The only one we’ll discuss is the one that was the subject of the dual discovery by Duflot et al. and then later Wojtczuck et al. –Getting into SMRAM: SMM Reloaded, duflot.pdfhttps://cansecwest.com/csw09/csw09- duflot.pdf –Attacking Memory via Intel CPU Cache Poisoning, The attack is brilliant in its simplicity Memory Caching Types 5 From Intel Vol. 3. Ch. "Memory Cache Control"

Write-back (WB) The point of Write-back caching is to reduce the amount of bus traffic between the processor and memory Reads come from cache lines on cache hits Writes are performed in the cache and not immediately written/flushed to memory Both read and write misses cause cache fills Modified CPU cache lines are written back (write-back) to memory at a later time* *Read the Intel Software Developers Guide Volume 3 Simply put, reading/writing from/to a memory region that uses write-back caching will initially fill a line in the CPU cache Subsequent reads/writes from/to that address will be from/to cache instead of memory Until the processor writes-back that cache to memory* 6

7 (D_LCK bit)

8

9

The fix: SMRR The preceding is a great example of how security researchers can influence industry for the better. Damn fine job. System-Management Range Register (SMRR) was introduced in Intel’s x64 architecture* Provides a PHYSBASE/PHYSMASK pair just like MTRRs Prevents the kind of attack that we just saw in the preceding example SMRR restricts access to the address range defined in the SMRR registers Defines the memory type (caching) for the SMRAM range SMRRs can be written to only when the processor is in SMM SMRR takes priority over MTRR in case of overlapping ranges * This is one of the only architecture-dependent security mechanisms. So far up to this point all has been x32/x64 agnostic 10

SMRR When the processor is in SMM: –Memory accesses to this range will use the memory type defined in SMRR_PHYSBASE When the processor is not in SMM: –Memory reads return a fixed value (0xFF in my experience) –Memory writes are ignored –Memory type is Uncacheable 11

Verify SMRR Support: IA32_MTRRCAP SMRR is supported on a system if bit 11 in the IA32_MTRRCAP MSR is set Verify next that it is being used 12

SMRR MSR Number If you try to read the SMRR of your system, be sure to verify its location using the developers guide (MSR chapter) The MSR register addresses are non "architectural" and will therefore differ between architectures –That’s why they are called Model-Specific Registers RW-E does not appear to handle exceptions well since reading the wrong MSR will crash your system –As of latest version For the reference E6400 (Core2Duo) 13

Homework heads up Find the value of SMRR_PHYSBASE for your particular hardware 14