coreboot/src/lib
Julius Werner 99f4683adf Introduce bootblock self-decompression
Masked ROMs are the silent killers of boot speed on devices without
memory-mapped SPI flash. They often contain awfully slow SPI drivers
(presumably bit-banged) that take hundreds of milliseconds to load our
bootblock, and every extra kilobyte of bootblock size has a hugely
disproportionate impact on boot speed. The coreboot timestamps can never
show that component, but it impacts our users all the same.

This patch tries to alleviate that issue a bit by allowing us to
compress the bootblock with LZ4, which can cut its size down to nearly
half. Of course, masked ROMs usually don't come with decompression
algorithms built in, so we need to introduce a little decompression stub
that can decompress the rest of the bootblock. This is done by creating
a new "decompressor" stage which runs before the bootblock, but includes
the compressed bootblock code in its data section. It needs to be as
small as possible to get a real benefit from this approach, which means
no device drivers, no console output, no exception handling, etc.
Besides the decompression algorithm itself we only include the timer
driver so that we can measure the boot speed impact of decompression. On
ARM and ARM64 systems, we also need to give SoC code a chance to
initialize the MMU, since running decompression without MMU is
prohibitively slow on these architectures.

This feature is implemented for ARM and ARM64 architectures for now,
although most of it is architecture-independent and it should be
relatively simple to port to other platforms where a masked ROM loads
the bootblock into SRAM. It is also supposed to be a clean starting
point from which later optimizations can hopefully cut down the
decompression stub size (currently ~4K on RK3399) a bit more.

NOTE: Bootblock compression is not for everyone. Possible side effects
include trying to run LZ4 on CPUs that come out of reset extremely
underclocked or enabling this too early in SoC bring-up and getting
frustrated trying to find issues in an undebuggable environment. Ask
your SoC vendor if bootblock compression is right for you.

Change-Id: I0dc1cad9ae7508892e477739e743cd1afb5945e8
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/26340
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2018-05-22 02:44:14 +00:00
..
gnat lib/gnat: Drop Restriction No_Exception_Propagation 2018-05-19 20:39:09 +00:00
b64_decode.c src/lib: Add "int" following "unsigned" 2017-03-09 17:24:17 +01:00
boot_device.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
bootblock.c Introduce bootblock self-decompression 2018-05-22 02:44:14 +00:00
bootmem.c bootmem: Keep OS memory map separate from the start 2018-05-10 01:24:40 +00:00
bootmode.c bootmode: Get rid of CONFIG_BOOTMODE_STRAPS 2016-07-28 00:36:22 +02:00
cbfs.c lib/cbfs.c: fix typo 2018-05-02 07:58:23 +00:00
cbmem_common.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
cbmem_console.c Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
cbmem_stage_cache.c lib/stage_cache: Add save/get raw storage 2018-02-07 16:22:40 +00:00
compute_ip_checksum.c src/lib: Wrap lines at 80 columns 2017-03-13 17:21:02 +01:00
coreboot_table.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
debug.c src/lib: Add "int" following "unsigned" 2017-03-09 17:24:17 +01:00
decompressor.c Introduce bootblock self-decompression 2018-05-22 02:44:14 +00:00
delay.c src/lib: Add space before ( 2017-03-09 17:30:21 +01:00
device_tree.c lib/devicetree: Integrate flattened devicetree support 2018-04-30 09:33:32 +00:00
dimm_info_util.c src/lib/dimm_info_util.c: Add methods to convert from SMBIOS to SPD 2018-04-11 14:41:59 +00:00
edid.c lib/edid: Split out fill_lb_framebuffer() 2017-05-30 18:32:44 +02:00
edid_fill_fb.c lib/edid: Split out fill_lb_framebuffer() 2017-05-30 18:32:44 +02:00
ext_stage_cache.c lib/ext_stage_cache: include prog arg in stage cache metadata 2018-04-24 14:39:36 +00:00
fallback_boot.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
fmap.c lib/fmap: provide RW region device support 2016-08-19 18:17:04 +02:00
gcc.c src/lib: Move asmlinkage before type 2017-03-13 17:21:26 +01:00
gcov-glue.c src/lib: add IS_ENABLED() around Kconfig symbol references 2017-07-06 00:19:37 +00:00
gcov-io.c src/lib: Use tabs instead of spaces 2017-03-13 15:46:02 +01:00
gcov-io.h Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
gcov-iov.h
generic_dump_spd.c src/lib: Add space before ( 2017-03-09 17:30:21 +01:00
generic_sdram.c src/lib: add IS_ENABLED() around Kconfig symbol references 2017-07-06 00:19:37 +00:00
gpio.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
halt.c src/lib: Fix brace positions 2017-03-13 17:21:16 +01:00
hardwaremain.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
hexdump.c
hexstrtobin.c hexstrtobin: Add a library function to decode ASCII hex into binary 2016-05-21 05:58:51 +02:00
hw-time-timer.adb Hook up libhwbase in ramstage 2016-11-29 23:45:40 +01:00
imd.c Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
imd_cbmem.c lib/bootmem: Introduce custom bootmem tags 2018-04-30 09:33:49 +00:00
jpeg.c src/lib: Fix checkpatch warning: no spaces at the start of a line 2017-07-25 14:26:07 +00:00
jpeg.h src/lib: Wrap lines at 80 columns 2017-03-13 17:21:02 +01:00
Kconfig lib/devicetree: Integrate flattened devicetree support 2018-04-30 09:33:32 +00:00
libgcc.c
libgcov.c Rename __attribute__((packed)) --> __packed 2017-07-13 19:45:59 +00:00
list.c lib/devicetree: Integrate flattened devicetree support 2018-04-30 09:33:32 +00:00
lzma.c lib/lzma: Respect dstn argument 2018-03-26 10:19:11 +00:00
lzmadecode.c lib/lzmadecode: Add block around UpdateBit1() 2018-04-09 09:44:15 +00:00
lzmadecode.h src/lib: Wrap lines at 80 columns 2017-03-13 17:21:02 +01:00
Makefile.inc Introduce bootblock self-decompression 2018-05-22 02:44:14 +00:00
malloc.c src/lib: add IS_ENABLED() around Kconfig symbol references 2017-07-06 00:19:37 +00:00
memchr.c
memcmp.c src/lib: Add space before ( 2017-03-09 17:30:21 +01:00
memcpy.c
memmove.c src/lib: Add space before ( 2017-03-09 17:30:21 +01:00
memrange.c lib/memrange: Introduce method to clone memrange 2018-04-11 15:11:04 +00:00
memset.c
nhlt.c lib/nhlt: add support for passing subsystem_id to endpoint's structure 2018-05-09 10:06:04 +00:00
primitive_memtest.c src/lib: Add space before ( 2017-03-09 17:30:21 +01:00
prog_loaders.c lib/prog_loaders: Store CBFS type in struct prog 2018-05-16 20:02:52 +00:00
prog_ops.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
program.ld Introduce bootblock self-decompression 2018-05-22 02:44:14 +00:00
ramtest.c {device,drivers,lib,mb,nb}: Use only one space after 'if' 2018-05-09 13:11:04 +00:00
reg_script.c lib/reg_script.c: Remove unused assignment 2017-11-03 07:51:56 +00:00
region_file.c lib: add region file support 2016-12-08 16:10:28 +01:00
reset.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
rmodule.c stage_cache: Add rmodule params in metadata 2017-09-08 03:17:52 +00:00
rmodule.ld
romstage_handoff.c lib: put romstage_handoff implementation in own compilation unit 2016-12-01 08:16:47 +01:00
romstage_stack.c intel post-car: Increase stacktop alignment 2016-11-18 20:59:12 +01:00
rtc.c lib: Add real-time-clock functions 2016-06-24 20:22:05 +02:00
selfboot.c lib/bootmem: Add more bootmem tags 2018-05-04 10:05:36 +00:00
spd_bin.c intel/common/smbus: increase spd read performance 2017-10-31 15:49:55 +00:00
stack.c src/lib: Wrap lines at 80 columns 2017-03-13 17:21:02 +01:00
thread.c src/lib: Wrap lines at 80 columns 2017-03-13 17:21:02 +01:00
timer.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00
timer_queue.c src/lib: Fix spacing 2017-03-13 17:16:08 +01:00
timestamp.c timestamp: Increase max number of timestamps 2018-05-14 07:37:40 +00:00
trace.c src/lib: Fix checkpatch warnings 2016-09-07 22:28:00 +02:00
ubsan.c src/lib/ubsan: Indent macros to improve readability 2017-09-21 19:46:44 +00:00
version.c lib/version: Correct whitespace alignment 2016-07-15 00:10:50 +02:00
wrdd.c compiler.h: add __weak macro 2018-04-24 14:37:59 +00:00