[PATCH 014/112] efi: payload: image: use assigned barebox loader type on x86

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Jan 3 10:11:34 PST 2024


Starting with Linux v6.2, there's a loader type assigned to barebox:

  commit a27e292b8a54e24f85181d949fac8c51fdec8ff3
  Author:     Ahmad Fatoum <a.fatoum at pengutronix.de>
  AuthorDate: Sun Oct 2 14:57:53 2022 +0200
  Commit:     Borislav Petkov <bp at suse.de>
  CommitDate: Mon Oct 17 11:22:33 2022 +0200

      Documentation/x86/boot: Reserve type_of_loader=13 for barebox

      barebox[1], a bootloader for mostly ARM and MIPS embedded systems, can
      also be built as EFI payload for x86[2] to provide redundant power-fail
      safe, watchdog-supervised boot up.

      Since its v2015.09.0 release, it has been booting Linux on x86 with
      type_of_loader=0xff[3]. Reserve 13, the next free id, so that can be
      used instead in the future.

      [1]: https://www.barebox.org/
      [2]: https://www.barebox.org/doc/latest/boards/efi.html
      [3]: https://elixir.bootlin.com/barebox/v2022.09.0/source/common/efi/payload/image.c#L217

      Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
      Signed-off-by: Borislav Petkov <bp at suse.de>
      Link: https://lore.kernel.org/r/20221002125752.3400831-1-a.fatoum@pengutronix.de

Thus, let's start making use of that.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 efi/payload/image.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/efi/payload/image.c b/efi/payload/image.c
index b7f4b7560b4b..a8748da1df88 100644
--- a/efi/payload/image.c
+++ b/efi/payload/image.c
@@ -261,7 +261,10 @@ static int do_bootm_efi(struct image_data *data)
 	memset(boot_header, 0, 0x4000);
 	memcpy(boot_header, image_header, sizeof(*image_header));
 
-	boot_header->type_of_loader = 0xff;
+	/* Refer to Linux kernel commit a27e292b8a54
+	 * ("Documentation/x86/boot: Reserve type_of_loader=13 for barebox")
+	 */
+	boot_header->type_of_loader = 0x13;
 
 	if (data->initrd_file) {
 		tmp = read_file(data->initrd_file, &size);
-- 
2.39.2




More information about the barebox mailing list