@@ -553,9 +553,9 @@ int get_usable_memory_ranges(struct crash_mem **mem_ranges)
553553#endif /* CONFIG_KEXEC_FILE */
554554
555555#ifdef CONFIG_CRASH_DUMP
556- static int crash_exclude_mem_range_guarded (struct crash_mem * * mem_ranges ,
557- unsigned long long mstart ,
558- unsigned long long mend )
556+ int arch_crash_exclude_mem_range (struct crash_mem * * mem_ranges ,
557+ unsigned long long mstart ,
558+ unsigned long long mend )
559559{
560560 struct crash_mem * tmem = * mem_ranges ;
561561
@@ -604,18 +604,10 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges)
604604 sort_memory_ranges (* mem_ranges , true);
605605 }
606606
607- /* Exclude crashkernel region */
608- ret = crash_exclude_mem_range_guarded (mem_ranges , crashk_res .start , crashk_res .end );
607+ ret = crash_exclude_core_ranges (mem_ranges );
609608 if (ret )
610609 goto out ;
611610
612- for (i = 0 ; i < crashk_cma_cnt ; ++ i ) {
613- ret = crash_exclude_mem_range_guarded (mem_ranges , crashk_cma_ranges [i ].start ,
614- crashk_cma_ranges [i ].end );
615- if (ret )
616- goto out ;
617- }
618-
619611 /*
620612 * FIXME: For now, stay in parity with kexec-tools but if RTAS/OPAL
621613 * regions are exported to save their context at the time of
@@ -641,89 +633,4 @@ int get_crash_memory_ranges(struct crash_mem **mem_ranges)
641633 pr_err ("Failed to setup crash memory ranges\n" );
642634 return ret ;
643635}
644-
645- /**
646- * remove_mem_range - Removes the given memory range from the range list.
647- * @mem_ranges: Range list to remove the memory range to.
648- * @base: Base address of the range to remove.
649- * @size: Size of the memory range to remove.
650- *
651- * (Re)allocates memory, if needed.
652- *
653- * Returns 0 on success, negative errno on error.
654- */
655- int remove_mem_range (struct crash_mem * * mem_ranges , u64 base , u64 size )
656- {
657- u64 end ;
658- int ret = 0 ;
659- unsigned int i ;
660- u64 mstart , mend ;
661- struct crash_mem * mem_rngs = * mem_ranges ;
662-
663- if (!size )
664- return 0 ;
665-
666- /*
667- * Memory range are stored as start and end address, use
668- * the same format to do remove operation.
669- */
670- end = base + size - 1 ;
671-
672- for (i = 0 ; i < mem_rngs -> nr_ranges ; i ++ ) {
673- mstart = mem_rngs -> ranges [i ].start ;
674- mend = mem_rngs -> ranges [i ].end ;
675-
676- /*
677- * Memory range to remove is not part of this range entry
678- * in the memory range list
679- */
680- if (!(base >= mstart && end <= mend ))
681- continue ;
682-
683- /*
684- * Memory range to remove is equivalent to this entry in the
685- * memory range list. Remove the range entry from the list.
686- */
687- if (base == mstart && end == mend ) {
688- for (; i < mem_rngs -> nr_ranges - 1 ; i ++ ) {
689- mem_rngs -> ranges [i ].start = mem_rngs -> ranges [i + 1 ].start ;
690- mem_rngs -> ranges [i ].end = mem_rngs -> ranges [i + 1 ].end ;
691- }
692- mem_rngs -> nr_ranges -- ;
693- goto out ;
694- }
695- /*
696- * Start address of the memory range to remove and the
697- * current memory range entry in the list is same. Just
698- * move the start address of the current memory range
699- * entry in the list to end + 1.
700- */
701- else if (base == mstart ) {
702- mem_rngs -> ranges [i ].start = end + 1 ;
703- goto out ;
704- }
705- /*
706- * End address of the memory range to remove and the
707- * current memory range entry in the list is same.
708- * Just move the end address of the current memory
709- * range entry in the list to base - 1.
710- */
711- else if (end == mend ) {
712- mem_rngs -> ranges [i ].end = base - 1 ;
713- goto out ;
714- }
715- /*
716- * Memory range to remove is not at the edge of current
717- * memory range entry. Split the current memory entry into
718- * two half.
719- */
720- else {
721- size = mem_rngs -> ranges [i ].end - end + 1 ;
722- mem_rngs -> ranges [i ].end = base - 1 ;
723- ret = add_mem_range (mem_ranges , end + 1 , size );
724- }
725- }
726- out :
727- return ret ;
728- }
729636#endif /* CONFIG_CRASH_DUMP */
0 commit comments