mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Introduce a probe_user_read_inst() function to use in cases where probe_user_read() is used for getting an instruction. This will be more useful for prefixed instructions. Signed-off-by: Jordan Niethe <jniethe5@gmail.com> Reviewed-by: Alistair Popple <alistair@popple.id.au> [mpe: Don't write to *inst on error, fold in __user annotations] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200506034050.24806-14-jniethe5@gmail.com
43 lines
848 B
C
43 lines
848 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#ifndef _ASM_POWERPC_INST_H
|
|
#define _ASM_POWERPC_INST_H
|
|
|
|
/*
|
|
* Instruction data type for POWER
|
|
*/
|
|
|
|
struct ppc_inst {
|
|
u32 val;
|
|
} __packed;
|
|
|
|
#define ppc_inst(x) ((struct ppc_inst){ .val = x })
|
|
|
|
static inline u32 ppc_inst_val(struct ppc_inst x)
|
|
{
|
|
return x.val;
|
|
}
|
|
|
|
static inline int ppc_inst_primary_opcode(struct ppc_inst x)
|
|
{
|
|
return ppc_inst_val(x) >> 26;
|
|
}
|
|
|
|
static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x)
|
|
{
|
|
return ppc_inst(swab32(ppc_inst_val(x)));
|
|
}
|
|
|
|
static inline struct ppc_inst ppc_inst_read(const struct ppc_inst *ptr)
|
|
{
|
|
return *ptr;
|
|
}
|
|
|
|
static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
|
|
{
|
|
return ppc_inst_val(x) == ppc_inst_val(y);
|
|
}
|
|
|
|
int probe_user_read_inst(struct ppc_inst *inst,
|
|
struct ppc_inst __user *nip);
|
|
|
|
#endif /* _ASM_POWERPC_INST_H */
|