hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/arch/riscv/include/asm/ptrace.h
....@@ -1,14 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2012 Regents of the University of California
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of the GNU General Public License
6
- * as published by the Free Software Foundation, version 2.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
124 */
135
146 #ifndef _ASM_RISCV_PTRACE_H
....@@ -20,7 +12,7 @@
2012 #ifndef __ASSEMBLY__
2113
2214 struct pt_regs {
23
- unsigned long sepc;
15
+ unsigned long epc;
2416 unsigned long ra;
2517 unsigned long sp;
2618 unsigned long gp;
....@@ -52,12 +44,12 @@
5244 unsigned long t4;
5345 unsigned long t5;
5446 unsigned long t6;
55
- /* Supervisor CSRs */
56
- unsigned long sstatus;
57
- unsigned long sbadaddr;
58
- unsigned long scause;
59
- /* a0 value before the syscall */
60
- unsigned long orig_a0;
47
+ /* Supervisor/Machine CSRs */
48
+ unsigned long status;
49
+ unsigned long badaddr;
50
+ unsigned long cause;
51
+ /* a0 value before the syscall */
52
+ unsigned long orig_a0;
6153 };
6254
6355 #ifdef CONFIG_64BIT
....@@ -66,51 +58,47 @@
6658 #define REG_FMT "%08lx"
6759 #endif
6860
69
-#define user_mode(regs) (((regs)->sstatus & SR_SPP) == 0)
61
+#define user_mode(regs) (((regs)->status & SR_PP) == 0)
7062
7163
7264 /* Helpers for working with the instruction pointer */
73
-#define GET_IP(regs) ((regs)->sepc)
74
-#define SET_IP(regs, val) (GET_IP(regs) = (val))
75
-
7665 static inline unsigned long instruction_pointer(struct pt_regs *regs)
7766 {
78
- return GET_IP(regs);
67
+ return regs->epc;
7968 }
8069 static inline void instruction_pointer_set(struct pt_regs *regs,
8170 unsigned long val)
8271 {
83
- SET_IP(regs, val);
72
+ regs->epc = val;
8473 }
8574
8675 #define profile_pc(regs) instruction_pointer(regs)
8776
8877 /* Helpers for working with the user stack pointer */
89
-#define GET_USP(regs) ((regs)->sp)
90
-#define SET_USP(regs, val) (GET_USP(regs) = (val))
91
-
9278 static inline unsigned long user_stack_pointer(struct pt_regs *regs)
9379 {
94
- return GET_USP(regs);
80
+ return regs->sp;
9581 }
9682 static inline void user_stack_pointer_set(struct pt_regs *regs,
9783 unsigned long val)
9884 {
99
- SET_USP(regs, val);
85
+ regs->sp = val;
10086 }
10187
10288 /* Helpers for working with the frame pointer */
103
-#define GET_FP(regs) ((regs)->s0)
104
-#define SET_FP(regs, val) (GET_FP(regs) = (val))
105
-
10689 static inline unsigned long frame_pointer(struct pt_regs *regs)
10790 {
108
- return GET_FP(regs);
91
+ return regs->s0;
10992 }
11093 static inline void frame_pointer_set(struct pt_regs *regs,
11194 unsigned long val)
11295 {
113
- SET_FP(regs, val);
96
+ regs->s0 = val;
97
+}
98
+
99
+static inline unsigned long regs_return_value(struct pt_regs *regs)
100
+{
101
+ return regs->a0;
114102 }
115103
116104 #endif /* __ASSEMBLY__ */