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