1242275Sneel/*- 2242275Sneel * Copyright (c) 2012 NetApp, Inc. 3242275Sneel * All rights reserved. 4242275Sneel * 5242275Sneel * Redistribution and use in source and binary forms, with or without 6242275Sneel * modification, are permitted provided that the following conditions 7242275Sneel * are met: 8242275Sneel * 1. Redistributions of source code must retain the above copyright 9242275Sneel * notice, this list of conditions and the following disclaimer. 10242275Sneel * 2. Redistributions in binary form must reproduce the above copyright 11242275Sneel * notice, this list of conditions and the following disclaimer in the 12242275Sneel * documentation and/or other materials provided with the distribution. 13242275Sneel * 14242275Sneel * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 15242275Sneel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16242275Sneel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17242275Sneel * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 18242275Sneel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19242275Sneel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20242275Sneel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21242275Sneel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22242275Sneel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23242275Sneel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24242275Sneel * SUCH DAMAGE. 25242275Sneel * 26242275Sneel * $FreeBSD$ 27242275Sneel */ 28242275Sneel 29242275Sneel#ifndef _VMM_HOST_H_ 30242275Sneel#define _VMM_HOST_H_ 31242275Sneel 32242275Sneel#ifndef _KERNEL 33242275Sneel#error "no user-servicable parts inside" 34242275Sneel#endif 35242275Sneel 36267427Sjhbstruct xsave_limits { 37267427Sjhb int xsave_enabled; 38267427Sjhb uint64_t xcr0_allowed; 39267427Sjhb uint32_t xsave_max_size; 40267427Sjhb}; 41267427Sjhb 42242275Sneelvoid vmm_host_state_init(void); 43242275Sneel 44242275Sneeluint64_t vmm_get_host_pat(void); 45242275Sneeluint64_t vmm_get_host_efer(void); 46242275Sneeluint64_t vmm_get_host_cr0(void); 47242275Sneeluint64_t vmm_get_host_cr4(void); 48267427Sjhbuint64_t vmm_get_host_xcr0(void); 49242275Sneeluint64_t vmm_get_host_datasel(void); 50242275Sneeluint64_t vmm_get_host_codesel(void); 51242275Sneeluint64_t vmm_get_host_tsssel(void); 52242275Sneeluint64_t vmm_get_host_fsbase(void); 53242275Sneeluint64_t vmm_get_host_idtrbase(void); 54267427Sjhbconst struct xsave_limits *vmm_get_xsave_limits(void); 55242275Sneel 56242275Sneel/* 57242275Sneel * Inline access to host state that is used on every VM entry 58242275Sneel */ 59242275Sneelstatic __inline uint64_t 60242275Sneelvmm_get_host_trbase(void) 61242275Sneel{ 62242275Sneel 63242275Sneel return ((uint64_t)PCPU_GET(tssp)); 64242275Sneel} 65242275Sneel 66242275Sneelstatic __inline uint64_t 67242275Sneelvmm_get_host_gdtrbase(void) 68242275Sneel{ 69242275Sneel 70242275Sneel return ((uint64_t)&gdt[NGDT * curcpu]); 71242275Sneel} 72242275Sneel 73242275Sneelstruct pcpu; 74242275Sneelextern struct pcpu __pcpu[]; 75242275Sneel 76242275Sneelstatic __inline uint64_t 77242275Sneelvmm_get_host_gsbase(void) 78242275Sneel{ 79242275Sneel 80242275Sneel return ((uint64_t)&__pcpu[curcpu]); 81242275Sneel} 82242275Sneel 83242275Sneel#endif 84