Skip to contentSkip to conversation

vpl: Introduce a verifying program loader

PATCH Superseded Simon Glass 3 participants 17 messages Jul 12, 2021 – Sep 2, 2021

Subsystems (8)
Kbuild Library code GPIO Common clk +4 more subsystems

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover vpl: Introduce a verifying program loader

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

 Kconfig                                    |  10 +
 Makefile                                   |  15 +-
 arch/sandbox/Kconfig                       |   8 +
 common/Kconfig                             |  67 ++++++
 common/spl/Kconfig                         | 226 +++++++++++++++++++--
 common/spl/spl.c                           |  25 ++-
 doc/develop/index.rst                      |   1 +
 doc/{README.SPL => develop/spl.rst}        |  99 +++++----
 drivers/clk/Kconfig                        |  10 +
 drivers/core/Makefile                      |   2 +-
 drivers/gpio/Kconfig                       |  11 +
 drivers/i2c/Kconfig                        |  11 +
 drivers/misc/Kconfig                       |  19 ++
 drivers/pinctrl/Kconfig                    |  18 +-
 drivers/rtc/Kconfig                        |   9 +
 drivers/serial/Kconfig                     |  20 ++
 drivers/sysreset/Kconfig                   |  10 +
 drivers/timer/Kconfig                      |  10 +
 include/bootstage.h                        |   2 +
 include/linux/kconfig.h                    |   3 +
 include/spl.h                              |  20 +-
 lib/Kconfig                                |  62 ++++++
 scripts/Kbuild.include                     |   4 +
 scripts/Makefile.autoconf                  |  12 ++
 scripts/Makefile.build                     |   4 +
 scripts/Makefile.lib                       |   5 +
 scripts/Makefile.spl                       |  37 +++-
 test/test-main.c                           |   2 +-
 tools/binman/etype/u_boot_vpl.py           |  42 ++++
 tools/binman/etype/u_boot_vpl_bss_pad.py   |  44 ++++
 tools/binman/etype/u_boot_vpl_dtb.py       |  28 +++
 tools/binman/etype/u_boot_vpl_expanded.py  |  45 ++++
 tools/binman/etype/u_boot_vpl_nodtb.py     |  42 ++++
 tools/binman/ftest.py                      | 110 ++++++++--
 tools/binman/state.py                      |   3 +-
 tools/binman/test/082_fdt_update_all.dts   |   2 +
 tools/binman/test/201_u_boot_vpl.dts       |  11 +
 tools/binman/test/202_u_boot_vpl_nodtb.dts |  13 ++
 tools/binman/test/203_fdt_incl_vpl.dts     |  13 ++
 tools/binman/test/204_vpl_bss_pad.dts      |  17 ++
 40 files changed, 997 insertions(+), 95 deletions(-)
 rename doc/{README.SPL => develop/spl.rst} (61%)
 create mode 100644 tools/binman/etype/u_boot_vpl.py
 create mode 100644 tools/binman/etype/u_boot_vpl_bss_pad.py
 create mode 100644 tools/binman/etype/u_boot_vpl_dtb.py
 create mode 100644 tools/binman/etype/u_boot_vpl_expanded.py
 create mode 100644 tools/binman/etype/u_boot_vpl_nodtb.py
 create mode 100644 tools/binman/test/201_u_boot_vpl.dts
 create mode 100644 tools/binman/test/202_u_boot_vpl_nodtb.dts
 create mode 100644 tools/binman/test/203_fdt_incl_vpl.dts
 create mode 100644 tools/binman/test/204_vpl_bss_pad.dts
Signature · 1 line
2.32.0.93.g670b81a890-goog
#1 lore raw

PATCH v3 1/7 doc: Convert SPL documentation to ReST

Move this documentation over to .rst format.

---

(no changes since v1)

 doc/develop/index.rst               |  1 +
 doc/{README.SPL => develop/spl.rst} | 36 +++++++++++++++--------------
 2 files changed, 20 insertions(+), 17 deletions(-)
 rename doc/{README.SPL => develop/spl.rst} (87%)
doc/develop/index.rst +1 -0
index 3edffbc6373..79f345c9331 100644
@@ -14,6 +14,7 @@ Implementation
    global_data
    logging
    menus
+   spl
    uefi/index
    version
 
doc/develop/spl.rst renamed from doc/README.SPL +19 -17
similarity index 87%
rename from doc/README.SPL
rename to doc/develop/spl.rst
index 2beb6d8f11b..1165f95335f 100644
@@ -20,19 +20,19 @@ u-boot-spl.map.
 A config option named CONFIG_SPL_BUILD is enabled by Kconfig for SPL.
 Source files can therefore be compiled for SPL with different settings.
 
-For example:
+For example::
 
-ifeq ($(CONFIG_SPL_BUILD),y)
-obj-y += board_spl.o
-else
-obj-y += board.o
-endif
+   ifeq ($(CONFIG_SPL_BUILD),y)
+   obj-y += board_spl.o
+   else
+   obj-y += board.o
+   endif
 
-obj-$(CONFIG_SPL_BUILD) += foo.o
+   obj-$(CONFIG_SPL_BUILD) += foo.o
 
-#ifdef CONFIG_SPL_BUILD
-	foo();
-#endif
+   #ifdef CONFIG_SPL_BUILD
+           foo();
+   #endif
 
 
 The building of SPL images can be enabled by CONFIG_SPL option in Kconfig.
@@ -71,11 +71,13 @@ Device tree
 The U-Boot device tree is filtered by the fdtgrep tools during the build
 process to generate a much smaller device tree used in SPL (spl/u-boot-spl.dtb)
 with:
+
 - the mandatory nodes (/alias, /chosen, /config)
 - the nodes with one pre-relocation property:
   'u-boot,dm-pre-reloc' or 'u-boot,dm-spl'
 
 fdtgrep is also used to remove:
+
 - the properties defined in CONFIG_OF_SPL_REMOVE_PROPS
 - all the pre-relocation properties
   ('u-boot,dm-pre-reloc', 'u-boot,dm-spl' and 'u-boot,dm-tpl')
@@ -98,14 +100,14 @@ stack usage at various points in run sequence of SPL.  The -fstack-usage option
 to gcc will produce '.su' files (such as arch/arm/cpu/armv7/syslib.su) that
 will give stack usage information and cflow can construct program flow.
 
-Must have gcc 4.6 or later, which supports -fstack-usage
+Must have gcc 4.6 or later, which supports -fstack-usage:
 
-1) Build normally
-2) Perform the following shell command to generate a list of C files used in
-SPL:
-$ find spl -name '*.su' | sed -e 's:^spl/::' -e 's:[.]su$:.c:' > used-spl.list
-3) Execute cflow:
-$ cflow --main=board_init_r `cat used-spl.list` 2>&1 | $PAGER
+#. Build normally
+#. Perform the following shell command to generate a list of C files used in
+   SPL:
+#. `find spl -name '*.su' | sed -e 's:^spl/::' -e 's:[.]su$:.c:' > used-spl.list`
+#. Execute cflow:
+   `$ cflow --main=board_init_r $(cat used-spl.list) 2>&1 | $PAGER`
 
 cflow will spit out a number of warnings as it does not parse
 the config files and picks functions based on #ifdef.  Parsing the '.i'
Signature · 1 line
2.32.0.93.g670b81a890-goog
#2 lore raw

PATCH v3 2/7 doc: Expand SPL docs to explain the phase and config

In reply to Simon Glass

Add a bit more information about how to use SPL.

---

(no changes since v1)

 doc/develop/spl.rst | 59 +++++++++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 23 deletions(-)
doc/develop/spl.rst +36 -23
index 1165f95335f..c2a29a8c0a4 100644
@@ -42,29 +42,42 @@ configured by defining CONFIG_SPL_TEXT_BASE. The linker script has to be
 defined with CONFIG_SPL_LDSCRIPT.
 
 To support generic U-Boot libraries and drivers in the SPL binary one can
-optionally define CONFIG_SPL_XXX_SUPPORT. Currently following options
-are supported:
-
-CONFIG_SPL_LIBCOMMON_SUPPORT (common/libcommon.o)
-CONFIG_SPL_LIBDISK_SUPPORT (disk/libdisk.o)
-CONFIG_SPL_I2C_SUPPORT (drivers/i2c/libi2c.o)
-CONFIG_SPL_GPIO_SUPPORT (drivers/gpio/libgpio.o)
-CONFIG_SPL_MMC_SUPPORT (drivers/mmc/libmmc.o)
-CONFIG_SPL_SERIAL_SUPPORT (drivers/serial/libserial.o)
-CONFIG_SPL_SPI_FLASH_SUPPORT (drivers/mtd/spi/libspi_flash.o)
-CONFIG_SPL_SPI_SUPPORT (drivers/spi/libspi.o)
-CONFIG_SPL_FS_FAT (fs/fat/libfat.o)
-CONFIG_SPL_FS_EXT4
-CONFIG_SPL_LIBGENERIC_SUPPORT (lib/libgeneric.o)
-CONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o)
-CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/raw/libnand.o)
-CONFIG_SPL_DRIVERS_MISC_SUPPORT (drivers/misc)
-CONFIG_SPL_DMA (drivers/dma/libdma.o)
-CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
-CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/raw/nand_spl_load.o)
-CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
-CONFIG_SPL_RAM_DEVICE (common/spl/spl.c)
-CONFIG_SPL_WATCHDOG_SUPPORT (drivers/watchdog/libwatchdog.o)
+optionally define CONFIG_SPL_XXX_SUPPORT (or CONFIG_SPL_XXX_SUPPORT for older
+options).
+
+Adding SPL-specific code
+------------------------
+
+To check whether a feature is enabled, use CONFIG_IS_ENABLED()::
+
+  if (CONFIG_IS_ENABLED(CLK))
+      ...
+
+This checks CONFIG_CLK for the main build, CONFIG_SPL_CLK for the SPL build,
+CONFIG_TPL_CLK for the TPL build, etc.
+
+U-Boot Phases
+-------------
+
+U-Boot boots through the following phases:
+
+TPL
+   Very early init, as tiny as possible. This loads SPL.
+
+SPL
+   Secondary program loader. Sets up SDRAM and loads U-Boot proper. It may also
+   load other firmware components.
+
+U-Boot
+   U-Boot proper, containing the command line and boot logic.
+
+
+Checking the boot phase
+-----------------------
+
+Use `spl_phase()` to find the current U-Boot phase, e.g. `PHASE_SPL`. You can
+also find the previous and next phase and get the phase name.
+
 
 Device tree
 -----------
Signature · 1 line
2.32.0.93.g670b81a890-goog
#3 lore raw

PATCH v3 3/7 test: Tidy up test building with SPL

In reply to Simon Glass

We can in principle add tests to any SPL build, e.g. TPL or VPL. Update the build rules to handle this.

---

(no changes since v1)

 Makefile             | 2 +-
 scripts/Makefile.spl | 2 +-
 test/test-main.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Makefile +1 -1
index 0d3192cebad..f7f62979ae2 100644
@@ -841,7 +841,7 @@ libs-$(CONFIG_API) += api/
 ifdef CONFIG_POST
 libs-y += post/
 endif
-libs-$(CONFIG_UNIT_TEST) += test/
+libs-$(CONFIG_$(SPL_TPL_)UNIT_TEST) += test/
 libs-$(CONFIG_UT_ENV) += test/env/
 libs-$(CONFIG_UT_OPTEE) += test/optee/
 libs-$(CONFIG_UT_OVERLAY) += test/overlay/
scripts/Makefile.spl +1 -1
index 5be1a9ba1b1..ffe919dafab 100644
@@ -109,7 +109,7 @@ libs-y += dts/
 libs-y += fs/
 libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
 libs-$(CONFIG_SPL_NET_SUPPORT) += net/
-libs-$(CONFIG_SPL_UNIT_TEST) += test/
+libs-$(CONFIG_$(SPL_TPL_)UNIT_TEST) += test/
 
 head-y		:= $(addprefix $(obj)/,$(head-y))
 libs-y		:= $(addprefix $(obj)/,$(libs-y))
test/test-main.c +1 -1
index 7afe8741cf9..3cdf6849c57 100644
@@ -45,7 +45,7 @@ static int dm_test_pre_run(struct unit_test_state *uts)
 	uts->force_fail_alloc = false;
 	uts->skip_post_probe = false;
 	gd->dm_root = NULL;
-	if (IS_ENABLED(CONFIG_UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+	if (CONFIG_IS_ENABLED(UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA))
 		memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
 	arch_reset_for_test();
 
Signature · 1 line
2.32.0.93.g670b81a890-goog
#4 lore raw

PATCH v3 4/7 spl: Move TPL_HASH_SUPPORT down next to other TPL options

In reply to Simon Glass

This option should be next to other TPL options, not next to the SPL hash option, so it matches the placement conventions in this file.

Move it.

---

(no changes since v1)

 common/spl/Kconfig | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
common/spl/Kconfig +11 -11
index fa80524cfb2..10384b835b2 100644
@@ -519,17 +519,6 @@ config SPL_HASH_SUPPORT
 	  this option to build system-specific drivers for hash acceleration
 	  as part of an SPL build.
 
-config TPL_HASH_SUPPORT
-	bool "Support hashing drivers in TPL"
-	depends on TPL
-	select SHA1
-	select SHA256
-	help
-	  Enable hashing drivers in SPL. These drivers can be used to
-	  accelerate secure boot processing in secure applications. Enable
-	  this option to build system-specific drivers for hash acceleration
-	  as part of an SPL build.
-
 config SPL_DMA
 	bool "Support DMA drivers"
 	help
@@ -1491,6 +1480,17 @@ config TPL_GPIO_SUPPORT
 	  for example. Enable this option to build the drivers in
 	  drivers/gpio as part of an TPL build.
 
+config TPL_HASH_SUPPORT
+	bool "Support hashing drivers in TPL"
+	depends on TPL
+	select SHA1
+	select SHA256
+	help
+	  Enable hashing drivers in SPL. These drivers can be used to
+	  accelerate secure boot processing in secure applications. Enable
+	  this option to build system-specific drivers for hash acceleration
+	  as part of an SPL build.
+
 config TPL_I2C_SUPPORT
 	bool "Support I2C"
 	help
Signature · 1 line
2.32.0.93.g670b81a890-goog
#5 lore raw

PATCH v3 5/7 binman: Add VPL support

In reply to Simon Glass

Add support for U-Boot's Verifying Program Loader phase.

---

(no changes since v1)

 tools/binman/etype/u_boot_vpl.py           |  42 ++++++++
 tools/binman/etype/u_boot_vpl_bss_pad.py   |  44 +++++++++
 tools/binman/etype/u_boot_vpl_dtb.py       |  28 ++++++
 tools/binman/etype/u_boot_vpl_expanded.py  |  45 +++++++++
 tools/binman/etype/u_boot_vpl_nodtb.py     |  42 ++++++++
 tools/binman/ftest.py                      | 110 +++++++++++++++++----
 tools/binman/state.py                      |   3 +-
 tools/binman/test/082_fdt_update_all.dts   |   2 +
 tools/binman/test/201_u_boot_vpl.dts       |  11 +++
 tools/binman/test/202_u_boot_vpl_nodtb.dts |  13 +++
 tools/binman/test/203_fdt_incl_vpl.dts     |  13 +++
 tools/binman/test/204_vpl_bss_pad.dts      |  17 ++++
 12 files changed, 348 insertions(+), 22 deletions(-)
 create mode 100644 tools/binman/etype/u_boot_vpl.py
 create mode 100644 tools/binman/etype/u_boot_vpl_bss_pad.py
 create mode 100644 tools/binman/etype/u_boot_vpl_dtb.py
 create mode 100644 tools/binman/etype/u_boot_vpl_expanded.py
 create mode 100644 tools/binman/etype/u_boot_vpl_nodtb.py
 create mode 100644 tools/binman/test/201_u_boot_vpl.dts
 create mode 100644 tools/binman/test/202_u_boot_vpl_nodtb.dts
 create mode 100644 tools/binman/test/203_fdt_incl_vpl.dts
 create mode 100644 tools/binman/test/204_vpl_bss_pad.dts
tools/binman/etype/u_boot_vpl.py new file +42 -0
new file mode 100644
index 00000000000..9daaca4f6fd
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass <[email protected]>
+#
+# Entry-type module for vpl/u-boot-vpl.bin
+#
+
+from binman import elf
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
+
+class Entry_u_boot_vpl(Entry_blob):
+    """U-Boot VPL binary
+
+    Properties / Entry arguments:
+        - filename: Filename of u-boot-vpl.bin (default 'vpl/u-boot-vpl.bin')
+
+    This is the U-Boot VPL (Verifying Program Loader) binary. This is a small
+    binary which loads before SPL, typically into on-chip SRAM. It is
+    responsible for locating, loading and jumping to SPL, the next-stage
+    loader. Note that VPL is not relocatable so must be loaded to the correct
+    address in SRAM, or written to run from the correct address if direct
+    flash execution is possible (e.g. on x86 devices).
+
+    SPL can access binman symbols at runtime. See:
+
+        'Access to binman entry offsets at run time (symbols)'
+
+    in the binman README for more information.
+
+    The ELF file 'vpl/u-boot-vpl' must also be available for this to work, since
+    binman uses that to look up symbols to write into the VPL binary.
+    """
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)
+        self.elf_fname = 'vpl/u-boot-vpl'
+
+    def GetDefaultFilename(self):
+        return 'vpl/u-boot-vpl.bin'
+
+    def WriteSymbols(self, section):
+        elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage())
tools/binman/etype/u_boot_vpl_bss_pad.py new file +44 -0

44 lines not on this page · raw message

tools/binman/etype/u_boot_vpl_dtb.py new file +28 -0
new file mode 100644
index 00000000000..f6253bf2431
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2016 Google, Inc
+# Written by Simon Glass <[email protected]>
+#
+# Entry-type module for U-Boot device tree in VPL (Verifying Program Loader)
+#
+
+from binman.entry import Entry
+from binman.etype.blob_dtb import Entry_blob_dtb
+
+class Entry_u_boot_vpl_dtb(Entry_blob_dtb):
+    """U-Boot VPL device tree
+
+    Properties / Entry arguments:
+        - filename: Filename of u-boot.dtb (default 'vpl/u-boot-vpl.dtb')
+
+    This is the VPL device tree, containing configuration information for
+    VPL. VPL needs this to know what devices are present and which drivers
+    to activate.
+    """
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)
+
+    def GetDefaultFilename(self):
+        return 'vpl/u-boot-vpl.dtb'
+
+    def GetFdtEtype(self):
+        return 'u-boot-vpl-dtb'
tools/binman/etype/u_boot_vpl_expanded.py new file +45 -0

45 lines not on this page · raw message

tools/binman/etype/u_boot_vpl_nodtb.py new file +42 -0

42 lines not on this page · raw message

tools/binman/ftest.py +89 -21

201 lines not on this page · raw message

tools/binman/state.py +2 -1
index dfb17604554..e4a3abd2805 100644
@@ -17,6 +17,7 @@ from patman import tout
 DTB_TYPE_FNAME = {
     'u-boot-spl-dtb': 'spl/u-boot-spl.dtb',
     'u-boot-tpl-dtb': 'tpl/u-boot-tpl.dtb',
+    'u-boot-vpl-dtb': 'vpl/u-boot-vpl.dtb',
     }
 
 # Records the device-tree files known to binman, keyed by entry type (e.g.
@@ -263,7 +264,7 @@ def GetAllFdts():
     """Yield all device tree files being used by binman
 
     Yields:
-        Device trees being used (U-Boot proper, SPL, TPL)
+        Device trees being used (U-Boot proper, SPL, TPL, VPL)
     """
     if main_dtb:
         yield main_dtb
tools/binman/test/082_fdt_update_all.dts +2 -0
index 284975cc289..1aea56989f0 100644
@@ -14,5 +14,7 @@
 		};
 		u-boot-tpl-dtb {
 		};
+		u-boot-vpl-dtb {
+		};
 	};
 };
tools/binman/test/201_u_boot_vpl.dts new file +11 -0
new file mode 100644
index 00000000000..a3a281a91e0
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+	binman {
+		u-boot-vpl {
+		};
+		u-boot-vpl-dtb {
+		};
+	};
+};
tools/binman/test/202_u_boot_vpl_nodtb.dts new file +13 -0
new file mode 100644
index 00000000000..055016badd5
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-vpl-nodtb {
+		};
+	};
+};
tools/binman/test/203_fdt_incl_vpl.dts new file +13 -0
new file mode 100644
index 00000000000..435256fe317
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-vpl {
+		};
+	};
+};
tools/binman/test/204_vpl_bss_pad.dts new file +17 -0
new file mode 100644
index 00000000000..d1e55fff4f2
@@ -0,0 +1,17 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-vpl {
+		};
+
+		u-boot-vpl-bss-pad {
+		};
+
+		u-boot {
+		};
+	};
+};
Signature · 1 line
2.32.0.93.g670b81a890-goog
#6 lore raw

PATCH v3 6/7 Introduce Verifying Program Loader (VPL)

In reply to Simon Glass

Add support for VPL, a new phase of U-Boot. This runs after TPL. It is responsible for selecting which SPL binary to run, based on a verified-boot process.

---

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

 Makefile                  | 13 +++++++++++++
 common/spl/Kconfig        | 15 ++++++++++++++-
 common/spl/spl.c          | 25 ++++++++++++++++++++++---
 doc/develop/spl.rst       |  6 +++++-
 include/bootstage.h       |  2 ++
 include/linux/kconfig.h   |  3 +++
 include/spl.h             | 20 +++++++++++++++++---
 scripts/Kbuild.include    |  4 ++++
 scripts/Makefile.autoconf | 12 ++++++++++++
 scripts/Makefile.build    |  4 ++++
 scripts/Makefile.lib      |  5 +++++
 scripts/Makefile.spl      | 35 ++++++++++++++++++++++++++---------
 12 files changed, 127 insertions(+), 17 deletions(-)
Makefile +13 -0
index f7f62979ae2..b2ba80ca5de 100644
@@ -946,6 +946,7 @@ INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
 endif
 endif
 INPUTS-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
+INPUTS-$(CONFIG_VPL) += vpl/u-boot-vpl.bin
 INPUTS-$(CONFIG_OF_SEPARATE) += u-boot.dtb
 INPUTS-$(CONFIG_BINMAN_STANDALONE_FDT) += u-boot.dtb
 ifeq ($(CONFIG_SPL_FRAMEWORK),y)
@@ -1986,6 +1987,18 @@ tpl/u-boot-tpl.bin: tools prepare \
 	$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
 	$(TPL_SIZE_CHECK)
 
+tpl/u-boot-tpl: tools prepare \
+		$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)
+	$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
+
+vpl/u-boot-vpl.bin: vpl/u-boot-vpl
+	@:
+	$(VPL_SIZE_CHECK)
+
+vpl/u-boot-vpl: tools prepare \
+		$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_OF_HOSTFILE)$(CONFIG_VPL_OF_PLATDATA),dts/dt.dtb)
+	$(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.spl all
+
 TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
 
 FIND := find
common/spl/Kconfig +14 -1
index 10384b835b2..0443197cd55 100644
@@ -1,4 +1,4 @@
-menu "SPL / TPL"
+menu "SPL / TPL / VPL"
 
 config SUPPORT_SPL
 	bool
@@ -6,6 +6,9 @@ config SUPPORT_SPL
 config SUPPORT_TPL
 	bool
 
+config SUPPORT_VPL
+	bool
+
 config SPL_DFU_NO_RESET
 	bool
 
@@ -280,6 +283,16 @@ config SPL_READ_ONLY
 	  writeable memory) of anything it wants to modify, such as
 	  device-private data.
 
+config TPL_SEPARATE_BSS
+	bool "BSS section is in a different memory region from text"
+	default y if SPL_SEPARATE_BSS
+	help
+	  Some platforms need a large BSS region in TPL and can provide this
+	  because RAM is already set up. In this case BSS can be moved to RAM.
+	  This option should then be enabled so that the correct device tree
+	  location is used. Normally we put the device tree at the end of BSS
+	  but with this option enabled, it goes at _image_binary_end.
+
 config SPL_BANNER_PRINT
 	bool "Enable output of the SPL banner 'U-Boot SPL ...'"
 	default y
common/spl/spl.c +22 -3
index eba77cace6d..27ed855c018 100644
@@ -55,6 +55,11 @@ binman_sym_declare(ulong, spl, image_pos);
 binman_sym_declare(ulong, spl, size);
 #endif
 
+#ifdef CONFIG_VPL
+binman_sym_declare(ulong, vpl, image_pos);
+binman_sym_declare(ulong, vpl, size);
+#endif
+
 /* Define board data structure */
 static struct bd_info bdata __attribute__ ((section(".data")));
 
@@ -139,21 +144,33 @@ void spl_fixup_fdt(void *fdt_blob)
 
 ulong spl_get_image_pos(void)
 {
-	return spl_phase() == PHASE_TPL ?
+#ifdef CONFIG_VPL
+	if (spl_next_phase() == PHASE_VPL)
+		return binman_sym(ulong, vpl, image_pos);
+#endif
+	return spl_next_phase() == PHASE_SPL ?
 		binman_sym(ulong, spl, image_pos) :
 		binman_sym(ulong, u_boot_any, image_pos);
 }
 
 ulong spl_get_image_size(void)
 {
-	return spl_phase() == PHASE_TPL ?
+#ifdef CONFIG_VPL
+	if (spl_next_phase() == PHASE_VPL)
+		return binman_sym(ulong, vpl, size);
+#endif
+	return spl_next_phase() == PHASE_SPL ?
 		binman_sym(ulong, spl, size) :
 		binman_sym(ulong, u_boot_any, size);
 }
 
 ulong spl_get_image_text_base(void)
 {
-	return spl_phase() == PHASE_TPL ? CONFIG_SPL_TEXT_BASE :
+#ifdef CONFIG_VPL
+	if (spl_next_phase() == PHASE_VPL)
+		return CONFIG_VPL_TEXT_BASE;
+#endif
+	return spl_next_phase() == PHASE_SPL ? CONFIG_SPL_TEXT_BASE :
 		CONFIG_SYS_TEXT_BASE;
 }
 
@@ -430,6 +447,8 @@ static enum bootstage_id get_bootstage_id(bool start)
 
 	if (IS_ENABLED(CONFIG_TPL_BUILD) && phase == PHASE_TPL)
 		return start ? BOOTSTAGE_ID_START_TPL : BOOTSTAGE_ID_END_TPL;
+	else if (IS_ENABLED(CONFIG_VPL_BUILD) && phase == PHASE_VPL)
+		return start ? BOOTSTAGE_ID_START_VPL : BOOTSTAGE_ID_END_VPL;
 	else
 		return start ? BOOTSTAGE_ID_START_SPL : BOOTSTAGE_ID_END_SPL;
 }
doc/develop/spl.rst +5 -1
index c2a29a8c0a4..ede79431118 100644
@@ -62,7 +62,11 @@ U-Boot Phases
 U-Boot boots through the following phases:
 
 TPL
-   Very early init, as tiny as possible. This loads SPL.
+   Very early init, as tiny as possible. This loads SPL (or VPL if enabled).
+
+VPL
+   Optional verification step, which can select one of several SPL binaries,
+   if A/B verified boot
 
 SPL
    Secondary program loader. Sets up SDRAM and loads U-Boot proper. It may also
include/bootstage.h +2 -0
index f837a387c8c..1a384e5b60a 100644
@@ -176,6 +176,8 @@ enum bootstage_id {
 	BOOTSTAGE_ID_END_TPL,
 	BOOTSTAGE_ID_START_SPL,
 	BOOTSTAGE_ID_END_SPL,
+	BOOTSTAGE_ID_START_VPL,
+	BOOTSTAGE_ID_END_VPL,
 	BOOTSTAGE_ID_START_UBOOT_F,
 	BOOTSTAGE_ID_START_UBOOT_R,
 	BOOTSTAGE_ID_USB_START,
include/linux/kconfig.h +3 -0
index d109ed3119e..26f1216f7da 100644
@@ -37,6 +37,8 @@
 
 #if defined(CONFIG_TPL_BUILD)
 #define _CONFIG_PREFIX TPL_
+#elif defined(CONFIG_VPL_BUILD)
+#define _CONFIG_PREFIX VPL_
 #elif defined(CONFIG_SPL_BUILD)
 #define _CONFIG_PREFIX SPL_
 #else
@@ -52,6 +54,7 @@
  *  CONFIG_FOO if CONFIG_SPL_BUILD is undefined,
  *  CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined.
  *  CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined.
+ *  CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined.
  */
 #define CONFIG_VAL(option)  config_val(option)
 
include/spl.h +17 -3
index cee9a42ddb5..d9fe4e1bfd4 100644
@@ -60,6 +60,7 @@ static inline bool u_boot_first_phase(void)
 enum u_boot_phase {
 	PHASE_NONE,	/* Invalid phase, signifying before U-Boot */
 	PHASE_TPL,	/* Running in TPL */
+	PHASE_VPL,	/* Running in VPL */
 	PHASE_SPL,	/* Running in SPL */
 	PHASE_BOARD_F,	/* Running in U-Boot before relocation */
 	PHASE_BOARD_R,	/* Running in U-Boot after relocation */
@@ -112,7 +113,9 @@ static inline enum u_boot_phase spl_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
 	return PHASE_TPL;
-#elif CONFIG_SPL_BUILD
+#elif defined(CONFIG_VPL_BUILD)
+	return PHASE_VPL;
+#elif defined(CONFIG_SPL_BUILD)
 	return PHASE_SPL;
 #else
 	DECLARE_GLOBAL_DATA_PTR;
@@ -134,10 +137,15 @@ static inline enum u_boot_phase spl_prev_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
 	return PHASE_NONE;
+#elif defined(CONFIG_VPL_BUILD)
+	return PHASE_TPL;	/* VPL requires TPL */
 #elif defined(CONFIG_SPL_BUILD)
-	return IS_ENABLED(CONFIG_TPL) ? PHASE_TPL : PHASE_NONE;
+	return IS_ENABLED(CONFIG_VPL) ? PHASE_VPL :
+		IS_ENABLED(CONFIG_TPL) ? PHASE_TPL :
+		PHASE_NONE;
 #else
-	return IS_ENABLED(CONFIG_SPL) ? PHASE_SPL : PHASE_NONE;
+	return IS_ENABLED(CONFIG_SPL) ? PHASE_SPL :
+		PHASE_NONE;
 #endif
 }
 
@@ -150,6 +158,8 @@ static inline enum u_boot_phase spl_prev_phase(void)
 static inline enum u_boot_phase spl_next_phase(void)
 {
 #ifdef CONFIG_TPL_BUILD
+	return IS_ENABLED(CONFIG_VPL) ? PHASE_VPL : PHASE_SPL;
+#elif defined(CONFIG_VPL_BUILD)
 	return PHASE_SPL;
 #else
 	return PHASE_BOARD_F;
@@ -166,6 +176,8 @@ static inline const char *spl_phase_name(enum u_boot_phase phase)
 	switch (phase) {
 	case PHASE_TPL:
 		return "TPL";
+	case PHASE_VPL:
+		return "VPL";
 	case PHASE_SPL:
 		return "SPL";
 	case PHASE_BOARD_F:
@@ -180,6 +192,8 @@ static inline const char *spl_phase_name(enum u_boot_phase phase)
 #ifdef CONFIG_SPL_BUILD
 # ifdef CONFIG_TPL_BUILD
 #  define SPL_TPL_NAME	"TPL"
+# elif defined(CONFIG_VPL_BUILD)
+#  define SPL_TPL_NAME	"VPL"
 # else
 #  define SPL_TPL_NAME	"SPL"
 # endif
scripts/Kbuild.include +4 -0
index dfb67226b08..c87d9c9f5f2 100644
@@ -325,11 +325,15 @@ endif
 
 ifdef CONFIG_SPL_BUILD
 SPL_ := SPL_
+ifeq ($(CONFIG_VPL_BUILD),y)
+SPL_TPL_ := VPL_
+else
 ifeq ($(CONFIG_TPL_BUILD),y)
 SPL_TPL_ := TPL_
 else
 SPL_TPL_ := SPL_
 endif
+endif
 else
 SPL_ :=
 SPL_TPL_ :=
scripts/Makefile.autoconf +12 -0
index 0bfc1b2a629..ad556f80f71 100644
@@ -18,6 +18,10 @@ ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && ec
 __all: tpl/include/autoconf.mk
 endif
 
+ifeq ($(shell grep -q '^CONFIG_VPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
+__all: vpl/include/autoconf.mk
+endif
+
 include include/config/auto.conf
 
 include scripts/Kbuild.include
@@ -84,6 +88,10 @@ tpl/u-boot.cfg: include/config.h FORCE
 	$(Q)mkdir -p $(dir $@)
 	$(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
 
+vpl/u-boot.cfg: include/config.h FORCE
+	$(Q)mkdir -p $(dir $@)
+	$(call cmd,u_boot_cfg,-DCONFIG_SPL_BUILD -DCONFIG_VPL_BUILD)
+
 include/autoconf.mk: u-boot.cfg
 	$(call cmd,autoconf)
 
@@ -95,6 +103,10 @@ tpl/include/autoconf.mk: tpl/u-boot.cfg
 	$(Q)mkdir -p $(dir $@)
 	$(call cmd,autoconf)
 
+vpl/include/autoconf.mk: vpl/u-boot.cfg
+	$(Q)mkdir -p $(dir $@)
+	$(call cmd,autoconf)
+
 # include/config.h
 # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
 define filechk_config_h
scripts/Makefile.build +4 -0
index 7e59ca54cd0..1d72ba18ebd 100644
@@ -4,6 +4,9 @@
 # ==========================================================================
 
 # Modified for U-Boot
+prefix := vpl
+src := $(patsubst $(prefix)/%,%,$(obj))
+ifeq ($(obj),$(src))
 prefix := tpl
 src := $(patsubst $(prefix)/%,%,$(obj))
 ifeq ($(obj),$(src))
@@ -13,6 +16,7 @@ ifeq ($(obj),$(src))
 prefix := .
 endif
 endif
+endif
 
 PHONY := __build
 __build:
scripts/Makefile.lib +5 -0
index 78bbebe7e93..c08ad44db5f 100644
@@ -556,16 +556,21 @@ cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
 # 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
 # pass removes various unused properties from the remaining nodes.
 # The output is typically a much smaller device tree file.
+ifeq ($(CONFIG_VPL_BUILD),y)
+fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-vpl
+else
 ifeq ($(CONFIG_TPL_BUILD),y)
 fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
 else
 fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
 endif
+endif
 quiet_cmd_fdtgrep = FDTGREP $@
       cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \
 		-n /chosen -n /config -O dtb | \
 	$(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
 		-P u-boot,dm-pre-reloc -P u-boot,dm-spl -P u-boot,dm-tpl \
+		 -P u-boot,dm-vpl \
 		$(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
 
 # fdt_rm_props
scripts/Makefile.spl +26 -9
index ffe919dafab..082ddb9c5f2 100644
@@ -27,8 +27,16 @@ UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
+else
+ifeq ($(CONFIG_VPL_BUILD),y)
+KBUILD_CPPFLAGS += -DCONFIG_VPL_BUILD
+endif
 endif
 
+ifeq ($(CONFIG_VPL_BUILD),y)
+SPL_BIN := u-boot-vpl
+SPL_NAME := vpl
+else
 ifeq ($(CONFIG_TPL_BUILD),y)
 SPL_BIN := u-boot-tpl
 SPL_NAME := tpl
@@ -36,16 +44,21 @@ else
 SPL_BIN := u-boot-spl
 SPL_NAME := spl
 endif
+endif
 
 export SPL_NAME
 
 ifdef CONFIG_SPL_BUILD
 SPL_ := SPL_
+ifeq ($(CONFIG_VPL_BUILD),y)
+SPL_TPL_ := VPL_
+else
 ifeq ($(CONFIG_TPL_BUILD),y)
 SPL_TPL_ := TPL_
 else
 SPL_TPL_ := SPL_
 endif
+endif
 else
 SPL_ :=
 SPL_TPL_ :=
@@ -57,6 +70,9 @@ endif
 ifeq ($(obj)$(CONFIG_SUPPORT_TPL),tpl)
 $(error You cannot build TPL without enabling CONFIG_SUPPORT_TPL)
 endif
+ifeq ($(obj)$(CONFIG_SUPPORT_VPL),vpl)
+$(error You cannot build VPL without enabling CONFIG_SUPPORT_VPL)
+endif
 
 include $(srctree)/config.mk
 include $(srctree)/arch/$(ARCH)/Makefile
@@ -90,13 +106,12 @@ libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
 endif
 libs-y += common/init/
 
+# Special handling for a few options which support SPL/TPL/VPL
+libs-$(CONFIG_$(SPL_TPL_)LIBCOMMON_SUPPORT) += common/ cmd/ env/
+libs-$(CONFIG_$(SPL_TPL_)LIBGENERIC_SUPPORT) += lib/
+
 # Special handling for a few options which support SPL/TPL
-ifeq ($(CONFIG_TPL_BUILD),y)
-libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
-libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/
-else
-libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
-libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
+ifeq ($(CONFIG_TPL_BUILD)$(CONFIG_VPL_BUILD),)
 ifdef CONFIG_SPL_FRAMEWORK
 libs-$(CONFIG_PARTITIONS) += disk/
 endif
@@ -182,7 +197,7 @@ LDPPFLAGS += \
 	  sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
 
 # Turn various CONFIG symbols into IMAGE symbols for easy reuse of
-# the scripts between SPL and TPL.
+# the scripts between SPL, TPL and VPL.
 ifneq ($(CONFIG_$(SPL_TPL_)MAX_SIZE),)
 LDPPFLAGS += -DIMAGE_MAX_SIZE=$(CONFIG_$(SPL_TPL_)MAX_SIZE)
 endif
@@ -264,6 +279,7 @@ ifeq ($(CONFIG_SYS_SOC),"at91")
 INPUTS-y	+= $(obj)/boot.bin
 endif
 
+ifndef CONFIG_VPL_BUILD
 ifdef CONFIG_TPL_BUILD
 INPUTS-$(CONFIG_TPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-tpl.bin \
 	$(obj)/u-boot-x86-reset16-tpl.bin
@@ -271,6 +287,7 @@ else
 INPUTS-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-spl.bin \
 	$(obj)/u-boot-x86-reset16-spl.bin
 endif
+endif
 
 INPUTS-$(CONFIG_ARCH_ZYNQ)		+= $(obj)/boot.bin
 INPUTS-$(CONFIG_ARCH_ZYNQMP)	+= $(obj)/boot.bin
@@ -310,7 +327,7 @@ endif
 
 ifneq ($(build_dtb),)
 $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
-		$(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
+		$(if $(CONFIG_$(SPL_TPL_)SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
 		$(FINAL_DTB_CONTAINER)  FORCE
 	$(call if_changed,cat)
 
@@ -401,7 +418,7 @@ LDFLAGS_$(SPL_BIN) += $(call ld-option, --no-dynamic-linker)
 
 LDFLAGS_$(SPL_BIN) += --build-id=none
 
-# Pick the best-match (i.e. SPL_TEXT_BASE for SPL, TPL_TEXT_BASE for TPL)
+# Pick the best match (e.g. SPL_TEXT_BASE for SPL, TPL_TEXT_BASE for TPL)
 ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_$(SPL_TPL_)TEXT_BASE)
 endif
Signature · 1 line
2.32.0.93.g670b81a890-goog
#7 lore raw

PATCH v3 7/7 vpl: Add Kconfig options for VPL

In reply to Simon Glass

Add VPL versions of commonly used Kconfig options.

---

(no changes since v1)

 Kconfig                  |  10 +++
 arch/sandbox/Kconfig     |   8 ++
 common/Kconfig           |  67 ++++++++++++++
 common/spl/Kconfig       | 189 +++++++++++++++++++++++++++++++++++++++
 drivers/clk/Kconfig      |  10 +++
 drivers/core/Makefile    |   2 +-
 drivers/gpio/Kconfig     |  11 +++
 drivers/i2c/Kconfig      |  11 +++
 drivers/misc/Kconfig     |  19 ++++
 drivers/pinctrl/Kconfig  |  18 +++-
 drivers/rtc/Kconfig      |   9 ++
 drivers/serial/Kconfig   |  20 +++++
 drivers/sysreset/Kconfig |  10 +++
 drivers/timer/Kconfig    |  10 +++
 lib/Kconfig              |  62 +++++++++++++
 15 files changed, 453 insertions(+), 3 deletions(-)
Kconfig +10 -0
index f8c1a77bedb..8cd8c59d045 100644
@@ -264,6 +264,16 @@ config TPL_SYS_MALLOC_F_LEN
 	  particular needs this to operate, so that it can allocate the
 	  initial serial device and any others that are needed.
 
+config VPL_SYS_MALLOC_F_LEN
+	hex "Size of malloc() pool in VPL before relocation"
+	depends on SYS_MALLOC_F && VPL
+	default SYS_MALLOC_F_LEN
+	help
+	  Before relocation, memory is very limited on many platforms. Still,
+	  we can provide a small malloc() pool if needed. Driver model in
+	  particular needs this to operate, so that it can allocate the
+	  initial serial device and any others that are needed.
+
 menuconfig EXPERT
 	bool "Configure standard U-Boot features (expert users)"
 	default y
arch/sandbox/Kconfig +8 -0
index f83282d9d56..e504b08b951 100644
@@ -29,6 +29,14 @@ config SANDBOX_SPL
 	bool "Enable SPL for sandbox"
 	select SUPPORT_SPL
 
+config SANDBOX_TPL
+	bool "Enable TPL for sandbox"
+	select SUPPORT_TPL
+
+config SANDBOX_VPL
+	bool "Enable VPL for sandbox"
+	select SUPPORT_VPL
+
 config SYS_CONFIG_NAME
 	default "sandbox_spl" if SANDBOX_SPL
 	default "sandbox" if !SANDBOX_SPL
common/Kconfig +67 -0

91 lines not on this page · raw message

common/spl/Kconfig +189 -0

213 lines not on this page · raw message

drivers/clk/Kconfig +10 -0
index e07c6dd78a6..4b0bed66bfb 100644
@@ -30,6 +30,16 @@ config TPL_CLK
 	  setting up clocks within TPL, and allows the same drivers to be
 	  used as U-Boot proper.
 
+config VPL_CLK
+	bool "Enable clock support in VPL"
+	depends on CLK && VPL_DM
+	help
+	  The clock subsystem adds a small amount of overhead to the image.
+	  If this is acceptable and you have a need to use clock drivers in
+	  SPL, enable this option. It might provide a cleaner interface to
+	  setting up clocks within TPL, and allows the same drivers to be
+	  used as U-Boot proper.
+
 config CLK_BCM6345
 	bool "Clock controller driver for BCM6345"
 	depends on CLK && ARCH_BMIPS
drivers/core/Makefile +1 -1
index 5edd4e41357..07a0886383f 100644
@@ -5,7 +5,7 @@
 obj-y	+= device.o fdtaddr.o lists.o root.o uclass.o util.o
 obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o
 obj-$(CONFIG_DEVRES) += devres.o
-obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE)	+= device-remove.o
+obj-$(CONFIG_$(SPL_TPL_)DM_DEVICE_REMOVE)	+= device-remove.o
 obj-$(CONFIG_$(SPL_)SIMPLE_BUS)	+= simple-bus.o
 obj-$(CONFIG_SIMPLE_PM_BUS)	+= simple-pm-bus.o
 obj-$(CONFIG_DM)	+= dump.o
drivers/gpio/Kconfig +11 -0
index de4dc51d4b4..36a0074f5b9 100644
@@ -36,6 +36,17 @@ config TPL_DM_GPIO
 	  particular GPIOs that they provide. The uclass interface
 	  is defined in include/asm-generic/gpio.h.
 
+config VPL_DM_GPIO
+	bool "Enable Driver Model for GPIO drivers in VPL"
+	depends on DM_GPIO && VPL_DM && VPL_GPIO
+	default y
+	help
+	  Enable driver model for GPIO access in VPL. The standard GPIO
+	  interface (gpio_get_value(), etc.) is then implemented by
+	  the GPIO uclass. Drivers provide methods to query the
+	  particular GPIOs that they provide. The uclass interface
+	  is defined in include/asm-generic/gpio.h.
+
 config GPIO_HOG
 	bool "Enable GPIO hog support"
 	depends on DM_GPIO
drivers/i2c/Kconfig +11 -0
index 35d6e2c8ec5..31f9cb44769 100644
@@ -25,6 +25,17 @@ config SPL_DM_I2C
 	  device (bus child) info is kept as parent platdata. The interface
 	  is defined in include/i2c.h.
 
+config VPL_DM_I2C
+	bool "Enable Driver Model for I2C drivers in VPL"
+	depends on VPL_DM && DM_I2C
+	default y
+	help
+	  Enable driver model for I2C. The I2C uclass interface: probe, read,
+	  write and speed, is implemented with the bus drivers operations,
+	  which provide methods for bus setting and data transfer. Each chip
+	  device (bus child) info is kept as parent platdata. The interface
+	  is defined in include/i2c.h.
+
 config I2C_CROS_EC_TUNNEL
 	tristate "Chrome OS EC tunnel I2C bus"
 	depends on CROS_EC
drivers/misc/Kconfig +19 -0
index 997b7132211..12f419771a2 100644
@@ -122,6 +122,16 @@ config TPL_CROS_EC
 	  control access to the battery and main PMIC depending on the
 	  device. You can use the 'crosec' command to access it.
 
+config VPL_CROS_EC
+	bool "Enable Chrome OS EC in VPL"
+	depends on VPL
+	help
+	  Enable access to the Chrome OS EC in VPL. This is a separate
+	  microcontroller typically available on a SPI bus on Chromebooks. It
+	  provides access to the keyboard, some internal storage and may
+	  control access to the battery and main PMIC depending on the
+	  device. You can use the 'crosec' command to access it.
+
 config CROS_EC_I2C
 	bool "Enable Chrome OS EC I2C driver"
 	depends on CROS_EC
@@ -185,6 +195,15 @@ config TPL_CROS_EC_SANDBOX
 	  EC flash read/write/erase support and a few other things. It is
 	  enough to perform a Chrome OS verified boot on sandbox.
 
+config VPL_CROS_EC_SANDBOX
+	bool "Enable Chrome OS EC sandbox driver in VPL"
+	depends on VPL_CROS_EC && SANDBOX
+	help
+	  Enable a sandbox emulation of the Chrome OS EC in VPL. This supports
+	  keyboard (use the -l flag to enable the LCD), verified boot context,
+	  EC flash read/write/erase support and a few other things. It is
+	  enough to perform a Chrome OS verified boot on sandbox.
+
 config CROS_EC_SPI
 	bool "Enable Chrome OS EC SPI driver"
 	depends on CROS_EC
drivers/pinctrl/Kconfig +16 -2
index 77fb8511144..d967a82f726 100644
@@ -89,20 +89,34 @@ config TPL_PINCTRL
 	  This option is an TPL variant of the PINCTRL option.
 	  See the help of PINCTRL for details.
 
+config VPL_PINCTRL
+	bool "Support pin controllers in VPL"
+	depends on VPL && VPL_DM
+	help
+	  This option is an VPL variant of the PINCTRL option.
+	  See the help of PINCTRL for details.
+
 config SPL_PINCTRL_FULL
 	bool "Support full pin controllers in SPL"
 	depends on SPL_PINCTRL && SPL_OF_CONTROL
 	default n if TARGET_STM32F746_DISCO
 	default y
 	help
-	  This option is an SPL-variant of the PINCTRL_FULL option.
+	  This option is an SPL variant of the PINCTRL_FULL option.
 	  See the help of PINCTRL_FULL for details.
 
 config TPL_PINCTRL_FULL
 	bool "Support full pin controllers in TPL"
 	depends on TPL_PINCTRL && TPL_OF_CONTROL
 	help
-	  This option is an TPL-variant of the PINCTRL_FULL option.
+	  This option is a TPL variant of the PINCTRL_FULL option.
+	  See the help of PINCTRL_FULL for details.
+
+config VPL_PINCTRL_FULL
+	bool "Support full pin controllers in VPL"
+	depends on VPL_PINCTRL && VPL_OF_CONTROL
+	help
+	  This option is a VPL variant of the PINCTRL_FULL option.
 	  See the help of PINCTRL_FULL for details.
 
 config SPL_PINCTRL_GENERIC
drivers/rtc/Kconfig +9 -0
index cbdfddb80f6..3de6d3fb4d8 100644
@@ -32,6 +32,15 @@ config TPL_DM_RTC
 	  drivers to perform the actual functions. See rtc.h for a
 	  description of the API.
 
+config VPL_DM_RTC
+	bool "Enable Driver Model for RTC drivers in VPL"
+	depends on VPL_DM
+	help
+	  Enable drver model for real-time-clock drivers. The RTC uclass
+	  then provides the rtc_get()/rtc_set() interface, delegating to
+	  drivers to perform the actual functions. See rtc.h for a
+	  description of the API.
+
 config RTC_ENABLE_32KHZ_OUTPUT
 	bool "Enable RTC 32Khz output"
 	help
drivers/serial/Kconfig +20 -0
index 961e3fb0314..a8fdffe2ccf 100644
@@ -63,6 +63,16 @@ config TPL_SERIAL_PRESENT
 	  This option enables the full UART in TPL, so if is it disabled,
 	  the full UART driver will be omitted, thus saving space.
 
+config VPL_SERIAL_PRESENT
+	bool "Provide a serial driver in VPL"
+	depends on DM_SERIAL && VPL
+	default y
+	help
+	  In very space-constrained devices even the full UART driver is too
+	  large. In this case the debug UART can still be used in some cases.
+	  This option enables the full UART in TPL, so if is it disabled,
+	  the full UART driver will be omitted, thus saving space.
+
 # Logic to allow us to use the imply keyword to set what the default port
 # should be.  The default is otherwise 1.
 config CONS_INDEX_0
@@ -172,6 +182,16 @@ config TPL_DM_SERIAL
 	  implements serial_putc() etc. The uclass interface is
 	  defined in include/serial.h.
 
+config VPL_DM_SERIAL
+	bool "Enable Driver Model for serial drivers in VPL"
+	depends on DM_SERIAL
+	default y if VPL && DM_SERIAL
+	help
+	  Enable driver model for serial in VPL. This replaces
+	  drivers/serial/serial.c with the serial uclass, which
+	  implements serial_putc() etc. The uclass interface is
+	  defined in include/serial.h.
+
 config DEBUG_UART
 	bool "Enable an early debug UART for debugging"
 	help
drivers/sysreset/Kconfig +10 -0
index ac77ffbc8be..fec6fed6c31 100644
@@ -31,6 +31,16 @@ config TPL_SYSRESET
 	  to effect a reset. The uclass will try all available drivers when
 	  reset_walk() is called.
 
+config VPL_SYSRESET
+	bool "Enable support for system reset drivers in VPL mode"
+	depends on SYSRESET && VPL_DM
+	default y if TPL_SYSRESET
+	help
+	  Enable system reset drivers which can be used to reset the CPU or
+	  board. Each driver can provide a reset method which will be called
+	  to effect a reset. The uclass will try all available drivers when
+	  reset_walk() is called.
+
 if SYSRESET
 
 config SYSRESET_CMD_RESET
drivers/timer/Kconfig +10 -0
index ee81dfa7768..ac601f00ecf 100644
@@ -27,6 +27,16 @@ config TPL_TIMER
 	  function. This enables the drivers in drivers/timer as part of an
 	  TPL build.
 
+config VPL_TIMER
+	bool "Enable driver model for timer drivers in VPL"
+	depends on TIMER && VPL
+	default y if TPL_TIMER
+	help
+	  Enable support for timer drivers in VPL. These can be used to get
+	  a timer value when in VPL, or perhaps for implementing a delay
+	  function. This enables the drivers in drivers/timer as part of an
+	  TPL build.
+
 config TIMER_EARLY
 	bool "Allow timer to be used early in U-Boot"
 	depends on TIMER
lib/Kconfig +62 -0

116 lines not on this page · raw message

Signature · 1 line
2.32.0.93.g670b81a890-goog
#8 lore raw
In reply to Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Regards,
Simon

#9 lore raw
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Signature · 1 line
Tom
#10 lore raw

Hi Tom,

Quoted 37 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

#11 lore raw

Hi

Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 18 lines · Tom Rini
Quoted 16 lines · Simon Glass

Hi Tom,

Quoted 13 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Let's try to understand. So we can have:

TPL (redundant most of cpus support it) -> VPL -\

      -> SPL1 -\ = > UBOOT_B e/o fitImage

                    | -> ATF1
                    | -> TEE1

      -> SPL2  -\ => UBOOT_A e/o fitImage
                    | => ATF2
                    | => TEE2

If you have this kind of system TPL and VPL can be combined. Is this the scenario we will use with this patchset?

The funny thing here is that a lot of people ask to update the TPL. After adding the VPL the communication will happen using hob memory area?

One of the most interesting parts will be to tag the TPL(x) to know what of them the bootrom load.

Michael

Quoted 38 lines
Quoted 19 lines
Quoted 16 lines
Quoted 7 lines

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

Quoted 7 lines

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

#12 lore raw

Hi Michael,

Quoted 31 lines · Michael Nazzareno Trimarchi

Hi

Quoted 22 lines · Simon Glass

Hi Tom,

Quoted 18 lines · Tom Rini
Quoted 16 lines · Simon Glass

Hi Tom,

Quoted 13 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Let's try to understand. So we can have:

TPL (redundant most of cpus support it) -> VPL -\

Quoted 8 lines
      -> SPL1 -\ = > UBOOT_B e/o fitImage

                    | -> ATF1
                    | -> TEE1

      -> SPL2  -\ => UBOOT_A e/o fitImage
                    | => ATF2
                    | => TEE2

I'm not quite sure how to read that diagram. I think we should have SPLA_ and SPL_B (and perhaps SPL_RECOVERY) so it matches with U-Boot proper.

Quoted 3 lines

If you have this kind of system TPL and VPL can be combined. Is this the scenario we will use with this patchset?

Only if there is space to store both the early-init code and the verified boot. So for coral this is not possible.

But if I understand things correctly, then yes this is the idea.

Regards,
Simon

Quoted 70 lines

The funny thing here is that a lot of people ask to update the TPL. After adding the VPL the communication will happen using hob memory area?

One of the most interesting parts will be to tag the TPL(x) to know what of them the bootrom load.

Michael

Quoted 38 lines
Quoted 19 lines
Quoted 16 lines
Quoted 7 lines

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

Quoted 7 lines

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

#13 lore raw
In reply to Simon Glass
Quoted 59 lines · Simon Glass

Hi Tom,

Quoted 37 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

Quoted 7 lines

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

There's always a "no updates before HERE" line to draw, as you need a fall-back option. Since you mention SDRAM, does that mean both TPL and VPL are running in SRAM/similar space? If so, why isn't this just part of TPL, for when you have "a lot" of pre-SDRAM memory to use?

Signature · 1 line
Tom
#14 lore raw

Hi Tom,

Quoted 67 lines · Tom Rini
Quoted 65 lines · Simon Glass

Hi Tom,

Quoted 37 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

Quoted 6 lines
Quoted 1 line

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

There's always a "no updates before HERE" line to draw, as you need a fall-back option. Since you mention SDRAM, does that mean both TPL and VPL are running in SRAM/similar space? If so, why isn't this just part of TPL, for when you have "a lot" of pre-SDRAM memory to use?

It depends on the architecture. For coral (and other modern x86 devices) there is 32KB which is enough to run TPL but not enough to run VPL. So TPL sets up 'Cache-as-RAM' which provides additional SRAM. Other architectures may have their own constraints.

But another key difference is that we use OF_PLATDATA in TPL and that is fine for the basic init needed there. But VPL needs lots of drivers as well as info about the firmware image layout so it adds to the work needed to get them running in that environment. So ideally, VPL can be built without OF_PLATDATA.

Or put it another way, TPL needs to be as small as possible so it can run on the widest array of devices. VPL is an optional phase (only used with verified boot) so we should not pollute TPL with that. I have a lot of other thoughts about all of this, some of which are in the VBE doc...

Regards,
SImon

#15 lore raw
Quoted 78 lines · Simon Glass

Hi Tom,

Quoted 67 lines · Tom Rini
Quoted 65 lines · Simon Glass

Hi Tom,

Quoted 37 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

Quoted 6 lines
Quoted 1 line

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

There's always a "no updates before HERE" line to draw, as you need a fall-back option. Since you mention SDRAM, does that mean both TPL and VPL are running in SRAM/similar space? If so, why isn't this just part of TPL, for when you have "a lot" of pre-SDRAM memory to use?

Quoted 4 lines

It depends on the architecture. For coral (and other modern x86 devices) there is 32KB which is enough to run TPL but not enough to run VPL. So TPL sets up 'Cache-as-RAM' which provides additional SRAM. Other architectures may have their own constraints.

And in this case then VPL sets up DRAM?

Quoted 11 lines

But another key difference is that we use OF_PLATDATA in TPL and that is fine for the basic init needed there. But VPL needs lots of drivers as well as info about the firmware image layout so it adds to the work needed to get them running in that environment. So ideally, VPL can be built without OF_PLATDATA.

Or put it another way, TPL needs to be as small as possible so it can run on the widest array of devices. VPL is an optional phase (only used with verified boot) so we should not pollute TPL with that. I have a lot of other thoughts about all of this, some of which are in the VBE doc...

Right, the intention behind allowing "TPL" in-tree was that we have enough cases where we're size constrained and just need to allow for something "functional enough". This was what the old PowerPC "SPL" was about, and SoCs keep coming out with relatively tiny initial memory spaces.

I guess my concerns at the high level fall in to a few spots:
- I don't really like the idea of having to introduce yet another stage. At that point, what infrastructure from U-Boot is it really even using?
- In order to use this we're now needing platforms to support TPL to add in VPL.
- That kind of ties in to another part of the issue I see. Why is this not just a feature to enable in earlier stage?
- Why do we have both verified and "A/B or recovery" in the same spot?

Some of this I guess comes down to my thinking about how yes, x86 is constrained, but we have a lot of other platforms with 128/256/way more pre-SDRAM memory available and verified is the key feature to enable rather than A/B update. And again, what does the verified part of this provide over FIT_SIGNATURE? Outside of that A/B case, at least.

Signature · 1 line
Tom
#16 lore raw

Hi Tom,

(just to reply to this old email)

Quoted 80 lines · Tom Rini
Quoted 78 lines · Simon Glass

Hi Tom,

Quoted 73 lines · Tom Rini
Quoted 59 lines · Simon Glass

Hi Tom,

Quoted 37 lines · Tom Rini
Quoted 32 lines · Simon Glass

Hi Tom,

Quoted 20 lines · Simon Glass

U-Boot provides a verified-boot feature based around FIT, but there is no standard way of implementing it for a board. At present the various required pieces must be built up separately, to produce a working implementation. In particular, there is no built-in support for selecting A/B boot or recovery mode.

This series introduces VPL, a verified program loader. Its purpose is to run the verified-boot process and decide which SPL binary should be run. Adding VPL into the boot flow provides a standard way of implementing verified boot. So far, only the phase itself is added along with some Kconfig options. The next step is to create a build for sandbox.

Changes in v3:
- Move VPL Kconfig options to a separate patch
- Add full build support for VPL

Changes in v2:
- Add some more VPL Kconfig options

Quoted 8 lines

Simon Glass (7):
doc: Convert SPL documentation to ReST
doc: Expand SPL docs to explain the phase and config
test: Tidy up test building with SPL
spl: Move TPL_HASH_SUPPORT down next to other TPL options
binman: Add VPL support
Introduce Verifying Program Loader (VPL)
vpl: Add Kconfig options for VPL

Quoted 2 lines

Any thoughts on this one? I have a few updates so can send a rebase v4 if that helps.

Quoted 8 lines

Perhaps some of these general questions would be answered with seeing an implementation for not just sandbox, but real hardware too. But I'm missing what this provides exactly that we can't do already, or that would justify a whole new stage rather than just some updates within existing logic. What is this doing over SPL_FIT_SIGNATURE for example? Checking in with a TPM to confirm good measurements? Having written that out, now I really do want to see this implemented on real hardware much more so than sandbox.

Yes it was actually implemented on coral, an x86 Chromebook which is in-tree. I have various patches to come but the docs are at [1]

The core reason for it is that SPL sets up SDRAM (and perhaps other things) so needs to be updateable, so we cannot boot the vboot logic in SPL. TPL often has very small size limits so it is difficult to put it in there. I am thinking that VPL can be an optional phase used only if verified boot is enabled. That makes it easy since it has a defined purpose which can be enabled/disabled.

Quoted 7 lines

BTW in doing this I wonder whether we should look again at the SPL_TPL_ Makefile variables. Do you think PHASE might be better?

Regards,
Simon

[1] https://github.com/sjg20/u-boot/blob/cros-2021.04/cros/doc/cros_coral.rst

There's always a "no updates before HERE" line to draw, as you need a fall-back option. Since you mention SDRAM, does that mean both TPL and VPL are running in SRAM/similar space? If so, why isn't this just part of TPL, for when you have "a lot" of pre-SDRAM memory to use?

Quoted 6 lines
Quoted 4 lines

It depends on the architecture. For coral (and other modern x86 devices) there is 32KB which is enough to run TPL but not enough to run VPL. So TPL sets up 'Cache-as-RAM' which provides additional SRAM. Other architectures may have their own constraints.

And in this case then VPL sets up DRAM?

No, SPL. Nothing changes there.

Quoted 13 lines
Quoted 7 lines

But another key difference is that we use OF_PLATDATA in TPL and that is fine for the basic init needed there. But VPL needs lots of drivers as well as info about the firmware image layout so it adds to the work needed to get them running in that environment. So ideally, VPL can be built without OF_PLATDATA.

Quoted 5 lines

Or put it another way, TPL needs to be as small as possible so it can run on the widest array of devices. VPL is an optional phase (only used with verified boot) so we should not pollute TPL with that. I have a lot of other thoughts about all of this, some of which are in the VBE doc...

Quoted 8 lines

Right, the intention behind allowing "TPL" in-tree was that we have enough cases where we're size constrained and just need to allow for something "functional enough". This was what the old PowerPC "SPL" was about, and SoCs keep coming out with relatively tiny initial memory spaces.

I guess my concerns at the high level fall in to a few spots:
- I don't really like the idea of having to introduce yet another stage.

Well I've been avoiding it for years...

Quoted 2 lines

At that point, what infrastructure from U-Boot is it really even using?

Well the verification will be in VPL in U-Boot.

Quoted 2 lines

- In order to use this we're now needing platforms to support TPL to add in VPL.

Not necessarily. If the platform has enough memory to enable verification in TPL then that is still an option.

Quoted 2 lines

- That kind of ties in to another part of the issue I see. Why is this not just a feature to enable in earlier stage?

Yes that's possible, but it cannot be implemented in TPL in quite a few platforms, as I see it.

Quoted 1 line

- Why do we have both verified and "A/B or recovery" in the same spot?

I'm not sure what this means, sorry.

Quoted 6 lines

Some of this I guess comes down to my thinking about how yes, x86 is constrained, but we have a lot of other platforms with 128/256/way more pre-SDRAM memory available and verified is the key feature to enable rather than A/B update. And again, what does the verified part of this provide over FIT_SIGNATURE? Outside of that A/B case, at least.

It uses FIT_SIGNATURE, but with U-Boot being the target binary. So there are two updateable parts: firmware and kernel.

Regards,
Simon