powerpc: Make probe_kernel_read_inst() common to PPC32 and PPC64
We have two independant versions of probe_kernel_read_inst(), one for PPC32 and one for PPC64. The PPC32 is identical to the first part of the PPC64 version. The remaining part of PPC64 version is not relevant for PPC32, but not contradictory, so we can easily have a common function with the PPC64 part opted out via a IS_ENABLED(CONFIG_PPC64). The only need is to add a version of ppc_inst_prefix() for 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/f7b9dfddef3b3760182c7e5466356c121a293dc9.1618405715.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
6ac7897f08
commit
6449078d50
@ -102,6 +102,8 @@ static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
|
||||
|
||||
#define ppc_inst(x) ((struct ppc_inst){ .val = x })
|
||||
|
||||
#define ppc_inst_prefix(x, y) ppc_inst(x)
|
||||
|
||||
static inline bool ppc_inst_prefixed(struct ppc_inst x)
|
||||
{
|
||||
return false;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <asm/inst.h>
|
||||
#include <asm/ppc-opcode.h>
|
||||
|
||||
#ifdef CONFIG_PPC64
|
||||
int probe_kernel_read_inst(struct ppc_inst *inst,
|
||||
struct ppc_inst *src)
|
||||
{
|
||||
@ -18,7 +17,7 @@ int probe_kernel_read_inst(struct ppc_inst *inst,
|
||||
err = copy_from_kernel_nofault(&val, src, sizeof(val));
|
||||
if (err)
|
||||
return err;
|
||||
if (get_op(val) == OP_PREFIX) {
|
||||
if (IS_ENABLED(CONFIG_PPC64) && get_op(val) == OP_PREFIX) {
|
||||
err = copy_from_kernel_nofault(&suffix, (void *)src + 4, 4);
|
||||
*inst = ppc_inst_prefix(val, suffix);
|
||||
} else {
|
||||
@ -26,17 +25,3 @@ int probe_kernel_read_inst(struct ppc_inst *inst,
|
||||
}
|
||||
return err;
|
||||
}
|
||||
#else /* !CONFIG_PPC64 */
|
||||
int probe_kernel_read_inst(struct ppc_inst *inst,
|
||||
struct ppc_inst *src)
|
||||
{
|
||||
unsigned int val;
|
||||
int err;
|
||||
|
||||
err = copy_from_kernel_nofault(&val, src, sizeof(val));
|
||||
if (!err)
|
||||
*inst = ppc_inst(val);
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_PPC64 */
|
||||
|
Loading…
Reference in New Issue
Block a user