Full support for Ginger Console
[linux-ginger.git] / arch / s390 / include / asm / kvm_para.h
blob6964db226f83ee3d27e7bde23e5269bef95d3e61
1 /*
2 * asm-s390/kvm_para.h - definition for paravirtual devices on s390
4 * Copyright IBM Corp. 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.
10 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
13 #ifndef __S390_KVM_PARA_H
14 #define __S390_KVM_PARA_H
16 #ifdef __KERNEL__
19 * Hypercalls for KVM on s390. The calling convention is similar to the
20 * s390 ABI, so we use R2-R6 for parameters 1-5. In addition we use R1
21 * as hypercall number and R7 as parameter 6. The return value is
22 * written to R2. We use the diagnose instruction as hypercall. To avoid
23 * conflicts with existing diagnoses for LPAR and z/VM, we do not use
24 * the instruction encoded number, but specify the number in R1 and
25 * use 0x500 as KVM hypercall
27 * Copyright IBM Corp. 2007,2008
28 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
30 * This work is licensed under the terms of the GNU GPL, version 2.
33 static inline long kvm_hypercall0(unsigned long nr)
35 register unsigned long __nr asm("1") = nr;
36 register long __rc asm("2");
38 asm volatile ("diag 2,4,0x500\n"
39 : "=d" (__rc) : "d" (__nr): "memory", "cc");
40 return __rc;
43 static inline long kvm_hypercall1(unsigned long nr, unsigned long p1)
45 register unsigned long __nr asm("1") = nr;
46 register unsigned long __p1 asm("2") = p1;
47 register long __rc asm("2");
49 asm volatile ("diag 2,4,0x500\n"
50 : "=d" (__rc) : "d" (__nr), "0" (__p1) : "memory", "cc");
51 return __rc;
54 static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
55 unsigned long p2)
57 register unsigned long __nr asm("1") = nr;
58 register unsigned long __p1 asm("2") = p1;
59 register unsigned long __p2 asm("3") = p2;
60 register long __rc asm("2");
62 asm volatile ("diag 2,4,0x500\n"
63 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2)
64 : "memory", "cc");
65 return __rc;
68 static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
69 unsigned long p2, unsigned long p3)
71 register unsigned long __nr asm("1") = nr;
72 register unsigned long __p1 asm("2") = p1;
73 register unsigned long __p2 asm("3") = p2;
74 register unsigned long __p3 asm("4") = p3;
75 register long __rc asm("2");
77 asm volatile ("diag 2,4,0x500\n"
78 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
79 "d" (__p3) : "memory", "cc");
80 return __rc;
84 static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
85 unsigned long p2, unsigned long p3,
86 unsigned long p4)
88 register unsigned long __nr asm("1") = nr;
89 register unsigned long __p1 asm("2") = p1;
90 register unsigned long __p2 asm("3") = p2;
91 register unsigned long __p3 asm("4") = p3;
92 register unsigned long __p4 asm("5") = p4;
93 register long __rc asm("2");
95 asm volatile ("diag 2,4,0x500\n"
96 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
97 "d" (__p3), "d" (__p4) : "memory", "cc");
98 return __rc;
101 static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
102 unsigned long p2, unsigned long p3,
103 unsigned long p4, unsigned long p5)
105 register unsigned long __nr asm("1") = nr;
106 register unsigned long __p1 asm("2") = p1;
107 register unsigned long __p2 asm("3") = p2;
108 register unsigned long __p3 asm("4") = p3;
109 register unsigned long __p4 asm("5") = p4;
110 register unsigned long __p5 asm("6") = p5;
111 register long __rc asm("2");
113 asm volatile ("diag 2,4,0x500\n"
114 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
115 "d" (__p3), "d" (__p4), "d" (__p5) : "memory", "cc");
116 return __rc;
119 static inline long kvm_hypercall6(unsigned long nr, unsigned long p1,
120 unsigned long p2, unsigned long p3,
121 unsigned long p4, unsigned long p5,
122 unsigned long p6)
124 register unsigned long __nr asm("1") = nr;
125 register unsigned long __p1 asm("2") = p1;
126 register unsigned long __p2 asm("3") = p2;
127 register unsigned long __p3 asm("4") = p3;
128 register unsigned long __p4 asm("5") = p4;
129 register unsigned long __p5 asm("6") = p5;
130 register unsigned long __p6 asm("7") = p6;
131 register long __rc asm("2");
133 asm volatile ("diag 2,4,0x500\n"
134 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
135 "d" (__p3), "d" (__p4), "d" (__p5), "d" (__p6)
136 : "memory", "cc");
137 return __rc;
140 /* kvm on s390 is always paravirtualization enabled */
141 static inline int kvm_para_available(void)
143 return 1;
146 /* No feature bits are currently assigned for kvm on s390 */
147 static inline unsigned int kvm_arch_para_features(void)
149 return 0;
152 #endif
154 #endif /* __S390_KVM_PARA_H */