From: Hari Bathini <hidden> Date: 2017-08-03 09:24:50
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,*Fillinsomeinfosforusebythekernellateron*/if(prom_memory_limit){-__be64val=cpu_to_be64(prom_memory_limit);prom_setprop(prom.chosen,"/chosen","linux,memory-limit",-&val,sizeof(val));+&prom_memory_limit,sizeof(prom_memory_limit));}#ifdef CONFIG_PPC64if(prom_iommu_off)
From: Hari Bathini <hidden> Date: 2017-08-03 09:25:31
Early cmdline parser looks for "mem=" substring in the cmdline
string but it could also succeed when cmdline string contains
parameters like 'fadump_reserve_mem=' or such leading to undesired
results. Add support to skip proceeding in such case.
Fixes: cf68787b68a2 ("powerpc/prom_init: Evaluate mem kernel parameter for early allocation")
Cc: stable@vger.kernel.org # 2.6.32+
Cc: Benjamin Krill <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Hari Bathini <hidden> Date: 2017-08-03 09:25:37
Early cmdline parser looks for "disable_radix" substring in the cmdline
string but it could also succeed when cmdline string contains parameters
like 'x_disable_radix' or disable_radix_type=' or such causing undesired
actions. Add support to skip proceeding in such cases.
Fixes: 014d02cbf16b ("powerpc: Update to new option-vector-5 format for CAS")
Cc: stable@vger.kernel.org # 4.11+
Cc: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
From: Hari Bathini <hidden> Date: 2017-08-03 09:25:55
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 <redacted>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2017-08-04 01:38:06
On Thu, 2017-08-03 at 14:54 +0530, Hari Bathini wrote:
quoted hunk
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,*Fillinsomeinfosforusebythekernellateron*/if(prom_memory_limit){-__be64val=cpu_to_be64(prom_memory_limit);prom_setprop(prom.chosen,"/chosen","linux,memory-limit",-&val,sizeof(val));+&prom_memory_limit,sizeof(prom_memory_limit));}#ifdef CONFIG_PPC64if(prom_iommu_off)
NACK. The device-tree is big endian by convention.
Ben.
From: Benjamin Herrenschmidt <hidden> Date: 2017-08-04 01:48:56
On Fri, 2017-08-04 at 11:37 +1000, Benjamin Herrenschmidt wrote:
On Thu, 2017-08-03 at 14:54 +0530, Hari Bathini wrote:
quoted
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,*Fillinsomeinfosforusebythekernellateron*/if(prom_memory_limit){-__be64val=cpu_to_be64(prom_memory_limit);prom_setprop(prom.chosen,"/chosen","linux,memory-limit",-&val,sizeof(val));+&prom_memory_limit,sizeof(prom_memory_limit));}#ifdef CONFIG_PPC64if(prom_iommu_off)
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-08-04 03:51:51
Hari Bathini [off-list ref] writes:
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
As Ben said, this is not OK. The flat device tree is a data
structure with a specified format[1], we don't violate the spec just to
avoid an endian swap.
Is there an actual bug you're trying to solve?
cheers
[1]: https://www.devicetree.org/
@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,*Fillinsomeinfosforusebythekernellateron*/if(prom_memory_limit){-__be64val=cpu_to_be64(prom_memory_limit);prom_setprop(prom.chosen,"/chosen","linux,memory-limit",-&val,sizeof(val));+&prom_memory_limit,sizeof(prom_memory_limit));}#ifdef CONFIG_PPC64if(prom_iommu_off)
From: Hari Bathini <hidden> Date: 2017-08-04 05:32:23
On Friday 04 August 2017 09:21 AM, Michael Ellerman wrote:
Hari Bathini [off-list ref] writes:
quoted
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
As Ben said, this is not OK. The flat device tree is a data
structure with a specified format[1], we don't violate the spec just to
avoid an endian swap.
Is there an actual bug you're trying to solve?
Yep. While retrieving this property in prom.c, no endian conversion is
being done.
It was broken for a while. Let me do the endian swap in prom.c while
retrieving..
Thanks
Hari
@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,*Fillinsomeinfosforusebythekernellateron*/if(prom_memory_limit){-__be64val=cpu_to_be64(prom_memory_limit);prom_setprop(prom.chosen,"/chosen","linux,memory-limit",-&val,sizeof(val));+&prom_memory_limit,sizeof(prom_memory_limit));}#ifdef CONFIG_PPC64if(prom_iommu_off)
From: Hari Bathini <hidden> Date: 2017-08-04 05:35:15
On Friday 04 August 2017 07:17 AM, Benjamin Herrenschmidt wrote:
On Fri, 2017-08-04 at 11:37 +1000, Benjamin Herrenschmidt wrote:
quoted
On Thu, 2017-08-03 at 14:54 +0530, Hari Bathini wrote:
quoted
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,*Fillinsomeinfosforusebythekernellateron*/if(prom_memory_limit){-__be64val=cpu_to_be64(prom_memory_limit);prom_setprop(prom.chosen,"/chosen","linux,memory-limit",-&val,sizeof(val));+&prom_memory_limit,sizeof(prom_memory_limit));}#ifdef CONFIG_PPC64if(prom_iommu_off)
NACK. The device-tree is big endian by convention
Also that probably breaks kexec.
Actually, mem= is broken for a while as endian conversion is done for
linux,memory-limit node
in prom_init.c but not in prom.c. Will post fix with endian conversion
done in prom.c..
Thanks
Hari
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-08-04 10:14:40
Hari Bathini [off-list ref] writes:
On Friday 04 August 2017 09:21 AM, Michael Ellerman wrote:
quoted
Hari Bathini [off-list ref] writes:
quoted
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
As Ben said, this is not OK. The flat device tree is a data
structure with a specified format[1], we don't violate the spec just to
avoid an endian swap.
Is there an actual bug you're trying to solve?
Yep. While retrieving this property in prom.c, no endian conversion is
being done.
It was broken for a while. Let me do the endian swap in prom.c while
retrieving..
Does it actually not work though, mem=x on the command line?
I think that code in prom.c is basically dead code, it's still there
because we were afraid removing it would break something. These days we
parse the command line early enough that we don't need those properties.
cheers
From: Hari Bathini <hidden> Date: 2017-08-04 18:39:00
On Friday 04 August 2017 03:44 PM, Michael Ellerman wrote:
Hari Bathini [off-list ref] writes:
quoted
On Friday 04 August 2017 09:21 AM, Michael Ellerman wrote:
quoted
Hari Bathini [off-list ref] writes:
quoted
As linux,memory-limit node is set and also later used by the kernel,
avoid endian conversions for this property.
Fixes: 493adffcb43f ("powerpc: Make prom_init.c endian safe")
Cc: stable@vger.kernel.org # 3.12+
Cc: Anton Blanchard <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Hari Bathini <redacted>
---
arch/powerpc/kernel/prom_init.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
As Ben said, this is not OK. The flat device tree is a data
structure with a specified format[1], we don't violate the spec just to
avoid an endian swap.
Is there an actual bug you're trying to solve?
Yep. While retrieving this property in prom.c, no endian conversion is
being done.
It was broken for a while. Let me do the endian swap in prom.c while
retrieving..
Does it actually not work though, mem=x on the command line?
mem=X works fine. The problem is with the early cmdline parsing of
'mem=' in prom_init, which is treating fadump_reserve_mem=X as
mem=X. So, when fadump_reserve_mem=X is passed, endian swapped
version of X is set to memory_limit as early parser takes it for mem=X
and linux,memory-limit read is not endian safe currently. This bug
was not hit so far as prom_memory_limit is set only when X is
< ram_top && > alloc_bottom which is not the case generally.
I think that code in prom.c is basically dead code, it's still there
because we were afraid removing it would break something. These days we
parse the command line early enough that we don't need those properties.
This problem is not seen with mem=X as memory_limit is overwritten
with the right value as soon as parse_early_param() is called in prom.
Should I just get rid of linux,memory-limit node and mem=X handling
from early_cmdline_parse() in prom_init as this has been broken for
a while and nobody seem to have had a problem with that?
Thanks
Hari