vmx.c (f76fc5d414cca9800385f735df4e572a81b54efe) | vmx.c (b01c2033255e5b9ca1981311d44d6955760cd7bc) |
---|---|
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 --- 37 unchanged lines hidden (view full) --- 46#include <machine/pmap.h> 47#include <machine/segments.h> 48#include <machine/specialreg.h> 49#include <machine/vmparam.h> 50 51#include <x86/apicreg.h> 52 53#include <machine/vmm.h> | 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 --- 37 unchanged lines hidden (view full) --- 46#include <machine/pmap.h> 47#include <machine/segments.h> 48#include <machine/specialreg.h> 49#include <machine/vmparam.h> 50 51#include <x86/apicreg.h> 52 53#include <machine/vmm.h> |
54#include "vmm_host.h" |
|
54#include "vmm_lapic.h" 55#include "vmm_msr.h" 56#include "vmm_ktr.h" 57#include "vmm_stat.h" 58 59#include "vmx_msr.h" 60#include "ept.h" 61#include "vmx_cpufunc.h" 62#include "vmx.h" 63#include "x86.h" 64#include "vmx_controls.h" 65#include "vmm_instruction_emul.h" 66 | 55#include "vmm_lapic.h" 56#include "vmm_msr.h" 57#include "vmm_ktr.h" 58#include "vmm_stat.h" 59 60#include "vmx_msr.h" 61#include "ept.h" 62#include "vmx_cpufunc.h" 63#include "vmx.h" 64#include "x86.h" 65#include "vmx_controls.h" 66#include "vmm_instruction_emul.h" 67 |
67#define CR4_VMXE (1UL << 13) 68 | |
69#define PINBASED_CTLS_ONE_SETTING \ 70 (PINBASED_EXTINT_EXITING | \ 71 PINBASED_NMI_EXITING | \ 72 PINBASED_VIRTUAL_NMI) 73#define PINBASED_CTLS_ZERO_SETTING 0 74 75#define PROCBASED_CTLS_WINDOW_SETTING \ 76 (PROCBASED_INT_WINDOW_EXITING | \ --- 36 unchanged lines hidden (view full) --- 113#define guest_msr_rw(vmx, msr) \ 114 msr_bitmap_change_access((vmx)->msr_bitmap, (msr), MSR_BITMAP_ACCESS_RW) 115 116#define HANDLED 1 117#define UNHANDLED 0 118 119MALLOC_DEFINE(M_VMX, "vmx", "vmx"); 120 | 68#define PINBASED_CTLS_ONE_SETTING \ 69 (PINBASED_EXTINT_EXITING | \ 70 PINBASED_NMI_EXITING | \ 71 PINBASED_VIRTUAL_NMI) 72#define PINBASED_CTLS_ZERO_SETTING 0 73 74#define PROCBASED_CTLS_WINDOW_SETTING \ 75 (PROCBASED_INT_WINDOW_EXITING | \ --- 36 unchanged lines hidden (view full) --- 112#define guest_msr_rw(vmx, msr) \ 113 msr_bitmap_change_access((vmx)->msr_bitmap, (msr), MSR_BITMAP_ACCESS_RW) 114 115#define HANDLED 1 116#define UNHANDLED 0 117 118MALLOC_DEFINE(M_VMX, "vmx", "vmx"); 119 |
121extern struct pcpu __pcpu[]; 122 | |
123int vmxon_enabled[MAXCPU]; 124static char vmxon_region[MAXCPU][PAGE_SIZE] __aligned(PAGE_SIZE); 125 126static uint32_t pinbased_ctls, procbased_ctls, procbased_ctls2; 127static uint32_t exit_ctls, entry_ctls; 128 129static uint64_t cr0_ones_mask, cr0_zeros_mask; 130static uint64_t cr4_ones_mask, cr4_zeros_mask; --- 700 unchanged lines hidden (view full) --- 831 832 if (lastcpu == curcpu) { 833 error = 0; 834 goto done; 835 } 836 837 vmm_stat_incr(vmx->vm, vcpu, VCPU_MIGRATIONS, 1); 838 | 120int vmxon_enabled[MAXCPU]; 121static char vmxon_region[MAXCPU][PAGE_SIZE] __aligned(PAGE_SIZE); 122 123static uint32_t pinbased_ctls, procbased_ctls, procbased_ctls2; 124static uint32_t exit_ctls, entry_ctls; 125 126static uint64_t cr0_ones_mask, cr0_zeros_mask; 127static uint64_t cr4_ones_mask, cr4_zeros_mask; --- 700 unchanged lines hidden (view full) --- 828 829 if (lastcpu == curcpu) { 830 error = 0; 831 goto done; 832 } 833 834 vmm_stat_incr(vmx->vm, vcpu, VCPU_MIGRATIONS, 1); 835 |
839 error = vmwrite(VMCS_HOST_TR_BASE, (u_long)PCPU_GET(tssp)); | 836 error = vmwrite(VMCS_HOST_TR_BASE, vmm_get_host_trbase()); |
840 if (error != 0) 841 goto done; 842 | 837 if (error != 0) 838 goto done; 839 |
843 error = vmwrite(VMCS_HOST_GDTR_BASE, (u_long)&gdt[NGDT * curcpu]); | 840 error = vmwrite(VMCS_HOST_GDTR_BASE, vmm_get_host_gdtrbase()); |
844 if (error != 0) 845 goto done; 846 | 841 if (error != 0) 842 goto done; 843 |
847 error = vmwrite(VMCS_HOST_GS_BASE, (u_long)&__pcpu[curcpu]); | 844 error = vmwrite(VMCS_HOST_GS_BASE, vmm_get_host_gsbase()); |
848 if (error != 0) 849 goto done; 850 851 /* 852 * If we are using VPIDs then invalidate all mappings tagged with 'vpid' 853 * 854 * We do this because this vcpu was executing on a different host 855 * cpu when it last ran. We do not track whether it invalidated --- 997 unchanged lines hidden --- | 845 if (error != 0) 846 goto done; 847 848 /* 849 * If we are using VPIDs then invalidate all mappings tagged with 'vpid' 850 * 851 * We do this because this vcpu was executing on a different host 852 * cpu when it last ran. We do not track whether it invalidated --- 997 unchanged lines hidden --- |