On Mon, Oct 16, 2017 at 09:13:30AM -0700, David Daney wrote: > On 10/15/2017 11:53 PM, Simon Horman wrote: > > On Thu, Oct 12, 2017 at 02:02:25PM -0700, David Daney wrote: > > > Some kernel versions running on MIPS split the System RAM memory > > > regions reported in /proc/iomem. This may cause loading of the kexec > > > kernel to fail if it crosses one of the splits. > > > > > > Fix by merging adjacent memory ranges that have the same type. > > > > > > Signed-off-by: David Daney <david.daney@xxxxxxxxxx> > > > --- > > > kexec/arch/mips/kexec-mips.c | 14 ++++++++++---- > > > 1 file changed, 10 insertions(+), 4 deletions(-) > > > > > > diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c > > > index 2e5b700..415c2ed 100644 > > > --- a/kexec/arch/mips/kexec-mips.c > > > +++ b/kexec/arch/mips/kexec-mips.c > > > @@ -60,10 +60,16 @@ int get_memory_ranges(struct memory_range **range, int *ranges, > > > } else { > > > continue; > > > } > > > - memory_range[memory_ranges].start = start; > > > - memory_range[memory_ranges].end = end; > > > - memory_range[memory_ranges].type = type; > > > - memory_ranges++; > > > + if (memory_ranges > 0 && > > > > It seems that this will never merge the first memory range > > with subsequent ones. Is that intentional? > > > With the first range (index 0), no other range yet exists to merge with. We > can only test for merging with the second and subsequent ranges (indices 1 > and above). To do otherwise would cause us to read things from *before* the > beginning of the array ... Yes, of course. I see that now. I've applied this patch. > > > > > > > + memory_range[memory_ranges - 1].end == start && > > ... here. > > > > + memory_range[memory_ranges - 1].type == type) { > > > + memory_range[memory_ranges - 1].end = end; > > > + } else { > > > + memory_range[memory_ranges].start = start; > > > + memory_range[memory_ranges].end = end; > > > + memory_range[memory_ranges].type = type; > > > + memory_ranges++; > > > + } > > > } > > > fclose(fp); > > > *range = memory_range; > > > -- > > > 2.9.5 > > > > > > > > > _______________________________________________ > > > kexec mailing list > > > kexec@xxxxxxxxxxxxxxxxxxx > > > http://lists.infradead.org/mailman/listinfo/kexec > > > > > > _______________________________________________ > kexec mailing list > kexec@xxxxxxxxxxxxxxxxxxx > http://lists.infradead.org/mailman/listinfo/kexec >