mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
powerpc: Don't use 'struct ppc_inst' to reference instruction location
'struct ppc_inst' is an internal representation of an instruction, but in-memory instructions are and will remain a table of 'u32' forever. Replace all 'struct ppc_inst *' used for locating an instruction in memory by 'u32 *'. This removes a lot of undue casts to 'struct ppc_inst *'. It also helps locating ab-use of 'struct ppc_inst' dereference. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> [mpe: Fix ppc_inst_next(), use u32 instead of unsigned int] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/7062722b087228e42cbd896e39bfdf526d6a340a.1621516826.git.christophe.leroy@csgroup.eu
This commit is contained in:
committed by
Michael Ellerman
parent
e90a21ea80
commit
69d4d6e5fd
@@ -23,13 +23,13 @@
|
||||
#define BRANCH_ABSOLUTE 0x2
|
||||
|
||||
bool is_offset_in_branch_range(long offset);
|
||||
int create_branch(struct ppc_inst *instr, const struct ppc_inst *addr,
|
||||
int create_branch(struct ppc_inst *instr, const u32 *addr,
|
||||
unsigned long target, int flags);
|
||||
int create_cond_branch(struct ppc_inst *instr, const struct ppc_inst *addr,
|
||||
int create_cond_branch(struct ppc_inst *instr, const u32 *addr,
|
||||
unsigned long target, int flags);
|
||||
int patch_branch(struct ppc_inst *addr, unsigned long target, int flags);
|
||||
int patch_instruction(struct ppc_inst *addr, struct ppc_inst instr);
|
||||
int raw_patch_instruction(struct ppc_inst *addr, struct ppc_inst instr);
|
||||
int patch_branch(u32 *addr, unsigned long target, int flags);
|
||||
int patch_instruction(u32 *addr, struct ppc_inst instr);
|
||||
int raw_patch_instruction(u32 *addr, struct ppc_inst instr);
|
||||
|
||||
static inline unsigned long patch_site_addr(s32 *site)
|
||||
{
|
||||
@@ -38,18 +38,18 @@ static inline unsigned long patch_site_addr(s32 *site)
|
||||
|
||||
static inline int patch_instruction_site(s32 *site, struct ppc_inst instr)
|
||||
{
|
||||
return patch_instruction((struct ppc_inst *)patch_site_addr(site), instr);
|
||||
return patch_instruction((u32 *)patch_site_addr(site), instr);
|
||||
}
|
||||
|
||||
static inline int patch_branch_site(s32 *site, unsigned long target, int flags)
|
||||
{
|
||||
return patch_branch((struct ppc_inst *)patch_site_addr(site), target, flags);
|
||||
return patch_branch((u32 *)patch_site_addr(site), target, flags);
|
||||
}
|
||||
|
||||
static inline int modify_instruction(unsigned int *addr, unsigned int clr,
|
||||
unsigned int set)
|
||||
{
|
||||
return patch_instruction((struct ppc_inst *)addr, ppc_inst((*addr & ~clr) | set));
|
||||
return patch_instruction(addr, ppc_inst((*addr & ~clr) | set));
|
||||
}
|
||||
|
||||
static inline int modify_instruction_site(s32 *site, unsigned int clr, unsigned int set)
|
||||
@@ -59,9 +59,8 @@ static inline int modify_instruction_site(s32 *site, unsigned int clr, unsigned
|
||||
|
||||
int instr_is_relative_branch(struct ppc_inst instr);
|
||||
int instr_is_relative_link_branch(struct ppc_inst instr);
|
||||
unsigned long branch_target(const struct ppc_inst *instr);
|
||||
int translate_branch(struct ppc_inst *instr, const struct ppc_inst *dest,
|
||||
const struct ppc_inst *src);
|
||||
unsigned long branch_target(const u32 *instr);
|
||||
int translate_branch(struct ppc_inst *instr, const u32 *dest, const u32 *src);
|
||||
extern bool is_conditional_branch(struct ppc_inst instr);
|
||||
#ifdef CONFIG_PPC_BOOK3E_64
|
||||
void __patch_exception(int exc, unsigned long addr);
|
||||
|
||||
Reference in New Issue
Block a user