Re: Linux-next-20200302: arm64 build failed

Mike Rapoport
2020-03-02T13:54:55Z

On Mon, Mar 02, 2020 at 10:47:27AM +0000, Will Deacon wrote:
> [+Anshuman and Catalin]
>
> On Mon, Mar 02, 2020 at 01:58:26PM +0530, Naresh Kamboju wrote:
> > Linux-Next 20200302 arm64 build failed due to below errors,
> > Suspecting patch causing this build break.
> >
> > 87d900aef3e2 arm/arm64: add support for folded p4d page tables
> >
> > Error log,
> > -------------
> > arch/arm64/mm/mmu.c: In function 'unmap_hotplug_pud_range':
> > include/linux/compiler.h:284:1: error: incompatible type for argument
> > 1 of 'p4d_page_paddr'
> > ({ \
> > ^
> > arch/arm64/include/asm/memory.h:270:45: note: in definition of macro
> > '__phys_to_virt'
> > #define __phys_to_virt(x) ((unsigned long)((x) - physvirt_offset))
> > ^
> > arch/arm64/include/asm/pgtable.h:629:42: note: in expansion of macro '__va'
> > #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr))))
> > ^~~~
> > include/linux/compiler.h:293:22: note: in expansion of macro '__READ_ONCE'
> > #define READ_ONCE(x) __READ_ONCE(x, 1)
> > ^~~~~~~~~~~
> > arch/arm64/include/asm/pgtable.h:628:52: note: in expansion of macro 'READ_ONCE'
> > #define pud_offset_phys(dir, addr) (p4d_page_paddr(READ_ONCE(*(dir)))
> > + pud_index(addr) * sizeof(pud_t))
> > ^~~~~~~~~
> > arch/arm64/include/asm/pgtable.h:629:47: note: in expansion of macro
> > 'pud_offset_phys'
> > #define pud_offset(dir, addr) ((pud_t *)__va(pud_offset_phys((dir), (addr))))
> > ^~~~~~~~~~~~~~~
> > arch/arm64/mm/mmu.c:827:10: note: in expansion of macro 'pud_offset'
> > pudp = pud_offset(pgdp, addr);
> > ^~~~~~~~~~
>
> Looks like we need an implementation of unmap_hotplug_p4d_range() to
> walk the dummy p4d level. Unfortunately, we don't have the folded p4d
> patches in the arm64 tree so we'll either need a common branch or the
> hotplug patches will need to be dropped for the moment.

unmap_hotplug_p4d_range() is easy :)

From c7a5d08ff51ca2057b6b0289c4423bdfd7643518 Mon Sep 17 00:00:00 2001
From: Mike Rapoport <rppt@linux.ibm.com>
Date: Mon, 2 Mar 2020 15:53:17 +0200
Subject: [PATCH] arm64/mm: implement unmap_hotplug_p4d_range

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
arch/arm64/mm/mmu.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 05ec8e5f1436..c76b11577558 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -840,6 +840,24 @@ static void unmap_hotplug_pud_range(pgd_t *pgdp, unsigned long addr,
} while (addr = next, addr < end);
}

+static void unmap_hotplug_p4d_range(pgd_t *pgd, unsigned long addr,
+ unsigned long end, bool free_mapped)
+{
+ unsigned long next;
+ pgd_t *p4dp, p4d;
+
+ do {
+ next = p4d_addr_end(addr, end);
+ p4dp = p4d_offset(pgd, addr);
+ p4d = READ_ONCE(*p4dp);
+ if (p4d_none(p4d))
+ continue;
+
+ WARN_ON(!p4d_present(p4d));
+ unmap_hotplug_pud_range(p4dp, addr, next, free_mapped);
+ } while (addr = next, addr < end);
+}
+
static void unmap_hotplug_range(unsigned long addr, unsigned long end,
bool free_mapped)
{
@@ -854,7 +872,7 @@ static void unmap_hotplug_range(unsigned long addr, unsigned long end,
continue;

WARN_ON(!pgd_present(pgd));
- unmap_hotplug_pud_range(pgdp, addr, next, free_mapped);
+ unmap_hotplug_p4d_range(pgdp, addr, next, free_mapped);
} while (addr = next, addr < end);
}

--
2.21.1

> Will

--
Sincerely yours,
Mike.