systemd-boot/rmc-boot.inc: update to work with v237 and meson

Patch changes:
* 0001-sd-boot-Link-RMC-library-into-bootloader-and-stub.patch removed
because make is no longer used.
* 0001-sd-boot-stub-check-LoadOptions-contains-data.patch removed because
it was accepted upstream.
* 0001-partially-revert-sd-boot-stub-Obtain-PE-section-offs.patch added to
support RMC functionality. Upstream removed a snippet that found the
root directory because they didn't need it anymore, but RMC does.
* 0002-sd-boot-fix-RMC-compatibility-with-systemd-boot-and-.patch added
to support building with meson instead of make.
* Others refreshed

inc file changes:
* Don't commit pin, we can maintain these patches OK for now
* EXTRA_OEMAKE -> EXTRA_OEMESON, and removed some superfluous options

Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
This commit is contained in:
California Sullivan 2018-03-20 16:21:33 -07:00
parent 90d32d53cf
commit f2502f90ab
8 changed files with 148 additions and 123 deletions

View File

@ -0,0 +1,46 @@
From beb095f41d458b7d684c0cd6cac1749e2fc3f29b Mon Sep 17 00:00:00 2001
From: California Sullivan <california.l.sullivan@intel.com>
Date: Wed, 21 Mar 2018 13:01:26 -0700
Subject: [PATCH 1/5] partially revert "sd-boot: stub: Obtain PE section
offsets from RAM, not disk (#6250)"
Only revert the section for finding the root_dir, as RMC needs this to
find its database file.
Upstream-Status: Inappropriate [upstream doesn't need the root_dir].
Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
---
src/boot/efi/stub.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index ff45cebd4..540ca5985 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -30,6 +30,8 @@ static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE;
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
EFI_LOADED_IMAGE *loaded_image;
+ EFI_FILE *root_dir;
+ CHAR16 *loaded_image_path;
CHAR8 *b;
UINTN size;
BOOLEAN secure = FALSE;
@@ -58,6 +60,13 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
return err;
}
+ root_dir = LibOpenRoot(loaded_image->DeviceHandle);
+ if (!root_dir) {
+ Print(L"Unable to open root directory: %r ", err);
+ uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
+ return EFI_LOAD_ERROR;
+ }
+
if (efivar_get_raw(&global_guid, L"SecureBoot", &b, &size) == EFI_SUCCESS) {
if (*b > 0)
secure = TRUE;
--
2.14.3

View File

@ -1,39 +0,0 @@
From fe1c2fdfe81f2ac2b41fe8543ba07f1911770d26 Mon Sep 17 00:00:00 2001
From: Jianxun Zhang <jianxun.zhang@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@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

View File

@ -1,42 +0,0 @@
From 87cd5a5e0f06ceb7f9dbdcc4029e0c279a38e6ad Mon Sep 17 00:00:00 2001
From: Mikko Ylinen <mikko.ylinen@linux.intel.com>
Date: Mon, 27 Feb 2017 10:04:03 +0200
Subject: [PATCH] sd-boot: stub: check LoadOptions contains data
With some UEFI shells LoadOptionsSize is reported being > 0
but the corresponding LoadOptions does not contain any data
(the first element has value 0).
When that happens, the stub feature that allows .cmdline to be
replaced by what's in LoadOptions ends up copying nothing/random
data to the kernel cmdline resulting in different kinds of boot
problems.
To fix this, add a check to see if LoadOptions contains data
before replacing the .cmdline.
Upstream-Status: Accepted [https://github.com/systemd/systemd/pull/5467]
Fixes [YOCTO #11078].
Signed-off-by: Mikko Ylinen <mikko.ylinen@linux.intel.com>
---
src/boot/efi/stub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
index 7c1ffb1bc..b7d5d3cda 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -87,7 +87,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
cmdline_len = szs[0];
/* if we are not in secure boot mode, accept a custom command line and replace the built-in one */
- if (!secure && loaded_image->LoadOptionsSize > 0) {
+ if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 *)loaded_image->LoadOptions != 0) {
CHAR16 *options;
CHAR8 *line;
UINTN i;
--
2.11.0

View File

@ -0,0 +1,62 @@
From af977853ab722194c4754e6693f430f50a42190f Mon Sep 17 00:00:00 2001
From: California Sullivan <california.l.sullivan@intel.com>
Date: Tue, 20 Mar 2018 10:08:14 -0700
Subject: [PATCH 2/5] sd-boot: fix RMC compatibility with systemd-boot and
meson
With autotools swapped out for meson a number of things need to be
changed.
Upstream-Status: Pending
Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
---
meson_options.txt | 2 ++
src/boot/efi/meson.build | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/meson_options.txt b/meson_options.txt
index 39822d6cd..d8a480401 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -279,6 +279,8 @@ option('efi-ldsdir', type : 'string',
description : 'path to the EFI lds directory')
option('efi-includedir', type : 'string', value : '/usr/include/efi',
description : 'path to the EFI header directory')
+option('rmc-includedir', type : 'string', value : '/usr/include/rmc',
+ description : 'path to the RMC header directory')
option('tpm-pcrindex', type : 'string', value : '8',
description : 'TPM PCR register number to use')
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
index 9f9ec4911..266ff928f 100644
--- a/src/boot/efi/meson.build
+++ b/src/boot/efi/meson.build
@@ -83,6 +83,7 @@ if have_gnu_efi
efi_conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
efi_conf.set10('ENABLE_TPM', get_option('tpm'))
efi_conf.set('SD_TPM_PCR', get_option('tpm-pcrindex'))
+ efi_conf.set('RMC_EFI', 'true')
efi_config_h = configure_file(
output : 'efi_config.h',
@@ -121,6 +122,7 @@ if have_gnu_efi
'-Wsign-compare',
'-Wno-missing-field-initializers',
'-isystem', efi_incdir,
+ '-isystem', get_option('rmc-includedir'),
'-isystem', join_paths(efi_incdir, gnu_efi_arch),
'-include', efi_config_h]
if efi_arch == 'x86_64'
@@ -191,7 +193,7 @@ if have_gnu_efi
output : tuple[0],
command : efi_ld.split() + ['-o', '@OUTPUT@'] +
efi_ldflags + tuple[2] +
- ['-lefi', '-lgnuefi', libgcc_file_name])
+ ['-lefi', '-lgnuefi', '-lrmcefi', libgcc_file_name])
test('no-undefined-symbols-' + tuple[0],
no_undefined_symbols,
--
2.14.3

View File

@ -1,7 +1,7 @@
From a3c4fc8c2847fe289a617bcba1d905f580f0e18d Mon Sep 17 00:00:00 2001
From b780c67c780bae2f834d73017044680fabca4268 Mon Sep 17 00:00:00 2001
From: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Date: Wed, 1 Jun 2016 16:32:22 -0700
Subject: [PATCH 2/3] sd-boot: Load board-specific boot entries from RMC
Subject: [PATCH 3/5] sd-boot: Load board-specific boot entries from RMC
database
RMC provides a centralized database file on ESP. The DB contains
@ -38,15 +38,16 @@ bootloader skips loading any boot entries from ESP.
Upstream-Status: Pending
Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
---
src/boot/efi/boot.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 145 insertions(+), 2 deletions(-)
src/boot/efi/boot.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 146 insertions(+), 2 deletions(-)
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index 30c1ead..d1b029b 100644
index b9c7c8394..93cfaf193 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -15,6 +15,7 @@
@@ -16,6 +16,7 @@
#include <efi.h>
#include <efilib.h>
@ -54,7 +55,7 @@ index 30c1ead..d1b029b 100644
#include "console.h"
#include "disk.h"
@@ -33,6 +34,9 @@ static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot
@@ -35,6 +36,9 @@ static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot
static const EFI_GUID global_guid = EFI_GLOBAL_VARIABLE;
@ -64,7 +65,7 @@ index 30c1ead..d1b029b 100644
enum loader_type {
LOADER_UNDEFINED,
LOADER_EFI,
@@ -1702,6 +1706,136 @@ static VOID config_free(Config *config) {
@@ -1684,6 +1688,136 @@ static VOID config_free(Config *config) {
FreePool(config->entry_oneshot);
}
@ -201,7 +202,7 @@ index 30c1ead..d1b029b 100644
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
CHAR16 *s;
CHAR8 *b;
@@ -1714,6 +1848,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
@@ -1696,6 +1830,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
UINT64 init_usec;
BOOLEAN menu = FALSE;
CHAR16 uuid[37];
@ -209,16 +210,17 @@ index 30c1ead..d1b029b 100644
InitializeLib(image, sys_table);
init_usec = time_usec();
@@ -1745,6 +1880,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
return EFI_LOAD_ERROR;
@@ -1736,6 +1871,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
}
}
+ /* Initialize rmc before loading any config */
+ rmc_initialize(root_dir, sys_table, &rmc_db, &rmc_fp);
+
/* the filesystem path to this image, to prevent adding ourselves to the menu */
loaded_image_path = DevicePathToStr(loaded_image->FilePath);
@@ -1753,11 +1890,15 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
efivar_set(L"LoaderImageIdentifier", loaded_image_path, FALSE);
@@ -1743,11 +1881,15 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
ZeroMem(&config, sizeof(Config));
config_load_defaults(&config, root_dir);
@ -236,7 +238,7 @@ index 30c1ead..d1b029b 100644
/* sort entries after version number */
config_sort_entries(&config);
@@ -1851,6 +1992,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
@@ -1841,6 +1983,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
out:
FreePool(loaded_image_path);
config_free(&config);
@ -246,5 +248,5 @@ index 30c1ead..d1b029b 100644
uefi_call_wrapper(BS->CloseProtocol, 4, image, &LoadedImageProtocol, image, NULL);
return err;
--
2.7.4
2.14.3

View File

@ -1,7 +1,7 @@
From 1e33f99e13a70c19c1f63f6ef1c5522a09adece6 Mon Sep 17 00:00:00 2001
From 159c8c54f92fb44d8abd2919fa83ad1cb640fac3 Mon Sep 17 00:00:00 2001
From: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Date: Mon, 20 Jun 2016 13:08:20 -0700
Subject: [PATCH 3/3] sd-boot: Support global kernel command line fragment
Subject: [PATCH 4/5] sd-boot: Support global kernel command line fragment
Query file blob KBOOTPARAM from RMC. If it exists, we append
it to the new linux boot entry's cmdline. A boot entry could
@ -12,15 +12,16 @@ these cases.
Upstream-Status: Pending
Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
---
src/boot/efi/boot.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
index d1b029b..8dffc48 100644
index 93cfaf193..2f400db3c 100644
--- a/src/boot/efi/boot.c
+++ b/src/boot/efi/boot.c
@@ -846,6 +846,40 @@ static VOID config_add_entry(Config *config, ConfigEntry *entry) {
@@ -851,6 +851,40 @@ static VOID config_add_entry(Config *config, ConfigEntry *entry) {
config->entries = ReallocatePool(config->entries,
sizeof(VOID *) * config->entry_count, sizeof(VOID *) * i);
}
@ -62,5 +63,5 @@ index d1b029b..8dffc48 100644
}
--
2.7.4
2.14.3

View File

@ -1,7 +1,7 @@
From 4cb9c65ea9c0eba3ba04d036dccd4a5ab3d2547b Mon Sep 17 00:00:00 2001
From 405a77233dde990fa7815d1546dc5a6b5a608479 Mon Sep 17 00:00:00 2001
From: Mikko Ylinen <mikko.ylinen@intel.com>
Date: Fri, 27 Jan 2017 13:31:45 +0200
Subject: [PATCH] sd-boot: support global kernel command line in EFI stub
Subject: [PATCH 5/5] 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
@ -14,15 +14,16 @@ Implements [YOCTO #10924].
Upstream-status: Pending
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
Signed-off-by: California Sullivan <california.l.sullivan@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
index 540ca5985..11047477b 100644
--- a/src/boot/efi/stub.c
+++ b/src/boot/efi/stub.c
@@ -13,6 +13,7 @@
@@ -14,6 +14,7 @@
#include <efi.h>
#include <efilib.h>
@ -30,7 +31,7 @@ index 1e250f34f..f3865199f 100644
#include "disk.h"
#include "graphics.h"
@@ -48,6 +49,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
@@ -49,6 +50,9 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
UINTN cmdline_len;
CHAR16 uuid[37];
EFI_STATUS err;
@ -40,7 +41,7 @@ index 1e250f34f..f3865199f 100644
InitializeLib(image, sys_table);
@@ -112,6 +116,35 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
@@ -109,6 +113,35 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
#endif
}
@ -77,5 +78,5 @@ index 1e250f34f..f3865199f 100644
if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS)
efivar_set(L"LoaderDevicePartUUID", uuid, FALSE);
--
2.11.0
2.14.3

View File

@ -1,21 +1,15 @@
# Pin systemd revision down for systemd-boot recipe.
# Patches could not be applied cleanly when systemd in OE is updated,
# though we don't expect a lot of changes could happen in bootloader.
# RMC is designed to support a large number of types of boards, so we
# should do explicit update with validation to prevent regression even
# resolving conflicts for a new tip could be done in a short time.
# Revision: systemd v232 in OE
SRCREV_intel-x86-common = "a1e2ef7ec912902d8142e7cb5830cbfb47dba86c"
# This patchset contains hooks that allows systemd-boot to use RMC capablilities.
DEPENDS_append_intel-x86-common = " rmc rmc-efi"
EXTRA_OEMAKE_append_intel-x86-common = ' EFI_LDFLAGS="-L${STAGING_DIR_HOST}/usr/lib" EFI_CFLAGS="-I${STAGING_INCDIR}/rmc -DRMC_EFI"'
EXTRA_OEMESON_append_intel-x86-common = ' \
-Drmc-includedir="${STAGING_INCDIR}/rmc" \
'
SRC_URI_append_intel-x86-common = " \
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-sd-boot-stub-check-LoadOptions-contains-data.patch \
file://0001-partially-revert-sd-boot-stub-Obtain-PE-section-offs.patch \
file://0002-sd-boot-fix-RMC-compatibility-with-systemd-boot-and-.patch \
file://0003-sd-boot-Load-board-specific-boot-entries-from-RMC-da.patch \
file://0004-sd-boot-Support-global-kernel-command-line-fragment.patch \
file://0005-sd-boot-support-global-kernel-command-line-in-EFI-st.patch \
"