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 47ASSYM(VMXCTX_GUEST_RDI, offsetof(struct vmxctx, guest_rdi)); 48ASSYM(VMXCTX_GUEST_RSI, offsetof(struct vmxctx, guest_rsi)); 49ASSYM(VMXCTX_GUEST_RDX, offsetof(struct vmxctx, guest_rdx)); 50ASSYM(VMXCTX_GUEST_RCX, offsetof(struct vmxctx, guest_rcx)); 51ASSYM(VMXCTX_GUEST_R8, offsetof(struct vmxctx, guest_r8)); 52ASSYM(VMXCTX_GUEST_R9, offsetof(struct vmxctx, guest_r9)); 53ASSYM(VMXCTX_GUEST_RAX, offsetof(struct vmxctx, guest_rax)); 54ASSYM(VMXCTX_GUEST_RBX, offsetof(struct vmxctx, guest_rbx)); 55ASSYM(VMXCTX_GUEST_RBP, offsetof(struct vmxctx, guest_rbp)); 56ASSYM(VMXCTX_GUEST_R10, offsetof(struct vmxctx, guest_r10)); 57ASSYM(VMXCTX_GUEST_R11, offsetof(struct vmxctx, guest_r11)); 58ASSYM(VMXCTX_GUEST_R12, offsetof(struct vmxctx, guest_r12)); 59ASSYM(VMXCTX_GUEST_R13, offsetof(struct vmxctx, guest_r13)); 60ASSYM(VMXCTX_GUEST_R14, offsetof(struct vmxctx, guest_r14)); 61ASSYM(VMXCTX_GUEST_R15, offsetof(struct vmxctx, guest_r15)); 62ASSYM(VMXCTX_GUEST_CR2, offsetof(struct vmxctx, guest_cr2)); 63 64ASSYM(VMXCTX_HOST_R15, offsetof(struct vmxctx, host_r15)); 65ASSYM(VMXCTX_HOST_R14, offsetof(struct vmxctx, host_r14)); 66ASSYM(VMXCTX_HOST_R13, offsetof(struct vmxctx, host_r13)); 67ASSYM(VMXCTX_HOST_R12, offsetof(struct vmxctx, host_r12)); 68ASSYM(VMXCTX_HOST_RBP, offsetof(struct vmxctx, host_rbp)); 69ASSYM(VMXCTX_HOST_RSP, offsetof(struct vmxctx, host_rsp)); 70ASSYM(VMXCTX_HOST_RBX, offsetof(struct vmxctx, host_rbx)); 71 72ASSYM(VMXCTX_INST_FAIL_STATUS, offsetof(struct vmxctx, inst_fail_status)); 73 74ASSYM(VM_FAIL_INVALID, VM_FAIL_INVALID); 75ASSYM(VM_FAIL_VALID, VM_FAIL_VALID); 76ASSYM(VMX_GUEST_VMEXIT, VMX_GUEST_VMEXIT); 77ASSYM(VMX_VMRESUME_ERROR, VMX_VMRESUME_ERROR); 78ASSYM(VMX_VMLAUNCH_ERROR, VMX_VMLAUNCH_ERROR); 79 80ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); 81 82ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active)); 83ASSYM(PM_EPTGEN, offsetof(struct pmap, pm_eptgen)); 84 85ASSYM(KERNEL_SS, GSEL(GDATA_SEL, SEL_KPL)); 86ASSYM(KERNEL_CS, GSEL(GCODE_SEL, SEL_KPL)); 87 88ASSYM(PAGE_SIZE, PAGE_SIZE); 89ASSYM(KERNBASE, KERNBASE); 90