Deleted Added
sdiff udiff text old ( 262352 ) new ( 266339 )
full compact
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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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: stable/10/sys/amd64/vmm/intel/vmcs.c 266339 2014-05-17 19:11:08Z jhb $
27 */
28
29#include "opt_ddb.h"
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/10/sys/amd64/vmm/intel/vmcs.c 266339 2014-05-17 19:11:08Z jhb $");
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

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

310
311 error = 0;
312done:
313 VMCLEAR(vmcs);
314 return (error);
315}
316
317int
318vmcs_init(struct vmcs *vmcs)
319{
320 int error, codesel, datasel, tsssel;
321 u_long cr0, cr4, efer;
322 uint64_t pat, fsbase, idtrbase;
323 uint32_t exc_bitmap;
324
325 codesel = vmm_get_host_codesel();
326 datasel = vmm_get_host_datasel();
327 tsssel = vmm_get_host_tsssel();
328
329 /*
330 * Make sure we have a "current" VMCS to work with.
331 */
332 VMPTRLD(vmcs);
333
334 /* Initialize guest IA32_PAT MSR with the default value */
335 pat = PAT_VALUE(0, PAT_WRITE_BACK) |
336 PAT_VALUE(1, PAT_WRITE_THROUGH) |
337 PAT_VALUE(2, PAT_UNCACHED) |
338 PAT_VALUE(3, PAT_UNCACHEABLE) |
339 PAT_VALUE(4, PAT_WRITE_BACK) |
340 PAT_VALUE(5, PAT_WRITE_THROUGH) |
341 PAT_VALUE(6, PAT_UNCACHED) |

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

397 if ((error = vmwrite(VMCS_HOST_FS_BASE, fsbase)) != 0)
398 goto done;
399
400 idtrbase = vmm_get_host_idtrbase();
401 if ((error = vmwrite(VMCS_HOST_IDTR_BASE, idtrbase)) != 0)
402 goto done;
403
404 /* instruction pointer */
405 if ((error = vmwrite(VMCS_HOST_RIP, (u_long)vmx_exit_guest)) != 0)
406 goto done;
407
408 /* exception bitmap */
409 exc_bitmap = 1 << IDT_MC;
410 if ((error = vmwrite(VMCS_EXCEPTION_BITMAP, exc_bitmap)) != 0)
411 goto done;
412
413 /* link pointer */
414 if ((error = vmwrite(VMCS_LINK_POINTER, ~0)) != 0)
415 goto done;

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

468 else
469 db_printf("Exit Reason: %u\n", exit & 0xffff);
470 db_printf("Qualification: %#lx\n", vmcs_exit_qualification());
471 db_printf("Guest Linear Address: %#lx\n",
472 vmcs_read(VMCS_GUEST_LINEAR_ADDRESS));
473 switch (exit & 0x8000ffff) {
474 case EXIT_REASON_EXCEPTION:
475 case EXIT_REASON_EXT_INTR:
476 val = vmcs_read(VMCS_EXIT_INTR_INFO);
477 db_printf("Interrupt Type: ");
478 switch (val >> 8 & 0x7) {
479 case 0:
480 db_printf("external");
481 break;
482 case 2:
483 db_printf("NMI");
484 break;

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

490 break;
491 default:
492 db_printf("?? %lu", val >> 8 & 0x7);
493 break;
494 }
495 db_printf(" Vector: %lu", val & 0xff);
496 if (val & 0x800)
497 db_printf(" Error Code: %lx",
498 vmcs_read(VMCS_EXIT_INTR_ERRCODE));
499 db_printf("\n");
500 break;
501 case EXIT_REASON_EPT_FAULT:
502 case EXIT_REASON_EPT_MISCONFIG:
503 db_printf("Guest Physical Address: %#lx\n",
504 vmcs_read(VMCS_GUEST_PHYSICAL_ADDRESS));
505 break;
506 }
507 db_printf("VM-instruction error: %#lx\n", vmcs_instruction_error());
508}
509#endif