Re: [PATCH 1/4] powerpc/prom: avoid endian conversions for linux, memory-limit node
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
[1]: https://www.devicetree.org/quoted
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 613f79f..723df83 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c@@ -3180,9 +3180,8 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4, * Fill in some infos for use by the kernel later on */ if (prom_memory_limit) { - __be64 val = 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_PPC64 if (prom_iommu_off)