OSDN Git Service

powerpc: Use a function for byte swapping instructions
authorJordan Niethe <jniethe5@gmail.com>
Wed, 6 May 2020 03:40:29 +0000 (13:40 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 18 May 2020 14:10:37 +0000 (00:10 +1000)
Use a function for byte swapping instructions in preparation of a more
complicated instruction type.

Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Balamuruhan S <bala24@linux.ibm.com>
Link: https://lore.kernel.org/r/20200506034050.24806-10-jniethe5@gmail.com
arch/powerpc/include/asm/inst.h
arch/powerpc/kernel/align.c

index 09b4ec7..ff2c8fe 100644 (file)
@@ -18,4 +18,9 @@ static inline int ppc_inst_primary_opcode(u32 x)
        return ppc_inst_val(x) >> 26;
 }
 
+static inline u32 ppc_inst_swab(u32 x)
+{
+       return ppc_inst(swab32(ppc_inst_val(x)));
+}
+
 #endif /* _ASM_POWERPC_INST_H */
index 47dbba8..a63216d 100644 (file)
@@ -310,7 +310,7 @@ int fix_alignment(struct pt_regs *regs)
                /* We don't handle PPC little-endian any more... */
                if (cpu_has_feature(CPU_FTR_PPC_LE))
                        return -EIO;
-               instr = swab32(instr);
+               instr = ppc_inst_swab(instr);
        }
 
 #ifdef CONFIG_SPE