blob: bebcaf6e33239f97f9025b2476961dc6a2eda57e [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * linux/include/asm-arm/proc-armv/ptrace.h
3 *
4 * Copyright (C) 1996-1999 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef __ASM_PROC_PTRACE_H
11#define __ASM_PROC_PTRACE_H
12
David Feng85fd5f12013-12-14 11:47:35 +080013#ifdef CONFIG_ARM64
14
15#define PCMASK 0
16
17#ifndef __ASSEMBLY__
18
19/*
20 * This struct defines the way the registers are stored
21 * on the stack during an exception.
22 */
23struct pt_regs {
Sean Anderson2d755492022-03-22 17:17:35 -040024 unsigned long unused;
David Feng85fd5f12013-12-14 11:47:35 +080025 unsigned long elr;
Sean Anderson2d755492022-03-22 17:17:35 -040026 unsigned long esr;
David Feng85fd5f12013-12-14 11:47:35 +080027 unsigned long regs[31];
28};
29
30#endif /* __ASSEMBLY__ */
31
32#else /* CONFIG_ARM64 */
33
wdenkc6097192002-11-03 00:24:07 +000034#define USR26_MODE 0x00
35#define FIQ26_MODE 0x01
36#define IRQ26_MODE 0x02
37#define SVC26_MODE 0x03
38#define USR_MODE 0x10
39#define FIQ_MODE 0x11
40#define IRQ_MODE 0x12
41#define SVC_MODE 0x13
Stephen Warren039091c2018-06-22 13:03:16 -060042#define MON_MODE 0x16
wdenkc6097192002-11-03 00:24:07 +000043#define ABT_MODE 0x17
Marc Zyngier6b5b1292014-07-12 14:24:01 +010044#define HYP_MODE 0x1a
wdenkc6097192002-11-03 00:24:07 +000045#define UND_MODE 0x1b
46#define SYSTEM_MODE 0x1f
47#define MODE_MASK 0x1f
48#define T_BIT 0x20
49#define F_BIT 0x40
50#define I_BIT 0x80
Marc Zyngier6b5b1292014-07-12 14:24:01 +010051#define A_BIT 0x100
wdenkc6097192002-11-03 00:24:07 +000052#define CC_V_BIT (1 << 28)
53#define CC_C_BIT (1 << 29)
54#define CC_Z_BIT (1 << 30)
55#define CC_N_BIT (1 << 31)
56#define PCMASK 0
57
58#ifndef __ASSEMBLY__
59
60/* this struct defines the way the registers are stored on the
61 stack during a system call. */
62
63struct pt_regs {
64 long uregs[18];
65};
66
67#define ARM_cpsr uregs[16]
68#define ARM_pc uregs[15]
69#define ARM_lr uregs[14]
70#define ARM_sp uregs[13]
71#define ARM_ip uregs[12]
72#define ARM_fp uregs[11]
73#define ARM_r10 uregs[10]
74#define ARM_r9 uregs[9]
75#define ARM_r8 uregs[8]
76#define ARM_r7 uregs[7]
77#define ARM_r6 uregs[6]
78#define ARM_r5 uregs[5]
79#define ARM_r4 uregs[4]
80#define ARM_r3 uregs[3]
81#define ARM_r2 uregs[2]
82#define ARM_r1 uregs[1]
83#define ARM_r0 uregs[0]
84#define ARM_ORIG_r0 uregs[17]
85
wdenkc6097192002-11-03 00:24:07 +000086#ifdef __KERNEL__
87
88#define user_mode(regs) \
89 (((regs)->ARM_cpsr & 0xf) == 0)
90
Heinrich Schuchardt77587ca2019-06-23 12:59:31 +020091#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
wdenkc6097192002-11-03 00:24:07 +000092#define thumb_mode(regs) \
93 (((regs)->ARM_cpsr & T_BIT))
94#else
95#define thumb_mode(regs) (0)
96#endif
97
98#define processor_mode(regs) \
99 ((regs)->ARM_cpsr & MODE_MASK)
100
101#define interrupts_enabled(regs) \
102 (!((regs)->ARM_cpsr & I_BIT))
103
104#define fast_interrupts_enabled(regs) \
105 (!((regs)->ARM_cpsr & F_BIT))
106
107#define condition_codes(regs) \
108 ((regs)->ARM_cpsr & (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT))
109
110/* Are the current registers suitable for user mode?
111 * (used to maintain security in signal handlers)
112 */
113static inline int valid_user_regs(struct pt_regs *regs)
114{
115 if ((regs->ARM_cpsr & 0xf) == 0 &&
116 (regs->ARM_cpsr & (F_BIT|I_BIT)) == 0)
117 return 1;
118
119 /*
120 * Force CPSR to something logical...
121 */
122 regs->ARM_cpsr &= (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT|0x10);
123
124 return 0;
125}
126
127#endif /* __KERNEL__ */
128
129#endif /* __ASSEMBLY__ */
130
David Feng85fd5f12013-12-14 11:47:35 +0800131#endif /* CONFIG_ARM64 */
132
wdenkc6097192002-11-03 00:24:07 +0000133#endif