We already add the start_pad to the resource->start but fails to section align the start. This make sure with altmap we compute the right first pfn when start_pad is zero and we are doing an align down of start address. vmem_altmap_offset() adjust the section aligned base_pfn offset. So we need to make sure we account for the same when computing base_pfn. ie, for altmap_valid case, our pfn_first should be: pfn_first = altmap->base_pfn + vmem_altmap_offset(altmap); Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxx> --- kernel/memremap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/memremap.c b/kernel/memremap.c index 1490e63f69a9..bf488b8658e7 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -60,9 +60,11 @@ static unsigned long pfn_first(struct dev_pagemap *pgmap) struct vmem_altmap *altmap = &pgmap->altmap; unsigned long pfn; - pfn = res->start >> PAGE_SHIFT; - if (pgmap->altmap_valid) - pfn += vmem_altmap_offset(altmap); + if (pgmap->altmap_valid) { + pfn = altmap->base_pfn + vmem_altmap_offset(altmap); + } else + pfn = PHYS_PFN(res->start); + return pfn; } -- 2.21.0