diff mbox

[2/4] powerpc/prom: fix early parsing of parameters

Message ID 150175228769.9806.13262099086753853191.stgit@hbathini.in.ibm.com (mailing list archive)
State Rejected
Headers show

Commit Message

Hari Bathini Aug. 3, 2017, 9:24 a.m. UTC
Parameters 'mem=', 'iommu=' and the like, which affect the iommu are
parsed early in the boot process. This parser looks for a parameter
substring like 'iommu=' in the cmdline string but it could also succeed
when cmdline string contains parameters like 'x_iommu=' or such leading
to undesired results. Add support to skip proceeding in such cases.

Fixes: 9b6b563c0d2d ("powerpc: Merge in the ppc64 version of the prom code.")
Cc: stable@vger.kernel.org # 2.6.15+
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Hari Bathini <hbathini@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/prom_init.c |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

kernel test robot Aug. 6, 2017, 8:36 a.m. UTC | #1
Hi Hari,

[auto build test ERROR on powerpc/next]
[also build test ERROR on v4.13-rc3 next-20170804]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Hari-Bathini/powerpc-prom-avoid-endian-conversions-for-linux-memory-limit-node/20170804-060315
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-mpc836x_rdk_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

Note: the linux-review/Hari-Bathini/powerpc-prom-avoid-endian-conversions-for-linux-memory-limit-node/20170804-060315 HEAD 10b214586e70ec6cd64fea14d0e0997cf74a6fea builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> arch/powerpc/kernel/prom_init.c:600:13: error: 'is_substring_param' defined but not used [-Werror=unused-function]
    static bool is_substring_param(const char *cmdline, const char *str)
                ^~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors

vim +/is_substring_param +600 arch/powerpc/kernel/prom_init.c

   595	
   596	/*
   597	 * Check if str is a suffix of another param as "mem=" could
   598	 * be "iomem=" as well.
   599	 */
 > 600	static bool is_substring_param(const char *cmdline, const char *str)
   601	{
   602		char *p;
   603		bool ret = false;
   604	
   605		if (cmdline == str)
   606			ret = true;
   607		else {
   608			p = (char *)(str - 1);
   609			if (*p == ' ' || *p == '"')
   610				ret = true;
   611		}
   612	
   613		return ret;
   614	}
   615	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 723df83..7030145 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -594,6 +594,26 @@  static unsigned long prom_memparse(const char *ptr, const char **retptr)
 }
 
 /*
+ * Check if str is a suffix of another param as "mem=" could
+ * be "iomem=" as well.
+ */
+static bool is_substring_param(const char *cmdline, const char *str)
+{
+	char *p;
+	bool ret = false;
+
+	if (cmdline == str)
+		ret = true;
+	else {
+		p = (char *)(str - 1);
+		if (*p == ' ' || *p == '"')
+			ret = true;
+	}
+
+	return ret;
+}
+
+/*
  * Early parsing of the command line passed to the kernel, used for
  * "mem=x" and the options that affect the iommu
  */
@@ -617,7 +637,7 @@  static void __init early_cmdline_parse(void)
 
 #ifdef CONFIG_PPC64
 	opt = strstr(prom_cmd_line, "iommu=");
-	if (opt) {
+	if (opt && is_substring_param(prom_cmd_line, opt)) {
 		prom_printf("iommu opt is: %s\n", opt);
 		opt += 6;
 		while (*opt && *opt == ' ')