15741Smrj /* 25741Smrj * CDDL HEADER START 35741Smrj * 45741Smrj * The contents of this file are subject to the terms of the 55741Smrj * Common Development and Distribution License (the "License"). 65741Smrj * You may not use this file except in compliance with the License. 75741Smrj * 85741Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95741Smrj * or http://www.opensolaris.org/os/licensing. 105741Smrj * See the License for the specific language governing permissions 115741Smrj * and limitations under the License. 125741Smrj * 135741Smrj * When distributing Covered Code, include this CDDL HEADER in each 145741Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155741Smrj * If applicable, add the following below this CDDL HEADER, with the 165741Smrj * fields enclosed by brackets "[]" replaced with your own identifying 175741Smrj * information: Portions Copyright [yyyy] [name of copyright owner] 185741Smrj * 195741Smrj * CDDL HEADER END 205741Smrj */ 215741Smrj 225741Smrj /* 236144Srab * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 245741Smrj * Use is subject to license terms. 255741Smrj */ 265741Smrj 275741Smrj /* 285741Smrj * 295741Smrj * Communication to/from hypervisor. 305741Smrj * 315741Smrj * Copyright (c) 2002-2004, K A Fraser 325741Smrj * 335741Smrj * Permission is hereby granted, free of charge, to any person obtaining a copy 345741Smrj * of this source file (the "Software"), to deal in the Software without 355741Smrj * restriction, including without limitation the rights to use, copy, modify, 365741Smrj * merge, publish, distribute, sublicense, and/or sell copies of the Software, 375741Smrj * and to permit persons to whom the Software is furnished to do so, subject to 385741Smrj * the following conditions: 395741Smrj * 405741Smrj * The above copyright notice and this permission notice shall be included in 415741Smrj * all copies or substantial portions of the Software. 425741Smrj * 435741Smrj * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 445741Smrj * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 455741Smrj * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 465741Smrj * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 475741Smrj * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 485741Smrj * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 495741Smrj * IN THE SOFTWARE. 505741Smrj */ 515741Smrj 525741Smrj #ifndef _SYS_HYPERVISOR_H 535741Smrj #define _SYS_HYPERVISOR_H 545741Smrj 555741Smrj #ifdef __cplusplus 565741Smrj extern "C" { 575741Smrj #endif 585741Smrj 595741Smrj #ifdef XPV_HVM_DRIVER 605741Smrj #include <sys/xpv_support.h> 615741Smrj #else 625741Smrj #include <sys/xpv_impl.h> 635741Smrj #endif 645741Smrj #include <sys/xen_errno.h> 655741Smrj 665741Smrj #if !defined(_ASM) 675741Smrj 685741Smrj #include <sys/processor.h> 695741Smrj #include <sys/cpuvar.h> 705741Smrj #ifndef XPV_HVM_DRIVER 715741Smrj #include <sys/xen_mmu.h> 725741Smrj #endif 735741Smrj #include <sys/systm.h> 745741Smrj #include <xen/public/callback.h> 755741Smrj #include <xen/public/event_channel.h> 765741Smrj #include <xen/public/grant_table.h> 775741Smrj #include <xen/public/io/blkif.h> 785741Smrj #include <xen/public/io/xenbus.h> 795741Smrj #include <xen/public/memory.h> 805741Smrj #include <xen/public/nmi.h> 815741Smrj #include <xen/public/physdev.h> 825741Smrj #include <xen/public/sched.h> 835741Smrj #include <xen/public/sysctl.h> 845741Smrj #include <xen/public/platform.h> 855741Smrj #include <xen/public/vcpu.h> 865741Smrj #include <xen/public/version.h> 875741Smrj #include <xen/public/acm_ops.h> 885741Smrj #include <xen/public/hvm/params.h> 895741Smrj 905741Smrj extern shared_info_t *HYPERVISOR_shared_info; 915741Smrj extern void *HYPERVISOR_console_page; 925741Smrj 935741Smrj /* -- move these definitions elsewhere -- */ 945741Smrj 955741Smrj extern int xen_debug_handler(void *); 965741Smrj extern void xen_printf(const char *, ...) __KPRINTFLIKE(1); 975741Smrj #pragma rarely_called(xen_printf) 985741Smrj 995741Smrj extern void xen_callback(void); 1005741Smrj extern void xen_failsafe_callback(void); 1015741Smrj 1025741Smrj extern hrtime_t xpv_gethrtime(void); 1035741Smrj extern hrtime_t xpv_getsystime(void); 1045741Smrj 1055741Smrj extern void xpv_time_suspend(void); 1065741Smrj extern void xpv_time_resume(void); 1075741Smrj 1085741Smrj extern void startup_xen_version(void); 109*7532SSean.Ye@Sun.COM extern void startup_xen_mca(void); 1105741Smrj 1115741Smrj extern void mach_cpucontext_reset(cpu_t *); 1125741Smrj extern void mach_cpucontext_restore(cpu_t *); 1135741Smrj 1145741Smrj extern void mp_enter_barrier(void); 1155741Smrj extern void mp_leave_barrier(void); 1165741Smrj 1175741Smrj extern cpuset_t cpu_suspend_lost_set; 1185741Smrj 1195741Smrj extern int xen_gdt_setprot(cpu_t *, uint_t); 1205741Smrj extern int xen_ldt_setprot(user_desc_t *, size_t, uint_t); 1215741Smrj 122*7532SSean.Ye@Sun.COM /* -- while you're down there, move these too -- */ 123*7532SSean.Ye@Sun.COM 124*7532SSean.Ye@Sun.COM typedef struct xen_mc_lcpu_cookie *xen_mc_lcpu_cookie_t; 125*7532SSean.Ye@Sun.COM 126*7532SSean.Ye@Sun.COM extern xen_mc_lcpu_cookie_t xen_physcpu_next(xen_mc_lcpu_cookie_t); 127*7532SSean.Ye@Sun.COM extern const char *xen_physcpu_vendorstr(xen_mc_lcpu_cookie_t); 128*7532SSean.Ye@Sun.COM extern int xen_physcpu_family(xen_mc_lcpu_cookie_t); 129*7532SSean.Ye@Sun.COM extern int xen_physcpu_model(xen_mc_lcpu_cookie_t); 130*7532SSean.Ye@Sun.COM extern int xen_physcpu_stepping(xen_mc_lcpu_cookie_t); 131*7532SSean.Ye@Sun.COM extern id_t xen_physcpu_chipid(xen_mc_lcpu_cookie_t); 132*7532SSean.Ye@Sun.COM extern id_t xen_physcpu_coreid(xen_mc_lcpu_cookie_t); 133*7532SSean.Ye@Sun.COM extern id_t xen_physcpu_strandid(xen_mc_lcpu_cookie_t); 134*7532SSean.Ye@Sun.COM extern boolean_t xen_physcpu_is_cmt(xen_mc_lcpu_cookie_t); 135*7532SSean.Ye@Sun.COM extern id_t xen_physcpu_logical_id(xen_mc_lcpu_cookie_t); 136*7532SSean.Ye@Sun.COM extern uint64_t xen_physcpu_mcg_cap(xen_mc_lcpu_cookie_t); 137*7532SSean.Ye@Sun.COM 1385741Smrj /* 1395741Smrj * Wrappered versions of the hypercalls that diagnose/panic on failure 1405741Smrj */ 1415741Smrj extern void xen_set_gdt(ulong_t *, int); 1425741Smrj extern void xen_set_ldt(user_desc_t *, uint_t); 1435741Smrj extern void xen_stack_switch(ulong_t, ulong_t); 1445741Smrj extern long xen_set_trap_table(trap_info_t *); 1455741Smrj 1465741Smrj #if defined(__amd64) 1475741Smrj extern void xen_set_segment_base(int, ulong_t); 1485741Smrj #endif /* __amd64 */ 1495741Smrj extern long xen_vcpu_up(processorid_t); 1505741Smrj extern long xen_vcpu_down(processorid_t); 1515741Smrj extern void xen_enable_user_iopl(void); 1525741Smrj extern void xen_disable_user_iopl(void); 1535741Smrj 154*7532SSean.Ye@Sun.COM extern int xen_get_physinfo(xen_sysctl_physinfo_t *); 155*7532SSean.Ye@Sun.COM extern int xen_get_mc_physcpuinfo(xen_mc_logical_cpu_t *, uint_t *); 156*7532SSean.Ye@Sun.COM extern uint_t xen_phys_ncpus; 157*7532SSean.Ye@Sun.COM extern xen_mc_logical_cpu_t *xen_phys_cpus; 158*7532SSean.Ye@Sun.COM 1595741Smrj /* 1605741Smrj * A quick way to ask if we're DOM0 or not .. 1615741Smrj */ 1625741Smrj #ifdef XPV_HVM_DRIVER 1635741Smrj 1645741Smrj #define DOMAIN_IS_INITDOMAIN(info) (__lintzero) 1655741Smrj #define DOMAIN_IS_PRIVILEGED(info) (__lintzero) 1665741Smrj 1675741Smrj #else 1685741Smrj 1695741Smrj #define DOMAIN_IS_INITDOMAIN(info) \ 1705741Smrj (((info)->flags & SIF_INITDOMAIN) == SIF_INITDOMAIN) 1715741Smrj 1725741Smrj #define DOMAIN_IS_PRIVILEGED(info) \ 1735741Smrj (((info)->flags & SIF_PRIVILEGED) == SIF_PRIVILEGED) 1745741Smrj 1755741Smrj #endif 1765741Smrj 1775741Smrj /* 1785741Smrj * start of day information passed up from the hypervisor 1795741Smrj */ 1805741Smrj extern start_info_t *xen_info; 1815741Smrj 1825741Smrj extern long __hypercall0(int); 1835741Smrj extern long __hypercall1(int, ulong_t); 1845741Smrj extern long __hypercall2(int, ulong_t, ulong_t); 1855741Smrj extern long __hypercall3(int, ulong_t, ulong_t, ulong_t); 1865741Smrj extern long __hypercall4(int, ulong_t, ulong_t, ulong_t, ulong_t); 1875741Smrj extern long __hypercall5(int, ulong_t, ulong_t, ulong_t, ulong_t, ulong_t); 1885741Smrj 1895741Smrj extern int __hypercall0_int(int); 1905741Smrj extern int __hypercall1_int(int, ulong_t); 1915741Smrj extern int __hypercall2_int(int, ulong_t, ulong_t); 1925741Smrj extern int __hypercall3_int(int, ulong_t, ulong_t, ulong_t); 1935741Smrj extern int __hypercall4_int(int, ulong_t, ulong_t, ulong_t, ulong_t); 1945741Smrj extern int __hypercall5_int(int, ulong_t, ulong_t, ulong_t, ulong_t, ulong_t); 1955741Smrj 1965741Smrj extern long HYPERVISOR_set_trap_table(trap_info_t *); 1975741Smrj extern int HYPERVISOR_mmu_update(mmu_update_t *, int, int *, domid_t); 1985741Smrj extern long HYPERVISOR_set_gdt(ulong_t *, int); 1995741Smrj extern long HYPERVISOR_stack_switch(ulong_t, ulong_t); 2005741Smrj #if defined(__amd64) 2015741Smrj extern long HYPERVISOR_set_callbacks(ulong_t, ulong_t, ulong_t); 2025741Smrj #else 2035741Smrj extern long HYPERVISOR_set_callbacks(ulong_t, ulong_t, ulong_t, ulong_t); 2045741Smrj #endif 2055741Smrj extern long HYPERVISOR_fpu_taskswitch(int); 2065741Smrj /* *** __HYPERVISOR_sched_op_compat *** OBSOLETED */ 2075741Smrj extern long HYPERVISOR_platform_op(xen_platform_op_t *); 2085741Smrj /* *** __HYPERVISOR_set_debugreg *** NOT IMPLEMENTED */ 2095741Smrj /* *** __HYPERVISOR_get_debugreg *** NOT IMPLEMENTED */ 2105741Smrj extern long HYPERVISOR_update_descriptor(maddr_t, uint64_t); 2115741Smrj extern long HYPERVISOR_memory_op(int, void *); 2125741Smrj extern long HYPERVISOR_multicall(void *, uint_t); 2135741Smrj extern int HYPERVISOR_update_va_mapping(ulong_t, uint64_t, ulong_t); 2145741Smrj extern long HYPERVISOR_set_timer_op(uint64_t); 2155741Smrj /* *** __HYPERVISOR_event_channel_op_compat *** OBSOLETED */ 2165741Smrj extern long HYPERVISOR_xen_version(int, void *); 2175741Smrj extern long HYPERVISOR_console_io(int, int, char *); 2185741Smrj /* *** __HYPERVISOR_physdev_op_compat *** OBSOLETED */ 2195741Smrj extern long HYPERVISOR_grant_table_op(unsigned int, void *, unsigned int); 2205741Smrj extern long HYPERVISOR_vm_assist(unsigned int, unsigned int); 2215741Smrj extern int HYPERVISOR_update_va_mapping_otherdomain(ulong_t, 2225741Smrj uint64_t, ulong_t, domid_t); 2235741Smrj /* *** __HYPERVISOR_iret *** IN i86xpv/sys/machprivregs.h */ 2245741Smrj extern long HYPERVISOR_vcpu_op(int, int, void *); 2255741Smrj #if defined(__amd64) 2265741Smrj extern long HYPERVISOR_set_segment_base(int, ulong_t); 2275741Smrj #endif /* __amd64 */ 2285741Smrj extern int HYPERVISOR_mmuext_op(struct mmuext_op *, int, uint_t *, domid_t); 2296144Srab extern long HYPERVISOR_acm_op(struct xen_acmctl *); 2305741Smrj extern long HYPERVISOR_nmi_op(int cmd, void *); 2315741Smrj extern long HYPERVISOR_sched_op(int, void *); 2325741Smrj extern long HYPERVISOR_callback_op(int, void *); 2335741Smrj /* *** __HYPERVISOR_xenoprof_op *** NOT IMPLEMENTED */ 2345741Smrj extern long HYPERVISOR_event_channel_op(int, void *); /* does return long */ 2355741Smrj extern long HYPERVISOR_physdev_op(int, void *); 2365741Smrj extern long HYPERVISOR_hvm_op(int cmd, void *); 2375741Smrj extern long HYPERVISOR_sysctl(xen_sysctl_t *); 2385741Smrj extern long HYPERVISOR_domctl(xen_domctl_t *domctl); 2395741Smrj /* *** __HYPERVISOR_kexec_op *** NOT IMPLEMENTED */ 240*7532SSean.Ye@Sun.COM extern long HYPERVISOR_mca(uint32_t, xen_mc_arg_t *); 2415741Smrj 2425741Smrj 2435741Smrj /* 2445741Smrj * HYPERCALL HELPER ROUTINES 2455741Smrj * These don't have their own unique hypercalls. 2465741Smrj */ 2475741Smrj extern long HYPERVISOR_yield(void); 2485741Smrj extern long HYPERVISOR_block(void); 2495741Smrj extern long HYPERVISOR_shutdown(uint_t); 2505741Smrj extern long HYPERVISOR_poll(evtchn_port_t *, uint_t, uint64_t); 2515741Smrj extern long HYPERVISOR_suspend(ulong_t); 2525741Smrj 2535741Smrj #endif /* !_ASM */ 2545741Smrj 2555741Smrj #ifdef __cplusplus 2565741Smrj } 2575741Smrj #endif 2585741Smrj 2595741Smrj #endif /* _SYS_HYPERVISOR_H */ 260