1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2011 NetApp, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #include <sys/param.h> 30 #include <sys/systm.h> 31 #include <sys/proc.h> 32 #include <sys/assym.h> 33 34 #include <vm/vm.h> 35 #include <vm/pmap.h> 36 #include <vm/vm_param.h> 37 38 #include <machine/vmm.h> 39 #include "vmx_cpufunc.h" 40 #include "vmx.h" 41 42 ASSYM(VMXCTX_GUEST_RDI, offsetof(struct vmxctx, guest_rdi)); 43 ASSYM(VMXCTX_GUEST_RSI, offsetof(struct vmxctx, guest_rsi)); 44 ASSYM(VMXCTX_GUEST_RDX, offsetof(struct vmxctx, guest_rdx)); 45 ASSYM(VMXCTX_GUEST_RCX, offsetof(struct vmxctx, guest_rcx)); 46 ASSYM(VMXCTX_GUEST_R8, offsetof(struct vmxctx, guest_r8)); 47 ASSYM(VMXCTX_GUEST_R9, offsetof(struct vmxctx, guest_r9)); 48 ASSYM(VMXCTX_GUEST_RAX, offsetof(struct vmxctx, guest_rax)); 49 ASSYM(VMXCTX_GUEST_RBX, offsetof(struct vmxctx, guest_rbx)); 50 ASSYM(VMXCTX_GUEST_RBP, offsetof(struct vmxctx, guest_rbp)); 51 ASSYM(VMXCTX_GUEST_R10, offsetof(struct vmxctx, guest_r10)); 52 ASSYM(VMXCTX_GUEST_R11, offsetof(struct vmxctx, guest_r11)); 53 ASSYM(VMXCTX_GUEST_R12, offsetof(struct vmxctx, guest_r12)); 54 ASSYM(VMXCTX_GUEST_R13, offsetof(struct vmxctx, guest_r13)); 55 ASSYM(VMXCTX_GUEST_R14, offsetof(struct vmxctx, guest_r14)); 56 ASSYM(VMXCTX_GUEST_R15, offsetof(struct vmxctx, guest_r15)); 57 ASSYM(VMXCTX_GUEST_CR2, offsetof(struct vmxctx, guest_cr2)); 58 59 ASSYM(VMXCTX_HOST_R15, offsetof(struct vmxctx, host_r15)); 60 ASSYM(VMXCTX_HOST_R14, offsetof(struct vmxctx, host_r14)); 61 ASSYM(VMXCTX_HOST_R13, offsetof(struct vmxctx, host_r13)); 62 ASSYM(VMXCTX_HOST_R12, offsetof(struct vmxctx, host_r12)); 63 ASSYM(VMXCTX_HOST_RBP, offsetof(struct vmxctx, host_rbp)); 64 ASSYM(VMXCTX_HOST_RSP, offsetof(struct vmxctx, host_rsp)); 65 ASSYM(VMXCTX_HOST_RBX, offsetof(struct vmxctx, host_rbx)); 66 67 ASSYM(VMXCTX_INST_FAIL_STATUS, offsetof(struct vmxctx, inst_fail_status)); 68 69 ASSYM(VM_FAIL_INVALID, VM_FAIL_INVALID); 70 ASSYM(VM_FAIL_VALID, VM_FAIL_VALID); 71 ASSYM(VMX_GUEST_VMEXIT, VMX_GUEST_VMEXIT); 72 ASSYM(VMX_VMRESUME_ERROR, VMX_VMRESUME_ERROR); 73 ASSYM(VMX_VMLAUNCH_ERROR, VMX_VMLAUNCH_ERROR); 74 75 ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); 76 77 ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); 78 ASSYM(PM_EPTGEN, offsetof(struct pmap, pm_eptgen)); 79 80 ASSYM(KERNEL_SS, GSEL(GDATA_SEL, SEL_KPL)); 81 ASSYM(KERNEL_CS, GSEL(GCODE_SEL, SEL_KPL)); 82 83 ASSYM(PAGE_SIZE, PAGE_SIZE); 84 ASSYM(KERNBASE, KERNBASE); 85