2008-10-23 05:26:29 +00:00
|
|
|
#ifndef _ASM_X86_KVM_PARA_H
|
|
|
|
#define _ASM_X86_KVM_PARA_H
|
2007-10-11 13:34:17 +00:00
|
|
|
|
|
|
|
#include <asm/processor.h>
|
2014-09-22 11:17:48 +00:00
|
|
|
#include <asm/alternative.h>
|
2012-12-14 22:37:13 +00:00
|
|
|
#include <uapi/asm/kvm_para.h>
|
2007-10-11 13:34:17 +00:00
|
|
|
|
2008-02-15 19:52:47 +00:00
|
|
|
extern void kvmclock_init(void);
|
2010-10-14 09:22:49 +00:00
|
|
|
extern int kvm_register_clock(char *txt);
|
2008-02-15 19:52:47 +00:00
|
|
|
|
2012-08-16 20:00:19 +00:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
2012-03-10 19:37:26 +00:00
|
|
|
bool kvm_check_and_clear_guest_paused(void);
|
|
|
|
#else
|
|
|
|
static inline bool kvm_check_and_clear_guest_paused(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-16 20:00:19 +00:00
|
|
|
#endif /* CONFIG_KVM_GUEST */
|
2008-02-15 19:52:47 +00:00
|
|
|
|
2014-09-22 11:17:48 +00:00
|
|
|
#define KVM_HYPERCALL \
|
|
|
|
ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
|
2007-10-11 13:34:17 +00:00
|
|
|
|
2012-08-07 07:40:13 +00:00
|
|
|
/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
|
2007-10-11 13:34:17 +00:00
|
|
|
* instruction. The hypervisor may replace it with something else but only the
|
|
|
|
* instructions are guaranteed to be supported.
|
|
|
|
*
|
|
|
|
* Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively.
|
|
|
|
* The hypercall number should be placed in rax and the return value will be
|
2012-12-10 21:31:51 +00:00
|
|
|
* placed in rax. No other registers will be clobbered unless explicitly
|
2007-10-11 13:34:17 +00:00
|
|
|
* noted by the particular hypercall.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline long kvm_hypercall0(unsigned int nr)
|
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
asm volatile(KVM_HYPERCALL
|
|
|
|
: "=a"(ret)
|
2008-07-03 16:02:36 +00:00
|
|
|
: "a"(nr)
|
|
|
|
: "memory");
|
2007-10-11 13:34:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
|
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
asm volatile(KVM_HYPERCALL
|
|
|
|
: "=a"(ret)
|
2008-07-03 16:02:36 +00:00
|
|
|
: "a"(nr), "b"(p1)
|
|
|
|
: "memory");
|
2007-10-11 13:34:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
|
|
|
|
unsigned long p2)
|
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
asm volatile(KVM_HYPERCALL
|
|
|
|
: "=a"(ret)
|
2008-07-03 16:02:36 +00:00
|
|
|
: "a"(nr), "b"(p1), "c"(p2)
|
|
|
|
: "memory");
|
2007-10-11 13:34:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
|
|
|
|
unsigned long p2, unsigned long p3)
|
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
asm volatile(KVM_HYPERCALL
|
|
|
|
: "=a"(ret)
|
2008-07-03 16:02:36 +00:00
|
|
|
: "a"(nr), "b"(p1), "c"(p2), "d"(p3)
|
|
|
|
: "memory");
|
2007-10-11 13:34:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
|
|
|
|
unsigned long p2, unsigned long p3,
|
|
|
|
unsigned long p4)
|
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
asm volatile(KVM_HYPERCALL
|
|
|
|
: "=a"(ret)
|
2008-07-03 16:02:36 +00:00
|
|
|
: "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
|
|
|
|
: "memory");
|
2007-10-11 13:34:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-07-29 12:47:56 +00:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
2014-01-27 13:49:40 +00:00
|
|
|
bool kvm_para_available(void);
|
2014-01-27 13:51:44 +00:00
|
|
|
unsigned int kvm_arch_para_features(void);
|
2010-07-29 12:47:56 +00:00
|
|
|
void __init kvm_guest_init(void);
|
2010-10-14 09:22:52 +00:00
|
|
|
void kvm_async_pf_task_wait(u32 token);
|
|
|
|
void kvm_async_pf_task_wake(u32 token);
|
|
|
|
u32 kvm_read_and_reset_pf_reason(void);
|
2011-07-11 19:28:19 +00:00
|
|
|
extern void kvm_disable_steal_time(void);
|
2013-08-06 09:25:41 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PARAVIRT_SPINLOCKS
|
|
|
|
void __init kvm_spinlock_init(void);
|
|
|
|
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
|
|
|
|
static inline void kvm_spinlock_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
|
|
|
|
|
|
|
|
#else /* CONFIG_KVM_GUEST */
|
|
|
|
#define kvm_guest_init() do {} while (0)
|
2010-10-14 09:22:52 +00:00
|
|
|
#define kvm_async_pf_task_wait(T) do {} while(0)
|
|
|
|
#define kvm_async_pf_task_wake(T) do {} while(0)
|
2013-08-06 09:25:41 +00:00
|
|
|
|
2014-01-27 13:49:40 +00:00
|
|
|
static inline bool kvm_para_available(void)
|
|
|
|
{
|
2015-03-30 23:46:09 +00:00
|
|
|
return false;
|
2014-01-27 13:49:40 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 13:51:44 +00:00
|
|
|
static inline unsigned int kvm_arch_para_features(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-20 16:34:54 +00:00
|
|
|
static inline u32 kvm_read_and_reset_pf_reason(void)
|
2010-10-14 09:22:52 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-07-11 19:28:19 +00:00
|
|
|
|
|
|
|
static inline void kvm_disable_steal_time(void)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2007-10-11 13:34:17 +00:00
|
|
|
#endif
|
|
|
|
|
2008-10-23 05:26:29 +00:00
|
|
|
#endif /* _ASM_X86_KVM_PARA_H */
|