Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/inst: ppc_inst_as_u64() becomes ppc_inst_as_ulong()

In order to simplify use on PPC32, change ppc_inst_as_u64()
into ppc_inst_as_ulong() that returns the 32 bits instruction
on PPC32.

Will be used when porting OPTPROBES to PPC32.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/22cadf29620664b600b82026d2a72b8b23351777.1618927318.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
693557eb e5223311

+10 -9
+7 -6
arch/powerpc/include/asm/inst.h
··· 147 147 return location + ppc_inst_len(tmp); 148 148 } 149 149 150 - static inline u64 ppc_inst_as_u64(struct ppc_inst x) 150 + static inline unsigned long ppc_inst_as_ulong(struct ppc_inst x) 151 151 { 152 - #ifdef CONFIG_CPU_LITTLE_ENDIAN 153 - return (u64)ppc_inst_suffix(x) << 32 | ppc_inst_val(x); 154 - #else 155 - return (u64)ppc_inst_val(x) << 32 | ppc_inst_suffix(x); 156 - #endif 152 + if (IS_ENABLED(CONFIG_PPC32)) 153 + return ppc_inst_val(x); 154 + else if (IS_ENABLED(CONFIG_CPU_LITTLE_ENDIAN)) 155 + return (u64)ppc_inst_suffix(x) << 32 | ppc_inst_val(x); 156 + else 157 + return (u64)ppc_inst_val(x) << 32 | ppc_inst_suffix(x); 157 158 } 158 159 159 160 #define PPC_INST_STR_LEN sizeof("00000000 00000000")
+1 -1
arch/powerpc/kernel/optprobes.c
··· 264 264 * 3. load instruction to be emulated into relevant register, and 265 265 */ 266 266 temp = ppc_inst_read((struct ppc_inst *)p->ainsn.insn); 267 - patch_imm64_load_insns(ppc_inst_as_u64(temp), 4, buff + TMPL_INSN_IDX); 267 + patch_imm64_load_insns(ppc_inst_as_ulong(temp), 4, buff + TMPL_INSN_IDX); 268 268 269 269 /* 270 270 * 4. branch back from trampoline
+1 -1
arch/powerpc/lib/code-patching.c
··· 26 26 27 27 __put_kernel_nofault(patch_addr, &val, u32, failed); 28 28 } else { 29 - u64 val = ppc_inst_as_u64(instr); 29 + u64 val = ppc_inst_as_ulong(instr); 30 30 31 31 __put_kernel_nofault(patch_addr, &val, u64, failed); 32 32 }
+1 -1
arch/powerpc/xmon/xmon.c
··· 2953 2953 if (!ppc_inst_prefixed(inst)) 2954 2954 dump_func(ppc_inst_val(inst), adr); 2955 2955 else 2956 - dump_func(ppc_inst_as_u64(inst), adr); 2956 + dump_func(ppc_inst_as_ulong(inst), adr); 2957 2957 printf("\n"); 2958 2958 } 2959 2959 return adr - first_adr;