linux/arch/x86/include/asm/xen/hypercall.h

/******************************************************************************
 * hypercall.h
 *
 * Linux-specific hypervisor handling.
 *
 * Copyright (c) 2002-2004, K A Fraser
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation; or, when distributed
 * separately from the Linux kernel or incorporated into other
 * software packages, subject to the following license:
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this source file (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy, modify,
 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#ifndef _ASM_X86_XEN_HYPERCALL_H
#define _ASM_X86_XEN_HYPERCALL_H

#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/pgtable.h>

#include <trace/events/xen.h>

#include <asm/page.h>
#include <asm/smap.h>
#include <asm/nospec-branch.h>

#include <xen/interface/xen.h>
#include <xen/interface/sched.h>
#include <xen/interface/physdev.h>
#include <xen/interface/platform.h>
#include <xen/interface/xen-mca.h>

struct xen_dm_op_buf;

/*
 * The hypercall asms have to meet several constraints:
 * - Work on 32- and 64-bit.
 *    The two architectures put their arguments in different sets of
 *    registers.
 *
 * - Work around asm syntax quirks
 *    It isn't possible to specify one of the rNN registers in a
 *    constraint, so we use explicit register variables to get the
 *    args into the right place.
 *
 * - Mark all registers as potentially clobbered
 *    Even unused parameters can be clobbered by the hypervisor, so we
 *    need to make sure gcc knows it.
 *
 * - Avoid compiler bugs.
 *    This is the tricky part.  Because x86_32 has such a constrained
 *    register set, gcc versions below 4.3 have trouble generating
 *    code when all the arg registers and memory are trashed by the
 *    asm.  There are syntactically simpler ways of achieving the
 *    semantics below, but they cause the compiler to crash.
 *
 *    The only combination I found which works is:
 *     - assign the __argX variables first
 *     - list all actually used parameters as "+r" (__argX)
 *     - clobber the rest
 *
 * The result certainly isn't pretty, and it really shows up cpp's
 * weakness as a macro language.  Sorry.  (But let's just give thanks
 * there aren't more than 5 arguments...)
 */

extern struct {} hypercall_page[];

#define __HYPERCALL
#define __HYPERCALL_ENTRY(x)

#ifdef CONFIG_X86_32
#define __HYPERCALL_RETREG
#define __HYPERCALL_ARG1REG
#define __HYPERCALL_ARG2REG
#define __HYPERCALL_ARG3REG
#define __HYPERCALL_ARG4REG
#define __HYPERCALL_ARG5REG
#else
#define __HYPERCALL_RETREG
#define __HYPERCALL_ARG1REG
#define __HYPERCALL_ARG2REG
#define __HYPERCALL_ARG3REG
#define __HYPERCALL_ARG4REG
#define __HYPERCALL_ARG5REG
#endif

#define __HYPERCALL_DECLS

#define __HYPERCALL_0PARAM
#define __HYPERCALL_1PARAM
#define __HYPERCALL_2PARAM
#define __HYPERCALL_3PARAM
#define __HYPERCALL_4PARAM
#define __HYPERCALL_5PARAM

#define __HYPERCALL_0ARG()
#define __HYPERCALL_1ARG(a1)
#define __HYPERCALL_2ARG(a1,a2)
#define __HYPERCALL_3ARG(a1,a2,a3)
#define __HYPERCALL_4ARG(a1,a2,a3,a4)
#define __HYPERCALL_5ARG(a1,a2,a3,a4,a5)

#define __HYPERCALL_CLOBBER5
#define __HYPERCALL_CLOBBER4
#define __HYPERCALL_CLOBBER3
#define __HYPERCALL_CLOBBER2
#define __HYPERCALL_CLOBBER1
#define __HYPERCALL_CLOBBER0

#define _hypercall0(type, name)

#define _hypercall1(type, name, a1)

#define _hypercall2(type, name, a1, a2)

#define _hypercall3(type, name, a1, a2, a3)

#define _hypercall4(type, name, a1, a2, a3, a4)

static inline long
xen_single_call(unsigned int call,
		unsigned long a1, unsigned long a2,
		unsigned long a3, unsigned long a4,
		unsigned long a5)
{}

static __always_inline void __xen_stac(void)
{}

static __always_inline void __xen_clac(void)
{}

static inline long
privcmd_call(unsigned int call,
	     unsigned long a1, unsigned long a2,
	     unsigned long a3, unsigned long a4,
	     unsigned long a5)
{}

#ifdef CONFIG_XEN_PV
static inline int
HYPERVISOR_set_trap_table(struct trap_info *table)
{}

static inline int
HYPERVISOR_mmu_update(struct mmu_update *req, int count,
		      int *success_count, domid_t domid)
{}

static inline int
HYPERVISOR_mmuext_op(struct mmuext_op *op, int count,
		     int *success_count, domid_t domid)
{}

static inline int
HYPERVISOR_set_gdt(unsigned long *frame_list, int entries)
{}

static inline int
HYPERVISOR_callback_op(int cmd, void *arg)
{}

static __always_inline int
HYPERVISOR_set_debugreg(int reg, unsigned long value)
{}

static __always_inline unsigned long
HYPERVISOR_get_debugreg(int reg)
{}

static inline int
HYPERVISOR_update_descriptor(u64 ma, u64 desc)
{}

static inline int
HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val,
			     unsigned long flags)
{}

static inline int
HYPERVISOR_set_segment_base(int reg, unsigned long value)
{}

static inline void
MULTI_fpu_taskswitch(struct multicall_entry *mcl, int set)
{}

static inline void
MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
			pte_t new_val, unsigned long flags)
{}

static inline void
MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr,
			struct desc_struct desc)
{}

static inline void
MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req,
		 int count, int *success_count, domid_t domid)
{}

static inline void
MULTI_mmuext_op(struct multicall_entry *mcl, struct mmuext_op *op, int count,
		int *success_count, domid_t domid)
{}

static inline void
MULTI_stack_switch(struct multicall_entry *mcl,
		   unsigned long ss, unsigned long esp)
{}
#endif

static __always_inline int
HYPERVISOR_sched_op(int cmd, void *arg)
{}

static inline long
HYPERVISOR_set_timer_op(u64 timeout)
{}

static inline int
HYPERVISOR_mca(struct xen_mc *mc_op)
{}

static inline int
HYPERVISOR_platform_op(struct xen_platform_op *op)
{}

static inline long
HYPERVISOR_memory_op(unsigned int cmd, void *arg)
{}

static inline int
HYPERVISOR_multicall(void *call_list, uint32_t nr_calls)
{}

static inline int
HYPERVISOR_event_channel_op(int cmd, void *arg)
{}

static __always_inline int
HYPERVISOR_xen_version(int cmd, void *arg)
{}

static inline int
HYPERVISOR_console_io(int cmd, int count, char *str)
{}

static inline int
HYPERVISOR_physdev_op(int cmd, void *arg)
{}

static inline int
HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count)
{}

static inline int
HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type)
{}

static inline int
HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args)
{}

static inline int
HYPERVISOR_suspend(unsigned long start_info_mfn)
{}

static inline unsigned long __must_check
HYPERVISOR_hvm_op(int op, void *arg)
{}

static inline int
HYPERVISOR_xenpmu_op(unsigned int op, void *arg)
{}

static inline int
HYPERVISOR_dm_op(
	domid_t dom, unsigned int nr_bufs, struct xen_dm_op_buf *bufs)
{}

#endif /* _ASM_X86_XEN_HYPERCALL_H */