[meta-intel] [PATCH 1/2] systemd-boot: use RMC database in EFI stub

Mikko Ylinen mikko.ylinen at intel.com
Fri Jan 27 05:36:00 PST 2017


systemd-boot's EFI stub can be built in an EFI executable
with the kernel, cmdline, and initrd.

This commit enables the EFI stub code to use the RMC database
and appends the board specific cmdline (KBOOTPARAM) to the
built-in cmdline.

Signed-off-by: Mikko Ylinen <mikko.ylinen at intel.com>
---
 ...Link-RMC-library-into-bootloader-and-stub.patch | 39 +++++++++++
 ...-sd-boot-Link-RMC-library-into-bootloader.patch | 31 ---------
 ...-kernel-command-line-fragment-in-EFI-stub.patch | 81 ++++++++++++++++++++++
 .../systemd-boot/systemd-boot_%.bbappend           |  3 +-
 4 files changed, 122 insertions(+), 32 deletions(-)
 create mode 100644 common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch
 delete mode 100644 common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader.patch
 create mode 100644 common/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch

diff --git a/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch b/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch
new file mode 100644
index 0000000..2f248e2
--- /dev/null
+++ b/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch
@@ -0,0 +1,39 @@
+From fe1c2fdfe81f2ac2b41fe8543ba07f1911770d26 Mon Sep 17 00:00:00 2001
+From: Jianxun Zhang <jianxun.zhang at linux.intel.com>
+Date: Sat, 21 May 2016 18:52:07 -0700
+Subject: [PATCH] sd-boot: Link RMC library into bootloader and stub
+
+Add RMC library into bootloader binary and stub.
+
+Upstream-Status: Pending
+
+Signed-off-by: Jianxun Zhang <jianxun.zhang at linux.intel.com>
+---
+ Makefile.am | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 305099ab6..9fb6f9b7b 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -2802,7 +2802,7 @@ $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(t
+ 
+ $(systemd_boot_solib): $(systemd_boot_objects)
+ 	$(AM_V_CCLD)$(LD) $(efi_ldflags) $(systemd_boot_objects) \
+-		-o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
++		-o $@ -lefi -lgnuefi -lrmcefi $(shell $(CC) -print-libgcc-file-name); \
+ 	nm -D -u $@ | grep ' U ' && exit 1 || :
+ 
+ $(systemd_boot): $(systemd_boot_solib)
+@@ -2852,7 +2852,7 @@ $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(t
+ 
+ $(stub_solib): $(stub_objects)
+ 	$(AM_V_CCLD)$(LD) $(efi_ldflags) $(stub_objects) \
+-		-o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
++		-o $@ -lefi -lgnuefi -lrmcefi $(shell $(CC) -print-libgcc-file-name); \
+ 	nm -D -u $@ | grep ' U ' && exit 1 || :
+ 
+ $(stub): $(stub_solib)
+-- 
+2.11.0
+
diff --git a/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader.patch b/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader.patch
deleted file mode 100644
index 626efce..0000000
--- a/common/recipes-bsp/systemd-boot/systemd-boot/0001-sd-boot-Link-RMC-library-into-bootloader.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From 1ccd031ce97501f8ee63f39e8794437d568115dc Mon Sep 17 00:00:00 2001
-From: Jianxun Zhang <jianxun.zhang at linux.intel.com>
-Date: Sat, 21 May 2016 18:52:07 -0700
-Subject: [PATCH 1/3] sd-boot: Link RMC library into bootloader
-
-Add RMC library into bootloader binary. EFI stub is not changed
-until we really need rmc in stub.
-
-Upstream-Status: Pending
-
-Signed-off-by: Jianxun Zhang <jianxun.zhang at linux.intel.com>
----
- Makefile.am | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Makefile.am b/Makefile.am
-index 305099a..df176a5 100644
---- a/Makefile.am
-+++ b/Makefile.am
-@@ -2802,7 +2802,7 @@ $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix $(t
- 
- $(systemd_boot_solib): $(systemd_boot_objects)
- 	$(AM_V_CCLD)$(LD) $(efi_ldflags) $(systemd_boot_objects) \
--		-o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
-+		-o $@ -lefi -lgnuefi -lrmcefi $(shell $(CC) -print-libgcc-file-name); \
- 	nm -D -u $@ | grep ' U ' && exit 1 || :
- 
- $(systemd_boot): $(systemd_boot_solib)
--- 
-2.7.4
-
diff --git a/common/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch b/common/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch
new file mode 100644
index 0000000..7508269
--- /dev/null
+++ b/common/recipes-bsp/systemd-boot/systemd-boot/0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch
@@ -0,0 +1,81 @@
+From 4cb9c65ea9c0eba3ba04d036dccd4a5ab3d2547b Mon Sep 17 00:00:00 2001
+From: Mikko Ylinen <mikko.ylinen at intel.com>
+Date: Fri, 27 Jan 2017 13:31:45 +0200
+Subject: [PATCH] sd-boot: support global kernel command line in EFI stub
+
+This change integrates rmc into EFI stub and supports a
+global fragment (RMC KBOOTPARAM) that is appended to the
+cmdline at boot.
+
+The fragment is board-specific and read from the database.
+
+Implements [YOCTO #10924].
+
+Upstream-status: Pending
+
+Signed-off-by: Mikko Ylinen <mikko.ylinen at intel.com>
+---
+ src/boot/efi/stub.c | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
+
+diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
+index 1e250f34f..f3865199f 100644
+--- a/src/boot/efi/stub.c
++++ b/src/boot/efi/stub.c
+@@ -13,6 +13,7 @@
+ 
+ #include <efi.h>
+ #include <efilib.h>
++#include <rmc_api.h>
+ 
+ #include "disk.h"
+ #include "graphics.h"
+@@ -48,6 +49,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
+         UINTN cmdline_len;
+         CHAR16 uuid[37];
+         EFI_STATUS err;
++        INTN len;
++        CHAR8 *rmc_db = NULL;
++        rmc_file_t rmc_file;
+ 
+         InitializeLib(image, sys_table);
+ 
+@@ -112,6 +116,35 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
+ #endif
+         }
+ 
++        len = file_read(root_dir, L"\\rmc.db", 0, 0, &rmc_db);
++        if (len <= 0)
++                rmc_db = NULL;
++
++        /* If the board has a fragment in rmc database, append it to the cmdline */
++        if (rmc_db && !rmc_gimme_file(sys_table, rmc_db, "KBOOTPARAM", &rmc_file)) {
++                CHAR8 *line;
++                UINTN i = 0;
++                UINTN j;
++
++                line = AllocatePool(rmc_file.blob_len + cmdline_len + 2);
++
++                while (i < cmdline_len && cmdline[i] != '\0') {
++                        line[i] = cmdline[i];
++                        i++;
++                }
++
++                line[i++] = ' ';
++
++                for (j=0; j < rmc_file.blob_len; j++)
++                        line[i+j] = rmc_file.blob[j];
++                line[i+j] = '\0';
++
++                cmdline = line;
++                cmdline_len = i + j;
++
++                FreePool(rmc_db);
++        }
++
+         /* export the device path this image is started from */
+         if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS)
+                 efivar_set(L"LoaderDevicePartUUID", uuid, FALSE);
+-- 
+2.11.0
+
diff --git a/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend b/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
index 12c1e5a..0db67b1 100644
--- a/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
+++ b/common/recipes-bsp/systemd-boot/systemd-boot_%.bbappend
@@ -15,9 +15,10 @@ EXTRA_OEMAKE_append_intel-x86-common = ' EFI_LDFLAGS="-L${STAGING_DIR_HOST}/usr/
 SRCREV_intel-x86-common = "a1e2ef7ec912902d8142e7cb5830cbfb47dba86c"
 
 SRC_URI_append_intel-x86-common = " \
-            file://0001-sd-boot-Link-RMC-library-into-bootloader.patch \
+            file://0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch \
             file://0002-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch \
             file://0003-sd-boot-Support-global-kernel-command-line-fragment.patch \
+            file://0004-sd-boot-Support-global-kernel-command-line-fragment-in-EFI-stub.patch \
             file://0001-efi-boot.c-workaround-for-Joule-BIOS-hang.patch \
             "
 
-- 
2.11.0

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the meta-intel mailing list