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 <asm-generic/compat.h>
14 static inline int is_compat_task(void)
16 if (!IS_ENABLED(CONFIG_COMPAT
))
19 return test_thread_flag(TIF_32BIT
);
22 static inline int is_compat_thread(struct thread_info
*thread
)
24 if (!IS_ENABLED(CONFIG_COMPAT
))
27 return test_ti_thread_flag(thread
, TIF_32BIT
);
30 static inline void set_compat_task(bool is_compat
)
33 set_thread_flag(TIF_32BIT
);
35 clear_thread_flag(TIF_32BIT
);
38 struct compat_user_regs_struct
{
73 static inline void regs_to_cregs(struct compat_user_regs_struct
*cregs
,
76 cregs
->pc
= (compat_ulong_t
) regs
->epc
;
77 cregs
->ra
= (compat_ulong_t
) regs
->ra
;
78 cregs
->sp
= (compat_ulong_t
) regs
->sp
;
79 cregs
->gp
= (compat_ulong_t
) regs
->gp
;
80 cregs
->tp
= (compat_ulong_t
) regs
->tp
;
81 cregs
->t0
= (compat_ulong_t
) regs
->t0
;
82 cregs
->t1
= (compat_ulong_t
) regs
->t1
;
83 cregs
->t2
= (compat_ulong_t
) regs
->t2
;
84 cregs
->s0
= (compat_ulong_t
) regs
->s0
;
85 cregs
->s1
= (compat_ulong_t
) regs
->s1
;
86 cregs
->a0
= (compat_ulong_t
) regs
->a0
;
87 cregs
->a1
= (compat_ulong_t
) regs
->a1
;
88 cregs
->a2
= (compat_ulong_t
) regs
->a2
;
89 cregs
->a3
= (compat_ulong_t
) regs
->a3
;
90 cregs
->a4
= (compat_ulong_t
) regs
->a4
;
91 cregs
->a5
= (compat_ulong_t
) regs
->a5
;
92 cregs
->a6
= (compat_ulong_t
) regs
->a6
;
93 cregs
->a7
= (compat_ulong_t
) regs
->a7
;
94 cregs
->s2
= (compat_ulong_t
) regs
->s2
;
95 cregs
->s3
= (compat_ulong_t
) regs
->s3
;
96 cregs
->s4
= (compat_ulong_t
) regs
->s4
;
97 cregs
->s5
= (compat_ulong_t
) regs
->s5
;
98 cregs
->s6
= (compat_ulong_t
) regs
->s6
;
99 cregs
->s7
= (compat_ulong_t
) regs
->s7
;
100 cregs
->s8
= (compat_ulong_t
) regs
->s8
;
101 cregs
->s9
= (compat_ulong_t
) regs
->s9
;
102 cregs
->s10
= (compat_ulong_t
) regs
->s10
;
103 cregs
->s11
= (compat_ulong_t
) regs
->s11
;
104 cregs
->t3
= (compat_ulong_t
) regs
->t3
;
105 cregs
->t4
= (compat_ulong_t
) regs
->t4
;
106 cregs
->t5
= (compat_ulong_t
) regs
->t5
;
107 cregs
->t6
= (compat_ulong_t
) regs
->t6
;
110 static inline void cregs_to_regs(struct compat_user_regs_struct
*cregs
,
111 struct pt_regs
*regs
)
113 regs
->epc
= (unsigned long) cregs
->pc
;
114 regs
->ra
= (unsigned long) cregs
->ra
;
115 regs
->sp
= (unsigned long) cregs
->sp
;
116 regs
->gp
= (unsigned long) cregs
->gp
;
117 regs
->tp
= (unsigned long) cregs
->tp
;
118 regs
->t0
= (unsigned long) cregs
->t0
;
119 regs
->t1
= (unsigned long) cregs
->t1
;
120 regs
->t2
= (unsigned long) cregs
->t2
;
121 regs
->s0
= (unsigned long) cregs
->s0
;
122 regs
->s1
= (unsigned long) cregs
->s1
;
123 regs
->a0
= (unsigned long) cregs
->a0
;
124 regs
->a1
= (unsigned long) cregs
->a1
;
125 regs
->a2
= (unsigned long) cregs
->a2
;
126 regs
->a3
= (unsigned long) cregs
->a3
;
127 regs
->a4
= (unsigned long) cregs
->a4
;
128 regs
->a5
= (unsigned long) cregs
->a5
;
129 regs
->a6
= (unsigned long) cregs
->a6
;
130 regs
->a7
= (unsigned long) cregs
->a7
;
131 regs
->s2
= (unsigned long) cregs
->s2
;
132 regs
->s3
= (unsigned long) cregs
->s3
;
133 regs
->s4
= (unsigned long) cregs
->s4
;
134 regs
->s5
= (unsigned long) cregs
->s5
;
135 regs
->s6
= (unsigned long) cregs
->s6
;
136 regs
->s7
= (unsigned long) cregs
->s7
;
137 regs
->s8
= (unsigned long) cregs
->s8
;
138 regs
->s9
= (unsigned long) cregs
->s9
;
139 regs
->s10
= (unsigned long) cregs
->s10
;
140 regs
->s11
= (unsigned long) cregs
->s11
;
141 regs
->t3
= (unsigned long) cregs
->t3
;
142 regs
->t4
= (unsigned long) cregs
->t4
;
143 regs
->t5
= (unsigned long) cregs
->t5
;
144 regs
->t6
= (unsigned long) cregs
->t6
;
147 #endif /* __ASM_COMPAT_H */