Re: [PATCH v4 09/14] mm: add ability to take further action in vm_area_desc

Lorenzo Stoakes
2025-09-18T09:14:57Z

Hi Andrew,

Finally could you apply the below, which has us return an error in case of
somebody implementing a buggy nommu action.

I also include a fix for the VMA unit tests where an enum declare was not
correctly propagated.

Cheers, Lorenzo

----8<----
From 17c8037bc3bfd5cdd52369dc6140d0fbbd03480d Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Date: Thu, 18 Sep 2025 08:08:31 +0100
Subject: [PATCH] fixup: return error on broken path, update vma_internal.h

Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
mm/util.c | 6 ++++--
tools/testing/vma/vma_internal.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/util.c b/mm/util.c
index 0c1c68285675..30ed284bb819 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1385,17 +1385,19 @@ EXPORT_SYMBOL(mmap_action_prepare);
int mmap_action_complete(struct mmap_action *action,
struct vm_area_struct *vma)
{
+ int err = 0;
+
switch (action->type) {
case MMAP_NOTHING:
break;
case MMAP_REMAP_PFN:
case MMAP_IO_REMAP_PFN:
WARN_ON_ONCE(1); /* nommu cannot handle this. */
-
+ err = -EINVAL;
break;
}

- return mmap_action_finish(action, vma, /* err = */0);
+ return mmap_action_finish(action, vma, err);
}
EXPORT_SYMBOL(mmap_action_complete);
#endif
diff --git a/tools/testing/vma/vma_internal.h b/tools/testing/vma/vma_internal.h
index 22ed38e8714e..d5028e5e905b 100644
--- a/tools/testing/vma/vma_internal.h
+++ b/tools/testing/vma/vma_internal.h
@@ -279,6 +279,7 @@ struct vm_area_struct;
enum mmap_action_type {
MMAP_NOTHING, /* Mapping is complete, no further action. */
MMAP_REMAP_PFN, /* Remap PFN range. */
+ MMAP_IO_REMAP_PFN, /* I/O remap PFN range. */
};

/*
--
2.51.0