From: Andrea Arcangeli <redacted>
[ Upstream commit 03800e0526ee25ed7c843ca1e57b69ac2a5af642 ]
25078dc1f74be16b858e914f52cc8f4d03c2271a first introduced an off by
one error in the ZONE_DMA initialization of PPC_BOOK3E_64=y and since
9739ab7eda459f0669ec9807e0d9be5020bab88c the off by one applies to
PPC32=y too. This simply corrects the off by one and should resolve
crashes like below:
[ 65.179101] page 0x7fff outside node 0 zone DMA [ 0x0 - 0x7fff ]
Unfortunately in various MM places "max" means a non inclusive end of
range. free_area_init_nodes max_zone_pfn parameter is one case and
MAX_ORDER is another one (unrelated) that comes by memory.
Reported-by: Zorro Lang <redacted>
Fixes: 25078dc1f74b ("powerpc: use mm zones more sensibly")
Fixes: 9739ab7eda45 ("powerpc: enable a 30-bit ZONE_DMA for 32-bit pmac")
Signed-off-by: Andrea Arcangeli <redacted>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190625141727.2883-1-aarcange@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/mm/mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Vaibhav Jain <redacted>
[ Upstream commit 3a855b7ac7d5021674aa3e1cc9d3bfd6b604e9c0 ]
In some cases initial bind of scm memory for an lpar can fail if
previously it wasn't released using a scm-unbind hcall. This situation
can arise due to panic of the previous kernel or forced lpar
fadump. In such cases the H_SCM_BIND_MEM return a H_OVERLAP error.
To mitigate such cases the patch updates papr_scm_probe() to force a
call to drc_pmem_unbind() in case the initial bind of scm memory fails
with EBUSY error. In case scm-bind operation again fails after the
forced scm-unbind then we follow the existing error path. We also
update drc_pmem_bind() to handle the H_OVERLAP error returned by phyp
and indicate it as a EBUSY error back to the caller.
Suggested-by: "Oliver O'Halloran" <oohall@gmail.com>
Signed-off-by: Vaibhav Jain <redacted>
Reviewed-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190629160610.23402-4-vaibhav@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/platforms/pseries/papr_scm.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
@@ -63,6 +64,10 @@ static int drc_pmem_bind(struct papr_scm_priv *p)}while(rc==H_BUSY);if(rc){+/* H_OVERLAP needs a separate error path */+if(rc==H_OVERLAP)+return-EBUSY;+dev_err(&p->pdev->dev,"bind err: %lld\n",rc);return-ENXIO;}
@@ -316,6 +321,14 @@ static int papr_scm_probe(struct platform_device *pdev)/* request the hypervisor to bind this region to somewhere in memory */rc=drc_pmem_bind(p);++/* If phyp says drc memory still bound then force unbound and retry */+if(rc==-EBUSY){+dev_warn(&pdev->dev,"Retrying bind after unbinding\n");+drc_pmem_unbind(p);+rc=drc_pmem_bind(p);+}+if(rc)gotoerr;
From: Wen Yang <redacted>
[ Upstream commit e0a12445d1cb186d875410d093a00d215bec6a89 ]
The cpu variable is still being used in the of_get_property() call
after the of_node_put() call, which may result in use-after-free.
Fixes: a9acc26b75f6 ("cpufreq/pasemi: fix possible object reference leak")
Signed-off-by: Wen Yang <redacted>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <redacted>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/cpufreq/pasemi-cpufreq.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
@@ -131,10 +131,18 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)interr=-ENODEV;cpu=of_get_cpu_node(policy->cpu,NULL);+if(!cpu)+gotoout;+max_freqp=of_get_property(cpu,"clock-frequency",NULL);of_node_put(cpu);-if(!cpu)+if(!max_freqp){+err=-EINVAL;gotoout;+}++/* we need the freq in kHz */+max_freq=*max_freqp/1000;dn=of_find_compatible_node(NULL,NULL,"1682m-sdc");if(!dn)
@@ -171,16 +179,6 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)}pr_debug("init cpufreq on CPU %d\n",policy->cpu);--max_freqp=of_get_property(cpu,"clock-frequency",NULL);-if(!max_freqp){-err=-EINVAL;-gotoout_unmap_sdcpwr;-}--/* we need the freq in kHz */-max_freq=*max_freqp/1000;-pr_debug("max clock-frequency is at %u kHz\n",max_freq);pr_debug("initializing frequency table\n");
@@ -198,9 +196,6 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)returncpufreq_generic_init(policy,pas_freqs,get_gizmo_latency());-out_unmap_sdcpwr:-iounmap(sdcpwr_mapbase);-out_unmap_sdcasr:iounmap(sdcasr_mapbase);out: