powerpc/nohash: Fix __ptep_set_access_flags() and ptep_set_wrprotect()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 26 Oct 2021 05:39:24 +0000 (07:39 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 27 Oct 2021 13:41:28 +0000 (00:41 +1100)
commitb1b93cb7e794e914787bf7d9936b57a149cdee4f
tree506cd2e2dfa5965f5d8f2bfdb9a5f0d0f92913f9
parent44a8214de96bafb5210e43bfa2c97c19bf75af3d
powerpc/nohash: Fix __ptep_set_access_flags() and ptep_set_wrprotect()

Commit 26973fa5ac0e ("powerpc/mm: use pte helpers in generic code")
changed those two functions to use pte helpers to determine which
bits to clear and which bits to set.

This change was based on the assumption that bits to be set/cleared
are always the same and can be determined by applying the pte
manipulation helpers on __pte(0).

But on platforms like book3e, the bits depend on whether the page
is a user page or not.

For the time being it more or less works because of _PAGE_EXEC being
used for user pages only and exec right being set at all time on
kernel page. But following patch will clean that and output of
pte_mkexec() will depend on the page being a user or kernel page.

Instead of trying to make an even more complicated helper where bits
would become dependent on the final pte value, come back to a more
static situation like before commit 26973fa5ac0e ("powerpc/mm: use
pte helpers in generic code"), by introducing an 8xx specific
version of __ptep_set_access_flags() and ptep_set_wrprotect().

Fixes: 26973fa5ac0e ("powerpc/mm: use pte helpers in generic code")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/922bdab3a220781bae2360ff3dd5adb7fe4d34f1.1635226743.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/nohash/32/pgtable.h
arch/powerpc/include/asm/nohash/32/pte-8xx.h