2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/svm_handler.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vm_guest_mem.h>
24 #include <palacios/vmm_decoder.h>
25 #include <palacios/vmm_ctrl_regs.h>
26 #include <palacios/svm_io.h>
27 #include <palacios/svm_halt.h>
28 #include <palacios/svm_pause.h>
29 #include <palacios/svm_wbinvd.h>
30 #include <palacios/vmm_intr.h>
31 #include <palacios/vmm_emulator.h>
32 #include <palacios/svm_msr.h>
33 #include <palacios/vmm_profiler.h>
38 int v3_handle_svm_exit(struct guest_info * info) {
39 vmcb_ctrl_t * guest_ctrl = 0;
40 vmcb_saved_state_t * guest_state = 0;
41 ulong_t exit_code = 0;
43 guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data));
44 guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
47 // Update the high level state
48 info->rip = guest_state->rip;
49 info->vm_regs.rsp = guest_state->rsp;
50 info->vm_regs.rax = guest_state->rax;
52 info->cpl = guest_state->cpl;
55 info->ctrl_regs.cr0 = guest_state->cr0;
56 info->ctrl_regs.cr2 = guest_state->cr2;
57 info->ctrl_regs.cr3 = guest_state->cr3;
58 info->ctrl_regs.cr4 = guest_state->cr4;
59 info->dbg_regs.dr6 = guest_state->dr6;
60 info->dbg_regs.dr7 = guest_state->dr7;
61 info->ctrl_regs.cr8 = guest_ctrl->guest_ctrl.V_TPR;
62 info->ctrl_regs.rflags = guest_state->rflags;
63 info->ctrl_regs.efer = guest_state->efer;
65 get_vmcb_segments((vmcb_t*)(info->vmm_data), &(info->segments));
66 info->cpu_mode = v3_get_cpu_mode(info);
67 info->mem_mode = v3_get_mem_mode(info);
70 exit_code = guest_ctrl->exit_code;
76 // Disable printing io exits due to bochs debug messages
77 //if (!((exit_code == VMEXIT_IOIO) && ((ushort_t)(guest_ctrl->exit_info1 >> 16) == 0x402))) {
80 // PrintDebug("SVM Returned: Exit Code: 0x%x \t\t(tsc=%ul)\n",exit_code, (uint_t)info->time_state.guest_tsc);
82 if ((0) && (exit_code < 0x4f)) {
85 // Dump out the instr stream
87 //PrintDebug("RIP: %x\n", guest_state->rip);
88 PrintDebug("RIP Linear: %p\n", (void *)get_addr_linear(info, info->rip, &(info->segments.cs)));
90 // OK, now we will read the instruction
91 // The only difference between PROTECTED and PROTECTED_PG is whether we read
92 // from guest_pa or guest_va
93 if (info->mem_mode == PHYSICAL_MEM) {
94 // The real rip address is actually a combination of the rip + CS base
95 ret = read_guest_pa_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 32, instr);
97 ret = read_guest_va_memory(info, get_addr_linear(info, info->rip, &(info->segments.cs)), 32, instr);
101 // I think we should inject a GPF into the guest
102 PrintDebug("Could not read instruction (ret=%d)\n", ret);
105 PrintDebug("Instr Stream:\n");
106 PrintTraceMemDump(instr, 32);
112 if (info->enable_profiler) {
113 rdtscll(info->profiler.start_time);
117 //PrintDebug("SVM Returned: Exit Code: %x\n",exit_code);
123 struct svm_io_info * io_info = (struct svm_io_info *)&(guest_ctrl->exit_info1);
125 if (io_info->type == 0) {
127 if (v3_handle_svm_io_outs(info) == -1 ) {
131 if (v3_handle_svm_io_out(info) == -1) {
137 if (v3_handle_svm_io_ins(info) == -1) {
141 if (v3_handle_svm_io_in(info) == -1) {
151 if (guest_ctrl->exit_info1 == 0) {
152 if (v3_handle_msr_read(info) == -1) {
155 } else if (guest_ctrl->exit_info1 == 1) {
156 if (v3_handle_msr_write(info) == -1) {
160 PrintError("Invalid MSR Operation\n");
166 case VMEXIT_CR0_WRITE:
168 #ifdef DEBUG_CTRL_REGS
169 PrintDebug("CR0 Write\n");
171 if (v3_handle_cr0_write(info) == -1) {
176 case VMEXIT_CR0_READ:
178 #ifdef DEBUG_CTRL_REGS
179 PrintDebug("CR0 Read\n");
181 if (v3_handle_cr0_read(info) == -1) {
186 case VMEXIT_CR3_WRITE:
188 #ifdef DEBUG_CTRL_REGS
189 PrintDebug("CR3 Write\n");
191 if (v3_handle_cr3_write(info) == -1) {
196 case VMEXIT_CR3_READ:
198 #ifdef DEBUG_CTRL_REGS
199 PrintDebug("CR3 Read\n");
201 if (v3_handle_cr3_read(info) == -1) {
206 case VMEXIT_CR4_WRITE:
208 #ifdef DEBUG_CTRL_REGS
209 PrintDebug("CR4 Write\n");
211 if (v3_handle_cr4_write(info) == -1) {
216 case VMEXIT_CR4_READ:
218 #ifdef DEBUG_CTRL_REGS
219 PrintDebug("CR4 Read\n");
221 if (v3_handle_cr4_read(info) == -1) {
229 addr_t fault_addr = guest_ctrl->exit_info2;
230 pf_error_t * error_code = (pf_error_t *)&(guest_ctrl->exit_info1);
231 #ifdef DEBUG_SHADOW_PAGING
232 PrintDebug("PageFault at %p (error=%d)\n",
233 (void *)fault_addr, *(uint_t *)error_code);
235 if (info->shdw_pg_mode == SHADOW_PAGING) {
236 if (v3_handle_shadow_pagefault(info, fault_addr, *error_code) == -1) {
240 PrintError("Page fault in un implemented paging mode\n");
247 PrintError("Currently unhandled Nested Page Fault\n");
254 if (info->shdw_pg_mode == SHADOW_PAGING) {
255 #ifdef DEBUG_SHADOW_PAGING
256 PrintDebug("Invlpg\n");
258 if (v3_handle_shadow_invlpg(info) == -1) {
264 (exit_code == VMEXIT_INVLPGA) ||
270 // handled by interrupt dispatch earlier
275 // handle_svm_smi(info); // ignored for now
281 PrintDebug("Guest halted\n");
283 if (v3_handle_svm_halt(info) == -1) {
289 //PrintDebug("Guest paused\n");
290 if (v3_handle_svm_pause(info) == -1) {
298 // Emulation handlers currently not used
301 #ifdef DEBUG_EMULATOR
302 PrintDebug("DEBUG EXCEPTION\n");
304 if (info->run_state == VM_EMULATING) {
305 if (v3_emulation_exit_handler(info) == -1) {
309 PrintError("VMMCALL with not emulator...\n");
318 #ifdef DEBUG_EMULATOR
319 PrintDebug("VMMCALL\n");
321 if (info->run_state == VM_EMULATING) {
322 if (v3_emulation_exit_handler(info) == -1) {
327 ulong_t tsc_spread = 0;
328 ullong_t exit_tsc = 0;
330 ulong_t rax = (ulong_t)info->vm_regs.rbx;
331 ulong_t rdx = (ulong_t)info->vm_regs.rcx;
333 *(ulong_t *)(&exit_tsc) = rax;
334 *(((ulong_t *)(&exit_tsc)) + 1) = rdx;
336 tsc_spread = info->exit_tsc - exit_tsc;
338 PrintError("VMMCALL tsc diff = %lu\n",tsc_spread);
341 PrintError("VMMCALL with not emulator...\n");
351 #ifdef DEBUG_EMULATOR
352 PrintDebug("WBINVD\n");
354 if (!v3_handle_svm_wbinvd(info)) {
363 /* Exits Following this line are NOT HANDLED */
364 /*=======================================================================*/
370 PrintDebug("Unhandled SVM Exit: %s\n", vmexit_code_to_str(exit_code));
372 rip_addr = get_addr_linear(info, guest_state->rip, &(info->segments.cs));
375 PrintError("SVM Returned:(VMCB=%p)\n", (void *)(info->vmm_data));
376 PrintError("RIP: %p\n", (void *)(addr_t)(guest_state->rip));
377 PrintError("RIP Linear: %p\n", (void *)(addr_t)(rip_addr));
379 PrintError("SVM Returned: Exit Code: %p\n", (void *)(addr_t)exit_code);
381 PrintError("io_info1 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info1));
382 PrintError("io_info1 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info1)) + 4));
384 PrintError("io_info2 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info2));
385 PrintError("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4));
394 // END OF SWITCH (EXIT_CODE)
397 if (info->enable_profiler) {
398 rdtscll(info->profiler.end_time);
399 v3_profile_exit(info, exit_code);
404 // Update the low level state
406 if (v3_intr_pending(info)) {
408 switch (v3_get_intr_type(info)) {
411 uint_t irq = v3_get_intr_number(info);
413 // check to see if ==-1 (non exists)
416 guest_ctrl->EVENTINJ.vector = irq;
417 guest_ctrl->EVENTINJ.valid = 1;
418 guest_ctrl->EVENTINJ.type = SVM_INJECTION_EXTERNAL_INTR;
421 guest_ctrl->guest_ctrl.V_IRQ = 1;
422 guest_ctrl->guest_ctrl.V_INTR_VECTOR = irq;
423 guest_ctrl->guest_ctrl.V_IGN_TPR = 1;
424 guest_ctrl->guest_ctrl.V_INTR_PRIO = 0xf;
425 #ifdef DEBUG_INTERRUPTS
426 PrintDebug("Injecting Interrupt %d (EIP=%p)\n",
427 guest_ctrl->guest_ctrl.V_INTR_VECTOR,
428 (void *)(addr_t)info->rip);
430 v3_injecting_intr(info, irq, EXTERNAL_IRQ);
435 guest_ctrl->EVENTINJ.type = SVM_INJECTION_NMI;
439 uint_t excp = v3_get_intr_number(info);
441 guest_ctrl->EVENTINJ.type = SVM_INJECTION_EXCEPTION;
443 if (info->intr_state.excp_error_code_valid) { //PAD
444 guest_ctrl->EVENTINJ.error_code = info->intr_state.excp_error_code;
445 guest_ctrl->EVENTINJ.ev = 1;
446 #ifdef DEBUG_INTERRUPTS
447 PrintDebug("Injecting error code %x\n", guest_ctrl->EVENTINJ.error_code);
451 guest_ctrl->EVENTINJ.vector = excp;
453 guest_ctrl->EVENTINJ.valid = 1;
454 #ifdef DEBUG_INTERRUPTS
455 PrintDebug("Injecting Interrupt %d (EIP=%p)\n",
456 guest_ctrl->EVENTINJ.vector,
457 (void *)(addr_t)info->rip);
459 v3_injecting_intr(info, excp, EXCEPTION);
463 guest_ctrl->EVENTINJ.type = SVM_INJECTION_SOFT_INTR;
466 guest_ctrl->EVENTINJ.type = SVM_INJECTION_VIRTUAL_INTR;
471 PrintError("Attempted to issue an invalid interrupt\n");
476 #ifdef DEBUG_INTERRUPTS
477 PrintDebug("No interrupts/exceptions pending\n");
481 guest_state->cr0 = info->ctrl_regs.cr0;
482 guest_state->cr2 = info->ctrl_regs.cr2;
483 guest_state->cr3 = info->ctrl_regs.cr3;
484 guest_state->cr4 = info->ctrl_regs.cr4;
485 guest_state->dr6 = info->dbg_regs.dr6;
486 guest_state->dr7 = info->dbg_regs.dr7;
487 guest_ctrl->guest_ctrl.V_TPR = info->ctrl_regs.cr8 & 0xff;
488 guest_state->rflags = info->ctrl_regs.rflags;
489 guest_state->efer = info->ctrl_regs.efer;
491 guest_state->cpl = info->cpl;
493 guest_state->rax = info->vm_regs.rax;
494 guest_state->rip = info->rip;
495 guest_state->rsp = info->vm_regs.rsp;
498 set_vmcb_segments((vmcb_t*)(info->vmm_data), &(info->segments));
500 if (exit_code == VMEXIT_INTR) {
501 //PrintDebug("INTR ret IP = %x\n", guest_state->rip);
508 static const char VMEXIT_CR0_READ_STR[] = "VMEXIT_CR0_READ";
509 static const char VMEXIT_CR1_READ_STR[] = "VMEXIT_CR1_READ";
510 static const char VMEXIT_CR2_READ_STR[] = "VMEXIT_CR2_READ";
511 static const char VMEXIT_CR3_READ_STR[] = "VMEXIT_CR3_READ";
512 static const char VMEXIT_CR4_READ_STR[] = "VMEXIT_CR4_READ";
513 static const char VMEXIT_CR5_READ_STR[] = "VMEXIT_CR5_READ";
514 static const char VMEXIT_CR6_READ_STR[] = "VMEXIT_CR6_READ";
515 static const char VMEXIT_CR7_READ_STR[] = "VMEXIT_CR7_READ";
516 static const char VMEXIT_CR8_READ_STR[] = "VMEXIT_CR8_READ";
517 static const char VMEXIT_CR9_READ_STR[] = "VMEXIT_CR9_READ";
518 static const char VMEXIT_CR10_READ_STR[] = "VMEXIT_CR10_READ";
519 static const char VMEXIT_CR11_READ_STR[] = "VMEXIT_CR11_READ";
520 static const char VMEXIT_CR12_READ_STR[] = "VMEXIT_CR12_READ";
521 static const char VMEXIT_CR13_READ_STR[] = "VMEXIT_CR13_READ";
522 static const char VMEXIT_CR14_READ_STR[] = "VMEXIT_CR14_READ";
523 static const char VMEXIT_CR15_READ_STR[] = "VMEXIT_CR15_READ";
524 static const char VMEXIT_CR0_WRITE_STR[] = "VMEXIT_CR0_WRITE";
525 static const char VMEXIT_CR1_WRITE_STR[] = "VMEXIT_CR1_WRITE";
526 static const char VMEXIT_CR2_WRITE_STR[] = "VMEXIT_CR2_WRITE";
527 static const char VMEXIT_CR3_WRITE_STR[] = "VMEXIT_CR3_WRITE";
528 static const char VMEXIT_CR4_WRITE_STR[] = "VMEXIT_CR4_WRITE";
529 static const char VMEXIT_CR5_WRITE_STR[] = "VMEXIT_CR5_WRITE";
530 static const char VMEXIT_CR6_WRITE_STR[] = "VMEXIT_CR6_WRITE";
531 static const char VMEXIT_CR7_WRITE_STR[] = "VMEXIT_CR7_WRITE";
532 static const char VMEXIT_CR8_WRITE_STR[] = "VMEXIT_CR8_WRITE";
533 static const char VMEXIT_CR9_WRITE_STR[] = "VMEXIT_CR9_WRITE";
534 static const char VMEXIT_CR10_WRITE_STR[] = "VMEXIT_CR10_WRITE";
535 static const char VMEXIT_CR11_WRITE_STR[] = "VMEXIT_CR11_WRITE";
536 static const char VMEXIT_CR12_WRITE_STR[] = "VMEXIT_CR12_WRITE";
537 static const char VMEXIT_CR13_WRITE_STR[] = "VMEXIT_CR13_WRITE";
538 static const char VMEXIT_CR14_WRITE_STR[] = "VMEXIT_CR14_WRITE";
539 static const char VMEXIT_CR15_WRITE_STR[] = "VMEXIT_CR15_WRITE";
540 static const char VMEXIT_DR0_READ_STR[] = "VMEXIT_DR0_READ";
541 static const char VMEXIT_DR1_READ_STR[] = "VMEXIT_DR1_READ";
542 static const char VMEXIT_DR2_READ_STR[] = "VMEXIT_DR2_READ";
543 static const char VMEXIT_DR3_READ_STR[] = "VMEXIT_DR3_READ";
544 static const char VMEXIT_DR4_READ_STR[] = "VMEXIT_DR4_READ";
545 static const char VMEXIT_DR5_READ_STR[] = "VMEXIT_DR5_READ";
546 static const char VMEXIT_DR6_READ_STR[] = "VMEXIT_DR6_READ";
547 static const char VMEXIT_DR7_READ_STR[] = "VMEXIT_DR7_READ";
548 static const char VMEXIT_DR8_READ_STR[] = "VMEXIT_DR8_READ";
549 static const char VMEXIT_DR9_READ_STR[] = "VMEXIT_DR9_READ";
550 static const char VMEXIT_DR10_READ_STR[] = "VMEXIT_DR10_READ";
551 static const char VMEXIT_DR11_READ_STR[] = "VMEXIT_DR11_READ";
552 static const char VMEXIT_DR12_READ_STR[] = "VMEXIT_DR12_READ";
553 static const char VMEXIT_DR13_READ_STR[] = "VMEXIT_DR13_READ";
554 static const char VMEXIT_DR14_READ_STR[] = "VMEXIT_DR14_READ";
555 static const char VMEXIT_DR15_READ_STR[] = "VMEXIT_DR15_READ";
556 static const char VMEXIT_DR0_WRITE_STR[] = "VMEXIT_DR0_WRITE";
557 static const char VMEXIT_DR1_WRITE_STR[] = "VMEXIT_DR1_WRITE";
558 static const char VMEXIT_DR2_WRITE_STR[] = "VMEXIT_DR2_WRITE";
559 static const char VMEXIT_DR3_WRITE_STR[] = "VMEXIT_DR3_WRITE";
560 static const char VMEXIT_DR4_WRITE_STR[] = "VMEXIT_DR4_WRITE";
561 static const char VMEXIT_DR5_WRITE_STR[] = "VMEXIT_DR5_WRITE";
562 static const char VMEXIT_DR6_WRITE_STR[] = "VMEXIT_DR6_WRITE";
563 static const char VMEXIT_DR7_WRITE_STR[] = "VMEXIT_DR7_WRITE";
564 static const char VMEXIT_DR8_WRITE_STR[] = "VMEXIT_DR8_WRITE";
565 static const char VMEXIT_DR9_WRITE_STR[] = "VMEXIT_DR9_WRITE";
566 static const char VMEXIT_DR10_WRITE_STR[] = "VMEXIT_DR10_WRITE";
567 static const char VMEXIT_DR11_WRITE_STR[] = "VMEXIT_DR11_WRITE";
568 static const char VMEXIT_DR12_WRITE_STR[] = "VMEXIT_DR12_WRITE";
569 static const char VMEXIT_DR13_WRITE_STR[] = "VMEXIT_DR13_WRITE";
570 static const char VMEXIT_DR14_WRITE_STR[] = "VMEXIT_DR14_WRITE";
571 static const char VMEXIT_DR15_WRITE_STR[] = "VMEXIT_DR15_WRITE";
572 static const char VMEXIT_EXCP0_STR[] = "VMEXIT_EXCP0";
573 static const char VMEXIT_EXCP1_STR[] = "VMEXIT_EXCP1";
574 static const char VMEXIT_EXCP2_STR[] = "VMEXIT_EXCP2";
575 static const char VMEXIT_EXCP3_STR[] = "VMEXIT_EXCP3";
576 static const char VMEXIT_EXCP4_STR[] = "VMEXIT_EXCP4";
577 static const char VMEXIT_EXCP5_STR[] = "VMEXIT_EXCP5";
578 static const char VMEXIT_EXCP6_STR[] = "VMEXIT_EXCP6";
579 static const char VMEXIT_EXCP7_STR[] = "VMEXIT_EXCP7";
580 static const char VMEXIT_EXCP8_STR[] = "VMEXIT_EXCP8";
581 static const char VMEXIT_EXCP9_STR[] = "VMEXIT_EXCP9";
582 static const char VMEXIT_EXCP10_STR[] = "VMEXIT_EXCP10";
583 static const char VMEXIT_EXCP11_STR[] = "VMEXIT_EXCP11";
584 static const char VMEXIT_EXCP12_STR[] = "VMEXIT_EXCP12";
585 static const char VMEXIT_EXCP13_STR[] = "VMEXIT_EXCP13";
586 static const char VMEXIT_EXCP14_STR[] = "VMEXIT_EXCP14";
587 static const char VMEXIT_EXCP15_STR[] = "VMEXIT_EXCP15";
588 static const char VMEXIT_EXCP16_STR[] = "VMEXIT_EXCP16";
589 static const char VMEXIT_EXCP17_STR[] = "VMEXIT_EXCP17";
590 static const char VMEXIT_EXCP18_STR[] = "VMEXIT_EXCP18";
591 static const char VMEXIT_EXCP19_STR[] = "VMEXIT_EXCP19";
592 static const char VMEXIT_EXCP20_STR[] = "VMEXIT_EXCP20";
593 static const char VMEXIT_EXCP21_STR[] = "VMEXIT_EXCP21";
594 static const char VMEXIT_EXCP22_STR[] = "VMEXIT_EXCP22";
595 static const char VMEXIT_EXCP23_STR[] = "VMEXIT_EXCP23";
596 static const char VMEXIT_EXCP24_STR[] = "VMEXIT_EXCP24";
597 static const char VMEXIT_EXCP25_STR[] = "VMEXIT_EXCP25";
598 static const char VMEXIT_EXCP26_STR[] = "VMEXIT_EXCP26";
599 static const char VMEXIT_EXCP27_STR[] = "VMEXIT_EXCP27";
600 static const char VMEXIT_EXCP28_STR[] = "VMEXIT_EXCP28";
601 static const char VMEXIT_EXCP29_STR[] = "VMEXIT_EXCP29";
602 static const char VMEXIT_EXCP30_STR[] = "VMEXIT_EXCP30";
603 static const char VMEXIT_EXCP31_STR[] = "VMEXIT_EXCP31";
604 static const char VMEXIT_INTR_STR[] = "VMEXIT_INTR";
605 static const char VMEXIT_NMI_STR[] = "VMEXIT_NMI";
606 static const char VMEXIT_SMI_STR[] = "VMEXIT_SMI";
607 static const char VMEXIT_INIT_STR[] = "VMEXIT_INIT";
608 static const char VMEXIT_VINITR_STR[] = "VMEXIT_VINITR";
609 static const char VMEXIT_CR0_SEL_WRITE_STR[] = "VMEXIT_CR0_SEL_WRITE";
610 static const char VMEXIT_IDTR_READ_STR[] = "VMEXIT_IDTR_READ";
611 static const char VMEXIT_GDTR_READ_STR[] = "VMEXIT_GDTR_READ";
612 static const char VMEXIT_LDTR_READ_STR[] = "VMEXIT_LDTR_READ";
613 static const char VMEXIT_TR_READ_STR[] = "VMEXIT_TR_READ";
614 static const char VMEXIT_IDTR_WRITE_STR[] = "VMEXIT_IDTR_WRITE";
615 static const char VMEXIT_GDTR_WRITE_STR[] = "VMEXIT_GDTR_WRITE";
616 static const char VMEXIT_LDTR_WRITE_STR[] = "VMEXIT_LDTR_WRITE";
617 static const char VMEXIT_TR_WRITE_STR[] = "VMEXIT_TR_WRITE";
618 static const char VMEXIT_RDTSC_STR[] = "VMEXIT_RDTSC";
619 static const char VMEXIT_RDPMC_STR[] = "VMEXIT_RDPMC";
620 static const char VMEXIT_PUSHF_STR[] = "VMEXIT_PUSHF";
621 static const char VMEXIT_POPF_STR[] = "VMEXIT_POPF";
622 static const char VMEXIT_CPUID_STR[] = "VMEXIT_CPUID";
623 static const char VMEXIT_RSM_STR[] = "VMEXIT_RSM";
624 static const char VMEXIT_IRET_STR[] = "VMEXIT_IRET";
625 static const char VMEXIT_SWINT_STR[] = "VMEXIT_SWINT";
626 static const char VMEXIT_INVD_STR[] = "VMEXIT_INVD";
627 static const char VMEXIT_PAUSE_STR[] = "VMEXIT_PAUSE";
628 static const char VMEXIT_HLT_STR[] = "VMEXIT_HLT";
629 static const char VMEXIT_INVLPG_STR[] = "VMEXIT_INVLPG";
630 static const char VMEXIT_INVLPGA_STR[] = "VMEXIT_INVLPGA";
631 static const char VMEXIT_IOIO_STR[] = "VMEXIT_IOIO";
632 static const char VMEXIT_MSR_STR[] = "VMEXIT_MSR";
633 static const char VMEXIT_TASK_SWITCH_STR[] = "VMEXIT_TASK_SWITCH";
634 static const char VMEXIT_FERR_FREEZE_STR[] = "VMEXIT_FERR_FREEZE";
635 static const char VMEXIT_SHUTDOWN_STR[] = "VMEXIT_SHUTDOWN";
636 static const char VMEXIT_VMRUN_STR[] = "VMEXIT_VMRUN";
637 static const char VMEXIT_VMMCALL_STR[] = "VMEXIT_VMMCALL";
638 static const char VMEXIT_VMLOAD_STR[] = "VMEXIT_VMLOAD";
639 static const char VMEXIT_VMSAVE_STR[] = "VMEXIT_VMSAVE";
640 static const char VMEXIT_STGI_STR[] = "VMEXIT_STGI";
641 static const char VMEXIT_CLGI_STR[] = "VMEXIT_CLGI";
642 static const char VMEXIT_SKINIT_STR[] = "VMEXIT_SKINIT";
643 static const char VMEXIT_RDTSCP_STR[] = "VMEXIT_RDTSCP";
644 static const char VMEXIT_ICEBP_STR[] = "VMEXIT_ICEBP";
645 static const char VMEXIT_WBINVD_STR[] = "VMEXIT_WBINVD";
646 static const char VMEXIT_MONITOR_STR[] = "VMEXIT_MONITOR";
647 static const char VMEXIT_MWAIT_STR[] = "VMEXIT_MWAIT";
648 static const char VMEXIT_MWAIT_CONDITIONAL_STR[] = "VMEXIT_MWAIT_CONDITIONAL";
649 static const char VMEXIT_NPF_STR[] = "VMEXIT_NPF";
650 static const char VMEXIT_INVALID_VMCB_STR[] = "VMEXIT_INVALID_VMCB";
654 const char * vmexit_code_to_str(uint_t exit_code) {
656 case VMEXIT_CR0_READ:
657 return VMEXIT_CR0_READ_STR;
658 case VMEXIT_CR1_READ:
659 return VMEXIT_CR1_READ_STR;
660 case VMEXIT_CR2_READ:
661 return VMEXIT_CR2_READ_STR;
662 case VMEXIT_CR3_READ:
663 return VMEXIT_CR3_READ_STR;
664 case VMEXIT_CR4_READ:
665 return VMEXIT_CR4_READ_STR;
666 case VMEXIT_CR5_READ:
667 return VMEXIT_CR5_READ_STR;
668 case VMEXIT_CR6_READ:
669 return VMEXIT_CR6_READ_STR;
670 case VMEXIT_CR7_READ:
671 return VMEXIT_CR7_READ_STR;
672 case VMEXIT_CR8_READ:
673 return VMEXIT_CR8_READ_STR;
674 case VMEXIT_CR9_READ:
675 return VMEXIT_CR9_READ_STR;
676 case VMEXIT_CR10_READ:
677 return VMEXIT_CR10_READ_STR;
678 case VMEXIT_CR11_READ:
679 return VMEXIT_CR11_READ_STR;
680 case VMEXIT_CR12_READ:
681 return VMEXIT_CR12_READ_STR;
682 case VMEXIT_CR13_READ:
683 return VMEXIT_CR13_READ_STR;
684 case VMEXIT_CR14_READ:
685 return VMEXIT_CR14_READ_STR;
686 case VMEXIT_CR15_READ:
687 return VMEXIT_CR15_READ_STR;
688 case VMEXIT_CR0_WRITE:
689 return VMEXIT_CR0_WRITE_STR;
690 case VMEXIT_CR1_WRITE:
691 return VMEXIT_CR1_WRITE_STR;
692 case VMEXIT_CR2_WRITE:
693 return VMEXIT_CR2_WRITE_STR;
694 case VMEXIT_CR3_WRITE:
695 return VMEXIT_CR3_WRITE_STR;
696 case VMEXIT_CR4_WRITE:
697 return VMEXIT_CR4_WRITE_STR;
698 case VMEXIT_CR5_WRITE:
699 return VMEXIT_CR5_WRITE_STR;
700 case VMEXIT_CR6_WRITE:
701 return VMEXIT_CR6_WRITE_STR;
702 case VMEXIT_CR7_WRITE:
703 return VMEXIT_CR7_WRITE_STR;
704 case VMEXIT_CR8_WRITE:
705 return VMEXIT_CR8_WRITE_STR;
706 case VMEXIT_CR9_WRITE:
707 return VMEXIT_CR9_WRITE_STR;
708 case VMEXIT_CR10_WRITE:
709 return VMEXIT_CR10_WRITE_STR;
710 case VMEXIT_CR11_WRITE:
711 return VMEXIT_CR11_WRITE_STR;
712 case VMEXIT_CR12_WRITE:
713 return VMEXIT_CR12_WRITE_STR;
714 case VMEXIT_CR13_WRITE:
715 return VMEXIT_CR13_WRITE_STR;
716 case VMEXIT_CR14_WRITE:
717 return VMEXIT_CR14_WRITE_STR;
718 case VMEXIT_CR15_WRITE:
719 return VMEXIT_CR15_WRITE_STR;
720 case VMEXIT_DR0_READ:
721 return VMEXIT_DR0_READ_STR;
722 case VMEXIT_DR1_READ:
723 return VMEXIT_DR1_READ_STR;
724 case VMEXIT_DR2_READ:
725 return VMEXIT_DR2_READ_STR;
726 case VMEXIT_DR3_READ:
727 return VMEXIT_DR3_READ_STR;
728 case VMEXIT_DR4_READ:
729 return VMEXIT_DR4_READ_STR;
730 case VMEXIT_DR5_READ:
731 return VMEXIT_DR5_READ_STR;
732 case VMEXIT_DR6_READ:
733 return VMEXIT_DR6_READ_STR;
734 case VMEXIT_DR7_READ:
735 return VMEXIT_DR7_READ_STR;
736 case VMEXIT_DR8_READ:
737 return VMEXIT_DR8_READ_STR;
738 case VMEXIT_DR9_READ:
739 return VMEXIT_DR9_READ_STR;
740 case VMEXIT_DR10_READ:
741 return VMEXIT_DR10_READ_STR;
742 case VMEXIT_DR11_READ:
743 return VMEXIT_DR11_READ_STR;
744 case VMEXIT_DR12_READ:
745 return VMEXIT_DR12_READ_STR;
746 case VMEXIT_DR13_READ:
747 return VMEXIT_DR13_READ_STR;
748 case VMEXIT_DR14_READ:
749 return VMEXIT_DR14_READ_STR;
750 case VMEXIT_DR15_READ:
751 return VMEXIT_DR15_READ_STR;
752 case VMEXIT_DR0_WRITE:
753 return VMEXIT_DR0_WRITE_STR;
754 case VMEXIT_DR1_WRITE:
755 return VMEXIT_DR1_WRITE_STR;
756 case VMEXIT_DR2_WRITE:
757 return VMEXIT_DR2_WRITE_STR;
758 case VMEXIT_DR3_WRITE:
759 return VMEXIT_DR3_WRITE_STR;
760 case VMEXIT_DR4_WRITE:
761 return VMEXIT_DR4_WRITE_STR;
762 case VMEXIT_DR5_WRITE:
763 return VMEXIT_DR5_WRITE_STR;
764 case VMEXIT_DR6_WRITE:
765 return VMEXIT_DR6_WRITE_STR;
766 case VMEXIT_DR7_WRITE:
767 return VMEXIT_DR7_WRITE_STR;
768 case VMEXIT_DR8_WRITE:
769 return VMEXIT_DR8_WRITE_STR;
770 case VMEXIT_DR9_WRITE:
771 return VMEXIT_DR9_WRITE_STR;
772 case VMEXIT_DR10_WRITE:
773 return VMEXIT_DR10_WRITE_STR;
774 case VMEXIT_DR11_WRITE:
775 return VMEXIT_DR11_WRITE_STR;
776 case VMEXIT_DR12_WRITE:
777 return VMEXIT_DR12_WRITE_STR;
778 case VMEXIT_DR13_WRITE:
779 return VMEXIT_DR13_WRITE_STR;
780 case VMEXIT_DR14_WRITE:
781 return VMEXIT_DR14_WRITE_STR;
782 case VMEXIT_DR15_WRITE:
783 return VMEXIT_DR15_WRITE_STR;
785 return VMEXIT_EXCP0_STR;
787 return VMEXIT_EXCP1_STR;
789 return VMEXIT_EXCP2_STR;
791 return VMEXIT_EXCP3_STR;
793 return VMEXIT_EXCP4_STR;
795 return VMEXIT_EXCP5_STR;
797 return VMEXIT_EXCP6_STR;
799 return VMEXIT_EXCP7_STR;
801 return VMEXIT_EXCP8_STR;
803 return VMEXIT_EXCP9_STR;
805 return VMEXIT_EXCP10_STR;
807 return VMEXIT_EXCP11_STR;
809 return VMEXIT_EXCP12_STR;
811 return VMEXIT_EXCP13_STR;
813 return VMEXIT_EXCP14_STR;
815 return VMEXIT_EXCP15_STR;
817 return VMEXIT_EXCP16_STR;
819 return VMEXIT_EXCP17_STR;
821 return VMEXIT_EXCP18_STR;
823 return VMEXIT_EXCP19_STR;
825 return VMEXIT_EXCP20_STR;
827 return VMEXIT_EXCP21_STR;
829 return VMEXIT_EXCP22_STR;
831 return VMEXIT_EXCP23_STR;
833 return VMEXIT_EXCP24_STR;
835 return VMEXIT_EXCP25_STR;
837 return VMEXIT_EXCP26_STR;
839 return VMEXIT_EXCP27_STR;
841 return VMEXIT_EXCP28_STR;
843 return VMEXIT_EXCP29_STR;
845 return VMEXIT_EXCP30_STR;
847 return VMEXIT_EXCP31_STR;
849 return VMEXIT_INTR_STR;
851 return VMEXIT_NMI_STR;
853 return VMEXIT_SMI_STR;
855 return VMEXIT_INIT_STR;
857 return VMEXIT_VINITR_STR;
858 case VMEXIT_CR0_SEL_WRITE:
859 return VMEXIT_CR0_SEL_WRITE_STR;
860 case VMEXIT_IDTR_READ:
861 return VMEXIT_IDTR_READ_STR;
862 case VMEXIT_GDTR_READ:
863 return VMEXIT_GDTR_READ_STR;
864 case VMEXIT_LDTR_READ:
865 return VMEXIT_LDTR_READ_STR;
867 return VMEXIT_TR_READ_STR;
868 case VMEXIT_IDTR_WRITE:
869 return VMEXIT_IDTR_WRITE_STR;
870 case VMEXIT_GDTR_WRITE:
871 return VMEXIT_GDTR_WRITE_STR;
872 case VMEXIT_LDTR_WRITE:
873 return VMEXIT_LDTR_WRITE_STR;
874 case VMEXIT_TR_WRITE:
875 return VMEXIT_TR_WRITE_STR;
877 return VMEXIT_RDTSC_STR;
879 return VMEXIT_RDPMC_STR;
881 return VMEXIT_PUSHF_STR;
883 return VMEXIT_POPF_STR;
885 return VMEXIT_CPUID_STR;
887 return VMEXIT_RSM_STR;
889 return VMEXIT_IRET_STR;
891 return VMEXIT_SWINT_STR;
893 return VMEXIT_INVD_STR;
895 return VMEXIT_PAUSE_STR;
897 return VMEXIT_HLT_STR;
899 return VMEXIT_INVLPG_STR;
901 return VMEXIT_INVLPGA_STR;
903 return VMEXIT_IOIO_STR;
905 return VMEXIT_MSR_STR;
906 case VMEXIT_TASK_SWITCH:
907 return VMEXIT_TASK_SWITCH_STR;
908 case VMEXIT_FERR_FREEZE:
909 return VMEXIT_FERR_FREEZE_STR;
910 case VMEXIT_SHUTDOWN:
911 return VMEXIT_SHUTDOWN_STR;
913 return VMEXIT_VMRUN_STR;
915 return VMEXIT_VMMCALL_STR;
917 return VMEXIT_VMLOAD_STR;
919 return VMEXIT_VMSAVE_STR;
921 return VMEXIT_STGI_STR;
923 return VMEXIT_CLGI_STR;
925 return VMEXIT_SKINIT_STR;
927 return VMEXIT_RDTSCP_STR;
929 return VMEXIT_ICEBP_STR;
931 return VMEXIT_WBINVD_STR;
933 return VMEXIT_MONITOR_STR;
935 return VMEXIT_MWAIT_STR;
936 case VMEXIT_MWAIT_CONDITIONAL:
937 return VMEXIT_MWAIT_CONDITIONAL_STR;
939 return VMEXIT_NPF_STR;
940 case VMEXIT_INVALID_VMCB:
941 return VMEXIT_INVALID_VMCB_STR;