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



Similar documents
Advanced x86: BIOS and System Management Mode Internals SPI Flash. Xeno Kovah && Corey Kallenberg LegbaCore, LLC

Single 2.5V - 3.6V or 2.7V - 3.6V supply Atmel RapidS serial interface: 66MHz maximum clock frequency. SPI compatible modes 0 and 3

Technical Note. SFDP for MT25Q Family. Introduction. TN-25-06: Serial Flash Discovery Parameters for MT25Q Family. Introduction

Intel architecture. Platform Basics. White Paper Todd Langley Systems Engineer/ Architect Intel Corporation. September 2010

Booting from NAND Flash Memory

8-Bit Flash Microcontroller for Smart Cards. AT89SCXXXXA Summary. Features. Description. Complete datasheet available under NDA

W25Q80, W25Q16, W25Q32 8M-BIT, 16M-BIT AND 32M-BIT SERIAL FLASH MEMORY WITH DUAL AND QUAD SPI

Programming Interface. for. Bus Master IDE Controller. Revision 1.0

Phoenix Technologies Ltd.

Attacking Hypervisors via Firmware and Hardware

SD Specifications Part A2 SD Host Controller Simplified Specification

3. USB FLASH DRIVE PREPARATION. Almost all current PC firmware permits booting from a USB drive, allowing the launch

Intel 8255x 10/100 Mbps Ethernet Controller Family

Microprocessor & Assembly Language

M25P05-A. 512-Kbit, serial flash memory, 50 MHz SPI bus interface. Features

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-17: Memory organisation, and types of memory

The Programming Interface

Intel Management Engine BIOS Extension (Intel MEBX) User s Guide

PCI-SIG ENGINEERING CHANGE REQUEST

Intel Extreme Memory Profile (Intel XMP) DDR3 Technology

BIOS and CMOS. Overview. The Function of BIOS. The Bus

Attacking Hypervisors via Firmware and Hardware

We r e going to play Final (exam) Jeopardy! "Answers:" "Questions:" - 1 -

Connecting AMD Flash Memory to a System Address Bus

1-Mbit (128K 8) Quad SPI nvsram with Real Time Clock

Implementation Guide. SAS Serial Protocol. for. Montana Department of Justice Gambling Control Division. October 22, Version 1.4.

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

Production Flash Programming Best Practices for Kinetis K- and L-series MCUs

Programming NAND devices

PCI IDE Controller. Specification. Revision 1.0

Introduction to BitLocker FVE

Wake on LAN Hardware Implementation Utilizing the Intel EP80579 Integrated Processor Product Line

AN10860_1. Contact information. NXP Semiconductors. LPC313x NAND flash data and bad block management

A DIY Hardware Packet Sniffer

Cautions When Using BitLocker Drive Encryption on PRIMERGY

Two Parts. Filesystem Interface. Filesystem design. Interface the user sees. Implementing the interface

miniflash User Manual

NAND Flash Memories. Understanding NAND Flash Factory Pre-Programming. Schemes

W25Q128FV 3V 128M-BIT SERIAL FLASH MEMORY WITH DUAL/QUAD SPI & QPI. Publication Release Date: August 24, 2015 Revision L

CCNA 2 Chapter 5. Managing Cisco IOS Software

EHCI: Enhanced Host Controller Interface For USB 2.0

Configuring a SSD RAID-0 Array on an AMD System

Microtronics technologies Mobile:

Fastboot Techniques for x86 Architectures. Marcus Bortel Field Application Engineer QNX Software Systems

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

MICROPROCESSOR. Exclusive for IACE Students iacehyd.blogspot.in Ph: /422 Page 1

RPDO 1 TPDO 1 TPDO 5 TPDO 6 TPDO 7 TPDO 8

Intel Desktop Board DP35DP. MLP Report. Motherboard Logo Program (MLP) 6/17/2008

Memory Systems. Static Random Access Memory (SRAM) Cell

This chapter explains how to update device drivers and apply hotfix.

Lesson 06: Basics of Software Development (W02D2

A+ Guide to Managing and Maintaining Your PC, 7e. Chapter 1 Introducing Hardware

Sample of Hardware Equipment Acceptance Form

Chapter 13. PIC Family Microcontroller

MARTECH SPI Tools. MARTECH SPI Tools User Manual v1.0. User Manual

EN25P64 EN25P Megabit Uniform Sector, Serial Flash Memory FEATURES GENERAL DESCRIPTION

Industrial Flash Storage Trends in Software and Security

MICROPROCESSOR AND MICROCOMPUTER BASICS

Command Processor for MPSSE and MCU Host Bus Emulation Modes

PCI-to-PCI Bridge Architecture Specification. Revision 1.1

MSM Software Feature Difference Between the MR Controller and the IR Controller

Type Message Description Probable Cause Suggested Action. Fan in the system is not functioning or room temperature

Backup and Recovery Procedures

Using the Kinetis Security and Flash Protection Features

MCF54418 NAND Flash Controller

Intel Rapid Storage Technology

Obj: Sec 1.0, to describe the relationship between hardware and software HW: Read p.2 9. Do Now: Name 3 parts of the computer.

University of Dublin Trinity College. Storage Hardware.

Dolphin In-Circuit programming Updating Firmware in the field

RAM & ROM Based Digital Design. ECE 152A Winter 2012

Intel Server Board S3420GPV

Samsung Magician v.4.5 Introduction and Installation Guide

Windows 7 XP Mode for HP Business PCs

CHAPTER 7: The CPU and Memory

Technical Support Bulletin Nr.18 Modbus Tips

Technical Note. Initialization Sequence for DDR SDRAM. Introduction. Initializing DDR SDRAM

(Refer Slide Time: 00:01:16 min)

Software Token Security & Provisioning: Innovation Galore!

Reverse engineering hardware for software reversers: studying an encrypted external HDD

A+ Guide to Software: Managing, Maintaining, and Troubleshooting, 5e. Chapter 3 Installing Windows

An overview of FAT12

PC Notebook Diagnostic Card

NFC Tag Type 5 Specification

Controlling TAS5026 Volume After Error Recovery

Chapter 2 Array Configuration [SATA Setup Utility] This chapter explains array configurations using this array controller.

Micro SDSC / SDHC / SDXC. Micro SD Data Sheet

Technical Note. Micron NAND Flash Controller via Xilinx Spartan -3 FPGA. Overview. TN-29-06: NAND Flash Controller on Spartan-3 Overview

BIOS Update Release Notes

TNM Programmer User Manual. For Windows 7 / Vista / XP. TNM Electronics Ltd.

Embedded Multi-Media Card Specification (e MMC 4.5)

VMWare Workstation 11 Installation MICROSOFT WINDOWS SERVER 2008 R2 STANDARD ENTERPRISE ED.

Basic Router and Switch Instructions (Cisco Devices)

Block 3 Size 0 KB 0 KB 16KB 32KB. Start Address N/A N/A F4000H F0000H. Start Address FA000H F8000H F8000H F8000H. Block 2 Size 8KB 16KB 16KB 16KB

ET-BASE AVR ATmega64/128

Measuring Cache and Memory Latency and CPU to Memory Bandwidth

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

Overview of the LTC2978 Configuration EEPROM (NVM) Revision 1.0

Chapter 4 System Unit Components. Discovering Computers Your Interactive Guide to the Digital World

AN 223: PCI-to-DDR SDRAM Reference Design

Transcription:

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

All materials are licensed under a Creative Commons Share Alike license. http://creativecommons.org/licenses/by-sa/3./ ABribuEon condieon: You must indicate that derivaeve work "Is derived from John BuBerworth & Xeno Kovah s Advanced Intel x86: BIOS and SMM class posted at hbp://opensecuritytraining.info/introbios.html 2

SPI Regions Required Required Added in ICH9 Intel has left room for additional regions The only ones required are the Flash Descriptor region and the BIOS region They are not listed in the order in which they will appear on the flash chip: Flash Descriptor will always be first, as listed, but BIOS will always be last so it ends at 4 GB of memory address space 3

Determining SPI Regions You can determine the regions on your flash by reading the FREG(n) registers in the SPI Base Address Registers (SPIBAR + {54 to 64h}) FREG to FREG4, each 32 bits If the Base is higher than the limit, the region is unused 4

Flash Descriptor Defines most (but not all) of the flash protection that are supported by the Controller Hub Not defined in flash descriptor: BIOS Range Write Protection SMI# Global Write protection (described elsewhere) Logically OR d together, if either are set then access is blocked Must be written during the manufacturing process and set to Read-Only when it leaves the manufacturer, per Intel Sometimes (rarely) the Flash Descriptor itself is left open and thus vulnerable 5

This "Flash Descriptor" structure is what's read by the ICH/PCH in order to populate and expose the information via RO registers (like FREG) in SPIBAR Signature FFA55Ah denotes the device has a valid descriptor and is therefore operating in Descriptor mode. Signature offset is located at on ICH8, ICH9, and ICH In PCH it has been moved to x and bytes thru xf are Reserved Pictured: ICH Flash Descriptor 6

Evolu:on of the Flash Descriptor from ICH to PCH ICH8 ICH9, ICH PCH S:ll 256 bits S:ll 256 bits Renamed Combined Offset shi)ed ICH 8, 9, are idenecal 7

The registers of the Flash Descriptor used to be documented fully in the I/O Controller Hub datasheets. In the Platform Controller Hub datasheets, however, the Descriptor offsets and registers are no longer described. For this reason, we will use the image of the flash descriptor as taken from ICH. FDBAR ICH used as example 8

When describing the protection mechanisms provided by the flash descriptor, I ll point out how they differ between ICH revisions where applicable Remember, this isn t an exercise in memorization but in acquiring new awareness and understanding, with that you can fill in details as they change in the future. The functionality described will be present, even if the offsets change in the future. Note: FDBAR is *not* a memory base address register. When you see later references to offsets from FDBAR, you re dealing in flash linear address offsets (so you need to be careful because FDBAR will differ depending on whether you re running an ICH () or PCH (x)) FDBAR ICH used as example 9

Signature Signature FFA55Ah identifies a valid flash descriptor A valid flash descriptor indicates the SPI flash is operating in Descriptor mode PCH and Management Engine each require a valid flash descriptor Located at FDBAR + h FDBAR defined in bits 2: in FREG (located in SPIBAR) Signature offset is located at on ICH8, ICH9, and ICH In PCH it has been moved to x and bytes thru xf are Reserved FDBAR

Descriptor Map Describes the data structure of the Flash Descriptor number of sections in the descriptor pointers to these sections as well as the size of each section # of physical SPI flash chips present FLMAP FLMAP FDBAR

Region Identifies the different regions of the SPI Flash (BIOS, Mgt Eng, etc.) Not to be confused with defining the flash descriptor map. Each FLREG register (-4) has a base and a limit, each corresponding to the range of that particular region FLREG = Flash Descriptor FLREG = BIOS FLREG2 = ME FLREG3 = GbE FLREG4 = Platform Data Disabled/unused regions will have a base of FFFh and a limit of h Can determine what regions are active If BIOS region is inactive, then the BIOS is located on the FWH 2

Keeping it straight FLREG- 4 are what's in the Flash Descriptor. The data from the Descriptor is then exposed through FREG- 4 registers. 3

Master Defines the Read/Write capabilities that each Flash Master has with respect to each of the SPI regions, including the flash descriptor Each SPI Master has a register that defines these permissions called the Flash Master register Permissions apply only to register access 4

Register layout is identical for each of the three masters Register location and layout is also identical across ICH8, ICH9, ICH Appears to be identical on PCH as well* Flash Master Permissions Should never be set anywhere! *Based on John s analysis of SPI serial flash dumps 5

Flash Master Permissions The requestor ID of the master attempting to access a region must match that of the defined requestor ID 2-Byte value CPU and ME must have requestor ID s of h GbE must have a requestor ID of 28h Each master will always have Read/Write permission to its own region CPU/BIOS will always be able to read the BIOS region of the SPI flash, and so on. This is by default and hardcoded by Intel BIOS 6

Example: FLMSTR meanings Master Section FLMAP (7:) defines Master section location at 6h Based on analysis of the Descriptor Map (FLMAP offset 8h), we have identified that the Master section begins at offset 6h of the Serial Flash (6h is left-shifted 4 bits). FLMAP = 226h (bits 7: define Flash Master location) FLMSTR (CPU/BIOS) = ABh FLMSTR2 (Mgt Engine) = CDh FLMSTR3 (GbE) = 8828h *HxD doesn t let you view the words in 32- bit format (with lible- endian interpretaeon) 7

FLMSTR (CPU/BIOS) Master Section FLMSTR (CPU/BIOS) = ABh Therefore CPU/BIOS has the following privileges: Write (bits 28:24) Can write to the Platform Data region of SPI Flash Can write to the BIOS region of SPI Flash Can write to the GbE region of SPI Flash Read (bits 2:6) Can read the Flash Descriptor of SPI flash Can read the BIOS region of SPI flash Can read the GbE region of SPI flash *Note: The FLMAP register defines 3h + SPI regions, therefore there is no PlaTorm Data region on this SPI flash. 8

CPU/BIOS Permissions = ABh A B *Note: The FLMAP register defines 3h + SPI regions, therefore there is no PlaTorm Data region on this SPI flash. 9

ME Permissions = CDh C D *Note: The FLMAP register defines 3h + SPI regions, therefore there is no PlaTorm Data region on this SPI flash. 2

GbE Permissions = 8828h 8 8 28 *Note: Requestor ID 28h is required on ICH8, ICH9, and ICH systems, in PCH this is 8h 2

Backup Deferred due to lack of Eme/importance for our purposes Included for completeness 22

Component Identifies the different flash chips themselves and their capabilities Read/Write/Erase clock frequencies Even if there are 2 SPI chips, there is still just a single component section The component section contains the Flash Invalid Instructions Register which says which instructions will be blocked from execution by the hardware 23

Yo Defines opcodes that will be prevented from running on the chip by the flash controller hardware Chip Erase (opcode xc7 is a good one to block) FLILL register is constant across ICH8, ICH9, ICH and appears to be the same on PCH* Same location (FCBA + 4h), same bit meanings *Based purely on my analysis of BIOS dumps on machines running PCH 24

Note on SPI Instructions (opcodes) Each ICH/PCH datasheet defines a minimal set of SPI commands that a chip must support H/W Sequencing Interoperability with Intel platform This table can serve a reference to identify any opcodes that are listed in the FLILL register However, each serial flash device may have unique capabilities and commands ICH Required Opcodes *Write Enable looks intereseng doesn t it? A future Advanced course goes into SPI Programming 25

Supported opcodes on an Atmel AT25DF32A SPI Serial Flash Taken straight from Atmel s datasheet Supports more than the minimum set required by Intel Notice it supports more than one Chip Erase command FLILL register must be filled out with these opcodes in mind, not just those that Intel lists hbp://www.atmel.com/images/doc3633.pdf 26

FLILL = h Looking at the Flash Invalid Instructions Register from the Copernicus BIOS dump, we can see that none are defined Although only 4 opcodes can be black-listed here, it s still a setting that should be used And the SPI Flash vendor s datasheet should be taken into account when defining forbidden opcodes I don t recall any other source that has provided this recommendation 27

Soft Straps First implemented in ICH8 In PCH, both regions are combined into a single PCH Soft Straps section Soft Strap data is read out of the SPI device prior to de-asserting a reset (power-on, in layman s terms) Configure specific functions within the chipset before the BIOS or any other software can intervene The specific details regarding the implementation of Soft Straps are located in Intel s confidential SPI programming guides 28

OEM Section and Descriptor Upper MAP OEM Section *CH does not read the OEM information 256 bytes (ICH8, ICH9, ICH, and PCH (up thru 8-series PCH ) Descriptor Upper MAP Describes the Base and length of the Management Vendor Specific Component Capabilities (VSCC) Table Base address is at FDBAR + EFCh (ICH8, ICH9, ICH, and PCH 2 ) Recall FDBAR is offset h on the flash chip on PCH, h on all others Most recent PCH at the Eme of this wrieng 2 Based on my analysis of BIOS binaries FDBAR 29

Management Engine VSCC* Table Contains the JEDEC ID of the Flash Chip Identifies the Vendor and Device ID of the SPI serial flash Describes the different attributes an SPI partition can have (Upper or Lower) Based on the value defined in the FPBA flash descriptor register in the Master section If SPI is defined as having one single partition, then only the attributes defined for the Upper partition are used. *VSCC = Vendor Specific Component CapabiliEes 3