Commit | Line | Data |
---|---|---|
5eedf9fe CL |
1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | ||
3 | #include <linux/uaccess.h> | |
4 | #include <linux/kernel.h> | |
5 | ||
39352430 CL |
6 | #include <asm/disassemble.h> |
7 | #include <asm/inst.h> | |
8 | #include <asm/ppc-opcode.h> | |
9 | ||
5eedf9fe CL |
10 | bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) |
11 | { | |
12 | return is_kernel_addr((unsigned long)unsafe_src); | |
13 | } | |
39352430 | 14 | |
c545b9f0 | 15 | int copy_inst_from_kernel_nofault(ppc_inst_t *inst, u32 *src) |
39352430 CL |
16 | { |
17 | unsigned int val, suffix; | |
18 | int err; | |
19 | ||
20 | err = copy_from_kernel_nofault(&val, src, sizeof(val)); | |
21 | if (err) | |
22 | return err; | |
23 | if (IS_ENABLED(CONFIG_PPC64) && get_op(val) == OP_PREFIX) { | |
69d4d6e5 | 24 | err = copy_from_kernel_nofault(&suffix, src + 1, sizeof(suffix)); |
39352430 CL |
25 | *inst = ppc_inst_prefix(val, suffix); |
26 | } else { | |
27 | *inst = ppc_inst(val); | |
28 | } | |
29 | return err; | |
30 | } |