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