arch/x86/lib: implement cmdline configuration property
PATCH 1/1 arch/x86/lib: implement cmdline configuration property
Implement the cmdline configuration property as described in the spec
[1]
[1]: https://fitspec.osfw.foundation/#id10
--- arch/x86/include/asm/zimage.h | 2 +- arch/x86/lib/bootm.c | 10 +++++++++- arch/x86/lib/zimage.c | 4 ++-- boot/image-fit.c | 30 +++++++++++++++++++++++++++++- include/image.h | 3 +++ 5 files changed, 44 insertions(+), 5 deletions(-)
arch/x86/include/asm/zimage.h +1 -1
@@ -132,7 +132,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size,* Return: 0 (always) */ int setup_zimage (struct boot_params *setup_base,char *cmd_line,int auto_boot, -ulong initrd_addr,ulong initrd_size,ulong cmdline_force); +ulong initrd_addr,ulong initrd_size,char *cmdline_force);/** * zboot_start() - Prepare to boot a zimage
arch/x86/lib/bootm.c +9 -1
@@ -61,6 +61,7 @@ int arch_fixup_memory_node(void *blob)static int boot_prep_linux (struct bootm_headers *images) {char *cmd_line_dest =NULL ; +const char *cmd_line_override =NULL ;struct legacy_img_hdr *hdr;int is_zimage =0 ;void *data =NULL ;
@@ -99,6 +100,13 @@ static int boot_prep_linux(struct bootm_headers *images)puts ("Can't get image data/size!\n" ); goto error; } + + ret =fit_image_get_cmdline (images->fit_hdr_os, + images->fit_noffset_cfg, + &cmd_line_override); +if (ret) +debug ("unable to retrieve cmdline for zimage\n" ); + is_zimage =1 ;#endif }
@@ -125,7 +133,7 @@ static int boot_prep_linux(struct bootm_headers *images)printf ("Setup at %#08lx\n" , images->ep); ret =setup_zimage ((void *)images->ep, cmd_line_dest,0 , images->rd_start, - images->rd_end - images->rd_start,0 ); + images->rd_end - images->rd_start, cmd_line_override);if (ret) {printf ("## Setting up boot parameters failed ...\n" );
arch/x86/lib/zimage.c +2 -2
@@ -276,7 +276,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, }int setup_zimage (struct boot_params *setup_base,char *cmd_line,int auto_boot, -ulong initrd_addr,ulong initrd_size,ulong cmdline_force) +ulong initrd_addr,ulong initrd_size,char *cmdline_force) {struct setup_header *hdr = &setup_base->hdr;int bootproto =get_boot_protocol (hdr, false);
@@ -333,7 +333,7 @@ int setup_zimage(struct boot_params *setup_base, char *cmd_line, int auto_boot,/* build command line at COMMAND_LINE_OFFSET */ if (cmdline_force) -strcpy (cmd_line, (char *)cmdline_force); +strcpy (cmd_line, cmdline_force);else build_command_line (cmd_line, auto_boot);if (IS_ENABLED (CONFIG_CMD_BOOTM )) {
boot/image-fit.c +29 -1
@@ -1096,6 +1096,32 @@ int fit_image_get_data(const void *fit, int noffset, const void **data,return ret; } +/** +* fit_image_get_cmdline - get image configuration command line +* @fit: pointer to the FIT format image header +* @cfg_noffset: configuration node offset +* @cmdline: double pointer to char, will hold pointer to the cmdline +* +* fit_image_get_cmdline() gets the cmdline from the configuration node. +* If the property is found its data start address is returned to the caller. +* +* returns: +* 0, on success +* -1, on failure +*/ +int fit_image_get_cmdline (const void *fit,int noffset,const char **cmdline) +{ +int len; + + *cmdline = (const char *)fdt_getprop (fit, noffset,FIT_CMDLINE , &len); +if (!cmdline) { +fit_get_debug (fit, noffset,FIT_CMDLINE , len); +return -1 ; + } + +return 0 ; +} +/** * fit_image_hash_get_algo - get hash algorithm name * @fit: pointer to the FIT format image header
@@ -2136,8 +2162,10 @@ int fit_image_load(struct bootm_headers *images, ulong addr, fit_base_uname_config =fdt_get_name (fit, cfg_noffset,NULL );printf (" Using '%s' configuration\n" , fit_base_uname_config);/* Remember this config */ -if (image_type ==IH_TYPE_KERNEL ) +if (image_type ==IH_TYPE_KERNEL ) { images->fit_uname_cfg = fit_base_uname_config; + images->fit_noffset_cfg = cfg_noffset; + }if (FIT_IMAGE_ENABLE_VERIFY && images->verify) {puts (" Verifying Hash Integrity ... " );
include/image.h +3 -0
@@ -365,6 +365,7 @@ struct bootm_headers {* format, even for SPL, this extra data size seems worth it. */ const char *fit_uname_cfg;/* configuration node unit name */ +int fit_noffset_cfg;/* os subimage node offset */ void *fit_hdr_os;/* os FIT image header */ const char *fit_uname_os;/* os subimage node unit name */
@@ -1108,6 +1109,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size,#define FIT_TFA_BL31_PROP "tfa-bl31"#define FIT_TEE_PROP "tee"#define FIT_COMPAT_PROP "compatible" +#define FIT_CMDLINE "cmdline"#define FIT_MAX_HASH_LEN HASH_MAX_DIGEST_SIZE
@@ -1259,6 +1261,7 @@ int fit_get_data_node(const void *fit, const char *image_uname,int fit_get_data_conf_prop (const void *fit,const char *prop_name,const void **data,size_t *size); +int fit_image_get_cmdline (const void *fit,int noffset,const char **cmdline);int fit_image_hash_get_algo (const void *fit,int noffset,const char **algo);int fit_image_hash_get_value (const void *fit,int noffset,uint8_t **value,int *value_len);
---
base-commit: 98cf83d81617f489d7ff7bf78d33e693e2799254
change-id: 20260401-cmdline-ab954a4e8828
Best regards,
Signature · 1 line
Guillaume Ranquet <[email protected]>
Hi Guillaume,
Quoted 12 lines · Guillaume Ranquet
arch/x86/lib: implement cmdline configuration propertyarch/x86/lib: implement cmdline configuration propertyImplement the cmdline configuration property as described in the spec
[1][1]: https://fitspec.osfw.foundation/#id10
Signed-off-by Guillaume Ranquet <[email protected]>
boot/image-fit.c int fit_image_get_data(const void *fit, int noffset, const void **data, · line 1101
Quoted 6 lines
boot/image-fit.c +6
-0@@ -1096,6 +1096,32 @@ int fit_image_get_data(const void *fit, int noffset, const void **data, +int fit_image_get_cmdline (const void *fit,int noffset,const char **cmdline) +{ +int len; + + *cmdline = (const char *)fdt_getprop (fit, noffset,FIT_CMDLINE , &len); +if (!cmdline) {
This should be 'if (!*cmdline)', right?
include/image.h int booti_setup(ulong image, ulong *relocated_addr, ulong *size, · line 1109
Quoted 3 lines
include/image.h +1
-0@@ -1108,6 +1109,7 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, +#define FIT_CMDLINE "cmdline"
Please can you rename this to FIT_CMDLINE_PROP to match the naming convention used by all the other property macros in this list.
include/image.h struct bootm_headers { · line 366
Quoted 4 lines
include/image.h +1
-0@@ -365,6 +365,7 @@ struct bootm_headers {const char *fit_uname_cfg;/* configuration node unit name */ +int fit_noffset_cfg;/* os subimage node offset */
The comment is misleading - this is a configuration node offset, not an os subimage node offset.
arch/x86/lib/zimage.c struct boot_params *load_zimage(char *image, unsigned long kernel_size, · line 279
Quoted 3 lines
arch/x86/lib/zimage.c +1
-0@@ -279,7 +279,7 @@ struct boot_params *load_zimage(char *image, unsigned long kernel_size, + ulong initrd_addr, ulong initrd_size, char *cmdline_force)
Since the cmdline data comes from the FIT and should not be modified, please can you use 'const char *cmdline_force'
Regards,
Simon