xref: /onnv-gate/usr/src/uts/intel/sys/hypervisor.h (revision 10942:eaa343de0d06)
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 /*
2310175SStuart.Maybee@Sun.COM  * Copyright 2009 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 
5910175SStuart.Maybee@Sun.COM #define	xen_mb	membar_enter
6010175SStuart.Maybee@Sun.COM #define	xen_wmb	membar_producer
6110175SStuart.Maybee@Sun.COM 
6210175SStuart.Maybee@Sun.COM #ifndef __xpv
635741Smrj #include <sys/xpv_support.h>
645741Smrj #else
655741Smrj #include <sys/xpv_impl.h>
665741Smrj #endif
675741Smrj #include <sys/xen_errno.h>
685741Smrj 
695741Smrj #if !defined(_ASM)
705741Smrj 
715741Smrj #include <sys/processor.h>
725741Smrj #include <sys/cpuvar.h>
7310175SStuart.Maybee@Sun.COM #ifdef __xpv
745741Smrj #include <sys/xen_mmu.h>
755741Smrj #endif
765741Smrj #include <sys/systm.h>
775741Smrj #include <xen/public/callback.h>
785741Smrj #include <xen/public/event_channel.h>
795741Smrj #include <xen/public/grant_table.h>
805741Smrj #include <xen/public/io/blkif.h>
815741Smrj #include <xen/public/io/xenbus.h>
825741Smrj #include <xen/public/memory.h>
835741Smrj #include <xen/public/nmi.h>
845741Smrj #include <xen/public/physdev.h>
855741Smrj #include <xen/public/sched.h>
865741Smrj #include <xen/public/platform.h>
875741Smrj #include <xen/public/vcpu.h>
885741Smrj #include <xen/public/version.h>
895741Smrj #include <xen/public/hvm/params.h>
905741Smrj 
915741Smrj extern shared_info_t *HYPERVISOR_shared_info;
925741Smrj extern void *HYPERVISOR_console_page;
935741Smrj 
945741Smrj /* -- move these definitions elsewhere -- */
955741Smrj 
965741Smrj extern int xen_debug_handler(void *);
975741Smrj extern void xen_printf(const char *, ...) __KPRINTFLIKE(1);
985741Smrj #pragma rarely_called(xen_printf)
995741Smrj 
1005741Smrj extern void xen_callback(void);
1015741Smrj extern void xen_failsafe_callback(void);
1025741Smrj 
1035741Smrj extern hrtime_t xpv_gethrtime(void);
1045741Smrj extern hrtime_t xpv_getsystime(void);
1055741Smrj 
1065741Smrj extern void xpv_time_suspend(void);
1075741Smrj extern void xpv_time_resume(void);
1085741Smrj 
1095741Smrj extern void startup_xen_version(void);
1107532SSean.Ye@Sun.COM extern void startup_xen_mca(void);
1115741Smrj 
1125741Smrj extern void mach_cpucontext_reset(cpu_t *);
1135741Smrj extern void mach_cpucontext_restore(cpu_t *);
1145741Smrj 
1155741Smrj extern void mp_enter_barrier(void);
1165741Smrj extern void mp_leave_barrier(void);
1175741Smrj 
1185741Smrj extern cpuset_t cpu_suspend_lost_set;
1195741Smrj 
1205741Smrj extern int xen_gdt_setprot(cpu_t *, uint_t);
1215741Smrj extern int xen_ldt_setprot(user_desc_t *, size_t, uint_t);
1225741Smrj 
1237532SSean.Ye@Sun.COM /* -- while you're down there, move these too -- */
1247532SSean.Ye@Sun.COM 
1257532SSean.Ye@Sun.COM typedef struct xen_mc_lcpu_cookie *xen_mc_lcpu_cookie_t;
1267532SSean.Ye@Sun.COM 
1277532SSean.Ye@Sun.COM extern xen_mc_lcpu_cookie_t xen_physcpu_next(xen_mc_lcpu_cookie_t);
1287532SSean.Ye@Sun.COM extern const char *xen_physcpu_vendorstr(xen_mc_lcpu_cookie_t);
1297532SSean.Ye@Sun.COM extern int xen_physcpu_family(xen_mc_lcpu_cookie_t);
1307532SSean.Ye@Sun.COM extern int xen_physcpu_model(xen_mc_lcpu_cookie_t);
1317532SSean.Ye@Sun.COM extern int xen_physcpu_stepping(xen_mc_lcpu_cookie_t);
1327532SSean.Ye@Sun.COM extern id_t xen_physcpu_chipid(xen_mc_lcpu_cookie_t);
1337532SSean.Ye@Sun.COM extern id_t xen_physcpu_coreid(xen_mc_lcpu_cookie_t);
1347532SSean.Ye@Sun.COM extern id_t xen_physcpu_strandid(xen_mc_lcpu_cookie_t);
135*10942STom.Pothier@Sun.COM extern id_t xen_physcpu_initial_apicid(xen_mc_lcpu_cookie_t);
1367532SSean.Ye@Sun.COM extern boolean_t xen_physcpu_is_cmt(xen_mc_lcpu_cookie_t);
1377532SSean.Ye@Sun.COM extern id_t xen_physcpu_logical_id(xen_mc_lcpu_cookie_t);
1387532SSean.Ye@Sun.COM extern uint64_t xen_physcpu_mcg_cap(xen_mc_lcpu_cookie_t);
1397532SSean.Ye@Sun.COM 
1407756SMark.Johnson@Sun.COM extern int xen_map_gref(uint_t cmd, gnttab_map_grant_ref_t *mapop,
1417756SMark.Johnson@Sun.COM     uint_t count, boolean_t uvaddr);
1427756SMark.Johnson@Sun.COM 
1435741Smrj /*
1445741Smrj  * Wrappered versions of the hypercalls that diagnose/panic on failure
1455741Smrj  */
1465741Smrj extern void xen_set_gdt(ulong_t *, int);
1475741Smrj extern void xen_set_ldt(user_desc_t *, uint_t);
1485741Smrj extern void xen_stack_switch(ulong_t, ulong_t);
1495741Smrj extern long xen_set_trap_table(trap_info_t *);
1505741Smrj 
1515741Smrj #if defined(__amd64)
1525741Smrj extern void xen_set_segment_base(int, ulong_t);
1535741Smrj #endif	/* __amd64 */
1545741Smrj extern long xen_vcpu_up(processorid_t);
1555741Smrj extern long xen_vcpu_down(processorid_t);
1565741Smrj extern void xen_enable_user_iopl(void);
1575741Smrj extern void xen_disable_user_iopl(void);
1585741Smrj 
1597532SSean.Ye@Sun.COM extern int xen_get_mc_physcpuinfo(xen_mc_logical_cpu_t *, uint_t *);
1607532SSean.Ye@Sun.COM extern uint_t xen_phys_ncpus;
1617532SSean.Ye@Sun.COM extern xen_mc_logical_cpu_t *xen_phys_cpus;
1627532SSean.Ye@Sun.COM 
16310175SStuart.Maybee@Sun.COM extern uint_t xpv_nr_phys_cpus(void);
16410175SStuart.Maybee@Sun.COM extern pgcnt_t xpv_nr_phys_pages(void);
16510175SStuart.Maybee@Sun.COM extern uint64_t xpv_cpu_khz(void);
16610175SStuart.Maybee@Sun.COM 
16710175SStuart.Maybee@Sun.COM 
1685741Smrj /*
1695741Smrj  * A quick way to ask if we're DOM0 or not ..
1705741Smrj  */
17110175SStuart.Maybee@Sun.COM #ifndef __xpv
1725741Smrj 
1735741Smrj #define	DOMAIN_IS_INITDOMAIN(info)	(__lintzero)
1745741Smrj #define	DOMAIN_IS_PRIVILEGED(info)	(__lintzero)
1755741Smrj 
1765741Smrj #else
1775741Smrj 
1785741Smrj #define	DOMAIN_IS_INITDOMAIN(info)	\
1795741Smrj 	(((info)->flags & SIF_INITDOMAIN) == SIF_INITDOMAIN)
1805741Smrj 
1815741Smrj #define	DOMAIN_IS_PRIVILEGED(info)	\
1825741Smrj 	(((info)->flags & SIF_PRIVILEGED) == SIF_PRIVILEGED)
1835741Smrj 
1845741Smrj #endif
1855741Smrj 
1865741Smrj /*
1875741Smrj  * start of day information passed up from the hypervisor
1885741Smrj  */
1895741Smrj extern start_info_t *xen_info;
1905741Smrj 
1915741Smrj extern long __hypercall0(int);
1925741Smrj extern long __hypercall1(int, ulong_t);
1935741Smrj extern long __hypercall2(int, ulong_t, ulong_t);
1945741Smrj extern long __hypercall3(int, ulong_t, ulong_t, ulong_t);
1955741Smrj extern long __hypercall4(int, ulong_t, ulong_t, ulong_t, ulong_t);
1965741Smrj extern long __hypercall5(int, ulong_t, ulong_t, ulong_t, ulong_t, ulong_t);
1975741Smrj 
1985741Smrj extern int __hypercall0_int(int);
1995741Smrj extern int __hypercall1_int(int, ulong_t);
2005741Smrj extern int __hypercall2_int(int, ulong_t, ulong_t);
2015741Smrj extern int __hypercall3_int(int, ulong_t, ulong_t, ulong_t);
2025741Smrj extern int __hypercall4_int(int, ulong_t, ulong_t, ulong_t, ulong_t);
2035741Smrj extern int __hypercall5_int(int, ulong_t, ulong_t, ulong_t, ulong_t, ulong_t);
2045741Smrj 
2055741Smrj extern long HYPERVISOR_set_trap_table(trap_info_t *);
2065741Smrj extern int HYPERVISOR_mmu_update(mmu_update_t *, int, int *, domid_t);
2075741Smrj extern long HYPERVISOR_set_gdt(ulong_t *, int);
2085741Smrj extern long HYPERVISOR_stack_switch(ulong_t, ulong_t);
2095741Smrj #if defined(__amd64)
2105741Smrj extern long HYPERVISOR_set_callbacks(ulong_t, ulong_t, ulong_t);
2115741Smrj #else
2125741Smrj extern long HYPERVISOR_set_callbacks(ulong_t, ulong_t, ulong_t, ulong_t);
2135741Smrj #endif
2145741Smrj extern long HYPERVISOR_fpu_taskswitch(int);
2155741Smrj /* *** __HYPERVISOR_sched_op_compat *** OBSOLETED */
2165741Smrj extern long HYPERVISOR_platform_op(xen_platform_op_t *);
2175741Smrj /* *** __HYPERVISOR_set_debugreg *** NOT IMPLEMENTED */
2185741Smrj /* *** __HYPERVISOR_get_debugreg *** NOT IMPLEMENTED */
2195741Smrj extern long HYPERVISOR_update_descriptor(maddr_t, uint64_t);
2205741Smrj extern long HYPERVISOR_memory_op(int, void *);
2215741Smrj extern long HYPERVISOR_multicall(void *, uint_t);
2225741Smrj extern int HYPERVISOR_update_va_mapping(ulong_t, uint64_t, ulong_t);
2235741Smrj extern long HYPERVISOR_set_timer_op(uint64_t);
2245741Smrj /* *** __HYPERVISOR_event_channel_op_compat *** OBSOLETED */
2255741Smrj extern long HYPERVISOR_xen_version(int, void *);
2265741Smrj extern long HYPERVISOR_console_io(int, int, char *);
2275741Smrj /* *** __HYPERVISOR_physdev_op_compat *** OBSOLETED */
2285741Smrj extern long HYPERVISOR_grant_table_op(unsigned int, void *, unsigned int);
2295741Smrj extern long HYPERVISOR_vm_assist(unsigned int, unsigned int);
2305741Smrj extern int HYPERVISOR_update_va_mapping_otherdomain(ulong_t,
2315741Smrj     uint64_t, ulong_t, domid_t);
2325741Smrj /* *** __HYPERVISOR_iret *** IN i86xpv/sys/machprivregs.h */
2335741Smrj extern long HYPERVISOR_vcpu_op(int, int, void *);
2345741Smrj #if defined(__amd64)
2355741Smrj extern long HYPERVISOR_set_segment_base(int, ulong_t);
2365741Smrj #endif	/* __amd64 */
2375741Smrj extern int HYPERVISOR_mmuext_op(struct mmuext_op *, int, uint_t *, domid_t);
2385741Smrj extern long HYPERVISOR_nmi_op(int cmd, void *);
2395741Smrj extern long HYPERVISOR_sched_op(int, void *);
2405741Smrj extern long HYPERVISOR_callback_op(int, void *);
2415741Smrj /* *** __HYPERVISOR_xenoprof_op *** NOT IMPLEMENTED */
2425741Smrj extern long HYPERVISOR_event_channel_op(int, void *); /* does return long */
2435741Smrj extern long HYPERVISOR_physdev_op(int, void *);
2445741Smrj extern long HYPERVISOR_hvm_op(int cmd, void *);
2455741Smrj /* *** __HYPERVISOR_kexec_op *** NOT IMPLEMENTED */
2467532SSean.Ye@Sun.COM extern long HYPERVISOR_mca(uint32_t, xen_mc_arg_t *);
2475741Smrj 
2485741Smrj /*
2495741Smrj  * HYPERCALL HELPER ROUTINES
2505741Smrj  *    These don't have their own unique hypercalls.
2515741Smrj  */
2525741Smrj extern long HYPERVISOR_yield(void);
2535741Smrj extern long HYPERVISOR_block(void);
2545741Smrj extern long HYPERVISOR_shutdown(uint_t);
2555741Smrj extern long HYPERVISOR_poll(evtchn_port_t *, uint_t, uint64_t);
2565741Smrj extern long HYPERVISOR_suspend(ulong_t);
2575741Smrj 
2585741Smrj #endif /* !_ASM */
2595741Smrj 
2605741Smrj #ifdef __cplusplus
2615741Smrj }
2625741Smrj #endif
2635741Smrj 
2645741Smrj #endif /* _SYS_HYPERVISOR_H */
265