Jonathan Zhang has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/47055 )
Change subject: [RFC]mb/ocp/deltalake: append Linuxboot command line option ......................................................................
[RFC]mb/ocp/deltalake: append Linuxboot command line option
If Linuxboot is used as payload, and if corresponding VPD variable is set, use the value to append Linuxboot command line option as defined at build time.
With this, user can customize linuxboot boot behavior without needing a different image. For example, user can increase log level.
Note that this code should not be in mainboard, I hope to get community feedback on where it should be.
TESTED=tested on DeltaLake, with this VPD setting: vpd -f build/coreboot.rom -i RW_VPD -s linux_command_line="loglevel=7 cpuidle.off=1"
Signed-off-by: Jonathan Zhang jonzhang@fb.com Signed-off-by: Bryant Ou Bryant.Ou.Q@gmail.com Change-Id: I5f5cde3957c2716864f55d70f18f47b493164ed8 --- M src/mainboard/ocp/deltalake/ramstage.c M src/mainboard/ocp/deltalake/vpd.h 2 files changed, 49 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/47055/1
diff --git a/src/mainboard/ocp/deltalake/ramstage.c b/src/mainboard/ocp/deltalake/ramstage.c index 9d57090..800ad5a 100644 --- a/src/mainboard/ocp/deltalake/ramstage.c +++ b/src/mainboard/ocp/deltalake/ramstage.c @@ -5,11 +5,13 @@ #include <bootstate.h> #include <drivers/ipmi/ipmi_ops.h> #include <drivers/ocp/dmi/ocp_dmi.h> +#include <drivers/vpd/vpd.h> #include <gpio.h> #include <soc/lewisburg_pch_gpio_defs.h> #include <soc/ramstage.h> #include <soc/soc_util.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <smbios.h> #include <device/pci_def.h> @@ -18,10 +20,15 @@ #include <hob_iiouds.h> #include <hob_memmap.h> #include <cpxsp_dl_gpio.h> +#include <program_loading.h>
#include "ipmi.h" +#include "vpd.h"
#define SLOT_ID_LEN 2 +/* copied from util/cbfstool/linux_trampoline.h */ +#define COMMAND_LINE_LOC 0x91000 +#define LINUX_CMD_LEN 72
extern struct fru_info_str fru_strings; static char slot_id_str[SLOT_ID_LEN]; @@ -307,3 +314,42 @@ }
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, pull_post_complete_pin, NULL); + +#if CONFIG_PAYLOAD_LINUX +/* + * If Linuxboot is the payload, and if LINUX_COMMAND_LINE is defined as VPD + * variable, use the value to append original Linux command line option as + * defined at build time + */ +void platform_segment_loaded(uintptr_t start, size_t size, int flags) +{ + if (start != COMMAND_LINE_LOC) + return; + + char cmdline[LINUX_CMD_LEN] = ""; + if (!vpd_gets(LINUX_COMMAND_LINE, cmdline, LINUX_CMD_LEN, VPD_RW_THEN_RO)) + return; + + char *orig_cmdline = strdup((char *)start); + char *new_cmdline = NULL; + size_t new_cmdline_len; + printk(BIOS_INFO, "Build time defined Linux command line: %s\n", + orig_cmdline); + printk(BIOS_INFO, "VPD defined Linux command line: %s\n", cmdline); + + new_cmdline = strconcat(orig_cmdline, " "); + new_cmdline = strconcat(new_cmdline, cmdline); + new_cmdline_len = strlen(new_cmdline); + printk(BIOS_INFO, "Updated Linux command line: %s, len: %ld\n", new_cmdline, new_cmdline_len); + if (new_cmdline_len >= size) { + printk(BIOS_ERR, "Updated Linux command line has size %ld bigger than %ld.\n", + new_cmdline_len, size); + free(new_cmdline); + return; + } + + memset((uint8_t *)start, 0, size); + memcpy((uint8_t *)start, new_cmdline, strlen(new_cmdline)); + free(new_cmdline); +} +#endif diff --git a/src/mainboard/ocp/deltalake/vpd.h b/src/mainboard/ocp/deltalake/vpd.h index 43070c2..cb9588b 100644 --- a/src/mainboard/ocp/deltalake/vpd.h +++ b/src/mainboard/ocp/deltalake/vpd.h @@ -36,4 +36,7 @@ #define COREBOOT_LOG_LEVEL "coreboot_log_level" #define COREBOOT_LOG_LEVEL_DEFAULT 4
+/* Linuxboot kernel command line */ +#define LINUX_COMMAND_LINE "linux_command_line" + #endif
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/47055 )
Change subject: [RFC]mb/ocp/deltalake: append Linuxboot command line option ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/47055/1/src/mainboard/ocp/deltalake... File src/mainboard/ocp/deltalake/ramstage.c:
https://review.coreboot.org/c/coreboot/+/47055/1/src/mainboard/ocp/deltalake... PS1, Line 343: printk(BIOS_INFO, "Updated Linux command line: %s, len: %ld\n", new_cmdline, new_cmdline_len); line over 96 characters
Jonathan Zhang has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/47055 )
Change subject: [RFC]mb/ocp/deltalake: append Linuxboot command line option ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/47055/1/src/mainboard/ocp/deltalake... File src/mainboard/ocp/deltalake/ramstage.c:
https://review.coreboot.org/c/coreboot/+/47055/1/src/mainboard/ocp/deltalake... PS1, Line 345: printk(BIOS_ERR, "Updated Linux command line has size %ld bigger than %ld.\n", I get this message: Updated Linux command line has size 96 bigger than 72. So when platform_segment_loaded() is called for Linuxboot payload, the command line size is only 72??? I am not able to find where 72 is defined.
Hello Marc Jones, build bot (Jenkins), Johnny Lin, Stefan Reinauer, insomniac, Angel Pons, Bryant Ou, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/47055
to look at the new patch set (#2).
Change subject: [RFC] mb/ocp/deltalake: append Linuxboot command line option ......................................................................
[RFC] mb/ocp/deltalake: append Linuxboot command line option
If Linuxboot is used as payload, and if corresponding VPD variable is set, use the value to append Linuxboot command line option as defined at build time.
With this, user can customize linuxboot boot behavior without needing a different image. For example, user can increase log level.
Note that this code should not be in mainboard, I hope to get community feedback on where it should be.
TESTED=tested on DeltaLake, with this VPD setting: vpd -f build/coreboot.rom -i RW_VPD -s linux_command_line="loglevel=7 cpuidle.off=1"
Signed-off-by: Jonathan Zhang jonzhang@fb.com Signed-off-by: Bryant Ou Bryant.Ou.Q@gmail.com Change-Id: I5f5cde3957c2716864f55d70f18f47b493164ed8 --- M src/mainboard/ocp/deltalake/ramstage.c M src/mainboard/ocp/deltalake/vpd.h 2 files changed, 48 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/47055/2
Hello build bot (Jenkins), Marc Jones, Johnny Lin, Stefan Reinauer, insomniac, Angel Pons, Bryant Ou, ron minnich,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/47055
to look at the new patch set (#3).
Change subject: [RFC] mb/ocp/deltalake: append Linuxboot command line option ......................................................................
[RFC] mb/ocp/deltalake: append Linuxboot command line option
If Linuxboot is used as payload, and if corresponding VPD variable is set, use the value to append Linuxboot command line option as defined at build time.
With this, user can customize linuxboot boot behavior without needing a different image. For example, user can increase log level.
Note that this code should not be in mainboard, I hope to get community feedback on where it should be.
TESTED=tested on DeltaLake, with this VPD setting: vpd -f build/coreboot.rom -i RW_VPD -s linux_command_line="loglevel=7 cpuidle.off=1"
Signed-off-by: Jonathan Zhang jonzhang@fb.com Signed-off-by: Bryant Ou Bryant.Ou.Q@gmail.com Change-Id: I5f5cde3957c2716864f55d70f18f47b493164ed8 --- M src/mainboard/ocp/deltalake/ramstage.c M src/mainboard/ocp/deltalake/vpd.h 2 files changed, 43 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/55/47055/3
Marc Jones has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/47055 )
Change subject: [RFC] mb/ocp/deltalake: append Linuxboot command line option ......................................................................
Patch Set 3:
(1 comment)
vpd has to update the coreboot image via cbfs, so it might make more sense to script or add the option to cbfstool to update the payload string.
I understand that vpd RO and RW are handy for the ocp solutions, but aren't implemented in other places, so a more general call to update the string might be more appropriate.
https://review.coreboot.org/c/coreboot/+/47055/3/src/mainboard/ocp/deltalake... File src/mainboard/ocp/deltalake/ramstage.c:
https://review.coreboot.org/c/coreboot/+/47055/3/src/mainboard/ocp/deltalake... PS3, Line 324: void platform_segment_loaded(uintptr_t start, size_t size, int flags) You probably don't need to call on every segment loaded. Can this be addressed just before the payload is called? I think that arch_bootstate_coreboot_exit() might be the correct call.