[SeaBIOS] Reducing SeaBIOS kernel entry time

Kevin O'Connor kevin at koconnor.net
Sat Jul 4 19:57:44 CEST 2015


On Fri, Jul 03, 2015 at 03:12:14PM +0100, Stefan Hajnoczi wrote:
> On Fri, Jul 3, 2015 at 2:13 PM, Kevin O'Connor <kevin at koconnor.net> wrote:
> > I took a look a month or so ago:
> >
> > http://article.gmane.org/gmane.comp.emulators.kvm.devel/136207
> >
> > Last test I ran I had SeaBIOS down to 16ms (not including the time to
> > deploy or jump to the linux kernel).  More reductions are also
> > possible - the above was just with Kconfig settings.
> >
> > Let me know if you want more info on how I did that.
> 
> That sounds interesting.  Do you have a .config or git branch?

See attached SeaBIOS config.  I profiled the results following the
directions at:

http://www.seabios.org/Debugging#Timing_debug_messages

The QEMU command line I used is:

qemu-system-x86_64 -k en-us -snapshot -L test -chardev pipe,path=qemudebugpipe,id=seabios -device isa-debugcon,iobase=0x402,chardev=seabios -enable-kvm

To get to these low start times (~16ms on my old AMD system) I
disabled debug messages in SeaBIOS.  (The debug messages themselves
take a few milliseconds.)  So, in order to do profiling via the debug
output, I manually added two small debug port writes (see seabios
patch below).  I end up seeing results like this on my machine:

======= Sat Jul  4 13:36:25 2015 (adjust=0.0us)
00.000: 1
00.014: 2
00.015: 2

As discussed in the thread linked to above, these numbers could be
improved further by making code changes (to seabios and/or qemu).
These tests were just with minimal seabios Kconfig changes.

Finally, note that this SeaBIOS setup is so stripped down that it
can't actually boot an OS.  The goal of the experiment was to time
SeaBIOS to the point where one could add an optimized Linux deployment
scheme to SeaBIOS - such as Paolo's idea of putting a kernel in a
"flash" based memory mapped region.  Thus, the seabios numbers above
would also need to include the cost of the kernel deployment and
launching, as well as the qemu startup costs, in order for them to be
truly meaningful.

-Kevin


--- a/src/boot.c
+++ b/src/boot.c
@@ -714,6 +714,7 @@ do_boot(int seq_nr)
     if (seq_nr >= BEVCount)
         boot_fail();
 
+    outb('2', 0x402); outb('\n', 0x402);
     // Boot the given BEV type.
     struct bev_s *ie = &BEV[seq_nr];
     switch (ie->type) {
diff --git a/src/post.c b/src/post.c
index 6157b50..9fd5f8f 100644
--- a/src/post.c
+++ b/src/post.c
@@ -329,6 +329,7 @@ handle_post(void)
 {
     if (!CONFIG_QEMU && !CONFIG_COREBOOT)
         return;
+    outb('1', 0x402); outb('\n', 0x402);
 
     serial_debug_preinit();
     debug_banner();
-------------- next part --------------
#
# 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 is not set
# CONFIG_THREADS is not set
# CONFIG_RELOCATE_INIT is not set
# CONFIG_BOOTMENU is not set
# CONFIG_BOOTORDER is not set
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_FLOPPY is not set
# CONFIG_PS2PORT is not set
# CONFIG_USB is not set
# CONFIG_SERIAL is not set
# CONFIG_LPT is not set
# CONFIG_USE_SMM is not set
CONFIG_MTRR_INIT=y
CONFIG_PMTIMER=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 is not set
CONFIG_BOOT=y
CONFIG_KEYBOARD=y
CONFIG_KBD_CALL_INT15_4F=y
CONFIG_MOUSE=y
CONFIG_S3_RESUME=y
# CONFIG_VGAHOOKS is not set
# CONFIG_DISABLE_A20 is not set
CONFIG_WRITABLE_UPPERMEMORY=y
# CONFIG_TCGBIOS is not set

#
# BIOS Tables
#
# CONFIG_PIRTABLE is not set
# CONFIG_MPTABLE is not set
# CONFIG_SMBIOS is not set
# CONFIG_ACPI is not set
# CONFIG_FW_ROMFILE_LOAD is not set

#
# 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_BUILD_VGABIOS is not set
CONFIG_VGA_EXTRA_STACK_SIZE=512

#
# Debugging
#
CONFIG_DEBUG_LEVEL=0


More information about the SeaBIOS mailing list