xref: /openbmc/linux/arch/riscv/kernel/asm-offsets.c (revision 8e74a48d)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2012 Regents of the University of California
4  * Copyright (C) 2017 SiFive
5  */
6 
7 #define GENERATING_ASM_OFFSETS
8 
9 #include <linux/kbuild.h>
10 #include <linux/mm.h>
11 #include <linux/sched.h>
12 #include <asm/kvm_host.h>
13 #include <asm/thread_info.h>
14 #include <asm/ptrace.h>
15 #include <asm/cpu_ops_sbi.h>
16 
17 void asm_offsets(void);
18 
19 void asm_offsets(void)
20 {
21 	OFFSET(TASK_THREAD_RA, task_struct, thread.ra);
22 	OFFSET(TASK_THREAD_SP, task_struct, thread.sp);
23 	OFFSET(TASK_THREAD_S0, task_struct, thread.s[0]);
24 	OFFSET(TASK_THREAD_S1, task_struct, thread.s[1]);
25 	OFFSET(TASK_THREAD_S2, task_struct, thread.s[2]);
26 	OFFSET(TASK_THREAD_S3, task_struct, thread.s[3]);
27 	OFFSET(TASK_THREAD_S4, task_struct, thread.s[4]);
28 	OFFSET(TASK_THREAD_S5, task_struct, thread.s[5]);
29 	OFFSET(TASK_THREAD_S6, task_struct, thread.s[6]);
30 	OFFSET(TASK_THREAD_S7, task_struct, thread.s[7]);
31 	OFFSET(TASK_THREAD_S8, task_struct, thread.s[8]);
32 	OFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);
33 	OFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);
34 	OFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);
35 	OFFSET(TASK_TI_FLAGS, task_struct, thread_info.flags);
36 	OFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count);
37 	OFFSET(TASK_TI_KERNEL_SP, task_struct, thread_info.kernel_sp);
38 	OFFSET(TASK_TI_USER_SP, task_struct, thread_info.user_sp);
39 
40 	OFFSET(TASK_THREAD_F0,  task_struct, thread.fstate.f[0]);
41 	OFFSET(TASK_THREAD_F1,  task_struct, thread.fstate.f[1]);
42 	OFFSET(TASK_THREAD_F2,  task_struct, thread.fstate.f[2]);
43 	OFFSET(TASK_THREAD_F3,  task_struct, thread.fstate.f[3]);
44 	OFFSET(TASK_THREAD_F4,  task_struct, thread.fstate.f[4]);
45 	OFFSET(TASK_THREAD_F5,  task_struct, thread.fstate.f[5]);
46 	OFFSET(TASK_THREAD_F6,  task_struct, thread.fstate.f[6]);
47 	OFFSET(TASK_THREAD_F7,  task_struct, thread.fstate.f[7]);
48 	OFFSET(TASK_THREAD_F8,  task_struct, thread.fstate.f[8]);
49 	OFFSET(TASK_THREAD_F9,  task_struct, thread.fstate.f[9]);
50 	OFFSET(TASK_THREAD_F10, task_struct, thread.fstate.f[10]);
51 	OFFSET(TASK_THREAD_F11, task_struct, thread.fstate.f[11]);
52 	OFFSET(TASK_THREAD_F12, task_struct, thread.fstate.f[12]);
53 	OFFSET(TASK_THREAD_F13, task_struct, thread.fstate.f[13]);
54 	OFFSET(TASK_THREAD_F14, task_struct, thread.fstate.f[14]);
55 	OFFSET(TASK_THREAD_F15, task_struct, thread.fstate.f[15]);
56 	OFFSET(TASK_THREAD_F16, task_struct, thread.fstate.f[16]);
57 	OFFSET(TASK_THREAD_F17, task_struct, thread.fstate.f[17]);
58 	OFFSET(TASK_THREAD_F18, task_struct, thread.fstate.f[18]);
59 	OFFSET(TASK_THREAD_F19, task_struct, thread.fstate.f[19]);
60 	OFFSET(TASK_THREAD_F20, task_struct, thread.fstate.f[20]);
61 	OFFSET(TASK_THREAD_F21, task_struct, thread.fstate.f[21]);
62 	OFFSET(TASK_THREAD_F22, task_struct, thread.fstate.f[22]);
63 	OFFSET(TASK_THREAD_F23, task_struct, thread.fstate.f[23]);
64 	OFFSET(TASK_THREAD_F24, task_struct, thread.fstate.f[24]);
65 	OFFSET(TASK_THREAD_F25, task_struct, thread.fstate.f[25]);
66 	OFFSET(TASK_THREAD_F26, task_struct, thread.fstate.f[26]);
67 	OFFSET(TASK_THREAD_F27, task_struct, thread.fstate.f[27]);
68 	OFFSET(TASK_THREAD_F28, task_struct, thread.fstate.f[28]);
69 	OFFSET(TASK_THREAD_F29, task_struct, thread.fstate.f[29]);
70 	OFFSET(TASK_THREAD_F30, task_struct, thread.fstate.f[30]);
71 	OFFSET(TASK_THREAD_F31, task_struct, thread.fstate.f[31]);
72 	OFFSET(TASK_THREAD_FCSR, task_struct, thread.fstate.fcsr);
73 #ifdef CONFIG_STACKPROTECTOR
74 	OFFSET(TSK_STACK_CANARY, task_struct, stack_canary);
75 #endif
76 
77 	DEFINE(PT_SIZE, sizeof(struct pt_regs));
78 	OFFSET(PT_EPC, pt_regs, epc);
79 	OFFSET(PT_RA, pt_regs, ra);
80 	OFFSET(PT_FP, pt_regs, s0);
81 	OFFSET(PT_S0, pt_regs, s0);
82 	OFFSET(PT_S1, pt_regs, s1);
83 	OFFSET(PT_S2, pt_regs, s2);
84 	OFFSET(PT_S3, pt_regs, s3);
85 	OFFSET(PT_S4, pt_regs, s4);
86 	OFFSET(PT_S5, pt_regs, s5);
87 	OFFSET(PT_S6, pt_regs, s6);
88 	OFFSET(PT_S7, pt_regs, s7);
89 	OFFSET(PT_S8, pt_regs, s8);
90 	OFFSET(PT_S9, pt_regs, s9);
91 	OFFSET(PT_S10, pt_regs, s10);
92 	OFFSET(PT_S11, pt_regs, s11);
93 	OFFSET(PT_SP, pt_regs, sp);
94 	OFFSET(PT_TP, pt_regs, tp);
95 	OFFSET(PT_A0, pt_regs, a0);
96 	OFFSET(PT_A1, pt_regs, a1);
97 	OFFSET(PT_A2, pt_regs, a2);
98 	OFFSET(PT_A3, pt_regs, a3);
99 	OFFSET(PT_A4, pt_regs, a4);
100 	OFFSET(PT_A5, pt_regs, a5);
101 	OFFSET(PT_A6, pt_regs, a6);
102 	OFFSET(PT_A7, pt_regs, a7);
103 	OFFSET(PT_T0, pt_regs, t0);
104 	OFFSET(PT_T1, pt_regs, t1);
105 	OFFSET(PT_T2, pt_regs, t2);
106 	OFFSET(PT_T3, pt_regs, t3);
107 	OFFSET(PT_T4, pt_regs, t4);
108 	OFFSET(PT_T5, pt_regs, t5);
109 	OFFSET(PT_T6, pt_regs, t6);
110 	OFFSET(PT_GP, pt_regs, gp);
111 	OFFSET(PT_ORIG_A0, pt_regs, orig_a0);
112 	OFFSET(PT_STATUS, pt_regs, status);
113 	OFFSET(PT_BADADDR, pt_regs, badaddr);
114 	OFFSET(PT_CAUSE, pt_regs, cause);
115 
116 	OFFSET(KVM_ARCH_GUEST_ZERO, kvm_vcpu_arch, guest_context.zero);
117 	OFFSET(KVM_ARCH_GUEST_RA, kvm_vcpu_arch, guest_context.ra);
118 	OFFSET(KVM_ARCH_GUEST_SP, kvm_vcpu_arch, guest_context.sp);
119 	OFFSET(KVM_ARCH_GUEST_GP, kvm_vcpu_arch, guest_context.gp);
120 	OFFSET(KVM_ARCH_GUEST_TP, kvm_vcpu_arch, guest_context.tp);
121 	OFFSET(KVM_ARCH_GUEST_T0, kvm_vcpu_arch, guest_context.t0);
122 	OFFSET(KVM_ARCH_GUEST_T1, kvm_vcpu_arch, guest_context.t1);
123 	OFFSET(KVM_ARCH_GUEST_T2, kvm_vcpu_arch, guest_context.t2);
124 	OFFSET(KVM_ARCH_GUEST_S0, kvm_vcpu_arch, guest_context.s0);
125 	OFFSET(KVM_ARCH_GUEST_S1, kvm_vcpu_arch, guest_context.s1);
126 	OFFSET(KVM_ARCH_GUEST_A0, kvm_vcpu_arch, guest_context.a0);
127 	OFFSET(KVM_ARCH_GUEST_A1, kvm_vcpu_arch, guest_context.a1);
128 	OFFSET(KVM_ARCH_GUEST_A2, kvm_vcpu_arch, guest_context.a2);
129 	OFFSET(KVM_ARCH_GUEST_A3, kvm_vcpu_arch, guest_context.a3);
130 	OFFSET(KVM_ARCH_GUEST_A4, kvm_vcpu_arch, guest_context.a4);
131 	OFFSET(KVM_ARCH_GUEST_A5, kvm_vcpu_arch, guest_context.a5);
132 	OFFSET(KVM_ARCH_GUEST_A6, kvm_vcpu_arch, guest_context.a6);
133 	OFFSET(KVM_ARCH_GUEST_A7, kvm_vcpu_arch, guest_context.a7);
134 	OFFSET(KVM_ARCH_GUEST_S2, kvm_vcpu_arch, guest_context.s2);
135 	OFFSET(KVM_ARCH_GUEST_S3, kvm_vcpu_arch, guest_context.s3);
136 	OFFSET(KVM_ARCH_GUEST_S4, kvm_vcpu_arch, guest_context.s4);
137 	OFFSET(KVM_ARCH_GUEST_S5, kvm_vcpu_arch, guest_context.s5);
138 	OFFSET(KVM_ARCH_GUEST_S6, kvm_vcpu_arch, guest_context.s6);
139 	OFFSET(KVM_ARCH_GUEST_S7, kvm_vcpu_arch, guest_context.s7);
140 	OFFSET(KVM_ARCH_GUEST_S8, kvm_vcpu_arch, guest_context.s8);
141 	OFFSET(KVM_ARCH_GUEST_S9, kvm_vcpu_arch, guest_context.s9);
142 	OFFSET(KVM_ARCH_GUEST_S10, kvm_vcpu_arch, guest_context.s10);
143 	OFFSET(KVM_ARCH_GUEST_S11, kvm_vcpu_arch, guest_context.s11);
144 	OFFSET(KVM_ARCH_GUEST_T3, kvm_vcpu_arch, guest_context.t3);
145 	OFFSET(KVM_ARCH_GUEST_T4, kvm_vcpu_arch, guest_context.t4);
146 	OFFSET(KVM_ARCH_GUEST_T5, kvm_vcpu_arch, guest_context.t5);
147 	OFFSET(KVM_ARCH_GUEST_T6, kvm_vcpu_arch, guest_context.t6);
148 	OFFSET(KVM_ARCH_GUEST_SEPC, kvm_vcpu_arch, guest_context.sepc);
149 	OFFSET(KVM_ARCH_GUEST_SSTATUS, kvm_vcpu_arch, guest_context.sstatus);
150 	OFFSET(KVM_ARCH_GUEST_HSTATUS, kvm_vcpu_arch, guest_context.hstatus);
151 	OFFSET(KVM_ARCH_GUEST_SCOUNTEREN, kvm_vcpu_arch, guest_csr.scounteren);
152 
153 	OFFSET(KVM_ARCH_HOST_ZERO, kvm_vcpu_arch, host_context.zero);
154 	OFFSET(KVM_ARCH_HOST_RA, kvm_vcpu_arch, host_context.ra);
155 	OFFSET(KVM_ARCH_HOST_SP, kvm_vcpu_arch, host_context.sp);
156 	OFFSET(KVM_ARCH_HOST_GP, kvm_vcpu_arch, host_context.gp);
157 	OFFSET(KVM_ARCH_HOST_TP, kvm_vcpu_arch, host_context.tp);
158 	OFFSET(KVM_ARCH_HOST_T0, kvm_vcpu_arch, host_context.t0);
159 	OFFSET(KVM_ARCH_HOST_T1, kvm_vcpu_arch, host_context.t1);
160 	OFFSET(KVM_ARCH_HOST_T2, kvm_vcpu_arch, host_context.t2);
161 	OFFSET(KVM_ARCH_HOST_S0, kvm_vcpu_arch, host_context.s0);
162 	OFFSET(KVM_ARCH_HOST_S1, kvm_vcpu_arch, host_context.s1);
163 	OFFSET(KVM_ARCH_HOST_A0, kvm_vcpu_arch, host_context.a0);
164 	OFFSET(KVM_ARCH_HOST_A1, kvm_vcpu_arch, host_context.a1);
165 	OFFSET(KVM_ARCH_HOST_A2, kvm_vcpu_arch, host_context.a2);
166 	OFFSET(KVM_ARCH_HOST_A3, kvm_vcpu_arch, host_context.a3);
167 	OFFSET(KVM_ARCH_HOST_A4, kvm_vcpu_arch, host_context.a4);
168 	OFFSET(KVM_ARCH_HOST_A5, kvm_vcpu_arch, host_context.a5);
169 	OFFSET(KVM_ARCH_HOST_A6, kvm_vcpu_arch, host_context.a6);
170 	OFFSET(KVM_ARCH_HOST_A7, kvm_vcpu_arch, host_context.a7);
171 	OFFSET(KVM_ARCH_HOST_S2, kvm_vcpu_arch, host_context.s2);
172 	OFFSET(KVM_ARCH_HOST_S3, kvm_vcpu_arch, host_context.s3);
173 	OFFSET(KVM_ARCH_HOST_S4, kvm_vcpu_arch, host_context.s4);
174 	OFFSET(KVM_ARCH_HOST_S5, kvm_vcpu_arch, host_context.s5);
175 	OFFSET(KVM_ARCH_HOST_S6, kvm_vcpu_arch, host_context.s6);
176 	OFFSET(KVM_ARCH_HOST_S7, kvm_vcpu_arch, host_context.s7);
177 	OFFSET(KVM_ARCH_HOST_S8, kvm_vcpu_arch, host_context.s8);
178 	OFFSET(KVM_ARCH_HOST_S9, kvm_vcpu_arch, host_context.s9);
179 	OFFSET(KVM_ARCH_HOST_S10, kvm_vcpu_arch, host_context.s10);
180 	OFFSET(KVM_ARCH_HOST_S11, kvm_vcpu_arch, host_context.s11);
181 	OFFSET(KVM_ARCH_HOST_T3, kvm_vcpu_arch, host_context.t3);
182 	OFFSET(KVM_ARCH_HOST_T4, kvm_vcpu_arch, host_context.t4);
183 	OFFSET(KVM_ARCH_HOST_T5, kvm_vcpu_arch, host_context.t5);
184 	OFFSET(KVM_ARCH_HOST_T6, kvm_vcpu_arch, host_context.t6);
185 	OFFSET(KVM_ARCH_HOST_SEPC, kvm_vcpu_arch, host_context.sepc);
186 	OFFSET(KVM_ARCH_HOST_SSTATUS, kvm_vcpu_arch, host_context.sstatus);
187 	OFFSET(KVM_ARCH_HOST_HSTATUS, kvm_vcpu_arch, host_context.hstatus);
188 	OFFSET(KVM_ARCH_HOST_SSCRATCH, kvm_vcpu_arch, host_sscratch);
189 	OFFSET(KVM_ARCH_HOST_STVEC, kvm_vcpu_arch, host_stvec);
190 	OFFSET(KVM_ARCH_HOST_SCOUNTEREN, kvm_vcpu_arch, host_scounteren);
191 
192 	OFFSET(KVM_ARCH_TRAP_SEPC, kvm_cpu_trap, sepc);
193 	OFFSET(KVM_ARCH_TRAP_SCAUSE, kvm_cpu_trap, scause);
194 	OFFSET(KVM_ARCH_TRAP_STVAL, kvm_cpu_trap, stval);
195 	OFFSET(KVM_ARCH_TRAP_HTVAL, kvm_cpu_trap, htval);
196 	OFFSET(KVM_ARCH_TRAP_HTINST, kvm_cpu_trap, htinst);
197 
198 	/* F extension */
199 
200 	OFFSET(KVM_ARCH_FP_F_F0, kvm_cpu_context, fp.f.f[0]);
201 	OFFSET(KVM_ARCH_FP_F_F1, kvm_cpu_context, fp.f.f[1]);
202 	OFFSET(KVM_ARCH_FP_F_F2, kvm_cpu_context, fp.f.f[2]);
203 	OFFSET(KVM_ARCH_FP_F_F3, kvm_cpu_context, fp.f.f[3]);
204 	OFFSET(KVM_ARCH_FP_F_F4, kvm_cpu_context, fp.f.f[4]);
205 	OFFSET(KVM_ARCH_FP_F_F5, kvm_cpu_context, fp.f.f[5]);
206 	OFFSET(KVM_ARCH_FP_F_F6, kvm_cpu_context, fp.f.f[6]);
207 	OFFSET(KVM_ARCH_FP_F_F7, kvm_cpu_context, fp.f.f[7]);
208 	OFFSET(KVM_ARCH_FP_F_F8, kvm_cpu_context, fp.f.f[8]);
209 	OFFSET(KVM_ARCH_FP_F_F9, kvm_cpu_context, fp.f.f[9]);
210 	OFFSET(KVM_ARCH_FP_F_F10, kvm_cpu_context, fp.f.f[10]);
211 	OFFSET(KVM_ARCH_FP_F_F11, kvm_cpu_context, fp.f.f[11]);
212 	OFFSET(KVM_ARCH_FP_F_F12, kvm_cpu_context, fp.f.f[12]);
213 	OFFSET(KVM_ARCH_FP_F_F13, kvm_cpu_context, fp.f.f[13]);
214 	OFFSET(KVM_ARCH_FP_F_F14, kvm_cpu_context, fp.f.f[14]);
215 	OFFSET(KVM_ARCH_FP_F_F15, kvm_cpu_context, fp.f.f[15]);
216 	OFFSET(KVM_ARCH_FP_F_F16, kvm_cpu_context, fp.f.f[16]);
217 	OFFSET(KVM_ARCH_FP_F_F17, kvm_cpu_context, fp.f.f[17]);
218 	OFFSET(KVM_ARCH_FP_F_F18, kvm_cpu_context, fp.f.f[18]);
219 	OFFSET(KVM_ARCH_FP_F_F19, kvm_cpu_context, fp.f.f[19]);
220 	OFFSET(KVM_ARCH_FP_F_F20, kvm_cpu_context, fp.f.f[20]);
221 	OFFSET(KVM_ARCH_FP_F_F21, kvm_cpu_context, fp.f.f[21]);
222 	OFFSET(KVM_ARCH_FP_F_F22, kvm_cpu_context, fp.f.f[22]);
223 	OFFSET(KVM_ARCH_FP_F_F23, kvm_cpu_context, fp.f.f[23]);
224 	OFFSET(KVM_ARCH_FP_F_F24, kvm_cpu_context, fp.f.f[24]);
225 	OFFSET(KVM_ARCH_FP_F_F25, kvm_cpu_context, fp.f.f[25]);
226 	OFFSET(KVM_ARCH_FP_F_F26, kvm_cpu_context, fp.f.f[26]);
227 	OFFSET(KVM_ARCH_FP_F_F27, kvm_cpu_context, fp.f.f[27]);
228 	OFFSET(KVM_ARCH_FP_F_F28, kvm_cpu_context, fp.f.f[28]);
229 	OFFSET(KVM_ARCH_FP_F_F29, kvm_cpu_context, fp.f.f[29]);
230 	OFFSET(KVM_ARCH_FP_F_F30, kvm_cpu_context, fp.f.f[30]);
231 	OFFSET(KVM_ARCH_FP_F_F31, kvm_cpu_context, fp.f.f[31]);
232 	OFFSET(KVM_ARCH_FP_F_FCSR, kvm_cpu_context, fp.f.fcsr);
233 
234 	/* D extension */
235 
236 	OFFSET(KVM_ARCH_FP_D_F0, kvm_cpu_context, fp.d.f[0]);
237 	OFFSET(KVM_ARCH_FP_D_F1, kvm_cpu_context, fp.d.f[1]);
238 	OFFSET(KVM_ARCH_FP_D_F2, kvm_cpu_context, fp.d.f[2]);
239 	OFFSET(KVM_ARCH_FP_D_F3, kvm_cpu_context, fp.d.f[3]);
240 	OFFSET(KVM_ARCH_FP_D_F4, kvm_cpu_context, fp.d.f[4]);
241 	OFFSET(KVM_ARCH_FP_D_F5, kvm_cpu_context, fp.d.f[5]);
242 	OFFSET(KVM_ARCH_FP_D_F6, kvm_cpu_context, fp.d.f[6]);
243 	OFFSET(KVM_ARCH_FP_D_F7, kvm_cpu_context, fp.d.f[7]);
244 	OFFSET(KVM_ARCH_FP_D_F8, kvm_cpu_context, fp.d.f[8]);
245 	OFFSET(KVM_ARCH_FP_D_F9, kvm_cpu_context, fp.d.f[9]);
246 	OFFSET(KVM_ARCH_FP_D_F10, kvm_cpu_context, fp.d.f[10]);
247 	OFFSET(KVM_ARCH_FP_D_F11, kvm_cpu_context, fp.d.f[11]);
248 	OFFSET(KVM_ARCH_FP_D_F12, kvm_cpu_context, fp.d.f[12]);
249 	OFFSET(KVM_ARCH_FP_D_F13, kvm_cpu_context, fp.d.f[13]);
250 	OFFSET(KVM_ARCH_FP_D_F14, kvm_cpu_context, fp.d.f[14]);
251 	OFFSET(KVM_ARCH_FP_D_F15, kvm_cpu_context, fp.d.f[15]);
252 	OFFSET(KVM_ARCH_FP_D_F16, kvm_cpu_context, fp.d.f[16]);
253 	OFFSET(KVM_ARCH_FP_D_F17, kvm_cpu_context, fp.d.f[17]);
254 	OFFSET(KVM_ARCH_FP_D_F18, kvm_cpu_context, fp.d.f[18]);
255 	OFFSET(KVM_ARCH_FP_D_F19, kvm_cpu_context, fp.d.f[19]);
256 	OFFSET(KVM_ARCH_FP_D_F20, kvm_cpu_context, fp.d.f[20]);
257 	OFFSET(KVM_ARCH_FP_D_F21, kvm_cpu_context, fp.d.f[21]);
258 	OFFSET(KVM_ARCH_FP_D_F22, kvm_cpu_context, fp.d.f[22]);
259 	OFFSET(KVM_ARCH_FP_D_F23, kvm_cpu_context, fp.d.f[23]);
260 	OFFSET(KVM_ARCH_FP_D_F24, kvm_cpu_context, fp.d.f[24]);
261 	OFFSET(KVM_ARCH_FP_D_F25, kvm_cpu_context, fp.d.f[25]);
262 	OFFSET(KVM_ARCH_FP_D_F26, kvm_cpu_context, fp.d.f[26]);
263 	OFFSET(KVM_ARCH_FP_D_F27, kvm_cpu_context, fp.d.f[27]);
264 	OFFSET(KVM_ARCH_FP_D_F28, kvm_cpu_context, fp.d.f[28]);
265 	OFFSET(KVM_ARCH_FP_D_F29, kvm_cpu_context, fp.d.f[29]);
266 	OFFSET(KVM_ARCH_FP_D_F30, kvm_cpu_context, fp.d.f[30]);
267 	OFFSET(KVM_ARCH_FP_D_F31, kvm_cpu_context, fp.d.f[31]);
268 	OFFSET(KVM_ARCH_FP_D_FCSR, kvm_cpu_context, fp.d.fcsr);
269 
270 	/*
271 	 * THREAD_{F,X}* might be larger than a S-type offset can handle, but
272 	 * these are used in performance-sensitive assembly so we can't resort
273 	 * to loading the long immediate every time.
274 	 */
275 	DEFINE(TASK_THREAD_RA_RA,
276 		  offsetof(struct task_struct, thread.ra)
277 		- offsetof(struct task_struct, thread.ra)
278 	);
279 	DEFINE(TASK_THREAD_SP_RA,
280 		  offsetof(struct task_struct, thread.sp)
281 		- offsetof(struct task_struct, thread.ra)
282 	);
283 	DEFINE(TASK_THREAD_S0_RA,
284 		  offsetof(struct task_struct, thread.s[0])
285 		- offsetof(struct task_struct, thread.ra)
286 	);
287 	DEFINE(TASK_THREAD_S1_RA,
288 		  offsetof(struct task_struct, thread.s[1])
289 		- offsetof(struct task_struct, thread.ra)
290 	);
291 	DEFINE(TASK_THREAD_S2_RA,
292 		  offsetof(struct task_struct, thread.s[2])
293 		- offsetof(struct task_struct, thread.ra)
294 	);
295 	DEFINE(TASK_THREAD_S3_RA,
296 		  offsetof(struct task_struct, thread.s[3])
297 		- offsetof(struct task_struct, thread.ra)
298 	);
299 	DEFINE(TASK_THREAD_S4_RA,
300 		  offsetof(struct task_struct, thread.s[4])
301 		- offsetof(struct task_struct, thread.ra)
302 	);
303 	DEFINE(TASK_THREAD_S5_RA,
304 		  offsetof(struct task_struct, thread.s[5])
305 		- offsetof(struct task_struct, thread.ra)
306 	);
307 	DEFINE(TASK_THREAD_S6_RA,
308 		  offsetof(struct task_struct, thread.s[6])
309 		- offsetof(struct task_struct, thread.ra)
310 	);
311 	DEFINE(TASK_THREAD_S7_RA,
312 		  offsetof(struct task_struct, thread.s[7])
313 		- offsetof(struct task_struct, thread.ra)
314 	);
315 	DEFINE(TASK_THREAD_S8_RA,
316 		  offsetof(struct task_struct, thread.s[8])
317 		- offsetof(struct task_struct, thread.ra)
318 	);
319 	DEFINE(TASK_THREAD_S9_RA,
320 		  offsetof(struct task_struct, thread.s[9])
321 		- offsetof(struct task_struct, thread.ra)
322 	);
323 	DEFINE(TASK_THREAD_S10_RA,
324 		  offsetof(struct task_struct, thread.s[10])
325 		- offsetof(struct task_struct, thread.ra)
326 	);
327 	DEFINE(TASK_THREAD_S11_RA,
328 		  offsetof(struct task_struct, thread.s[11])
329 		- offsetof(struct task_struct, thread.ra)
330 	);
331 
332 	DEFINE(TASK_THREAD_F0_F0,
333 		  offsetof(struct task_struct, thread.fstate.f[0])
334 		- offsetof(struct task_struct, thread.fstate.f[0])
335 	);
336 	DEFINE(TASK_THREAD_F1_F0,
337 		  offsetof(struct task_struct, thread.fstate.f[1])
338 		- offsetof(struct task_struct, thread.fstate.f[0])
339 	);
340 	DEFINE(TASK_THREAD_F2_F0,
341 		  offsetof(struct task_struct, thread.fstate.f[2])
342 		- offsetof(struct task_struct, thread.fstate.f[0])
343 	);
344 	DEFINE(TASK_THREAD_F3_F0,
345 		  offsetof(struct task_struct, thread.fstate.f[3])
346 		- offsetof(struct task_struct, thread.fstate.f[0])
347 	);
348 	DEFINE(TASK_THREAD_F4_F0,
349 		  offsetof(struct task_struct, thread.fstate.f[4])
350 		- offsetof(struct task_struct, thread.fstate.f[0])
351 	);
352 	DEFINE(TASK_THREAD_F5_F0,
353 		  offsetof(struct task_struct, thread.fstate.f[5])
354 		- offsetof(struct task_struct, thread.fstate.f[0])
355 	);
356 	DEFINE(TASK_THREAD_F6_F0,
357 		  offsetof(struct task_struct, thread.fstate.f[6])
358 		- offsetof(struct task_struct, thread.fstate.f[0])
359 	);
360 	DEFINE(TASK_THREAD_F7_F0,
361 		  offsetof(struct task_struct, thread.fstate.f[7])
362 		- offsetof(struct task_struct, thread.fstate.f[0])
363 	);
364 	DEFINE(TASK_THREAD_F8_F0,
365 		  offsetof(struct task_struct, thread.fstate.f[8])
366 		- offsetof(struct task_struct, thread.fstate.f[0])
367 	);
368 	DEFINE(TASK_THREAD_F9_F0,
369 		  offsetof(struct task_struct, thread.fstate.f[9])
370 		- offsetof(struct task_struct, thread.fstate.f[0])
371 	);
372 	DEFINE(TASK_THREAD_F10_F0,
373 		  offsetof(struct task_struct, thread.fstate.f[10])
374 		- offsetof(struct task_struct, thread.fstate.f[0])
375 	);
376 	DEFINE(TASK_THREAD_F11_F0,
377 		  offsetof(struct task_struct, thread.fstate.f[11])
378 		- offsetof(struct task_struct, thread.fstate.f[0])
379 	);
380 	DEFINE(TASK_THREAD_F12_F0,
381 		  offsetof(struct task_struct, thread.fstate.f[12])
382 		- offsetof(struct task_struct, thread.fstate.f[0])
383 	);
384 	DEFINE(TASK_THREAD_F13_F0,
385 		  offsetof(struct task_struct, thread.fstate.f[13])
386 		- offsetof(struct task_struct, thread.fstate.f[0])
387 	);
388 	DEFINE(TASK_THREAD_F14_F0,
389 		  offsetof(struct task_struct, thread.fstate.f[14])
390 		- offsetof(struct task_struct, thread.fstate.f[0])
391 	);
392 	DEFINE(TASK_THREAD_F15_F0,
393 		  offsetof(struct task_struct, thread.fstate.f[15])
394 		- offsetof(struct task_struct, thread.fstate.f[0])
395 	);
396 	DEFINE(TASK_THREAD_F16_F0,
397 		  offsetof(struct task_struct, thread.fstate.f[16])
398 		- offsetof(struct task_struct, thread.fstate.f[0])
399 	);
400 	DEFINE(TASK_THREAD_F17_F0,
401 		  offsetof(struct task_struct, thread.fstate.f[17])
402 		- offsetof(struct task_struct, thread.fstate.f[0])
403 	);
404 	DEFINE(TASK_THREAD_F18_F0,
405 		  offsetof(struct task_struct, thread.fstate.f[18])
406 		- offsetof(struct task_struct, thread.fstate.f[0])
407 	);
408 	DEFINE(TASK_THREAD_F19_F0,
409 		  offsetof(struct task_struct, thread.fstate.f[19])
410 		- offsetof(struct task_struct, thread.fstate.f[0])
411 	);
412 	DEFINE(TASK_THREAD_F20_F0,
413 		  offsetof(struct task_struct, thread.fstate.f[20])
414 		- offsetof(struct task_struct, thread.fstate.f[0])
415 	);
416 	DEFINE(TASK_THREAD_F21_F0,
417 		  offsetof(struct task_struct, thread.fstate.f[21])
418 		- offsetof(struct task_struct, thread.fstate.f[0])
419 	);
420 	DEFINE(TASK_THREAD_F22_F0,
421 		  offsetof(struct task_struct, thread.fstate.f[22])
422 		- offsetof(struct task_struct, thread.fstate.f[0])
423 	);
424 	DEFINE(TASK_THREAD_F23_F0,
425 		  offsetof(struct task_struct, thread.fstate.f[23])
426 		- offsetof(struct task_struct, thread.fstate.f[0])
427 	);
428 	DEFINE(TASK_THREAD_F24_F0,
429 		  offsetof(struct task_struct, thread.fstate.f[24])
430 		- offsetof(struct task_struct, thread.fstate.f[0])
431 	);
432 	DEFINE(TASK_THREAD_F25_F0,
433 		  offsetof(struct task_struct, thread.fstate.f[25])
434 		- offsetof(struct task_struct, thread.fstate.f[0])
435 	);
436 	DEFINE(TASK_THREAD_F26_F0,
437 		  offsetof(struct task_struct, thread.fstate.f[26])
438 		- offsetof(struct task_struct, thread.fstate.f[0])
439 	);
440 	DEFINE(TASK_THREAD_F27_F0,
441 		  offsetof(struct task_struct, thread.fstate.f[27])
442 		- offsetof(struct task_struct, thread.fstate.f[0])
443 	);
444 	DEFINE(TASK_THREAD_F28_F0,
445 		  offsetof(struct task_struct, thread.fstate.f[28])
446 		- offsetof(struct task_struct, thread.fstate.f[0])
447 	);
448 	DEFINE(TASK_THREAD_F29_F0,
449 		  offsetof(struct task_struct, thread.fstate.f[29])
450 		- offsetof(struct task_struct, thread.fstate.f[0])
451 	);
452 	DEFINE(TASK_THREAD_F30_F0,
453 		  offsetof(struct task_struct, thread.fstate.f[30])
454 		- offsetof(struct task_struct, thread.fstate.f[0])
455 	);
456 	DEFINE(TASK_THREAD_F31_F0,
457 		  offsetof(struct task_struct, thread.fstate.f[31])
458 		- offsetof(struct task_struct, thread.fstate.f[0])
459 	);
460 	DEFINE(TASK_THREAD_FCSR_F0,
461 		  offsetof(struct task_struct, thread.fstate.fcsr)
462 		- offsetof(struct task_struct, thread.fstate.f[0])
463 	);
464 
465 	/*
466 	 * We allocate a pt_regs on the stack when entering the kernel.  This
467 	 * ensures the alignment is sane.
468 	 */
469 	DEFINE(PT_SIZE_ON_STACK, ALIGN(sizeof(struct pt_regs), STACK_ALIGN));
470 
471 	OFFSET(KERNEL_MAP_VIRT_ADDR, kernel_mapping, virt_addr);
472 	OFFSET(SBI_HART_BOOT_TASK_PTR_OFFSET, sbi_hart_boot_data, task_ptr);
473 	OFFSET(SBI_HART_BOOT_STACK_PTR_OFFSET, sbi_hart_boot_data, stack_ptr);
474 }
475