/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/asm_linkage.h>
#ifndef __xpv
#include <sys/xpv_support.h>
#endif
#include <sys/hypervisor.h>
/*
* Hypervisor "system calls"
*
* i386
* %eax == call number
* args in registers (%ebx, %ecx, %edx, %esi, %edi)
*
* amd64
* %rax == call number
* args in registers (%rdi, %rsi, %rdx, %r10, %r8, %r9)
*
* Note that for amd64 we use %r10 instead of %rcx for passing 4th argument
* as in C calling convention since the "syscall" instruction clobbers %rcx.
*
* (These calls can be done more efficiently as gcc-style inlines, but
* for simplicity and help with initial debugging, we use these primitives
* to build the hypervisor calls up from C wrappers.)
*/
#if defined(__lint)
/*ARGSUSED*/
long
__hypercall0(int callnum)
{ return (0); }
/*ARGSUSED*/
long
{ return (0); }
/*ARGSUSED*/
long
{ return (0); }
/*ARGSUSED*/
long
{ return (0); }
/*ARGSUSED*/
long
{ return (0); }
/*ARGSUSED*/
long
__hypercall5(int callnum,
{ return (0); }
/*ARGSUSED*/
int
__hypercall0_int(int callnum)
{ return (0); }
/*ARGSUSED*/
int
{ return (0); }
/*ARGSUSED*/
int
{ return (0); }
/*ARGSUSED*/
int
{ return (0); }
/*ARGSUSED*/
int
{ return (0); }
/*ARGSUSED*/
int
__hypercall5_int(int callnum,
{ return (0); }
#else /* __lint */
/*
* XXPV grr - assembler can't deal with an instruction in a quoted string
*/
/*
* The method for issuing a hypercall (i.e. a system call to the
* hypervisor) varies from platform to platform. In 32-bit PV domains, an
* 'int 82' triggers the call. In 64-bit PV domains, a 'syscall' does the
* trick.
*
* HVM domains are more complicated. In all cases, we want to issue a
* VMEXIT instruction, but AMD and Intel use different opcodes to represent
* that instruction. Rather than build CPU-specific modules with the
* different opcodes, we use the 'hypercall page' provided by Xen. This
* page contains a collection of code stubs that do nothing except issue
* hypercalls using the proper instructions for this machine. To keep the
* wrapper code as simple and efficient as possible, we preallocate that
* page below. When the module is loaded, we ask Xen to remap the
* underlying PFN to that of the hypercall page.
*
* Note: this same mechanism could be used in PV domains, but using
* hypercall page requires a call and several more instructions than simply
* issuing the proper trap.
*/
#if !defined(__xpv)
.data
.text
#if defined(__amd64)
#define TRAP_INSTR \
#else
#define TRAP_INSTR \
#endif
#else /* !_xpv */
#if defined(__amd64)
#endif
#endif /* !__xpv */
#if defined(__amd64)
#endif /* __i386 */
#endif /* lint */