powerpc: Unify opcodes
RFC PATCH 1/1 powerpc: Unify opcodes
---
Wanted to get any feedback on this patch that unifies (or tries to) various opcode related functions into one file that we can use for emulation, code gen, and dealing with new insns old assemblers don't know about.
I've got a bit of cleanup in ppc_opcode.h but figured its good enough for review.
I'd like to get this into 2.6.29 if no one gripes too much.
- k
arch/powerpc/include/asm/code-patching.h | 4 +- arch/powerpc/include/asm/ppc_asm.h | 6 +-- arch/powerpc/include/asm/ppc_opcode.h | 62 ++++++++++++++++++++++++++++++ arch/powerpc/kernel/crash_dump.c | 2 +- arch/powerpc/kernel/ftrace.c | 8 ++-- arch/powerpc/kernel/module_64.c | 2 +- arch/powerpc/kernel/traps.c | 1 + arch/powerpc/lib/feature-fixups.c | 4 +- 8 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 arch/powerpc/include/asm/ppc_opcode.h
arch/powerpc/include/asm/code-patching.h +1 -3
@@ -11,9 +11,7 @@*/ #include <asm/types.h> - -#define PPC_NOP_INSTR 0x60000000 -#define PPC_LWSYNC_INSTR 0x7c2004ac +#include <asm/ppc_opcode.h> /* Flags for create_branch: * "b" == create_branch(addr, target, 0);
arch/powerpc/include/asm/ppc_asm.h +1 -5
@@ -7,6 +7,7 @@#include <linux/stringify.h> #include <asm/asm-compat.h> #include <asm/processor.h> +#include <asm/ppc_opcode.h> #ifndef __ASSEMBLY__#error __FILE__ should only be used in assembler files
@@ -167,11 +168,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \#define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority#define HMT_HIGH or 3,3,3 -/* handle instructions that older assemblers may not know */ -#define RFCI .long 0x4c000066/* rfci instruction */ -#define RFDI .long 0x4c00004e/* rfdi instruction */ -#define RFMCI .long 0x4c00004c/* rfmci instruction */ -#ifdef __KERNEL__#ifdef CONFIG_PPC64
arch/powerpc/include/asm/ppc_opcode.h new file +62 -0
62 lines not on this page · raw message
arch/powerpc/kernel/crash_dump.c +1 -1
@@ -48,7 +48,7 @@ static void __init create_trampoline(unsigned long addr)* branch to "addr" we jump to ("addr" + 32 MB). Although it requires * two instructions it doesn't require any registers. */ -patch_instruction (p,PPC_NOP_INSTR ); +patch_instruction (p,INST_NOP );patch_branch (++p, addr +PHYSICAL_START ,0 ); }
arch/powerpc/kernel/ftrace.c +4 -4
@@ -26,7 +26,7 @@#define DEBUGP (fmt , ...) do { } while (0)#endif -static unsigned int ftrace_nop =PPC_NOP_INSTR ; +static unsigned int ftrace_nop =INST_NOP ;#ifdef CONFIG_PPC32 # define GET_ADDR (addr) addr
@@ -319,7 +319,7 @@ __ftrace_make_nop(struct module *mod,return -EINVAL ; } - op =PPC_NOP_INSTR ; + op =INST_NOP ;if (probe_kernel_write ((void *)ip, &op,MCOUNT_INSN_SIZE ))return -EPERM ;
@@ -391,7 +391,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)* b +8; ld r2,40(r1) */ if (((op[0 ] !=0x48000008 ) || (op[1 ] !=0xe8410028 )) && - ((op[0 ] !=PPC_NOP_INSTR ) || (op[1 ] !=PPC_NOP_INSTR ))) { + ((op[0 ] !=INST_NOP ) || (op[1 ] !=INST_NOP ))) {printk (KERN_ERR "Expected NOPs but have %x %x\n" , op[0 ], op[1 ]);return -EINVAL ; }
@@ -434,7 +434,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)return -EFAULT ;/* It should be pointing to a nop */ -if (op !=PPC_NOP_INSTR ) { +if (op !=INST_NOP ) {printk (KERN_ERR "Expected NOP but have %x\n" , op);return -EINVAL ; }
arch/powerpc/kernel/module_64.c +1 -1
@@ -329,7 +329,7 @@ static unsigned long stub_for_addr(Elf64_Shdr *sechdrs,restore r2. */ static int restore_r2 (u32 *instruction,struct module *me) { -if (*instruction !=PPC_NOP_INSTR ) { +if (*instruction !=INST_NOP ) {printk ("%s: Expect noop after relocate, got %08x\n" , me->name, *instruction);return 0 ;
arch/powerpc/kernel/traps.c +1 -0
@@ -52,6 +52,7 @@#include <asm/processor.h> #endif #include <asm/kexec.h> +#include <asm/ppc_opcode.h> #if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC )int (*__debugger)(struct pt_regs *regs);
arch/powerpc/lib/feature-fixups.c +2 -2
@@ -85,7 +85,7 @@ static int patch_feature_section(unsigned long value, struct fixup_entry *fcur) }for (; dest < end; dest++) -patch_instruction (dest,PPC_NOP_INSTR ); +patch_instruction (dest,INST_NOP );return 0 ; }
@@ -122,7 +122,7 @@ void do_lwsync_fixups(unsigned long value, void *fixup_start, void *fixup_end)for (; start < end; start++) { dest = (void *)start + *start; -patch_instruction (dest,PPC_LWSYNC_INSTR ); +patch_instruction (dest,INST_LWSYNC ); } }
Signature · 1 line
1.5.6.5