]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: arm64: Drop sort_memblock_regions()
authorGavin Shan <gshan@redhat.com>
Tue, 11 Mar 2025 04:37:18 +0000 (14:37 +1000)
committerMarc Zyngier <maz@kernel.org>
Thu, 8 May 2025 10:29:45 +0000 (11:29 +0100)
Drop sort_memblock_regions() and avoid sorting the copied memory
regions to be ascending order on their base addresses, because the
source memory regions should have been sorted correctly when they
are added by memblock_add() or its variants.

This is generally reverting commit a14307f5310c ("KVM: arm64: Sort
the hypervisor memblocks"). No functional changes intended.

Signed-off-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Quentin Perret <qperret@google.com>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250311043718.91004-1-gshan@redhat.com
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/pkvm.c

index 0f89157d31fd6fbaacc3dc80f823524fe242686f..162d162ce8a6ebf45f2b4932ebf1d63e12020f29 100644 (file)
@@ -10,7 +10,6 @@
 #include <asm/kvm_mmu.h>
 #include <linux/memblock.h>
 #include <linux/mutex.h>
-#include <linux/sort.h>
 
 #include <asm/kvm_pkvm.h>
 
@@ -24,23 +23,6 @@ static unsigned int *hyp_memblock_nr_ptr = &kvm_nvhe_sym(hyp_memblock_nr);
 phys_addr_t hyp_mem_base;
 phys_addr_t hyp_mem_size;
 
-static int cmp_hyp_memblock(const void *p1, const void *p2)
-{
-       const struct memblock_region *r1 = p1;
-       const struct memblock_region *r2 = p2;
-
-       return r1->base < r2->base ? -1 : (r1->base > r2->base);
-}
-
-static void __init sort_memblock_regions(void)
-{
-       sort(hyp_memory,
-            *hyp_memblock_nr_ptr,
-            sizeof(struct memblock_region),
-            cmp_hyp_memblock,
-            NULL);
-}
-
 static int __init register_memblock_regions(void)
 {
        struct memblock_region *reg;
@@ -52,7 +34,6 @@ static int __init register_memblock_regions(void)
                hyp_memory[*hyp_memblock_nr_ptr] = *reg;
                (*hyp_memblock_nr_ptr)++;
        }
-       sort_memblock_regions();
 
        return 0;
 }