Subject: linux-next: build failure after merge of the akpm-current tree

From: Stephen Rothwell <[email-masked]>
Date: Mon, 14 Feb 2022 18:00:40 +1100

Hi all,

After merging the akpm-current tree, today's linux-next build (powerpc
allyesconfig) failed like this:

arch/powerpc/kvm/book3s_hv_uvmem.c: In function 'kvmppc_uvmem_get_page':
arch/powerpc/kvm/book3s_hv_uvmem.c:691:39: error: invalid use of undefined type 'struct dev_pagemap'
  691 |         pfn_first = kvmppc_uvmem_pgmap.range.start >> PAGE_SHIFT;
      |                                       ^
arch/powerpc/kvm/book3s_hv_uvmem.c:693:50: error: invalid use of undefined type 'struct dev_pagemap'
  693 |                    (range_len(&kvmppc_uvmem_pgmap.range) >> PAGE_SHIFT);
      |                                                  ^
arch/powerpc/kvm/book3s_hv_uvmem.c: In function 'kvmppc_uvmem_page_free':
arch/powerpc/kvm/book3s_hv_uvmem.c:1010:44: error: invalid use of undefined type 'struct dev_pagemap'
 1010 |                         (kvmppc_uvmem_pgmap.range.start >> PAGE_SHIFT);
      |                                            ^
arch/powerpc/kvm/book3s_hv_uvmem.c: At top level:
arch/powerpc/kvm/book3s_hv_uvmem.c:1026:21: error: variable 'kvmppc_uvmem_ops' has initializer but incomplete type
 1026 | static const struct dev_pagemap_ops kvmppc_uvmem_ops = {
      |                     ^~~~~~~~~~~~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1027:10: error: 'const struct dev_pagemap_ops' has no member named 'page_free'
 1027 |         .page_free = kvmppc_uvmem_page_free,
      |          ^~~~~~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1027:22: error: excess elements in struct initializer [-Werror]
 1027 |         .page_free = kvmppc_uvmem_page_free,
      |                      ^~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1027:22: note: (near initialization for 'kvmppc_uvmem_ops')
arch/powerpc/kvm/book3s_hv_uvmem.c:1028:10: error: 'const struct dev_pagemap_ops' has no member named 'migrate_to_ram'
 1028 |         .migrate_to_ram = kvmppc_uvmem_migrate_to_ram,
      |          ^~~~~~~~~~~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1028:27: error: excess elements in struct initializer [-Werror]
 1028 |         .migrate_to_ram = kvmppc_uvmem_migrate_to_ram,
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1028:27: note: (near initialization for 'kvmppc_uvmem_ops')
arch/powerpc/kvm/book3s_hv_uvmem.c: In function 'kvmppc_uvmem_init':
arch/powerpc/kvm/book3s_hv_uvmem.c:1172:27: error: invalid use of undefined type 'struct dev_pagemap'
 1172 |         kvmppc_uvmem_pgmap.type = MEMORY_DEVICE_PRIVATE;
      |                           ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1172:35: error: 'MEMORY_DEVICE_PRIVATE' undeclared (first use in this function); did you mean 'CONFIG_DEVICE_PRIVATE'?
 1172 |         kvmppc_uvmem_pgmap.type = MEMORY_DEVICE_PRIVATE;
      |                                   ^~~~~~~~~~~~~~~~~~~~~
      |                                   CONFIG_DEVICE_PRIVATE
arch/powerpc/kvm/book3s_hv_uvmem.c:1172:35: note: each undeclared identifier is reported only once for each function it appears in
arch/powerpc/kvm/book3s_hv_uvmem.c:1173:27: error: invalid use of undefined type 'struct dev_pagemap'
 1173 |         kvmppc_uvmem_pgmap.range.start = res->start;
      |                           ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1174:27: error: invalid use of undefined type 'struct dev_pagemap'
 1174 |         kvmppc_uvmem_pgmap.range.end = res->end;
      |                           ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1175:27: error: invalid use of undefined type 'struct dev_pagemap'
 1175 |         kvmppc_uvmem_pgmap.nr_range = 1;
      |                           ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1176:27: error: invalid use of undefined type 'struct dev_pagemap'
 1176 |         kvmppc_uvmem_pgmap.ops = &kvmppc_uvmem_ops;
      |                           ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1178:27: error: invalid use of undefined type 'struct dev_pagemap'
 1178 |         kvmppc_uvmem_pgmap.owner = &kvmppc_uvmem_pgmap;
      |                           ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1179:16: error: implicit declaration of function 'memremap_pages'; did you mean 'memcmp_pages'? [-Werror=implicit-function-declaration]
 1179 |         addr = memremap_pages(&kvmppc_uvmem_pgmap, NUMA_NO_NODE);
      |                ^~~~~~~~~~~~~~
      |                memcmp_pages
arch/powerpc/kvm/book3s_hv_uvmem.c:1179:14: error: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion]
 1179 |         addr = memremap_pages(&kvmppc_uvmem_pgmap, NUMA_NO_NODE);
      |              ^
arch/powerpc/kvm/book3s_hv_uvmem.c:1197:9: error: implicit declaration of function 'memunmap_pages'; did you mean 'memcmp_pages'? [-Werror=implicit-function-declaration]
 1197 |         memunmap_pages(&kvmppc_uvmem_pgmap);
      |         ^~~~~~~~~~~~~~
      |         memcmp_pages
In file included from include/linux/device.h:17,
                 from arch/powerpc/include/asm/io.h:27,
                 from include/linux/io.h:13,
                 from include/linux/irq.h:20,
                 from arch/powerpc/include/asm/hardirq.h:6,
                 from include/linux/hardirq.h:11,
                 from include/linux/highmem.h:11,
                 from include/linux/pagemap.h:11,
                 from arch/powerpc/kvm/book3s_hv_uvmem.c:89:
arch/powerpc/kvm/book3s_hv_uvmem.c: In function 'kvmppc_uvmem_free':
arch/powerpc/kvm/book3s_hv_uvmem.c:1210:46: error: invalid use of undefined type 'struct dev_pagemap'
 1210 |         release_mem_region(kvmppc_uvmem_pgmap.range.start,
      |                                              ^
include/linux/ioport.h:278:76: note: in definition of macro 'release_mem_region'
  278 | #define release_mem_region(start,n)     __release_region(&iomem_resource, (start), (n))
      |                                                                            ^~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1211:57: error: invalid use of undefined type 'struct dev_pagemap'
 1211 |                            range_len(&kvmppc_uvmem_pgmap.range));
      |                                                         ^
include/linux/ioport.h:278:85: note: in definition of macro 'release_mem_region'
  278 | #define release_mem_region(start,n)     __release_region(&iomem_resource, (start), (n))
      |                                                                                     ^
arch/powerpc/kvm/book3s_hv_uvmem.c: At top level:
arch/powerpc/kvm/book3s_hv_uvmem.c:99:27: error: storage size of 'kvmppc_uvmem_pgmap' isn't known
   99 | static struct dev_pagemap kvmppc_uvmem_pgmap;
      |                           ^~~~~~~~~~~~~~~~~~
arch/powerpc/kvm/book3s_hv_uvmem.c:1026:37: error: storage size of 'kvmppc_uvmem_ops' isn't known
 1026 | static const struct dev_pagemap_ops kvmppc_uvmem_ops = {
      |                                     ^~~~~~~~~~~~~~~~

Presumably caused by commit

  5ba71dc7727a ("mm: don't include <linux/memremap.h> in <linux/mm.h>")

I applied the following patch:

From: Stephen Rothwell <[email-masked]>
Date: Mon, 14 Feb 2022 17:47:53 +1100
Subject: [PATCH] fix for "mm: don't include <linux/memremap.h> in
 <linux/mm.h>"

Signed-off-by: Stephen Rothwell <[email-masked]>
---
 arch/powerpc/kvm/book3s_hv_uvmem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c
index 8b6438fa18fc..8cabdb39cbbc 100644
--- a/arch/powerpc/kvm/book3s_hv_uvmem.c
+++ b/arch/powerpc/kvm/book3s_hv_uvmem.c
@@ -91,6 +91,7 @@
 #include <linux/kvm_host.h>
 #include <linux/ksm.h>
 #include <linux/of.h>
+#include <linux/memremap.h>
 #include <asm/ultravisor.h>
 #include <asm/mman.h>
 #include <asm/kvm_ppc.h>
-- 
2.34.1

-- 
Cheers,
Stephen Rothwell