Re: [PATCH] x86/mm/pti: Handle unaligned addr to PMD-mapped page in pti_clone_pgtable

From: Linus Torvalds
Date: Mon Sep 23 2019 - 14:12:50 EST


On Mon, Sep 23, 2019 at 4:28 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> I'm conflicted on this one... the only use of addr here is
> pti_user_pagetable_walk_pmd() and that already masks things, so the
> fixup is 'pointless'.

No it's not.

The *other* use of 'addr' is

addr += PMD_SIZE;

and then repeat the loop.

And that repeat might then use it for the page-level case the next iteration.

> Also the location is weird; we'd want to do alignment enforcement before
> we commence the for-loop, methinks.

No. See again. The alignment is different for the different cases
inside the loop. Some do per-page stuff, some do per-pmd stuff, and
some do per-pud stuff.

And you don't know which you'll hit a-priori (because it's not limited
to the 'level' testing).

Linus