Re: BUG: unable to handle page fault for address - EIP: __kmap_local_page_prot

From: Peter Zijlstra
Date: Wed May 19 2021 - 15:25:58 EST


On Wed, May 19, 2021 at 08:50:54PM +0200, Thomas Gleixner wrote:
> On Wed, May 19 2021 at 20:38, Naresh Kamboju wrote:
> > While running LTP mm test suite on i386 kernel the following warning and BUG
> > reported on linux next 5.13.0-rc2-next-20210519.
> >
> > The warning is not regression, We have been noticing these warnings often on
> > i386
>
> Noticing? Did you report them?
>
> > but kernel BUG: looks to be a new crash.
>
> It's just the consequence of the problem which is pointed out by the
> warning. Fix below.

Maybe something like so as well?

---
mm/mremap.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/mm/mremap.c b/mm/mremap.c
index 47c255b60150..477a908bdb6b 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -210,6 +210,10 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
}

#ifdef CONFIG_HAVE_MOVE_PMD
+#if CONFIG_PGTABLE_LEVELS < 2
+#error "Can't very well move non-existant pgtable levels"
+#endif
+
static bool move_normal_pmd(struct vm_area_struct *vma, unsigned long old_addr,
unsigned long new_addr, pmd_t *old_pmd, pmd_t *new_pmd)
{
@@ -277,6 +281,10 @@ static inline bool move_normal_pmd(struct vm_area_struct *vma,
#endif

#ifdef CONFIG_HAVE_MOVE_PUD
+#if CONFIG_PGTABLE_LEVELS < 3
+#error "Can't very well move non-existant pgtable levels"
+#endif
+
static bool move_normal_pud(struct vm_area_struct *vma, unsigned long old_addr,
unsigned long new_addr, pud_t *old_pud, pud_t *new_pud)
{