revision 001 january 2019 - intel · now, within this 1.4 seconds of bios booting time, after...

20
Document Number: 338658-001 Open Source Firmware Development Reduce Firmware Booting Time Using Multi- Threaded Environment White Paper Revision 001 January 2019

Upload: others

Post on 29-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Document Number: 338658-001

Open Source Firmware Development Reduce Firmware Booting Time Using Multi-Threaded Environment White Paper Revision 001 January 2019

Page 2: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

2 338658

You may not use or facilitate the use of this document in connection with any infringement or other legal analysis concerning Intel products described herein. You agree to grant Intel a non-exclusive, royalty-free license to any patent claim thereafter drafted which includes subject matter disclosed herein.

No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document.

Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Learn more at Intel.com, or from the OEM or retailer.

No computer system can be absolutely secure. Intel does not assume any liability for lost or stolen data or systems or any damages resulting from such losses.

The products described may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.

Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.

Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Learn more at intel.com, or from the OEM or retailer.

All information provided here is subject to change without notice. Contact your Intel representative to obtain the latest Intel product specifications and roadmaps.

Copies of documents which have an order number and are referenced in this document may be obtained by calling 1-800-548-4725 or visit www.intel.com/design/literature.htm.

By using this document, in addition to any agreements you have with Intel, you accept the terms set forth below.

Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.

Intel, and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.

*Other names and brands may be claimed as the property of others.

Copyright © 2019, Intel Corporation. All rights reserved.

Page 3: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

338658 3

Contents 1 Introduction .................................................................................................... 5

1.1 Intended Audience ................................................................................ 5 1.2 Prerequisites ........................................................................................ 5

2 Overview ........................................................................................................ 6 2.1 Introduction to Coreboot ........................................................................ 6 2.2 Multithreading ...................................................................................... 6

3 Goal and Motivation ......................................................................................... 7

4 Implementation Schema ................................................................................... 8

5 Case Study ................................................................................................... 10 5.1 Setting Up the Board ........................................................................... 11

5.1.1 Download Coreboot Source Code .............................................. 11 5.1.2 Building Coreboot for “Board” ................................................... 11 5.1.3 Flashing coreboot ................................................................... 11

5.2 Boot Time Measurement with Existing Approach ...................................... 12 5.3 Detailed Implementation ...................................................................... 14

5.3.1 Coreboot Changes .................................................................. 15 5.3.2 Payload Changes .................................................................... 16

5.4 Final Boot Performance Time ................................................................. 16

6 Summary ..................................................................................................... 18

7 Glossary ....................................................................................................... 19

8 References .................................................................................................... 20

Figures

Figure 4-1. Platform Booting Time Segregation Between BIOS and OS ..................... 8 Figure 4-2. Comparison Between Existing and Proposed BIOS Flow ......................... 9 Figure 5-1. Sample Chrome Book Board Design Layout ........................................ 10 Figure 5-2. Chrome OS User Login Screen ......................................................... 12 Figure 5-3. Crosh Shell ................................................................................... 12 Figure 5-4. Firmware Warm Reboot Time till Kernel............................................. 13 Figure 5-5. Final firmware Warm Reboot Time till Kernel ...................................... 17

Page 4: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Introduction

4 338658

Revision History

Document Number

Revision Number

Description Revision Date

338658 001 • Initial release January 2019

§ §

Page 5: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Introduction

338658 5

1 Introduction Intel supports Coreboot (an open source firmware initiatives) projects for the Intel Kaby Lake SoC. This document describes the methodology of reducing firmware booting time by initializing I/O devices over multi-threaded environment.

1.1 Intended Audience This enabling guide is intended for firmware engineers, platform designers, and system developers.

1.2 Prerequisites • Users of this document should have prior experience with firmware development

using Coreboot (available at coreboot.org)

• Users should also be familiar with the Intel® Firmware Support Package (Intel® FSP), available at intel.com/fsp

• This document assumes the audience has experience with Intel® 64 and IA-32 Architectures.

§ §

Page 6: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Overview

6 338658

2 Overview In modern day world, where usage of IOT devices (like Automotive and Navigation devices, Home Appliance devices) and client devices are being rapidly increasing, performance is the key measures. Users are expecting the device to be operational as soon as they switch on the device. As per automotive device specification, infotainment or navigation device should be operational as and when user start the car engine, which means devices are expected to have a very short booting time requirement. Even this is the case with Laptop and Tablet users as well. It is also a fact that all modern day CPUs are multi-core processor in nature where two or more cores are capable of running in parallel to execute tasks, but basic platform initialization been handled by CPU boot strap code aka BIOS which is always executing in a single-threaded environment over the BSP. Hence initialization of peripherals which are independent in nature in terms of resources from each others still need to go through a sequential order during BIOS initialization phase.

Rather executing entire platform initialization in sequential order, all those independent resources initialization could have been done in parallel using other available CPU cores which are in dormant states during entire BIOS phase. While industry is keen talking about advancement and progress in technology and new discoveries, but still lagging in exploring the existing CPU features in order to improve boot time performance.

This paper describes how platform booting time can be optimized by executing I/O devices initialization over parallel threads during Pre OS (aka BIOS) phase. Also describes a case study done on boot time improvement by performing early initialization of eMMC* device over APs, so that payload can directly perform read operations from block device and boot to OS.

This paper focus on demonstrating the work on Open Source Firmware Development approach using Open Source BIOS aka Coreboot on Intel based Chrome* platform.

2.1 Introduction to Coreboot Coreboot, formerly known as LinuxBIOS, is a software project aimed at replacing proprietary firmware (BIOS or UEFI) found in most computers with a lightweight firmware designed to perform only the minimum number of tasks necessary to boot the platform. Coreboot is also known as open source BIOS.

2.2 Multithreading Multithreading is the ability of a CPU to execute multiple processes concurrently. In x86 platform, its responsibility of BSP (Bootstrap Processor) to perform multiprocessor initialization to bring APs (application processor) out from reset. In a multiprocessor (MP) environment each processor can perform independent execution of assigned task.

§ §

Page 7: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Goal and Motivation

338658 7

3 Goal and Motivation At Intel-SSG group Coreboot is developed and maintained to enable Google* Chrome devices like Chromebooks, etc. On Google* platforms booting to OS time is key measuring element. Right now there is a strict requirement of booting to OS by less than 1sec time.

In order to achieve this task, an initiative has been made to make use of multi-threaded environment at pre boot phase to perform all I/O initialization. In this case study, will discuss about making eMMC* initialization over application processor during Coreboot stage to achieve 300-400ms reduction in booting time.

§ §

Page 8: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Implementation Schema

8 338658

4 Implementation Schema At end-user level, by platform booting time of a device, it means the total time it takes to show something on the screen of the device. So, it mostly comprises of the BIOS booting time [till the first line of kernel is getting fetched] plus the OS booting time [till the login prompt].

For an example of a generic booting scenario where, suppose the total booting time of a device is ~3 seconds, then, within that, the pre-OS (BIOS) booting takes about ~1.4 seconds, and the Kernel (OS) boots in around ~1.6 seconds.

Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works in a single threaded environment, the BIOS will still continue to run on the BSP (boot strap processor, single core), although after ~400ms all the CPU cores are available.

Figure 4-1. Platform Booting Time Segregation Between BIOS and OS

Let us implement a scheduler to use the multi-core environment even in BIOS phase instead of just running entire BIOS execution only on BSP, even after all the cores are up. Here is an example of independent I/O initialization over multiprocessor environment–

A. Storage Device Initialization, example: eMMC, SATA, SD card, USB storage, etc.

B. Input and Output device initialization, example: USB keyboard, Graphics device, etc.

C. Security Device initialization, example: TPM. D. Other microcontroller initialization, example: Embedded Controller.

In this proposal, we can save around ~500-700 milliseconds of platform booting time in ideal case.

Page 9: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Implementation Schema

338658 9

Figure 4-2. Comparison Between Existing and Proposed BIOS Flow

§ §

Page 10: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

10 338658

5 Case Study This case study has been made on Google* Chrome device using Intel Kaby Lake SoC. Here is reference high level board block diagram to show the attached peripherals -

• Display over eDP*

• Storage eMMC* device

• SD card

• Connectivity Solutions

Figure 5-1. Sample Chrome Book Board Design Layout

Page 11: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

338658 11

BIOS – Coreboot

CPU – Intel® CoreTM m3-7Y30 CPU (x86 CPU)

Number of Cores – Quad Core CPU @2.6GHz

5.1 Setting Up the Board This section describes the process of adding a new platform (“board”) to the existing firmware project, based on a reference design.

5.1.1 Download Coreboot Source Code

1. Clone latest coreboot code as below:

$ git clone https://review.coreboot.org/coreboot.git

2. Place blobs (ucode, me.bin and FSP packages) in appropriate location.

Note: Consider the fact that ucode and ME kit for Kaby Lake SoC will be available from Intel VIP site. After product launch, FSP binary will be available externally as any other program.

5.1.2 Building Coreboot for “Board” 1. Build toolchain.

CPUS=$(nproc--ignore=1) make crossgcc-i386 iasl

2. Create coreboot .config The default options for this board should result in a fully working image:

# echo "CONFIG_VENDOR_GOOGLE=y" > .config

# echo "CONFIG_BOARD_GOOGLE_SORAKA=y" >> .config

3. Build image.

$ make # the image is generated as build/coreboot.rom

5.1.3 Flashing Coreboot

Follow below mechanism to flash final coreboot.rom image on board –

Flashing mechanism on Chromebooks are via servo using flashrom utility.

$ dut-control spi2_vref:pp3300 spi2_buf_en:on spi2_buf_on_flex_en:on warm_reset:on

$ sudo flashrom -n -p ft2232_spi:type=servo-v2 -w <bios_image>

$ dut-control spi2_vref:off spi2_buf_en:off spi2_buf_on_flex_en:off warm_reset:off

Page 12: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

12 338658

5.2 Boot Time Measurement with Existing Approach Upon flashing Coreboot image on targeted board, system will start booting and will reach to Chrome* OS logic screen as below.

Figure 5-2. Chrome OS User Login Screen

After login as user into Chrome* OS, Press CTRL + ALT + T keys from attached keyboard to launch crosh shell (command prompt/terminal) as below.

Figure 5-3. Crosh Shell

Page 13: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

338658 13

Type advance command as “cbmem -t” to list down detailed firmware booting time as below.

Figure 5-4. Firmware Warm Reboot Time till Kernel

Now analyze above figure which talks about firmware booting time. Focus on entries like 1040 and 1050.

1040:finished storage device initialization 1,141,229 (300,184)

1050:finished reading kernel from disk 1,280,169 (138,940)

These two entries together taking around 440ms time out of total firmware booting time of ~1.37sec. So, close to ~32% of entire platform booting time is consumed by storage initialization and reading first partition of kernel from storage drive alone.

Page 14: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

14 338658

5.3 Detailed Implementation This section will describe the detailed implementation schema to save additional ~440ms of firmware booting time as mentioned above.

First let us understand the Coreboot architecture and its role and responsibilities:

Primarily it has two major components as: 1. Coreboot – Does entire chipset and CPU initialization and PCI resource

enumeration. 2. Depthcharge – Payload for Chrome* OS to initialize storage subsystem and read

required partition from storage device to boot to OS.

In existing model, this entire firmware initialization flow will execute over BSP. Although at very early of “ramstage”, Coreboot will perform CPU initialization to take all application processors (AP) out from reset. Since then till booting to OS, those APs are in dormant state.

Take a detailed boot performance time data as below:

In this proposal, we are trying to pull in several payload related features like initialize storage controller and storage devices into “ramstage” also reading first kernel partitions to save read kernel time in payload. All these features are running over application processor in parallel to BSP is executing PCI enumeration and other chipset initialization task.

Here is detailed boot performance break down with proposed model:

Page 15: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

338658 15

As one can compare the modified flow with existing one to find that AP0 is running additional storage initialization related programming when BSP is still executing its primary job.

In this process we could save additional ~400ms of booting time. There could be still some possibility to optimize this work as other cores like AP1 and AP2 are still in dormant stage and free to execute any independent initialization as per requirement.

As mentioned above, in this proposal we had to make some changes in exiting Coreboot and Depthcharge working model. Below sections list down the specific code changes to achieve this target.

5.3.1 Coreboot Changes

Currently in existing model, ramstage is where majority of chipset initializations are taking place. As job responsibility of ramstage, it does the following: 1. CPU Multi-Processor Initialization – Coreboot is responsible to make multi-

processor initialization as per Intel® SDM guideline to take all possible APs out from reset. Coreboot has basic infrastructure to perform specific function execution over all APs or single AP based on APIC ID.

2. PCI Enumeration – Additionally ramstage is also responsible to making resource allocation and enabling those resources for PCI devices. This is must require step for payload to access various boot devices and associated device if any.

3. Hand-Off to Payload – Depthcharge being specific payload for chrome devices, it is a requirement for depthcharge to know certain information from Coreboot. Any information that Coreboot would like to pass to depthcharge will be in form of “sysinfo” table. It is a basic structure that passes certain information from Coreboot to payload [https://github.com/coreboot/coreboot/blob/master/payloads/libpayload/include/sysinfo.h]

In order to make early storage controller and device initialization (SDHC controller and eMMC* device) as part of ramstage over multi-threaded environment, here are list of changes that made it possible:

• Create common eMMC* init block – This block will be responsible to perform eMMC* storage controller and device initialization over application processor specific by APIC ID. It is prescribed to start eMMC* initialization as early as possible after the application processor are available to execute any operation. Hence in this block, we are focusing on three major tasks:

Assigned Fixed MMIO base address for eMMC* PCH controller to perform additional device related operation over MMIO space.

Initialize the SDHC controller. Initialize the media as in card device.

• Make fixed BAR assignment for eMMC* controller during PCI enumeration – As PCI enumeration will continue over BSP and in same time, we will have eMMC* controller and device initialization over AP (based on APIC ID), hence it is important to ensure that the MMIO base address for eMMC* controller remain unchanged during PCI enumeration as well.

• Pass SDHC controller and media information to payload – So far its payload to make storage controller initialization, hence it never looks for such data from Coreboot but in order to make eMMC* early initialization over APs to save boot time, it is also important to let payload know that eMMC* device is readily

Page 16: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

16 338658

available to continue booting to OS. Hence required to create additional controller and media structure into “sysinfo” table to pass from Coreboot to payload.

5.3.2 Payload Changes

Currently in existing model, depthcharge is where storage controller and media device initializations are taking place. 1. Storage Controller Initialization – Its responsibility to add required controller

details that need to be initialize. For an example, eMMC* controller PCI bus device function and required operational mode as HS400/HS200.

2. Storage Media Initialization – Additionally perform the required initialization of storage media device (here eMMC*) to know the number of block, section and size information.

3. Boot from media to OS – Once both controller and device have been initialized, it just read block from eMMC* device to boot to OS.

As entire storage controller and media devices are already been initialized by Coreboot during “ramstage” over APs hence here are list of changes that should let payload know about such design choices:

• Skip SDHC and Media initialization – Create a skip method to let depthcharge know that device is ready to use.

• Provide Device configuration – As part of sysinfo table, Coreboot should be able to pass required information about controller and devices to payload so that it can read kernel partition directly from block device without bother about re-initialization.

5.4 Final Boot Performance Time Finally we are ready to create new coreboot.rom with required Coreboot and depthcharge changes.

Coreboot Changes:

• https://review.coreboot.org/#/q/topic:%22Multi-threaded+EMMC+Init%22+(status:open)

Payload Changes:

• https://chromium-review.googlesource.com/c/chromiumos/platform/depthcharge/+/839163/1

• https://chromium-review.googlesource.com/c/chromiumos/platform/depthcharge/+/839164/1

Let system boot to crosh shell after flashing the new binary.

Run “cbmem -t” command from shell to captured boot performance time.

It saves around ~440ms of firmware booting time in this process.

Page 17: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Case Study

338658 17

Figure 5-5. Final Firmware Warm Reboot Time till Kernel

§ §

Page 18: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Summary

18 338658

6 Summary Platform booting time is critical in modern day computing devices. This paper describes how to optimize platform firmware booting time by introducing independent I/O devices initialization concept over multi-threaded environment. Although we have demonstrated this concept using Open Source BIOS aka Coreboot, this concept is equally evitable for UEFI BIOS as well due to the bottle neck of slow speed device initialization. We also discussed about the possibility of extending this support over remaining APs in order to make further boot time optimization.

§ §

Page 19: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

Glossary

338658 19

7 Glossary

Term Definition

AP Application Processor

BIOS Basic Input Output System

BSP Boot Strap Processor

Coreboot Open Source BIOS aka known as LinuxBIOS in past

Chrome OS Chromium OS is an open-source project that aims to build an operating system that provides a fast, simple, and more secure computing experience for people who spend most of their time on the web.

Crosh The Chromium OS shell. This is the homepage/documentation for the crosh, the Chromium OS shell. On a CrOS devices, user will be able to launch crosh by hitting Ctrl+Alt+T. For non-CrOS devices, it is most unlikely that do anything useful.

CPU A central processing unit (CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logic, controlling, and input/output (I/O) operations specified by the instructions.

Depthcharge The Chrome OS Bootloader.

FSP Firmware Support Package

IOT Internet of things

LinuxBIOS A FOSS project to replace closed BIOS firmware

MMIO Memory Mapped I/O

SoC System on Chip

UEFI Unified Extensible Firmware Interface. Firmware interface between the platform and the operating system. Predominate interfaces are in the boot services (BS) or pre OS. Few runtime (RT) services.

Flashrom Utility for identifying, reading, writing, verifying and erasing flash chips.

Servo Servo is a debug board used for Chromium OS test and development.

§ §

Page 20: Revision 001 January 2019 - Intel · Now, within this 1.4 seconds of BIOS booting time, after around ~400 milliseconds, all the CPU cores are up. But, traditionally, since BIOS works

References

20 338658

8 References [Coreboot] - https://www.coreboot.org/

[Chrome OS] - https://www.chromium.org/chromium-os

[Crosh] - https://chromium.googlesource.com/chromiumos/platform2/+/master/crosh/README.md

[Depthcharge] - https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices/custom-firmware

[flashrom] - https://www.flashrom.org/Flashrom

[FSP]-https://www.intel.com/content/www/us/en/intelligent-systems/intel-firmware-support-package/intel-fsp-overview.html

[servo] - https://www.chromium.org/chromium-os/servo

[UEFI] Unified Extensible Firmware Interface (UEFI) Specification, Version 2.4.b www.uefi.org

For more information, contact the below authors:

Barnali Sarkar ([email protected]) Client BIOS Engineer, working on UEFI BIOS with the Software and Services Group at Intel Corporation.

Subrata Banik ([email protected]) Open Source Coreboot Developer, working on delivering Chrome* products with the Software and Services Group at Intel Corporation.

§ §