powerpc: Unify opcode definitions and support
PATCH v3 1/1 powerpc: Unify opcode definitions and support
Create a new header that becomes a single location for defining PowerPC opcodes used by code that is either generationg instructions at runtime (fixups, debug, etc.), emulating instructions, or just compiling instructions old assemblers don't know about.
We currently don't handle the floating point emulation or alignment decode as both are better handled by the specific decode support they already have.
Added support for the new dcbzl, dcbal, msgsnd, tlbilx, & wait instructions since older assemblers don't know about them.
---
* Added PPC_ prefixes to everything to ensure namespace
* removed defines from traps.c
arch/powerpc/include/asm/code-patching.h | 4 +- arch/powerpc/include/asm/ppc-opcode.h | 68 ++++++++++++++++++++++++++++++ arch/powerpc/include/asm/ppc_asm.h | 6 +-- arch/powerpc/kernel/crash_dump.c | 2 +- arch/powerpc/kernel/entry_32.S | 8 ++-- arch/powerpc/kernel/ftrace.c | 8 ++-- arch/powerpc/kernel/head_booke.h | 2 +- arch/powerpc/kernel/module_64.c | 2 +- arch/powerpc/kernel/traps.c | 58 ++++++++----------------- arch/powerpc/lib/feature-fixups.c | 4 +- 10 files changed, 101 insertions(+), 61 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-opcode.h new file +68 -0
68 lines not on this page · raw message
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/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,PPC_INST_NOP );patch_branch (++p, addr +PHYSICAL_START ,0 ); }
arch/powerpc/kernel/entry_32.S +4 -4
@@ -956,7 +956,7 @@ ret_from_crit_exc: lwz r10,crit_srr1@l(r10); mtspr SPRN_SRR0,r9; mtspr SPRN_SRR1,r10; - RET_FROM_EXC_LEVEL(SPRN_CSRR0, SPRN_CSRR1, RFCI) + RET_FROM_EXC_LEVEL(SPRN_CSRR0, SPRN_CSRR1, PPC_RFCI) #endif /* CONFIG_40x */ #ifdef CONFIG_BOOKE
@@ -967,7 +967,7 @@ ret_from_crit_exc: stw r10,KSP_LIMIT(r9) RESTORE_xSRR(SRR0,SRR1); RESTORE_MMU_REGS; - RET_FROM_EXC_LEVEL(SPRN_CSRR0, SPRN_CSRR1, RFCI) + RET_FROM_EXC_LEVEL(SPRN_CSRR0, SPRN_CSRR1, PPC_RFCI) .globl ret_from_debug_exc ret_from_debug_exc:
@@ -981,7 +981,7 @@ ret_from_debug_exc: RESTORE_xSRR(SRR0,SRR1); RESTORE_xSRR(CSRR0,CSRR1); RESTORE_MMU_REGS; - RET_FROM_EXC_LEVEL(SPRN_DSRR0, SPRN_DSRR1, RFDI) + RET_FROM_EXC_LEVEL(SPRN_DSRR0, SPRN_DSRR1, PPC_RFDI) .globl ret_from_mcheck_exc ret_from_mcheck_exc:
@@ -992,7 +992,7 @@ ret_from_mcheck_exc: RESTORE_xSRR(CSRR0,CSRR1); RESTORE_xSRR(DSRR0,DSRR1); RESTORE_MMU_REGS; - RET_FROM_EXC_LEVEL(SPRN_MCSRR0, SPRN_MCSRR1, RFMCI) + RET_FROM_EXC_LEVEL(SPRN_MCSRR0, SPRN_MCSRR1, PPC_RFMCI) #endif /* CONFIG_BOOKE */ /*
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 =PPC_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 =PPC_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 ] !=PPC_INST_NOP ) || (op[1 ] !=PPC_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 !=PPC_INST_NOP ) {printk (KERN_ERR "Expected NOP but have %x\n" , op);return -EINVAL ; }
arch/powerpc/kernel/head_booke.h +1 -1
@@ -279,7 +279,7 @@ label:lwz r11,GPR11 (r8 ); \mfspr r8,DEBUG_SPRG ; \ \ -RFDI ; \ +PPC_RFDI ; \ b .; \ \/* continue normal handling for a debug exception... */ \
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 !=PPC_INST_NOP ) {printk ("%s: Expect noop after relocate, got %08x\n" , me->name, *instruction);return 0 ;
arch/powerpc/kernel/traps.c +18 -40
124 lines not on this page · raw message
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,PPC_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,PPC_INST_LWSYNC ); } }
Signature · 1 line
1.5.6.6
Quoted 17 lines · Kumar Gala
Create a new header that becomes a single location for defining PowerPC opcodes used by code that is either generationg instructions at runtime (fixups, debug, etc.), emulating instructions, or just compiling instructions old assemblers don't know about.
We currently don't handle the floating point emulation or alignment decode as both are better handled by the specific decode support they already have.
Added support for the new dcbzl, dcbal, msgsnd, tlbilx, & wait instructions since older assemblers don't know about them.
Signed-off-by Kumar Gala <[email protected]>---
* AddedPPC_prefixes to everything to ensure namespace
* removed defines fromtraps.c
Quoted 12 lines
arch/powerpc/include/asm/code-patching.h | 4 +- arch/powerpc/include/asm/ppc-opcode.h | 68 ++++++++++++++++++++++++++++++ arch/powerpc/include/asm/ppc_asm.h | 6 +-- arch/powerpc/kernel/crash_dump.c | 2 +- arch/powerpc/kernel/entry_32.S | 8 ++-- arch/powerpc/kernel/ftrace.c | 8 ++-- arch/powerpc/kernel/head_booke.h | 2 +- arch/powerpc/kernel/module_64.c | 2 +- arch/powerpc/kernel/traps.c | 58 ++++++++----------------- arch/powerpc/lib/feature-fixups.c | 4 +- 10 files changed, 101 insertions(+), 61 deletions(-) create mode 100644 arch/powerpc/include/asm/ppc-opcode.h
Shouldn't arch/powerpc/include/asm/disassemble.h be integrated with this?
-Hollis