Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.8.
 1// SPDX-License-Identifier: GPL-2.0-or-later
 2/*
 3 *  Copyright 2020, IBM Corporation.
 4 */
 5
 6#include <linux/uaccess.h>
 7#include <asm/disassemble.h>
 8#include <asm/inst.h>
 9#include <asm/ppc-opcode.h>
10
11#ifdef CONFIG_PPC64
12int probe_user_read_inst(struct ppc_inst *inst,
13			 struct ppc_inst __user *nip)
14{
15	unsigned int val, suffix;
16	int err;
17
18	err = copy_from_user_nofault(&val, nip, sizeof(val));
19	if (err)
20		return err;
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);
24	} else {
25		*inst = ppc_inst(val);
26	}
27	return err;
28}
29
30int probe_kernel_read_inst(struct ppc_inst *inst,
31			   struct ppc_inst *src)
32{
33	unsigned int val, suffix;
34	int err;
35
36	err = copy_from_kernel_nofault(&val, src, sizeof(val));
37	if (err)
38		return err;
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);
42	} else {
43		*inst = ppc_inst(val);
44	}
45	return err;
46}
47#else /* !CONFIG_PPC64 */
48int probe_user_read_inst(struct ppc_inst *inst,
49			 struct ppc_inst __user *nip)
50{
51	unsigned int val;
52	int err;
53
54	err = copy_from_user_nofault(&val, nip, sizeof(val));
55	if (!err)
56		*inst = ppc_inst(val);
57
58	return err;
59}
60
61int probe_kernel_read_inst(struct ppc_inst *inst,
62			   struct ppc_inst *src)
63{
64	unsigned int val;
65	int err;
66
67	err = copy_from_kernel_nofault(&val, src, sizeof(val));
68	if (!err)
69		*inst = ppc_inst(val);
70
71	return err;
72}
73#endif /* CONFIG_PPC64 */