[SeaBIOS] [Qemu-devel] SeaBIOS booting time optimization
Stefano Garzarella
sgarzare at redhat.com
Thu Nov 22 12:08:55 CET 2018
Hi,
I continued to investigate how to reduce the boot time with SeaBIOS
and QEMU when it used with linuxboot_dma.bin (-kernel parameter).
I reached ~12ms with a SeaBIOS configuration (attached) where I
disabled debug output, all Hardware support (except SMM & MTRRs) and I
applied a small patch to disable VGA setup and console (attached).
Samuel, I put also the total time to userspace (linux_start_user)
adding a probe in the kernel_init() and when I disabled the VGA in the
SeaBIOS I noticed also a speed up in the kernel boot phase.
Another approach that I tried, obtaining similar results, is to
recognize the linuxboot_dma.bin at runtime, then skip
device_hardware_setup(), enable_vga_console(), and vgarom_setup(). In
this case, I used the default configuration without disabling
anything.
Gerd, Kevin do you think these approaches can be acceptable in SeaBIOS?
Thanks,
Stefano
Booting times with several configurations:
- SeaBIOS default config + Stephen's TPM patch
qemu_init_end: 40.342836
fw_start: 40.528355 (+0.185519)
fw_do_boot: 108.679648 (+68.151293)
linux_start_boot: 110.961394 (+2.281746)
linux_start_user: 647.981995 (+537.020601)
- SeaBIOS config (CONFIG_DEBUG_LEVEL=0) + Stephen's TPM patch
qemu_init_end: 44.533900
fw_start: 44.763200 (+0.229300)
fw_do_boot: 98.881728 (+54.118528)
linux_start_boot: 100.925424 (+2.043696)
linux_start_user: 638.000481 (+537.075057)
- SeaBIOS config (CONFIG_DEBUG_LEVEL=0, disable all HW support except
SMM & MTRRs) + Stephen's TPM patch
qemu_init_end: 42.705257
fw_start: 42.915464 (+0.210207)
fw_do_boot: 91.982749 (+49.067285)
linux_start_boot: 93.970654 (+1.987905)
linux_start_user: 632.916320 (+538.945666)
- SeaBIOS config (CONFIG_DEBUG_LEVEL=0, disable all HW support except
SMM & MTRRs, CONFIG_DISABLE_VGA=y) + Stephen's TPM patch
qemu_init_end: 42.968648
fw_start: 43.154598 (+0.185950)
fw_do_boot: 55.808438 (+12.653840)
linux_start_boot: 57.170154 (+1.361716)
linux_start_user: 529.189856 (+472.019702)
Disable VGA patch:
From: Stefano Garzarella <sgarzare at redhat.com>
Date: Thu, 22 Nov 2018 10:55:23 +0100
Subject: [PATCH] qemu: Add CONFIG_DISABLE_VGA to disable VGA setup and console
Allow users to disable VGA setup and console. Useful to speed
up the boot with QEMU when -kernel parameter is used. Linux
kernel will also initialize the VGA during the boot phase.
Signed-off-by: Stefano Garzarella <sgarzare at redhat.com>
---
src/Kconfig | 7 +++++++
src/bootsplash.c | 2 ++
src/optionroms.c | 2 +-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/Kconfig b/src/Kconfig
index daf8222..b1f0ce6 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -364,6 +364,13 @@ menu "Hardware support"
help
Support for using the CPU timestamp counter as an internal
timing source.
+ config DISABLE_VGA
+ depends on QEMU
+ bool "Disable VGA setup"
+ default n
+ help
+ Skip VGA setup and console (useful to speed up the boot with QEMU
+ when -kernel parameter is used).
endmenu
menu "BIOS interfaces"
diff --git a/src/bootsplash.c b/src/bootsplash.c
index 165c98d..dde3314 100644
--- a/src/bootsplash.c
+++ b/src/bootsplash.c
@@ -39,6 +39,8 @@ call16_int10(struct bregs *br)
void
enable_vga_console(void)
{
+ if (CONFIG_DISABLE_VGA)
+ return;
dprintf(1, "Turning on vga text mode console\n");
struct bregs br;
diff --git a/src/optionroms.c b/src/optionroms.c
index fc992f6..a3b5a16 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -428,7 +428,7 @@ vgarom_setup(void)
{
int have_vga = 0;
- if (! CONFIG_OPTIONROMS)
+ if (!CONFIG_OPTIONROMS || CONFIG_DISABLE_VGA)
return;
dprintf(1, "Scan for VGA option rom\n");
--
2.19.1
SeaBIOS final configuration:
#
# Automatically generated file; DO NOT EDIT.
# SeaBIOS Configuration
#
#
# General Features
#
# CONFIG_COREBOOT is not set
CONFIG_QEMU=y
# CONFIG_CSM is not set
CONFIG_QEMU_HARDWARE=y
CONFIG_XEN=y
CONFIG_THREADS=y
CONFIG_RELOCATE_INIT=y
CONFIG_BOOTMENU=y
CONFIG_BOOTSPLASH=y
CONFIG_BOOTORDER=y
CONFIG_ENTRY_EXTRASTACK=y
CONFIG_MALLOC_UPPERMEMORY=y
CONFIG_ROM_SIZE=0
#
# Hardware support
#
# CONFIG_ATA is not set
# CONFIG_AHCI is not set
# CONFIG_SDCARD is not set
# CONFIG_VIRTIO_BLK is not set
# CONFIG_VIRTIO_SCSI is not set
# CONFIG_PVSCSI is not set
# CONFIG_ESP_SCSI is not set
# CONFIG_LSI_SCSI is not set
# CONFIG_MEGASAS is not set
# CONFIG_MPT_SCSI is not set
# CONFIG_FLASH_FLOPPY is not set
# CONFIG_NVME is not set
# CONFIG_PS2PORT is not set
# CONFIG_USB is not set
# CONFIG_SERIAL is not set
# CONFIG_SERCON is not set
# CONFIG_LPT is not set
# CONFIG_HARDWARE_IRQ is not set
CONFIG_USE_SMM=y
CONFIG_CALL32_SMM=y
CONFIG_MTRR_INIT=y
# CONFIG_PMTIMER is not set
# CONFIG_TSC_TIMER is not set
CONFIG_DISABLE_VGA=y
#
# BIOS interfaces
#
CONFIG_DRIVES=y
CONFIG_CDROM_BOOT=y
CONFIG_CDROM_EMU=y
CONFIG_PCIBIOS=y
CONFIG_APMBIOS=y
CONFIG_PNPBIOS=y
CONFIG_OPTIONROMS=y
CONFIG_PMM=y
CONFIG_BOOT=y
CONFIG_KEYBOARD=y
CONFIG_KBD_CALL_INT15_4F=y
CONFIG_MOUSE=y
CONFIG_S3_RESUME=y
CONFIG_VGAHOOKS=y
# CONFIG_DISABLE_A20 is not set
# CONFIG_WRITABLE_UPPERMEMORY is not set
CONFIG_TCGBIOS=y
#
# BIOS Tables
#
CONFIG_PIRTABLE=y
CONFIG_MPTABLE=y
CONFIG_SMBIOS=y
CONFIG_ACPI=y
CONFIG_ACPI_DSDT=y
CONFIG_FW_ROMFILE_LOAD=y
#
# VGA ROM
#
CONFIG_NO_VGABIOS=y
# CONFIG_VGA_STANDARD_VGA is not set
# CONFIG_VGA_CIRRUS is not set
# CONFIG_VGA_BOCHS is not set
# CONFIG_VGA_GEODEGX2 is not set
# CONFIG_VGA_GEODELX is not set
# CONFIG_DISPLAY_BOCHS is not set
# CONFIG_VGA_RAMFB is not set
# CONFIG_BUILD_VGABIOS is not set
CONFIG_VGA_EXTRA_STACK_SIZE=512
#
# Debugging
#
CONFIG_DEBUG_LEVEL=0
On Tue, Nov 20, 2018 at 12:22 PM Gerd Hoffmann <kraxel at redhat.com> wrote:
>
> Hi,
>
> > > Background: The drivers in seabios work on both virtual and physical
> > > hardware (you can run seabios as coreboot payload on physical hardware).
> > > There are quite a few places where are delays and timeouts which are
> > > required to work properly on physical hardware. But typically virtual
> > > hardware is alot faster. There is -- for example -- no time needed to
> > > establish a sata link. Link detection in ahci is instant on qemu.
> >
> > I'll investigate also other timeouts.
>
> I'd focus on legacy lpc/isa hardware here. PCI-ish hardware which has
> such timeouts (sata, usb, ...) typically isn't present in the virtual
> machine if you care about performance. Or, in other words, the best way
> to handle the sata link detection delay is to use "qemu -M q35,sata=off".
>
> cheers,
> Gerd
>
--
Stefano Garzarella
Red Hat
More information about the SeaBIOS
mailing list