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: sta...@vger.kernel.org # 2.6.15+ Cc: Paul Mackerras <pau...@samba.org> Signed-off-by: Hari Bathini <hbath...@linux.vnet.ibm.com> --- arch/powerpc/kernel/prom_init.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 == ' ')