From: Christian Ehrhardt <[EMAIL PROTECTED]>

This adds the guest portion of the hypercall infrastructure, basically an
illegal instruction with a defined layout.
See http://kvm.qumranet.com/kvmwiki/PowerPC_Hypercall_ABI for more detail
on the hypercall ABI for powerpc.

Signed-off-by: Christian Ehrhardt <[EMAIL PROTECTED]>
---

[diffstat]
 kvm_para.h |   33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

[diff]

diff --git a/include/asm-powerpc/kvm_para.h b/include/asm-powerpc/kvm_para.h
--- a/include/asm-powerpc/kvm_para.h
+++ b/include/asm-powerpc/kvm_para.h
@@ -25,6 +25,8 @@
 #ifdef __KERNEL__
 
 #include <linux/of.h>
+
+#define KVM_HYPERCALL_BIN 0x03ffffff
 
 static struct kvmppc_para_features {
        char *dtcell;
@@ -69,6 +71,37 @@
 
 void kvm_guest_init(void);
 
+static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
+{
+       register unsigned long hcall asm ("r0") = nr;
+       register unsigned long arg1 asm ("r3") = p1;
+       register long ret asm ("r11");
+
+       asm volatile(".long %1"
+                       : "=r"(ret)
+                       : "i"(KVM_HYPERCALL_BIN), "r"(hcall), "r"(arg1)
+                       : "r4", "r5", "r6", "r7", "r8",
+                         "r9", "r10", "r12", "cc");
+       return ret;
+}
+
+static inline long kvm_hypercall2(unsigned int nr,
+                                       unsigned long p1, unsigned long p2)
+{
+       register unsigned long hcall asm ("r0") = nr;
+       register unsigned long arg1 asm ("r3") = p1;
+       register unsigned long arg2 asm ("r4") = p2;
+       register long ret asm ("r11");
+
+       asm volatile(".long %1"
+                       : "=r"(ret)
+                       : "i"(KVM_HYPERCALL_BIN), "r"(hcall),
+                               "r"(arg1), "r"(arg2)
+                       : "r5", "r6", "r7", "r8",
+                         "r9", "r10", "r12", "cc");
+       return ret;
+}
+
 #endif /* __KERNEL__ */
 
 #endif /* __POWERPC_KVM_PARA_H__ */
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Reply via email to