diff options
author | Christophe Leroy <christophe.leroy@csgroup.eu> | 2021-12-02 13:00:27 +0100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2021-12-23 12:36:58 +0100 |
commit | 309a0a601864831510209531dd72da486225d8ae (patch) | |
tree | ab21cc80e9167a39c3bb6130d79fc637032d3d42 /arch/powerpc/include/asm/inst.h | |
parent | powerpc/code-patching: Move code patching selftests in its own file (diff) | |
download | linux-309a0a601864831510209531dd72da486225d8ae.tar.xz linux-309a0a601864831510209531dd72da486225d8ae.zip |
powerpc/code-patching: Replace patch_instruction() by ppc_inst_write() in selftests
The purpose of selftests is to check that instructions are
properly formed. Not to check that they properly run.
For that test it uses normal memory, not special test
memory.
In preparation of a future patch enforcing patch_instruction()
to be used only on valid text areas, implement a ppc_inst_write()
instruction which is the complement of ppc_inst_read(). This
new function writes the formated instruction in valid kernel
memory and doesn't bother about icache.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/7cf5335cc07ca9b6f8cdaa20ca9887fce4df3bea.1638446239.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/include/asm/inst.h')
-rw-r--r-- | arch/powerpc/include/asm/inst.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h index 95e5243d2997..80b6d74146c6 100644 --- a/arch/powerpc/include/asm/inst.h +++ b/arch/powerpc/include/asm/inst.h @@ -131,6 +131,14 @@ static inline unsigned long ppc_inst_as_ulong(ppc_inst_t x) return (u64)ppc_inst_val(x) << 32 | ppc_inst_suffix(x); } +static inline void ppc_inst_write(u32 *ptr, ppc_inst_t x) +{ + if (!ppc_inst_prefixed(x)) + *ptr = ppc_inst_val(x); + else + *(u64 *)ptr = ppc_inst_as_ulong(x); +} + #define PPC_INST_STR_LEN sizeof("00000000 00000000") static inline char *__ppc_inst_as_str(char str[PPC_INST_STR_LEN], ppc_inst_t x) |