Merge branch '2023-11-01-bootstd-fixes'

- Four patches to address issues with bootstd flows in some cases
This commit is contained in:
Tom Rini 2023-11-01 12:52:32 -04:00
commit 46ff7dd096
5 changed files with 44 additions and 7 deletions

View file

@ -752,7 +752,7 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline,
in_quote = false;
continue;
}
if (*p == '=') {
if (*p == '=' && !arg_end) {
arg_end = p;
val = p + 1;
} else if (*p == '"') {
@ -788,7 +788,8 @@ int cmdline_set_arg(char *buf, int maxlen, const char *cmdline,
}
/* if this is the target arg, update it */
if (!strncmp(from, set_arg, arg_end - from)) {
if (arg_end - from == set_arg_len &&
!strncmp(from, set_arg, set_arg_len)) {
if (!buf) {
bool has_quote = val_end[-1] == '"';

View file

@ -406,7 +406,7 @@ static int cros_read_file(struct udevice *dev, struct bootflow *bflow,
return -ENOSYS;
}
#if CONFIG_IS_ENABLED(BOOSTD_FULL)
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
static int cros_read_all(struct udevice *dev, struct bootflow *bflow)
{
int ret;
@ -419,7 +419,7 @@ static int cros_read_all(struct udevice *dev, struct bootflow *bflow)
return 0;
}
#endif /* BOOSTD_FULL */
#endif /* BOOTSTD_FULL */
static int cros_boot(struct udevice *dev, struct bootflow *bflow)
{
@ -458,9 +458,9 @@ static struct bootmeth_ops cros_bootmeth_ops = {
.read_bootflow = cros_read_bootflow,
.read_file = cros_read_file,
.boot = cros_boot,
#if CONFIG_IS_ENABLED(BOOSTD_FULL)
#if CONFIG_IS_ENABLED(BOOTSTD_FULL)
.read_all = cros_read_all,
#endif /* BOOSTD_FULL */
#endif /* BOOTSTD_FULL */
};
static const struct udevice_id cros_bootmeth_ids[] = {

View file

@ -14,6 +14,8 @@
#include <bootmeth.h>
#include <command.h>
#include <dm.h>
#include <efi_loader.h>
#include <efi_variable.h>
/**
* struct efi_mgr_priv - private info for the efi-mgr driver
@ -46,13 +48,26 @@ static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
{
struct efi_mgr_priv *priv = dev_get_priv(dev);
efi_status_t ret;
efi_uintn_t size;
u16 *bootorder;
if (priv->fake_dev) {
bflow->state = BOOTFLOWST_READY;
return 0;
}
/* To be implemented */
ret = efi_init_obj_list();
if (ret)
return log_msg_ret("init", ret);
/* Enable this method if the "BootOrder" UEFI exists. */
bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid,
&size);
if (bootorder) {
bflow->state = BOOTFLOWST_READY;
return 0;
}
return -EINVAL;
}

View file

@ -82,6 +82,7 @@ if SPI_FLASH
config BOOTDEV_SPI_FLASH
bool "SPI Flash bootdev support"
depends on BOOTSTD
help
Enable a boot device for SPI flash. This allows reading a script
from SPI flash so that it can be used to boot an Operating System.

View file

@ -973,6 +973,26 @@ static int bootflow_cmdline(struct unit_test_state *uts)
}
BOOTSTD_TEST(bootflow_cmdline, 0);
/* test a few special changes to a long command line */
static int bootflow_cmdline_special(struct unit_test_state *uts)
{
char buf[500];
int pos;
/*
* check handling of an argument which has an embedded '=', as well as
* handling of a argument which partially matches ("ro" and "root")
*/
ut_asserteq(32, cmdline_set_arg(
buf, sizeof(buf),
"loglevel=7 root=PARTUUID=d68352e3 rootwait ro noinitrd",
"root", NULL, &pos));
ut_asserteq_str("loglevel=7 rootwait ro noinitrd", buf);
return 0;
}
BOOTSTD_TEST(bootflow_cmdline_special, 0);
/* Test ChromiumOS bootmeth */
static int bootflow_cros(struct unit_test_state *uts)
{