[PATCH] armv8: mmu: don't panic when unmapping a page which isn't mapped

Ilias Apalodimas ilias.apalodimas at linaro.org
Tue Jun 23 11:17:30 CEST 2026


On Tue, 23 Jun 2026 at 12:07, Ilias Apalodimas
<ilias.apalodimas at linaro.org> wrote:
>
> On Fri, 12 Jun 2026 at 14:32, Casey Connolly <casey.connolly at linaro.org> wrote:
> >
> > If a caller tries to unmap a single page which is already part of an
> > unmapped block, set_one_region() will panic since there isn't a valid
> > block or table to contain the page. Detect this case explicitly and
> > return since no action needs to be taken.
> >
> > Signed-off-by: Casey Connolly <casey.connolly at linaro.org>
> > ---
> > Depends on my previous series which fixes unmapping regions
> >
> > https://lore.kernel.org/u-boot/20260608-b4-mmu-unmap-fixes-v6-0-ac0764cccf40@linaro.org/
> > ---
>
> Acked-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
>
> >  arch/arm/cpu/armv8/cache_v8.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
> > index 6c85022556ad..472887b5d99b 100644
> > --- a/arch/arm/cpu/armv8/cache_v8.c
> > +++ b/arch/arm/cpu/armv8/cache_v8.c
> > @@ -1003,8 +1003,13 @@ static u64 set_one_region(u64 start, u64 size, u64 attrs, bool flag, int level)
> >         int levelshift = level2shift(level);
> >         u64 levelsize = 1ULL << levelshift;
> >         u64 *pte = find_pte(start, level);
> >
> > +       /* Trying to unmap a region which is part of an already unmapped block, nothing to do */
> > +       if (pte_type(pte) == PTE_TYPE_FAULT && attrs == PTE_TYPE_FAULT && size < levelsize) {
> > +               return size;
> > +       }

On a second thought, you should check the size of the region as well.
What if the user starts from an unmapped region with size X but
requests to unmap a size Y with Y > X?

Thanks
/Ilias
> > +
> >         /* Can we can just modify the current level block/page? */
> >         if (is_aligned(start, size, levelsize)) {
> >                 if (attrs == PTE_TYPE_FAULT) {
> >                         if (pte_type(pte) == PTE_TYPE_TABLE && level < 3)
> > --
> > 2.53.0
> >


More information about the U-Boot mailing list