diff options
author | Christophe Leroy <christophe.leroy@c-s.fr> | 2018-11-09 17:33:17 +0000 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-12-19 18:56:32 +1100 |
commit | 36b08b431e2e282f78d09921ca55652d2c55eee5 (patch) | |
tree | 33cb6b2464db86caaa9493d91223bae99fc45316 /arch/powerpc/include/asm/code-patching.h | |
parent | 45090c26614fe991d9d5a2cd08e65c4d6680549a (diff) | |
download | lwn-36b08b431e2e282f78d09921ca55652d2c55eee5.tar.gz lwn-36b08b431e2e282f78d09921ca55652d2c55eee5.zip |
powerpc: add modify_instruction() and modify_instruction_site()
Add two helpers to avoid hardcoding of instructions modifications.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/include/asm/code-patching.h')
-rw-r--r-- | arch/powerpc/include/asm/code-patching.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h index 0eeed21e4898..2074b40f3fb5 100644 --- a/arch/powerpc/include/asm/code-patching.h +++ b/arch/powerpc/include/asm/code-patching.h @@ -49,6 +49,17 @@ static inline int patch_branch_site(s32 *site, unsigned long target, int flags) return patch_branch((unsigned int *)patch_site_addr(site), target, flags); } +static inline int modify_instruction(unsigned int *addr, unsigned int clr, + unsigned int set) +{ + return patch_instruction(addr, (*addr & ~clr) | set); +} + +static inline int modify_instruction_site(s32 *site, unsigned int clr, unsigned int set) +{ + return modify_instruction((unsigned int *)patch_site_addr(site), clr, set); +} + int instr_is_relative_branch(unsigned int instr); int instr_is_relative_link_branch(unsigned int instr); int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr); |