powerpc/mm/radix: Remove the retry in the split mapping logic
authorMichael Ellerman <mpe@ellerman.id.au>
Tue, 14 Aug 2018 12:01:44 +0000 (22:01 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 20 Oct 2018 02:26:47 +0000 (13:26 +1100)
commit57306c663d53f2e4fd856950703dc6bcfc98f7cb
tree5c85e4af8aa19092c2480c267f3c4b650b73629a
parent81d1b54dec95209ab5e5be2cf37182885f998753
powerpc/mm/radix: Remove the retry in the split mapping logic

When we have CONFIG_STRICT_KERNEL_RWX enabled, we want to split the
linear mapping at the text/data boundary so we can map the kernel
text read only.

The current logic uses a goto inside the for loop, which works, but is
hard to reason about.

When we hit the goto retry case we set max_mapping_size to PMD_SIZE
and go back to the start.

Setting max_mapping_size means we skip the PUD case and go to the PMD
case.

We know we will pass the alignment and gap checks because the only
reason we are there is we hit the goto retry, and that is guarded by
mapping_size == PUD_SIZE, which means addr is PUD aligned and gap is
greater or equal to PUD_SIZE.

So the only part of the check that can fail is the mmu_psize_defs
check for the 2M page size.

If we just duplicate that check we can avoid the goto, and we get the
same result.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/mm/pgtable-radix.c