Skip to contentSkip to conversation

powerpc/mm/altmap: Fix altmap boundary check

PATCH Applied Aneesh Kumar K.V 3 participants 3 messages Jul 24, 2023 – Jul 29, 2023 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/mm/altmap: Fix altmap boundary check

altmap->free includes the entire free space from which altmap blocks can be allocated. So when checking whether the kernel is doing altmap block free, compute the boundary correctly.

Cc David Hildenbrand <[email protected]>
Cc Dan Williams <[email protected]>
Fixes 9ef34630a461 ("powerpc/mm: Fallback to RAM if the altmap is unusable")
---
 arch/powerpc/mm/init_64.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/mm/init_64.c +1 -2
index fe1b83020e0d..0ec5b45b1e86 100644
@@ -314,8 +314,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end,
 	start = ALIGN_DOWN(start, page_size);
 	if (altmap) {
 		alt_start = altmap->base_pfn;
-		alt_end = altmap->base_pfn + altmap->reserve +
-			  altmap->free + altmap->alloc + altmap->align;
+		alt_end = altmap->base_pfn + altmap->reserve + altmap->free;
 	}
 
 	pr_debug("vmemmap_free %lx...%lx\n", start, end);
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Aneesh Kumar K.V

altmap->free includes the entire free space from which altmap blocks can be allocated. So when checking whether the kernel is doing altmap block free, compute the boundary correctly.

Cc David Hildenbrand <[email protected]>
Cc Dan Williams <[email protected]>
Fixes 9ef34630a461 ("powerpc/mm: Fallback to RAM if the altmap is unusable")
---
  arch/powerpc/mm/init_64.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
arch/powerpc/mm/init_64.c +0 -0
index fe1b83020e0d..0ec5b45b1e86 100644

arch/powerpc/mm/init_64.c void __ref vmemmap_free(unsigned long start, unsigned long end, · line 317

Quoted 6 lines
arch/powerpc/mm/init_64.c +1 -2
@@ -314,8 +314,7 @@ void __ref vmemmap_free(unsigned long start, unsigned long end,
  	start = ALIGN_DOWN(start, page_size);
  	if (altmap) {
  		alt_start = altmap->base_pfn;
-		alt_end = altmap->base_pfn + altmap->reserve +
-			  altmap->free + altmap->alloc + altmap->align;
+		alt_end = altmap->base_pfn + altmap->reserve + altmap->free;

Right, align is treated like allocated and align+alloc cannot exceed free.

Signature · 3 lines
Cheers,

David / dhildenb