* [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with --
@ 2022-06-30 4:38 hmy
2022-06-30 12:29 ` kernel test robot
2022-07-17 11:07 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: hmy @ 2022-06-30 4:38 UTC (permalink / raw)
To: robh+dt; +Cc: linux-kernel, hmy
when boot_command_line = grub-command "--" CONFIG_CMDLINE,
parse_args() will exit and without parsing the contents of CONFIG_CMDLINE
Signed-off-by: hmy <huanglin@uniontech.com>
---
drivers/of/fdt.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a8f5b6532165..696dc4179944 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1160,6 +1160,7 @@ int __init early_init_dt_scan_chosen(char *cmdline)
{
int l, node;
const char *p;
+ char *q;
const void *rng_seed;
const void *fdt = initial_boot_params;
@@ -1188,6 +1189,9 @@ int __init early_init_dt_scan_chosen(char *cmdline)
#if defined(CONFIG_CMDLINE_EXTEND)
strlcat(cmdline, " ", COMMAND_LINE_SIZE);
strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
+ q = strstr(data, "--");
+ if (q)
+ *q = '\0';
#elif defined(CONFIG_CMDLINE_FORCE)
strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
#else
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with --
2022-06-30 4:38 [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with -- hmy
@ 2022-06-30 12:29 ` kernel test robot
2022-07-17 11:07 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-06-30 12:29 UTC (permalink / raw)
To: hmy, robh+dt; +Cc: kbuild-all, linux-kernel, hmy
Hi hmy,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v5.19-rc4 next-20220630]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/hmy/FIX-CONFIG_CMDLINE-is-not-avail-when-kernel-config-line-in-grub-ends-with/20220630-124059
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-randconfig-a011 (https://download.01.org/0day-ci/archive/20220630/202206302025.8eyzYH5h-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/a68da93a13a9544ea17147828f16894ab6cfd204
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review hmy/FIX-CONFIG_CMDLINE-is-not-avail-when-kernel-config-line-in-grub-ends-with/20220630-124059
git checkout a68da93a13a9544ea17147828f16894ab6cfd204
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/of/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
drivers/of/fdt.c: In function 'early_init_dt_scan_chosen':
>> drivers/of/fdt.c:1163:15: warning: unused variable 'q' [-Wunused-variable]
1163 | char *q;
| ^
vim +/q +1163 drivers/of/fdt.c
1158
1159 int __init early_init_dt_scan_chosen(char *cmdline)
1160 {
1161 int l, node;
1162 const char *p;
> 1163 char *q;
1164 const void *rng_seed;
1165 const void *fdt = initial_boot_params;
1166
1167 node = fdt_path_offset(fdt, "/chosen");
1168 if (node < 0)
1169 node = fdt_path_offset(fdt, "/chosen@0");
1170 if (node < 0)
1171 return -ENOENT;
1172
1173 chosen_node_offset = node;
1174
1175 early_init_dt_check_for_initrd(node);
1176 early_init_dt_check_for_elfcorehdr(node);
1177
1178 /* Retrieve command line */
1179 p = of_get_flat_dt_prop(node, "bootargs", &l);
1180 if (p != NULL && l > 0)
1181 strlcpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
1182
1183 /*
1184 * CONFIG_CMDLINE is meant to be a default in case nothing else
1185 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
1186 * is set in which case we override whatever was found earlier.
1187 */
1188 #ifdef CONFIG_CMDLINE
1189 #if defined(CONFIG_CMDLINE_EXTEND)
1190 strlcat(cmdline, " ", COMMAND_LINE_SIZE);
1191 strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1192 q = strstr(data, "--");
1193 if (q)
1194 *q = '\0';
1195 #elif defined(CONFIG_CMDLINE_FORCE)
1196 strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1197 #else
1198 /* No arguments from boot loader, use kernel's cmdl*/
1199 if (!((char *)cmdline)[0])
1200 strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1201 #endif
1202 #endif /* CONFIG_CMDLINE */
1203
1204 pr_debug("Command line is: %s\n", (char *)cmdline);
1205
1206 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
1207 if (rng_seed && l > 0) {
1208 add_bootloader_randomness(rng_seed, l);
1209
1210 /* try to clear seed so it won't be found. */
1211 fdt_nop_property(initial_boot_params, node, "rng-seed");
1212
1213 /* update CRC check value */
1214 of_fdt_crc32 = crc32_be(~0, initial_boot_params,
1215 fdt_totalsize(initial_boot_params));
1216 }
1217
1218 return 0;
1219 }
1220
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with --
2022-06-30 4:38 [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with -- hmy
2022-06-30 12:29 ` kernel test robot
@ 2022-07-17 11:07 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-07-17 11:07 UTC (permalink / raw)
To: hmy, robh+dt; +Cc: kbuild-all, linux-kernel, hmy
Hi hmy,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v5.19-rc6 next-20220715]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/hmy/FIX-CONFIG_CMDLINE-is-not-avail-when-kernel-config-line-in-grub-ends-with/20220630-124059
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: loongarch-randconfig-c041-20220717 (https://download.01.org/0day-ci/archive/20220717/202207171910.KLJBcWEv-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/a68da93a13a9544ea17147828f16894ab6cfd204
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review hmy/FIX-CONFIG_CMDLINE-is-not-avail-when-kernel-config-line-in-grub-ends-with/20220630-124059
git checkout a68da93a13a9544ea17147828f16894ab6cfd204
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash drivers/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/of/fdt.c: In function 'early_init_dt_scan_chosen':
>> drivers/of/fdt.c:1192:20: error: 'data' undeclared (first use in this function); did you mean '_data'?
1192 | q = strstr(data, "--");
| ^~~~
| _data
drivers/of/fdt.c:1192:20: note: each undeclared identifier is reported only once for each function it appears in
vim +1192 drivers/of/fdt.c
1158
1159 int __init early_init_dt_scan_chosen(char *cmdline)
1160 {
1161 int l, node;
1162 const char *p;
1163 char *q;
1164 const void *rng_seed;
1165 const void *fdt = initial_boot_params;
1166
1167 node = fdt_path_offset(fdt, "/chosen");
1168 if (node < 0)
1169 node = fdt_path_offset(fdt, "/chosen@0");
1170 if (node < 0)
1171 return -ENOENT;
1172
1173 chosen_node_offset = node;
1174
1175 early_init_dt_check_for_initrd(node);
1176 early_init_dt_check_for_elfcorehdr(node);
1177
1178 /* Retrieve command line */
1179 p = of_get_flat_dt_prop(node, "bootargs", &l);
1180 if (p != NULL && l > 0)
1181 strlcpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
1182
1183 /*
1184 * CONFIG_CMDLINE is meant to be a default in case nothing else
1185 * managed to set the command line, unless CONFIG_CMDLINE_FORCE
1186 * is set in which case we override whatever was found earlier.
1187 */
1188 #ifdef CONFIG_CMDLINE
1189 #if defined(CONFIG_CMDLINE_EXTEND)
1190 strlcat(cmdline, " ", COMMAND_LINE_SIZE);
1191 strlcat(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
> 1192 q = strstr(data, "--");
1193 if (q)
1194 *q = '\0';
1195 #elif defined(CONFIG_CMDLINE_FORCE)
1196 strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1197 #else
1198 /* No arguments from boot loader, use kernel's cmdl*/
1199 if (!((char *)cmdline)[0])
1200 strlcpy(cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
1201 #endif
1202 #endif /* CONFIG_CMDLINE */
1203
1204 pr_debug("Command line is: %s\n", (char *)cmdline);
1205
1206 rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
1207 if (rng_seed && l > 0) {
1208 add_bootloader_randomness(rng_seed, l);
1209
1210 /* try to clear seed so it won't be found. */
1211 fdt_nop_property(initial_boot_params, node, "rng-seed");
1212
1213 /* update CRC check value */
1214 of_fdt_crc32 = crc32_be(~0, initial_boot_params,
1215 fdt_totalsize(initial_boot_params));
1216 }
1217
1218 return 0;
1219 }
1220
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-17 11:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30 4:38 [PATCH] FIX CONFIG_CMDLINE is not avail when kernel config line in grub ends with -- hmy
2022-06-30 12:29 ` kernel test robot
2022-07-17 11:07 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox