1 /* SPDX-License-Identifier: GPL-2.0-only */
5 #define COMPAT_UTS_MACHINE "riscv\0\0"
8 * Architecture specific compatibility types
10 #include <linux/types.h>
11 #include <linux/sched.h>
12 #include <linux/sched/task_stack.h>
13 #include <asm-generic/compat.h>
15 static inline int is_compat_task(void)
17 if (!IS_ENABLED(CONFIG_COMPAT
))
20 return test_thread_flag(TIF_32BIT
);
23 static inline int is_compat_thread(struct thread_info
*thread
)
25 if (!IS_ENABLED(CONFIG_COMPAT
))
28 return test_ti_thread_flag(thread
, TIF_32BIT
);
31 static inline void set_compat_task(bool is_compat
)
34 set_thread_flag(TIF_32BIT
);
36 clear_thread_flag(TIF_32BIT
);
39 struct compat_user_regs_struct
{
74 static inline void regs_to_cregs(struct compat_user_regs_struct
*cregs
,
77 cregs
->pc
= (compat_ulong_t
) regs
->epc
;
78 cregs
->ra
= (compat_ulong_t
) regs
->ra
;
79 cregs
->sp
= (compat_ulong_t
) regs
->sp
;
80 cregs
->gp
= (compat_ulong_t
) regs
->gp
;
81 cregs
->tp
= (compat_ulong_t
) regs
->tp
;
82 cregs
->t0
= (compat_ulong_t
) regs
->t0
;
83 cregs
->t1
= (compat_ulong_t
) regs
->t1
;
84 cregs
->t2
= (compat_ulong_t
) regs
->t2
;
85 cregs
->s0
= (compat_ulong_t
) regs
->s0
;
86 cregs
->s1
= (compat_ulong_t
) regs
->s1
;
87 cregs
->a0
= (compat_ulong_t
) regs
->a0
;
88 cregs
->a1
= (compat_ulong_t
) regs
->a1
;
89 cregs
->a2
= (compat_ulong_t
) regs
->a2
;
90 cregs
->a3
= (compat_ulong_t
) regs
->a3
;
91 cregs
->a4
= (compat_ulong_t
) regs
->a4
;
92 cregs
->a5
= (compat_ulong_t
) regs
->a5
;
93 cregs
->a6
= (compat_ulong_t
) regs
->a6
;
94 cregs
->a7
= (compat_ulong_t
) regs
->a7
;
95 cregs
->s2
= (compat_ulong_t
) regs
->s2
;
96 cregs
->s3
= (compat_ulong_t
) regs
->s3
;
97 cregs
->s4
= (compat_ulong_t
) regs
->s4
;
98 cregs
->s5
= (compat_ulong_t
) regs
->s5
;
99 cregs
->s6
= (compat_ulong_t
) regs
->s6
;
100 cregs
->s7
= (compat_ulong_t
) regs
->s7
;
101 cregs
->s8
= (compat_ulong_t
) regs
->s8
;
102 cregs
->s9
= (compat_ulong_t
) regs
->s9
;
103 cregs
->s10
= (compat_ulong_t
) regs
->s10
;
104 cregs
->s11
= (compat_ulong_t
) regs
->s11
;
105 cregs
->t3
= (compat_ulong_t
) regs
->t3
;
106 cregs
->t4
= (compat_ulong_t
) regs
->t4
;
107 cregs
->t5
= (compat_ulong_t
) regs
->t5
;
108 cregs
->t6
= (compat_ulong_t
) regs
->t6
;
111 static inline void cregs_to_regs(struct compat_user_regs_struct
*cregs
,
112 struct pt_regs
*regs
)
114 regs
->epc
= (unsigned long) cregs
->pc
;
115 regs
->ra
= (unsigned long) cregs
->ra
;
116 regs
->sp
= (unsigned long) cregs
->sp
;
117 regs
->gp
= (unsigned long) cregs
->gp
;
118 regs
->tp
= (unsigned long) cregs
->tp
;
119 regs
->t0
= (unsigned long) cregs
->t0
;
120 regs
->t1
= (unsigned long) cregs
->t1
;
121 regs
->t2
= (unsigned long) cregs
->t2
;
122 regs
->s0
= (unsigned long) cregs
->s0
;
123 regs
->s1
= (unsigned long) cregs
->s1
;
124 regs
->a0
= (unsigned long) cregs
->a0
;
125 regs
->a1
= (unsigned long) cregs
->a1
;
126 regs
->a2
= (unsigned long) cregs
->a2
;
127 regs
->a3
= (unsigned long) cregs
->a3
;
128 regs
->a4
= (unsigned long) cregs
->a4
;
129 regs
->a5
= (unsigned long) cregs
->a5
;
130 regs
->a6
= (unsigned long) cregs
->a6
;
131 regs
->a7
= (unsigned long) cregs
->a7
;
132 regs
->s2
= (unsigned long) cregs
->s2
;
133 regs
->s3
= (unsigned long) cregs
->s3
;
134 regs
->s4
= (unsigned long) cregs
->s4
;
135 regs
->s5
= (unsigned long) cregs
->s5
;
136 regs
->s6
= (unsigned long) cregs
->s6
;
137 regs
->s7
= (unsigned long) cregs
->s7
;
138 regs
->s8
= (unsigned long) cregs
->s8
;
139 regs
->s9
= (unsigned long) cregs
->s9
;
140 regs
->s10
= (unsigned long) cregs
->s10
;
141 regs
->s11
= (unsigned long) cregs
->s11
;
142 regs
->t3
= (unsigned long) cregs
->t3
;
143 regs
->t4
= (unsigned long) cregs
->t4
;
144 regs
->t5
= (unsigned long) cregs
->t5
;
145 regs
->t6
= (unsigned long) cregs
->t6
;
148 #endif /* __ASM_COMPAT_H */