Linux Audio

Check our new training course

Loading...
Note: File does not exist in v5.4.
 1// SPDX-License-Identifier: GPL-2.0-only
 2
 3#include <linux/uaccess.h>
 4#include <linux/kernel.h>
 5
 6#include <asm/disassemble.h>
 7#include <asm/inst.h>
 8#include <asm/ppc-opcode.h>
 9
10bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size)
11{
12	return is_kernel_addr((unsigned long)unsafe_src);
13}
14
15int copy_inst_from_kernel_nofault(struct ppc_inst *inst, u32 *src)
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) {
24		err = copy_from_kernel_nofault(&suffix, src + 1, sizeof(suffix));
25		*inst = ppc_inst_prefix(val, suffix);
26	} else {
27		*inst = ppc_inst(val);
28	}
29	return err;
30}