powerpc/code-patching: introduce patch_instructions()
authorHari Bathini <hbathini@linux.ibm.com>
Fri, 20 Oct 2023 14:13:54 +0000 (19:43 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 23 Oct 2023 09:33:19 +0000 (20:33 +1100)
commit465cabc97b42405eb89380ea6ba8d8b03e4ae1a2
treea4b39c07640dcee39428de047bb6cf2c3cbccad4
parentaad26d3b6af13c055b1d05dd253d2484551bde55
powerpc/code-patching: introduce patch_instructions()

patch_instruction() entails setting up pte, patching the instruction,
clearing the pte and flushing the tlb. If multiple instructions need
to be patched, every instruction would have to go through the above
drill unnecessarily. Instead, introduce patch_instructions() function
that sets up the pte, clears the pte and flushes the tlb only once
per page range of instructions to be patched. Duplicate most of the
patch_instruction() code instead of merging with it, to avoid the
performance degradation observed on ppc32, for patch_instruction(),
with the code path merged. Also, setup poking_init() always as BPF
expects poking_init() to be setup even when STRICT_KERNEL_RWX is off.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231020141358.643575-2-hbathini@linux.ibm.com
arch/powerpc/include/asm/code-patching.h
arch/powerpc/lib/code-patching.c