summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel/ptrace-ppc64.h
blob: e450ce01392ba2818ed8ffab78c4617c8aa92711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 *    Copyright (c) 2002 Stephen Rothwell, IBM Coproration
 *    Extracted from ptrace.c and ptrace32.c
 *
 * This file is subject to the terms and conditions of the GNU General
 * Public License.  See the file README.legal in the main directory of
 * this archive for more details.
 */

#ifndef _POWERPC_PTRACE_PPC64_H
#define _POWERPC_PTRACE_PPC64_H

/*
 * Set of msr bits that gdb can change on behalf of a process.
 */
#define MSR_DEBUGCHANGE	(MSR_FE0 | MSR_SE | MSR_BE | MSR_FE1)

/*
 * Max register writeable via put_reg
 */
#define PT_MAX_PUT_REG	PT_CCR

/*
 * Munging of MSR on return from get_regs
 *
 * Put the correct FP bits in, they might be wrong as a result
 * of our lazy FP restore.
 */

#define PT_MUNGE_MSR(msr, task)	({ (msr) | (task)->thread.fpexc_mode; })

static inline int ptrace_set_debugreg(struct task_struct *task,
				      unsigned long addr, unsigned long data)
{
	/* We only support one DABR and no IABRS at the moment */
	if (addr > 0)
		return -EINVAL;

	/* The bottom 3 bits are flags */
	if ((data & ~0x7UL) >= TASK_SIZE)
		return -EIO;

	/* Ensure translation is on */
	if (data && !(data & DABR_TRANSLATION))
		return -EIO;

	task->thread.dabr = data;
	return 0;
}

#endif /* _POWERPC_PTRACE_PPC64_H */