1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 2020, IBM Corporation.
6 #include <linux/uaccess.h>
7 #include <asm/disassemble.h>
9 #include <asm/ppc-opcode.h>
12 int probe_user_read_inst(struct ppc_inst
*inst
,
13 struct ppc_inst __user
*nip
)
15 unsigned int val
, suffix
;
18 err
= copy_from_user_nofault(&val
, nip
, sizeof(val
));
21 if (get_op(val
) == OP_PREFIX
) {
22 err
= copy_from_user_nofault(&suffix
, (void __user
*)nip
+ 4, 4);
23 *inst
= ppc_inst_prefix(val
, suffix
);
25 *inst
= ppc_inst(val
);
30 int probe_kernel_read_inst(struct ppc_inst
*inst
,
33 unsigned int val
, suffix
;
36 err
= copy_from_kernel_nofault(&val
, src
, sizeof(val
));
39 if (get_op(val
) == OP_PREFIX
) {
40 err
= copy_from_kernel_nofault(&suffix
, (void *)src
+ 4, 4);
41 *inst
= ppc_inst_prefix(val
, suffix
);
43 *inst
= ppc_inst(val
);
47 #else /* !CONFIG_PPC64 */
48 int probe_user_read_inst(struct ppc_inst
*inst
,
49 struct ppc_inst __user
*nip
)
54 err
= copy_from_user_nofault(&val
, nip
, sizeof(val
));
56 *inst
= ppc_inst(val
);
61 int probe_kernel_read_inst(struct ppc_inst
*inst
,
67 err
= copy_from_kernel_nofault(&val
, src
, sizeof(val
));
69 *inst
= ppc_inst(val
);
73 #endif /* CONFIG_PPC64 */