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/cdefs.h> 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 #include <sys/proc.h> 33 #include <sys/assym.h> 34 35 #include <vm/vm.h> 36 #include <vm/pmap.h> 37 #include <vm/vm_param.h> 38 39 #include <machine/vmm.h> 40 #include "vmx_cpufunc.h" 41 #include "vmx.h" 42 43 ASSYM(VMXCTX_GUEST_RDI, offsetof(struct vmxctx, guest_rdi)); 44 ASSYM(VMXCTX_GUEST_RSI, offsetof(struct vmxctx, guest_rsi)); 45 ASSYM(VMXCTX_GUEST_RDX, offsetof(struct vmxctx, guest_rdx)); 46 ASSYM(VMXCTX_GUEST_RCX, offsetof(struct vmxctx, guest_rcx)); 47 ASSYM(VMXCTX_GUEST_R8, offsetof(struct vmxctx, guest_r8)); 48 ASSYM(VMXCTX_GUEST_R9, offsetof(struct vmxctx, guest_r9)); 49 ASSYM(VMXCTX_GUEST_RAX, offsetof(struct vmxctx, guest_rax)); 50 ASSYM(VMXCTX_GUEST_RBX, offsetof(struct vmxctx, guest_rbx)); 51 ASSYM(VMXCTX_GUEST_RBP, offsetof(struct vmxctx, guest_rbp)); 52 ASSYM(VMXCTX_GUEST_R10, offsetof(struct vmxctx, guest_r10)); 53 ASSYM(VMXCTX_GUEST_R11, offsetof(struct vmxctx, guest_r11)); 54 ASSYM(VMXCTX_GUEST_R12, offsetof(struct vmxctx, guest_r12)); 55 ASSYM(VMXCTX_GUEST_R13, offsetof(struct vmxctx, guest_r13)); 56 ASSYM(VMXCTX_GUEST_R14, offsetof(struct vmxctx, guest_r14)); 57 ASSYM(VMXCTX_GUEST_R15, offsetof(struct vmxctx, guest_r15)); 58 ASSYM(VMXCTX_GUEST_CR2, offsetof(struct vmxctx, guest_cr2)); 59 60 ASSYM(VMXCTX_HOST_R15, offsetof(struct vmxctx, host_r15)); 61 ASSYM(VMXCTX_HOST_R14, offsetof(struct vmxctx, host_r14)); 62 ASSYM(VMXCTX_HOST_R13, offsetof(struct vmxctx, host_r13)); 63 ASSYM(VMXCTX_HOST_R12, offsetof(struct vmxctx, host_r12)); 64 ASSYM(VMXCTX_HOST_RBP, offsetof(struct vmxctx, host_rbp)); 65 ASSYM(VMXCTX_HOST_RSP, offsetof(struct vmxctx, host_rsp)); 66 ASSYM(VMXCTX_HOST_RBX, offsetof(struct vmxctx, host_rbx)); 67 68 ASSYM(VMXCTX_INST_FAIL_STATUS, offsetof(struct vmxctx, inst_fail_status)); 69 70 ASSYM(VM_FAIL_INVALID, VM_FAIL_INVALID); 71 ASSYM(VM_FAIL_VALID, VM_FAIL_VALID); 72 ASSYM(VMX_GUEST_VMEXIT, VMX_GUEST_VMEXIT); 73 ASSYM(VMX_VMRESUME_ERROR, VMX_VMRESUME_ERROR); 74 ASSYM(VMX_VMLAUNCH_ERROR, VMX_VMLAUNCH_ERROR); 75 76 ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); 77 78 ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); 79 ASSYM(PM_EPTGEN, offsetof(struct pmap, pm_eptgen)); 80 81 ASSYM(KERNEL_SS, GSEL(GDATA_SEL, SEL_KPL)); 82 ASSYM(KERNEL_CS, GSEL(GCODE_SEL, SEL_KPL)); 83 84 ASSYM(PAGE_SIZE, PAGE_SIZE); 85 ASSYM(KERNBASE, KERNBASE); 86