xref: /kvmtool/riscv/kvm-cpu.c (revision a416fdc2e664b8b8faf653fec636f93c187d2529)
1 #include "kvm/kvm-cpu.h"
2 #include "kvm/kvm.h"
3 #include "kvm/virtio.h"
4 #include "kvm/sbi.h"
5 #include "kvm/term.h"
6 
7 #include <asm/ptrace.h>
8 
9 static int debug_fd;
10 
11 void kvm_cpu__set_debug_fd(int fd)
12 {
13 	debug_fd = fd;
14 }
15 
16 int kvm_cpu__get_debug_fd(void)
17 {
18 	return debug_fd;
19 }
20 
21 struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
22 {
23 	struct kvm_cpu *vcpu;
24 	u64 timebase = 0;
25 	unsigned long isa = 0, id = 0;
26 	unsigned long masks[KVM_REG_RISCV_SBI_MULTI_REG_LAST + 1] = { 0 };
27 	int i, coalesced_offset, mmap_size;
28 	struct kvm_one_reg reg;
29 
30 	vcpu = calloc(1, sizeof(struct kvm_cpu));
31 	if (!vcpu)
32 		return NULL;
33 
34 	vcpu->vcpu_fd = ioctl(kvm->vm_fd, KVM_CREATE_VCPU, cpu_id);
35 	if (vcpu->vcpu_fd < 0)
36 		die_perror("KVM_CREATE_VCPU ioctl");
37 
38 	reg.id = RISCV_CONFIG_REG(isa);
39 	reg.addr = (unsigned long)&isa;
40 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
41 		die("KVM_GET_ONE_REG failed (config.isa)");
42 
43 	reg.id = RISCV_TIMER_REG(frequency);
44 	reg.addr = (unsigned long)&timebase;
45 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
46 		die("KVM_GET_ONE_REG failed (timer.frequency)");
47 
48 	mmap_size = ioctl(kvm->sys_fd, KVM_GET_VCPU_MMAP_SIZE, 0);
49 	if (mmap_size < 0)
50 		die_perror("KVM_GET_VCPU_MMAP_SIZE ioctl");
51 
52 	vcpu->kvm_run = mmap(NULL, mmap_size, PROT_RW, MAP_SHARED,
53 			     vcpu->vcpu_fd, 0);
54 	if (vcpu->kvm_run == MAP_FAILED)
55 		die("unable to mmap vcpu fd");
56 
57 	coalesced_offset = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION,
58 				 KVM_CAP_COALESCED_MMIO);
59 	if (coalesced_offset)
60 		vcpu->ring = (void *)vcpu->kvm_run +
61 			     (coalesced_offset * PAGE_SIZE);
62 
63 	reg.id = RISCV_CONFIG_REG(isa);
64 	reg.addr = (unsigned long)&isa;
65 	if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
66 		die("KVM_SET_ONE_REG failed (config.isa)");
67 
68 	if (kvm->cfg.arch.custom_mvendorid) {
69 		id = kvm->cfg.arch.custom_mvendorid;
70 		reg.id = RISCV_CONFIG_REG(mvendorid);
71 		reg.addr = (unsigned long)&id;
72 		if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
73 			die("KVM_SET_ONE_REG failed (config.mvendorid)");
74 	}
75 
76 	if (kvm->cfg.arch.custom_marchid) {
77 		id = kvm->cfg.arch.custom_marchid;
78 		reg.id = RISCV_CONFIG_REG(marchid);
79 		reg.addr = (unsigned long)&id;
80 		if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
81 			die("KVM_SET_ONE_REG failed (config.marchid)");
82 	}
83 
84 	if (kvm->cfg.arch.custom_mimpid) {
85 		id = kvm->cfg.arch.custom_mimpid;
86 		reg.id = RISCV_CONFIG_REG(mimpid);
87 		reg.addr = (unsigned long)&id;
88 		if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
89 			die("KVM_SET_ONE_REG failed (config.mimpid)");
90 	}
91 
92 	for (i = 0; i < KVM_RISCV_SBI_EXT_MAX; i++) {
93 		if (!kvm->cfg.arch.sbi_ext_disabled[i])
94 			continue;
95 		masks[KVM_REG_RISCV_SBI_MULTI_REG(i)] |=
96 					KVM_REG_RISCV_SBI_MULTI_MASK(i);
97 	}
98 	for (i = 0; i <= KVM_REG_RISCV_SBI_MULTI_REG_LAST; i++) {
99 		if (!masks[i])
100 			continue;
101 
102 		reg.id = RISCV_SBI_EXT_REG(KVM_REG_RISCV_SBI_MULTI_DIS, i);
103 		reg.addr = (unsigned long)&masks[i];
104 		if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
105 			die("KVM_SET_ONE_REG failed (sbi_ext %d)", i);
106 	}
107 
108 	/* Populate the vcpu structure. */
109 	vcpu->kvm		= kvm;
110 	vcpu->cpu_id		= cpu_id;
111 	vcpu->riscv_isa		= isa;
112 	vcpu->riscv_xlen	= __riscv_xlen;
113 	vcpu->riscv_timebase	= timebase;
114 	vcpu->is_running	= true;
115 
116 	return vcpu;
117 }
118 
119 void kvm_cpu__arch_nmi(struct kvm_cpu *cpu)
120 {
121 }
122 
123 void kvm_cpu__delete(struct kvm_cpu *vcpu)
124 {
125 	free(vcpu);
126 }
127 
128 static bool kvm_cpu_riscv_sbi(struct kvm_cpu *vcpu)
129 {
130 	char ch;
131 	bool ret = true;
132 	int dfd = kvm_cpu__get_debug_fd();
133 
134 	switch (vcpu->kvm_run->riscv_sbi.extension_id) {
135 	case SBI_EXT_0_1_CONSOLE_PUTCHAR:
136 		ch = vcpu->kvm_run->riscv_sbi.args[0];
137 		term_putc(&ch, 1, 0);
138 		vcpu->kvm_run->riscv_sbi.ret[0] = 0;
139 		break;
140 	case SBI_EXT_0_1_CONSOLE_GETCHAR:
141 		if (term_readable(0))
142 			vcpu->kvm_run->riscv_sbi.ret[0] =
143 					term_getc(vcpu->kvm, 0);
144 		else
145 			vcpu->kvm_run->riscv_sbi.ret[0] = SBI_ERR_FAILURE;
146 		break;
147 	default:
148 		dprintf(dfd, "Unhandled SBI call\n");
149 		dprintf(dfd, "extension_id=0x%lx function_id=0x%lx\n",
150 			vcpu->kvm_run->riscv_sbi.extension_id,
151 			vcpu->kvm_run->riscv_sbi.function_id);
152 		dprintf(dfd, "args[0]=0x%lx args[1]=0x%lx\n",
153 			vcpu->kvm_run->riscv_sbi.args[0],
154 			vcpu->kvm_run->riscv_sbi.args[1]);
155 		dprintf(dfd, "args[2]=0x%lx args[3]=0x%lx\n",
156 			vcpu->kvm_run->riscv_sbi.args[2],
157 			vcpu->kvm_run->riscv_sbi.args[3]);
158 		dprintf(dfd, "args[4]=0x%lx args[5]=0x%lx\n",
159 			vcpu->kvm_run->riscv_sbi.args[4],
160 			vcpu->kvm_run->riscv_sbi.args[5]);
161 		ret = false;
162 		break;
163 	};
164 
165 	return ret;
166 }
167 
168 bool kvm_cpu__handle_exit(struct kvm_cpu *vcpu)
169 {
170 	switch (vcpu->kvm_run->exit_reason) {
171 	case KVM_EXIT_RISCV_SBI:
172 		return kvm_cpu_riscv_sbi(vcpu);
173 	default:
174 		break;
175 	};
176 
177 	return false;
178 }
179 
180 void kvm_cpu__show_page_tables(struct kvm_cpu *vcpu)
181 {
182 }
183 
184 void kvm_cpu__reset_vcpu(struct kvm_cpu *vcpu)
185 {
186 	struct kvm *kvm = vcpu->kvm;
187 	struct kvm_mp_state mp_state;
188 	struct kvm_one_reg reg;
189 	unsigned long data;
190 
191 	if (ioctl(vcpu->vcpu_fd, KVM_GET_MP_STATE, &mp_state) < 0)
192 		die_perror("KVM_GET_MP_STATE failed");
193 
194 	/*
195 	 * If MP state is stopped then it means Linux KVM RISC-V emulates
196 	 * SBI v0.2 (or higher) with HART power managment and give VCPU
197 	 * will power-up at boot-time by boot VCPU. For such VCPU, we
198 	 * don't update PC, A0 and A1 here.
199 	 */
200 	if (mp_state.mp_state == KVM_MP_STATE_STOPPED)
201 		return;
202 
203 	reg.addr = (unsigned long)&data;
204 
205 	data	= kvm->arch.kern_guest_start;
206 	reg.id	= RISCV_CORE_REG(regs.pc);
207 	if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
208 		die_perror("KVM_SET_ONE_REG failed (pc)");
209 
210 	data	= vcpu->cpu_id;
211 	reg.id	= RISCV_CORE_REG(regs.a0);
212 	if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
213 		die_perror("KVM_SET_ONE_REG failed (a0)");
214 
215 	data	= kvm->arch.dtb_guest_start;
216 	reg.id	= RISCV_CORE_REG(regs.a1);
217 	if (ioctl(vcpu->vcpu_fd, KVM_SET_ONE_REG, &reg) < 0)
218 		die_perror("KVM_SET_ONE_REG failed (a1)");
219 }
220 
221 int kvm_cpu__get_endianness(struct kvm_cpu *vcpu)
222 {
223 	return VIRTIO_ENDIAN_LE;
224 }
225 
226 void kvm_cpu__show_code(struct kvm_cpu *vcpu)
227 {
228 	struct kvm_one_reg reg;
229 	unsigned long data;
230 	int debug_fd = kvm_cpu__get_debug_fd();
231 
232 	reg.addr = (unsigned long)&data;
233 
234 	dprintf(debug_fd, "\n*PC:\n");
235 	reg.id = RISCV_CORE_REG(regs.pc);
236 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
237 		die("KVM_GET_ONE_REG failed (show_code @ PC)");
238 
239 	kvm__dump_mem(vcpu->kvm, data, 32, debug_fd);
240 
241 	dprintf(debug_fd, "\n*RA:\n");
242 	reg.id = RISCV_CORE_REG(regs.ra);
243 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
244 		die("KVM_GET_ONE_REG failed (show_code @ RA)");
245 
246 	kvm__dump_mem(vcpu->kvm, data, 32, debug_fd);
247 }
248 
249 static void kvm_cpu__show_csrs(struct kvm_cpu *vcpu)
250 {
251 	struct kvm_one_reg reg;
252 	struct kvm_riscv_csr csr;
253 	unsigned long data;
254 	int debug_fd = kvm_cpu__get_debug_fd();
255 
256 	reg.addr = (unsigned long)&data;
257 	dprintf(debug_fd, "\n Control Status Registers:\n");
258 	dprintf(debug_fd,   " ------------------------\n");
259 
260 	reg.id		= RISCV_CSR_REG(sstatus);
261 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
262 		die("KVM_GET_ONE_REG failed (sstatus)");
263 	csr.sstatus = data;
264 
265 	reg.id		= RISCV_CSR_REG(sie);
266 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
267 		die("KVM_GET_ONE_REG failed (sie)");
268 	csr.sie = data;
269 
270 	reg.id		= RISCV_CSR_REG(stvec);
271 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
272 		die("KVM_GET_ONE_REG failed (stvec)");
273 	csr.stvec = data;
274 
275 	reg.id		= RISCV_CSR_REG(sip);
276 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
277 		die("KVM_GET_ONE_REG failed (sip)");
278 	csr.sip = data;
279 
280 	reg.id		= RISCV_CSR_REG(satp);
281 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
282 		die("KVM_GET_ONE_REG failed (satp)");
283 	csr.satp = data;
284 
285 	reg.id		= RISCV_CSR_REG(stval);
286 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
287 		die("KVM_GET_ONE_REG failed (stval)");
288 	csr.stval = data;
289 
290 	reg.id		= RISCV_CSR_REG(scause);
291 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
292 		die("KVM_GET_ONE_REG failed (SCAUSE)");
293 	csr.scause = data;
294 
295 	reg.id		= RISCV_CSR_REG(sscratch);
296 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
297 		die("KVM_GET_ONE_REG failed (sscartch)");
298 	csr.sscratch = data;
299 	dprintf(debug_fd, " SSTATUS:  0x%016lx\n", csr.sstatus);
300 	dprintf(debug_fd, " SIE:      0x%016lx\n", csr.sie);
301 	dprintf(debug_fd, " STVEC:    0x%016lx\n", csr.stvec);
302 	dprintf(debug_fd, " SIP:      0x%016lx\n", csr.sip);
303 	dprintf(debug_fd, " SATP:     0x%016lx\n", csr.satp);
304 	dprintf(debug_fd, " STVAL:    0x%016lx\n", csr.stval);
305 	dprintf(debug_fd, " SCAUSE:   0x%016lx\n", csr.scause);
306 	dprintf(debug_fd, " SSCRATCH: 0x%016lx\n", csr.sscratch);
307 }
308 
309 void kvm_cpu__show_registers(struct kvm_cpu *vcpu)
310 {
311 	struct kvm_one_reg reg;
312 	unsigned long data;
313 	int debug_fd = kvm_cpu__get_debug_fd();
314 	struct kvm_riscv_core core;
315 
316 	reg.addr = (unsigned long)&data;
317 
318 	reg.id		= RISCV_CORE_REG(mode);
319 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
320 		die("KVM_GET_ONE_REG failed (mode)");
321 	core.mode = data;
322 
323 	reg.id		= RISCV_CORE_REG(regs.pc);
324 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
325 		die("KVM_GET_ONE_REG failed (pc)");
326 	core.regs.pc = data;
327 
328 	reg.id		= RISCV_CORE_REG(regs.ra);
329 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
330 		die("KVM_GET_ONE_REG failed (ra)");
331 	core.regs.ra = data;
332 
333 	reg.id		= RISCV_CORE_REG(regs.sp);
334 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
335 		die("KVM_GET_ONE_REG failed (sp)");
336 	core.regs.sp = data;
337 
338 	reg.id		= RISCV_CORE_REG(regs.gp);
339 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
340 		die("KVM_GET_ONE_REG failed (gp)");
341 	core.regs.gp = data;
342 
343 	reg.id		= RISCV_CORE_REG(regs.tp);
344 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
345 		die("KVM_GET_ONE_REG failed (tp)");
346 	core.regs.tp = data;
347 
348 	reg.id		= RISCV_CORE_REG(regs.t0);
349 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
350 		die("KVM_GET_ONE_REG failed (t0)");
351 	core.regs.t0 = data;
352 
353 	reg.id		= RISCV_CORE_REG(regs.t1);
354 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
355 		die("KVM_GET_ONE_REG failed (t1)");
356 	core.regs.t1 = data;
357 
358 	reg.id		= RISCV_CORE_REG(regs.t2);
359 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
360 		die("KVM_GET_ONE_REG failed (t2)");
361 	core.regs.t2 = data;
362 
363 	reg.id		= RISCV_CORE_REG(regs.s0);
364 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
365 		die("KVM_GET_ONE_REG failed (s0)");
366 	core.regs.s0 = data;
367 
368 	reg.id		= RISCV_CORE_REG(regs.s1);
369 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
370 		die("KVM_GET_ONE_REG failed (s1)");
371 	core.regs.s1 = data;
372 
373 	reg.id		= RISCV_CORE_REG(regs.a0);
374 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
375 		die("KVM_GET_ONE_REG failed (a0)");
376 	core.regs.a0 = data;
377 
378 	reg.id		= RISCV_CORE_REG(regs.a1);
379 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
380 		die("KVM_GET_ONE_REG failed (a1)");
381 	core.regs.a1 = data;
382 
383 	reg.id		= RISCV_CORE_REG(regs.a2);
384 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
385 		die("KVM_GET_ONE_REG failed (a2)");
386 	core.regs.a2 = data;
387 
388 	reg.id		= RISCV_CORE_REG(regs.a3);
389 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
390 		die("KVM_GET_ONE_REG failed (a3)");
391 	core.regs.a3 = data;
392 
393 	reg.id		= RISCV_CORE_REG(regs.a4);
394 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
395 		die("KVM_GET_ONE_REG failed (a4)");
396 	core.regs.a4 = data;
397 
398 	reg.id		= RISCV_CORE_REG(regs.a5);
399 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
400 		die("KVM_GET_ONE_REG failed (a5)");
401 	core.regs.a5 = data;
402 
403 	reg.id		= RISCV_CORE_REG(regs.a6);
404 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
405 		die("KVM_GET_ONE_REG failed (a6)");
406 	core.regs.a6 = data;
407 
408 	reg.id		= RISCV_CORE_REG(regs.a7);
409 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
410 		die("KVM_GET_ONE_REG failed (a7)");
411 	core.regs.a7 = data;
412 
413 	reg.id		= RISCV_CORE_REG(regs.s2);
414 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
415 		die("KVM_GET_ONE_REG failed (s2)");
416 	core.regs.s2 = data;
417 
418 	reg.id		= RISCV_CORE_REG(regs.s3);
419 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
420 		die("KVM_GET_ONE_REG failed (s3)");
421 	core.regs.s3 = data;
422 
423 	reg.id		= RISCV_CORE_REG(regs.s4);
424 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
425 		die("KVM_GET_ONE_REG failed (s4)");
426 	core.regs.s4 = data;
427 
428 	reg.id		= RISCV_CORE_REG(regs.s5);
429 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
430 		die("KVM_GET_ONE_REG failed (s5)");
431 	core.regs.s5 = data;
432 
433 	reg.id		= RISCV_CORE_REG(regs.s6);
434 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
435 		die("KVM_GET_ONE_REG failed (s6)");
436 	core.regs.s6 = data;
437 
438 	reg.id		= RISCV_CORE_REG(regs.s7);
439 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
440 		die("KVM_GET_ONE_REG failed (s7)");
441 	core.regs.s7 = data;
442 
443 	reg.id		= RISCV_CORE_REG(regs.s8);
444 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
445 		die("KVM_GET_ONE_REG failed (s8)");
446 	core.regs.s8 = data;
447 
448 	reg.id		= RISCV_CORE_REG(regs.s9);
449 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
450 		die("KVM_GET_ONE_REG failed (s9)");
451 	core.regs.s9 = data;
452 
453 	reg.id		= RISCV_CORE_REG(regs.s10);
454 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
455 		die("KVM_GET_ONE_REG failed (s10)");
456 	core.regs.s10 = data;
457 
458 	reg.id		= RISCV_CORE_REG(regs.s11);
459 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
460 		die("KVM_GET_ONE_REG failed (s11)");
461 	core.regs.s11 = data;
462 
463 	reg.id		= RISCV_CORE_REG(regs.t3);
464 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
465 		die("KVM_GET_ONE_REG failed (t3)");
466 	core.regs.t3 = data;
467 
468 	reg.id		= RISCV_CORE_REG(regs.t4);
469 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
470 		die("KVM_GET_ONE_REG failed (t4)");
471 	core.regs.t4 = data;
472 
473 	reg.id		= RISCV_CORE_REG(regs.t5);
474 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
475 		die("KVM_GET_ONE_REG failed (t5)");
476 	core.regs.t5 = data;
477 
478 	reg.id		= RISCV_CORE_REG(regs.t6);
479 	if (ioctl(vcpu->vcpu_fd, KVM_GET_ONE_REG, &reg) < 0)
480 		die("KVM_GET_ONE_REG failed (t6)");
481 	core.regs.t6 = data;
482 
483 	dprintf(debug_fd, "\n General Purpose Registers:\n");
484 	dprintf(debug_fd,   " -------------------------\n");
485 	dprintf(debug_fd, " MODE:  0x%lx\n", data);
486 	dprintf(debug_fd, " PC: 0x%016lx   RA: 0x%016lx SP: 0x%016lx GP: 0x%016lx\n",
487 		core.regs.pc, core.regs.ra, core.regs.sp, core.regs.gp);
488 	dprintf(debug_fd, " TP: 0x%016lx   T0: 0x%016lx T1: 0x%016lx T2: 0x%016lx\n",
489 		core.regs.tp, core.regs.t0, core.regs.t1, core.regs.t2);
490 	dprintf(debug_fd, " S0: 0x%016lx   S1: 0x%016lx A0: 0x%016lx A1: 0x%016lx\n",
491 		core.regs.s0, core.regs.s1, core.regs.a0, core.regs.a1);
492 	dprintf(debug_fd, " A2: 0x%016lx   A3: 0x%016lx A4: 0x%016lx A5: 0x%016lx\n",
493 		core.regs.a2, core.regs.a3, core.regs.a4, core.regs.a5);
494 	dprintf(debug_fd, " A6: 0x%016lx   A7: 0x%016lx S2: 0x%016lx S3: 0x%016lx\n",
495 		core.regs.a6, core.regs.a7, core.regs.s2, core.regs.s3);
496 	dprintf(debug_fd, " S4: 0x%016lx   S5: 0x%016lx S6: 0x%016lx S7: 0x%016lx\n",
497 		core.regs.s4, core.regs.s5, core.regs.s6, core.regs.s7);
498 	dprintf(debug_fd, " S8: 0x%016lx   S9: 0x%016lx S10: 0x%016lx S11: 0x%016lx\n",
499 		core.regs.s8, core.regs.s9, core.regs.s10, core.regs.s11);
500 	dprintf(debug_fd, " T3: 0x%016lx   T4: 0x%016lx T5: 0x%016lx T6: 0x%016lx\n",
501 		core.regs.t3, core.regs.t4, core.regs.t5, core.regs.t6);
502 
503 	kvm_cpu__show_csrs(vcpu);
504 }
505