[RFC PATCH 2/3] x86: add generic hypercall support

Gregory Haskins
2009-05-05T13:25:43Z

This adds a hypercall() vector to x86 pv_cpu_ops to be optionally filled in
by a hypervisor driver as it loads its other pv_ops components. We also
declare x86 as CONFIG_HAVE_HYPERCALL to enable the generic hypercall code
whenever the user builds for x86.

Signed-off-by: Gregory Haskins <ghaskins@novell.com>
---

arch/Kconfig | 3 +++
arch/x86/Kconfig | 1 +
arch/x86/include/asm/paravirt.h | 13 +++++++++++++
arch/x86/include/asm/processor.h | 6 ++++++
4 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index 78a35e9..239b658 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -112,3 +112,6 @@ config HAVE_DMA_API_DEBUG

config HAVE_DEFAULT_NO_SPIN_MUTEXES
bool
+
+config HAVE_HYPERCALL
+ bool
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index df9e885..3c609cf 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -46,6 +46,7 @@ config X86
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_BZIP2
select HAVE_KERNEL_LZMA
+ select HAVE_HYPERCALL

config ARCH_DEFCONFIG
string
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 378e369..ed22c84 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -6,6 +6,7 @@
#ifdef CONFIG_PARAVIRT
#include <asm/pgtable_types.h>
#include <asm/asm.h>
+#include <asm/errno.h>

/* Bitmask of what can be clobbered: usually at least eax. */
#define CLBR_NONE 0
@@ -203,6 +204,8 @@ struct pv_cpu_ops {

void (*swapgs)(void);

+ long (*hypercall)(unsigned long nr, unsigned long *args, size_t count);
+
struct pv_lazy_ops lazy_mode;
};

@@ -723,6 +726,16 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
PVOP_VCALL4(pv_cpu_ops.cpuid, eax, ebx, ecx, edx);
}

+static inline long hypercall(unsigned long nr,
+ unsigned long *args,
+ size_t count)
+{
+ if (!pv_cpu_ops.hypercall)
+ return -EINVAL;
+
+ return pv_cpu_ops.hypercall(nr, args, count);
+}
+
/*
* These special macros can be used to get or set a debugging register
*/
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index c2cceae..8fa988d 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -570,6 +570,12 @@ static inline void native_swapgs(void)
#define __cpuid native_cpuid
#define paravirt_enabled() 0

+static inline long
+hypercall(unsigned long nr, unsigned long *args, size_t count)
+{
+ return -EINVAL;
+}
+
/*
* These special macros can be used to get or set a debugging register
*/