powerpc/64s: Fix stf mitigation patching w/strict RWX & hash
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 13 May 2021 14:08:00 +0000 (00:08 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 14 May 2021 07:27:37 +0000 (17:27 +1000)
commit5b48ba2fbd77bc68feebd336ffad5ff166782bde
treee87e6b90e7fa12a56f765b7cd181939ecaad1d6b
parent49b39ec248af863781a13aa6d81c5f69a2928094
powerpc/64s: Fix stf mitigation patching w/strict RWX & hash

The stf entry barrier fallback is unsafe to execute in a semi-patched
state, which can happen when enabling/disabling the mitigation with
strict kernel RWX enabled and using the hash MMU.

See the previous commit for more details.

Fix it by changing the order in which we patch the instructions.

Note the stf barrier fallback is only used on Power6 or earlier.

Fixes: bd573a81312f ("powerpc/mm/64s: Allow STRICT_KERNEL_RWX again")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210513140800.1391706-2-mpe@ellerman.id.au
arch/powerpc/lib/feature-fixups.c