Skip to content

Commit 7a8818e

Browse files
iamjpnmpe
authored andcommitted
powerpc/optprobes: Add register argument to patch_imm64_load_insns()
Currently patch_imm32_load_insns() is used to load an instruction to r4 to be emulated by emulate_step(). For prefixed instructions we would like to be able to load a 64bit immediate to r4. To prepare for this make patch_imm64_load_insns() take an argument that decides which register to load an immediate to - rather than hardcoding r3. Signed-off-by: Jordan Niethe <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b691505 commit 7a8818e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

arch/powerpc/kernel/optprobes.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -162,38 +162,38 @@ void patch_imm32_load_insns(unsigned int val, kprobe_opcode_t *addr)
162162

163163
/*
164164
* Generate instructions to load provided immediate 64-bit value
165-
* to register 'r3' and patch these instructions at 'addr'.
165+
* to register 'reg' and patch these instructions at 'addr'.
166166
*/
167-
void patch_imm64_load_insns(unsigned long val, kprobe_opcode_t *addr)
167+
void patch_imm64_load_insns(unsigned long val, int reg, kprobe_opcode_t *addr)
168168
{
169-
/* lis r3,(op)@highest */
169+
/* lis reg,(op)@highest */
170170
patch_instruction((struct ppc_inst *)addr,
171-
ppc_inst(PPC_INST_ADDIS | ___PPC_RT(3) |
171+
ppc_inst(PPC_INST_ADDIS | ___PPC_RT(reg) |
172172
((val >> 48) & 0xffff)));
173173
addr++;
174174

175-
/* ori r3,r3,(op)@higher */
175+
/* ori reg,reg,(op)@higher */
176176
patch_instruction((struct ppc_inst *)addr,
177-
ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
178-
___PPC_RS(3) | ((val >> 32) & 0xffff)));
177+
ppc_inst(PPC_INST_ORI | ___PPC_RA(reg) |
178+
___PPC_RS(reg) | ((val >> 32) & 0xffff)));
179179
addr++;
180180

181-
/* rldicr r3,r3,32,31 */
181+
/* rldicr reg,reg,32,31 */
182182
patch_instruction((struct ppc_inst *)addr,
183-
ppc_inst(PPC_INST_RLDICR | ___PPC_RA(3) |
184-
___PPC_RS(3) | __PPC_SH64(32) | __PPC_ME64(31)));
183+
ppc_inst(PPC_INST_RLDICR | ___PPC_RA(reg) |
184+
___PPC_RS(reg) | __PPC_SH64(32) | __PPC_ME64(31)));
185185
addr++;
186186

187-
/* oris r3,r3,(op)@h */
187+
/* oris reg,reg,(op)@h */
188188
patch_instruction((struct ppc_inst *)addr,
189-
ppc_inst(PPC_INST_ORIS | ___PPC_RA(3) |
190-
___PPC_RS(3) | ((val >> 16) & 0xffff)));
189+
ppc_inst(PPC_INST_ORIS | ___PPC_RA(reg) |
190+
___PPC_RS(reg) | ((val >> 16) & 0xffff)));
191191
addr++;
192192

193-
/* ori r3,r3,(op)@l */
193+
/* ori reg,reg,(op)@l */
194194
patch_instruction((struct ppc_inst *)addr,
195-
ppc_inst(PPC_INST_ORI | ___PPC_RA(3) |
196-
___PPC_RS(3) | (val & 0xffff)));
195+
ppc_inst(PPC_INST_ORI | ___PPC_RA(reg) |
196+
___PPC_RS(reg) | (val & 0xffff)));
197197
}
198198

199199
int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
@@ -249,7 +249,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *p)
249249
* Fixup the template with instructions to:
250250
* 1. load the address of the actual probepoint
251251
*/
252-
patch_imm64_load_insns((unsigned long)op, buff + TMPL_OP_IDX);
252+
patch_imm64_load_insns((unsigned long)op, 3, buff + TMPL_OP_IDX);
253253

254254
/*
255255
* 2. branch to optimized_callback() and emulate_step()

0 commit comments

Comments
 (0)