vmm_host.h revision 242275
174110Salex/*- 274110Salex * Copyright (c) 2012 NetApp, Inc. 374110Salex * All rights reserved. 474110Salex * 574110Salex * Redistribution and use in source and binary forms, with or without 674110Salex * modification, are permitted provided that the following conditions 774110Salex * are met: 874110Salex * 1. Redistributions of source code must retain the above copyright 974110Salex * notice, this list of conditions and the following disclaimer. 1074110Salex * 2. Redistributions in binary form must reproduce the above copyright 1174110Salex * notice, this list of conditions and the following disclaimer in the 1274110Salex * documentation and/or other materials provided with the distribution. 1374110Salex * 1474110Salex * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 1574110Salex * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1674110Salex * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1774110Salex * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 1874110Salex * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1974110Salex * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2074110Salex * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2174110Salex * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2274110Salex * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2374110Salex * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2474110Salex * SUCH DAMAGE. 2574110Salex * 2674110Salex * $FreeBSD: projects/bhyve/sys/amd64/vmm/vmm_host.h 242275 2012-10-29 01:51:24Z neel $ 2774110Salex */ 2874110Salex 2974110Salex#ifndef _VMM_HOST_H_ 3074110Salex#define _VMM_HOST_H_ 31230330Sed 3274110Salex#ifndef _KERNEL 3374110Salex#error "no user-servicable parts inside" 3474110Salex#endif 3574110Salex 3674110Salexvoid vmm_host_state_init(void); 3774110Salex 3888509Sdavidcuint64_t vmm_get_host_pat(void); 3988509Sdavidcuint64_t vmm_get_host_efer(void); 4084306Sruuint64_t vmm_get_host_cr0(void); 4184306Sruuint64_t vmm_get_host_cr4(void); 4274110Salexuint64_t vmm_get_host_datasel(void); 4374110Salexuint64_t vmm_get_host_codesel(void); 4474110Salexuint64_t vmm_get_host_tsssel(void); 4574110Salexuint64_t vmm_get_host_fsbase(void); 4674110Salexuint64_t vmm_get_host_idtrbase(void); 4774110Salex 4874110Salex/* 4974110Salex * Inline access to host state that is used on every VM entry 5074110Salex */ 5174110Salexstatic __inline uint64_t 5274110Salexvmm_get_host_trbase(void) 5374110Salex{ 5474110Salex 5574110Salex return ((uint64_t)PCPU_GET(tssp)); 5674110Salex} 5774110Salex 5874110Salexstatic __inline uint64_t 5974110Salexvmm_get_host_gdtrbase(void) 6074110Salex{ 6174110Salex 6274110Salex return ((uint64_t)&gdt[NGDT * curcpu]); 6374110Salex} 6474110Salex 6574110Salexstruct pcpu; 6674110Salexextern struct pcpu __pcpu[]; 6774110Salex 6874110Salexstatic __inline uint64_t 6974110Salexvmm_get_host_gsbase(void) 7074110Salex{ 71230330Sed 7274110Salex return ((uint64_t)&__pcpu[curcpu]); 7374110Salex} 7474110Salex 7574110Salex#endif 7674110Salex