2008-10-22 22:26:29 -07:00
|
|
|
#ifndef _ASM_X86_KVM_PARA_H
|
|
|
|
#define _ASM_X86_KVM_PARA_H
|
2007-10-11 15:34:17 +02:00
|
|
|
|
|
|
|
#include <asm/processor.h>
|
2014-09-22 13:17:48 +02:00
|
|
|
#include <asm/alternative.h>
|
2012-12-14 22:37:13 +00:00
|
|
|
#include <uapi/asm/kvm_para.h>
|
2007-10-11 15:34:17 +02:00
|
|
|
|
2008-02-15 17:52:47 -02:00
|
|
|
extern void kvmclock_init(void);
|
2010-10-14 11:22:49 +02:00
|
|
|
extern int kvm_register_clock(char *txt);
|
2008-02-15 17:52:47 -02:00
|
|
|
|
2012-08-16 17:00:19 -03:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
2012-03-10 14:37:26 -05: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 17:00:19 -03:00
|
|
|
#endif /* CONFIG_KVM_GUEST */
|
2008-02-15 17:52:47 -02:00
|
|
|
|
2014-09-22 13:17:48 +02:00
|
|
|
#define KVM_HYPERCALL \
|
|
|
|
ALTERNATIVE(".byte 0x0f,0x01,0xc1", ".byte 0x0f,0x01,0xd9", X86_FEATURE_VMMCALL)
|
2007-10-11 15:34:17 +02:00
|
|
|
|
2012-08-07 13:10:13 +05:30
|
|
|
/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall
|
2007-10-11 15:34:17 +02: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 15:31:51 -06:00
|
|
|
* placed in rax. No other registers will be clobbered unless explicitly
|
2007-10-11 15:34:17 +02: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 19:02:36 +03:00
|
|
|
: "a"(nr)
|
|
|
|
: "memory");
|
2007-10-11 15:34:17 +02: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 19:02:36 +03:00
|
|
|
: "a"(nr), "b"(p1)
|
|
|
|
: "memory");
|
2007-10-11 15:34:17 +02: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 19:02:36 +03:00
|
|
|
: "a"(nr), "b"(p1), "c"(p2)
|
|
|
|
: "memory");
|
2007-10-11 15:34:17 +02: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 19:02:36 +03:00
|
|
|
: "a"(nr), "b"(p1), "c"(p2), "d"(p3)
|
|
|
|
: "memory");
|
2007-10-11 15:34:17 +02: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 19:02:36 +03:00
|
|
|
: "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4)
|
|
|
|
: "memory");
|
2007-10-11 15:34:17 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-07-29 14:47:56 +02:00
|
|
|
#ifdef CONFIG_KVM_GUEST
|
2014-01-27 14:49:40 +01:00
|
|
|
bool kvm_para_available(void);
|
2014-01-27 14:51:44 +01:00
|
|
|
unsigned int kvm_arch_para_features(void);
|
2010-07-29 14:47:56 +02:00
|
|
|
void __init kvm_guest_init(void);
|
2010-10-14 11:22:52 +02: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 15:28:19 -04:00
|
|
|
extern void kvm_disable_steal_time(void);
|
2013-08-06 14:55:41 +05:30
|
|
|
|
|
|
|
#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 11:22:52 +02:00
|
|
|
#define kvm_async_pf_task_wait(T) do {} while(0)
|
|
|
|
#define kvm_async_pf_task_wake(T) do {} while(0)
|
2013-08-06 14:55:41 +05:30
|
|
|
|
2014-01-27 14:49:40 +01:00
|
|
|
static inline bool kvm_para_available(void)
|
|
|
|
{
|
2015-03-30 16:46:09 -07:00
|
|
|
return false;
|
2014-01-27 14:49:40 +01:00
|
|
|
}
|
|
|
|
|
2014-01-27 14:51:44 +01:00
|
|
|
static inline unsigned int kvm_arch_para_features(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-20 18:34:54 +02:00
|
|
|
static inline u32 kvm_read_and_reset_pf_reason(void)
|
2010-10-14 11:22:52 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-07-11 15:28:19 -04:00
|
|
|
|
|
|
|
static inline void kvm_disable_steal_time(void)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2007-10-11 15:34:17 +02:00
|
|
|
#endif
|
|
|
|
|
2008-10-22 22:26:29 -07:00
|
|
|
#endif /* _ASM_X86_KVM_PARA_H */
|