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