SPL EBBR - EFI System Partition support
v3 cover SPL EBBR - EFI System Partition support
This series adds support to locate an EFI System Partition on a disk and boot the next stage from such a parition if found. The next stage image is expected to be under the FIRMWARE directory as described in the EBBR specification [1]. Also update the spl_blk_fs and spl_fat drivers to prefer booting from ESP and fall back to the configured parition in case of a failure.
Changes in v3:
- Revert fallback change from v2
- Fix part_get_esp signature and header in part.h
- Add RB tag
Changes in v2:
- Rebase on latest next branch
- Enable SPL_ESP_BOOT by default
- For NVMe boot, remove fallback in case of ESP boot failure
Mayuresh Chitale (2):
part: Add a function to find ESP partition
spl: Add support for booting from ESP
common/spl/Kconfig | 8 ++++++ common/spl/spl_blk_fs.c | 60 ++++++++++++++++++++++++++++++----------- common/spl/spl_fat.c | 34 ++++++++++++++++++++--- disk/part.c | 16 +++++++++++ include/part.h | 13 +++++++++ 5 files changed, 111 insertions(+), 20 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/2 part: Add a function to find ESP partition
If a disk has an EFI system partition (ESP) then it can be used to locate the boot files. Add a function to find the ESP.
---
Changes in v3:
- Fix part_get_esp signature and header in part.h
disk/part.c | 16 ++++++++++++++++ include/part.h | 13 +++++++++++++ 2 files changed, 29 insertions(+)
disk/part.c +16 -0
@@ -848,3 +848,19 @@ int part_get_bootable(struct blk_desc *desc)return 0 ; } + +int part_get_esp (struct blk_desc *desc) +{ +struct disk_partition info; +int p; + +for (p =1 ; p <=MAX_SEARCH_PARTITIONS ; p++) { +int ret; + + ret =part_get_info (desc, p, &info); +if (!ret && (info.bootable &PART_EFI_SYSTEM_PARTITION )) +return p; + } + +return 0 ; +}
include/part.h +13 -0
@@ -690,6 +690,14 @@ int part_get_type_by_name(const char *name);*/ int part_get_bootable (struct blk_desc *desc); +/** +* part_get_esp() - Find the EFI system partition +* +* @desc: Block-device descriptor +* Return: the EFI system partition, or 0 if there is none +*/ +int part_get_esp (struct blk_desc *desc); +#else static inline int part_driver_get_count (void ) {return 0 ; }
@@ -700,6 +708,11 @@ static inline struct part_driver *part_driver_get_first(void)static inline bool part_get_bootable (struct blk_desc *desc) {return false; } +static inline int part_get_esp (struct blk_desc *desc) +{ +return 0 ; +} +#endif /* CONFIG_PARTITIONS */ #endif /* _PART_H */
Signature · 1 line
2.34.1
PATCH v3 2/2 spl: Add support for booting from ESP
In reply to Mayuresh ChitaleSome platforms as described by EBBR specification may store images in the FIRMWARE directory of the UEFI system partition(ESP). Add support to boot from the EFI system partition if it is enabled for a platform.
---
Changes in v3:
- Revert fallback change from v2
- Add RB tag
common/spl/Kconfig | 8 ++++++ common/spl/spl_blk_fs.c | 60 ++++++++++++++++++++++++++++++----------- common/spl/spl_fat.c | 34 ++++++++++++++++++++--- 3 files changed, 82 insertions(+), 20 deletions(-)
common/spl/Kconfig +8 -0
@@ -1292,6 +1292,14 @@ config SPL_SATA_RAW_U_BOOT_SECTOR Sector on the SATA disk to load U-Boot from, when the SATA disk is being used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes). +config SPL_ESP_BOOT + bool "Load next stage boot image from the UEFI system partition" + default y if BOOT_DEFAULTS + select SPL_PARTITION_TYPE_GUID + help + When enabled, first try to boot from the UEFI system partition as + described in the Ch.4 of the EBBR specification. + config SPL_NVME bool "NVM Express device support" depends on BLK
common/spl/spl_blk_fs.c +44 -16
96 lines not on this page · raw message
common/spl/spl_fat.c +30 -4
@@ -60,10 +60,10 @@ static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,return actread; } -int spl_load_image_fat (struct spl_image_info *spl_image, -struct spl_boot_device *bootdev, -struct blk_desc *block_dev,int partition, -const char *filename) +int spl_load_image_fat_one (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev, +struct blk_desc *block_dev,int partition, +const char *filename) {int err;loff_t size;
@@ -103,6 +103,32 @@ end:return err; } +int spl_load_image_fat (struct spl_image_info *spl_image, +struct spl_boot_device *bootdev, +struct blk_desc *block_dev,int partition, +const char *filename) +{ +int err, part; + +/* +* First try to boot from EFI System partition. In case of failure, +* fall back to the configured partition. +*/ +if (IS_ENABLED (CONFIG_SPL_ESP_BOOT )) { + part =part_get_esp (block_dev); +if (part) { + err =spl_load_image_fat_one (spl_image, bootdev, + block_dev, part, + filename); +if (!err) +return err; + } + } + +return spl_load_image_fat_one (spl_image, bootdev, block_dev, + partition, filename); +} +#if CONFIG_IS_ENABLED (OS_BOOT ) int spl_load_image_fat_os(struct spl_image_info *spl_image, struct spl_boot_device *bootdev,
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] spl: Add support for booting from ESP
Quoted 6 lines · Mayuresh Chitale
Some platforms as described by EBBR specification may store images in the FIRMWARE directory of the UEFI system partition(ESP). Add support to boot from the EFI system partition if it is enabled for a platform.
Signed-off-by Mayuresh Chitale <[email protected]>Reviewed-by Heinrich Schuchardt <[email protected]>
[snip]
Quoted 9 lines
common/spl/Kconfig +1
-0@@ -1292,6 +1292,14 @@ config SPL_SATA_RAW_U_BOOT_SECTOR Sector on the SATA disk to load U-Boot from, when the SATA disk is being used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes). +config SPL_ESP_BOOT
common/spl/Kconfig config SPL_SATA_RAW_U_BOOT_SECTOR · line 1305
Quoted 10 lines
common/spl/Kconfig +7
-0+ bool "Load next stage boot image from the UEFI system partition" + default y if BOOT_DEFAULTS + select SPL_PARTITION_TYPE_GUID + help + When enabled, first try to boot from the UEFI system partition as + described in the Ch.4 of the EBBR specification. + config SPL_NVME bool "NVM Express device support" depends on BLK
This introduces:
WARNING: unmet direct dependencies detected for SPL_PARTITION_TYPE_GUID
Depends on [n]: SPL_EFI_PARTITION [=n]
Selected by [y]:
- SPL_ESP_BOOT [=y] && SPL [=y]
On for example coreboot64.
Signature · 1 line
Tom