Deleted Added
full compact
vmcs.c (221914) vmcs.c (222605)
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#include "opt_ddb.h"
30
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD$");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/pcpu.h>
35
36#include <vm/vm.h>
37#include <vm/pmap.h>
38
39#include <machine/segments.h>
40#include <machine/pmap.h>
41
42#include <machine/vmm.h>
43#include "vmcs.h"
44#include "vmx_cpufunc.h"
45#include "ept.h"
46#include "vmx.h"
47
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD$");
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/pcpu.h>
37
38#include <vm/vm.h>
39#include <vm/pmap.h>
40
41#include <machine/segments.h>
42#include <machine/pmap.h>
43
44#include <machine/vmm.h>
45#include "vmcs.h"
46#include "vmx_cpufunc.h"
47#include "ept.h"
48#include "vmx.h"
49
50#ifdef DDB
51#include <ddb/ddb.h>
52#endif
53
48static uint64_t
49vmcs_fix_regval(uint32_t encoding, uint64_t val)
50{
51
52 switch (encoding) {
53 case VMCS_GUEST_CR0:
54 val = vmx_fix_cr0(val);
55 break;

--- 388 unchanged lines hidden (view full) ---

444 uint64_t val;
445
446 error = vmread(encoding, &val);
447 if (error != 0)
448 panic("vmcs_read(%u) error %d", encoding, error);
449
450 return (val);
451}
54static uint64_t
55vmcs_fix_regval(uint32_t encoding, uint64_t val)
56{
57
58 switch (encoding) {
59 case VMCS_GUEST_CR0:
60 val = vmx_fix_cr0(val);
61 break;

--- 388 unchanged lines hidden (view full) ---

450 uint64_t val;
451
452 error = vmread(encoding, &val);
453 if (error != 0)
454 panic("vmcs_read(%u) error %d", encoding, error);
455
456 return (val);
457}
458
459#ifdef DDB
460extern int vmxon_enabled[];
461
462DB_SHOW_COMMAND(vmcs, db_show_vmcs)
463{
464 uint64_t cur_vmcs, val;
465 uint32_t exit;
466
467 if (!vmxon_enabled[curcpu]) {
468 db_printf("VMX not enabled\n");
469 return;
470 }
471
472 if (have_addr) {
473 db_printf("Only current VMCS supported\n");
474 return;
475 }
476
477 vmptrst(&cur_vmcs);
478 if (cur_vmcs == VMCS_INITIAL) {
479 db_printf("No current VM context\n");
480 return;
481 }
482 db_printf("VMCS: %jx\n", cur_vmcs);
483 db_printf("VPID: %lu\n", vmcs_read(VMCS_VPID));
484 db_printf("Activity: ");
485 val = vmcs_read(VMCS_GUEST_ACTIVITY);
486 switch (val) {
487 case 0:
488 db_printf("Active");
489 break;
490 case 1:
491 db_printf("HLT");
492 break;
493 case 2:
494 db_printf("Shutdown");
495 break;
496 case 3:
497 db_printf("Wait for SIPI");
498 break;
499 default:
500 db_printf("Unknown: %#lx", val);
501 }
502 db_printf("\n");
503 exit = vmcs_read(VMCS_EXIT_REASON);
504 if (exit & 0x80000000)
505 db_printf("Entry Failure Reason: %u\n", exit & 0xffff);
506 else
507 db_printf("Exit Reason: %u\n", exit & 0xffff);
508 db_printf("Qualification: %#lx\n", vmcs_exit_qualification());
509 db_printf("Guest Linear Address: %#lx\n",
510 vmcs_read(VMCS_GUEST_LINEAR_ADDRESS));
511 switch (exit & 0x8000ffff) {
512 case EXIT_REASON_EXCEPTION:
513 case EXIT_REASON_EXT_INTR:
514 val = vmcs_read(VMCS_EXIT_INTERRUPTION_INFO);
515 db_printf("Interrupt Type: ");
516 switch (val >> 8 & 0x7) {
517 case 0:
518 db_printf("external");
519 break;
520 case 2:
521 db_printf("NMI");
522 break;
523 case 3:
524 db_printf("HW exception");
525 break;
526 case 4:
527 db_printf("SW exception");
528 break;
529 default:
530 db_printf("?? %lu", val >> 8 & 0x7);
531 break;
532 }
533 db_printf(" Vector: %lu", val & 0xff);
534 if (val & 0x800)
535 db_printf(" Error Code: %lx",
536 vmcs_read(VMCS_EXIT_INTERRUPTION_ERROR));
537 db_printf("\n");
538 break;
539 case EXIT_REASON_EPT_FAULT:
540 case EXIT_REASON_EPT_MISCONFIG:
541 db_printf("Guest Physical Address: %#lx\n",
542 vmcs_read(VMCS_GUEST_PHYSICAL_ADDRESS));
543 break;
544 }
545 db_printf("VM-instruction error: %#lx\n", vmcs_instruction_error());
546}
547#endif