2 * 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 * Hypercalls for KVM on s390. The calling convention is similar to the
14 * s390 ABI, so we use R2-R6 for parameters 1-5. In addition we use R1
15 * as hypercall number and R7 as parameter 6. The return value is
16 * written to R2. We use the diagnose instruction as hypercall. To avoid
17 * conflicts with existing diagnoses for LPAR and z/VM, we do not use
18 * the instruction encoded number, but specify the number in R1 and
19 * use 0x500 as KVM hypercall
21 * Copyright IBM Corp. 2007,2008
22 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
24 * This work is licensed under the terms of the GNU GPL, version 2.
26 #ifndef __S390_KVM_PARA_H
27 #define __S390_KVM_PARA_H
29 #include <uapi/asm/kvm_para.h>
32 static inline long __kvm_hypercall0(unsigned long nr
)
34 register unsigned long __nr
asm("1") = nr
;
35 register long __rc
asm("2");
37 asm volatile ("diag 2,4,0x500\n"
38 : "=d" (__rc
) : "d" (__nr
): "memory", "cc");
42 static inline long kvm_hypercall0(unsigned long nr
)
44 diag_stat_inc(DIAG_STAT_X500
);
45 return __kvm_hypercall0(nr
);
48 static inline long __kvm_hypercall1(unsigned long nr
, unsigned long p1
)
50 register unsigned long __nr
asm("1") = nr
;
51 register unsigned long __p1
asm("2") = p1
;
52 register long __rc
asm("2");
54 asm volatile ("diag 2,4,0x500\n"
55 : "=d" (__rc
) : "d" (__nr
), "0" (__p1
) : "memory", "cc");
59 static inline long kvm_hypercall1(unsigned long nr
, unsigned long p1
)
61 diag_stat_inc(DIAG_STAT_X500
);
62 return __kvm_hypercall1(nr
, p1
);
65 static inline long __kvm_hypercall2(unsigned long nr
, unsigned long p1
,
68 register unsigned long __nr
asm("1") = nr
;
69 register unsigned long __p1
asm("2") = p1
;
70 register unsigned long __p2
asm("3") = p2
;
71 register long __rc
asm("2");
73 asm volatile ("diag 2,4,0x500\n"
74 : "=d" (__rc
) : "d" (__nr
), "0" (__p1
), "d" (__p2
)
79 static inline long kvm_hypercall2(unsigned long nr
, unsigned long p1
,
82 diag_stat_inc(DIAG_STAT_X500
);
83 return __kvm_hypercall2(nr
, p1
, p2
);
86 static inline long __kvm_hypercall3(unsigned long nr
, unsigned long p1
,
87 unsigned long p2
, unsigned long p3
)
89 register unsigned long __nr
asm("1") = nr
;
90 register unsigned long __p1
asm("2") = p1
;
91 register unsigned long __p2
asm("3") = p2
;
92 register unsigned long __p3
asm("4") = p3
;
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
) : "memory", "cc");
101 static inline long kvm_hypercall3(unsigned long nr
, unsigned long p1
,
102 unsigned long p2
, unsigned long p3
)
104 diag_stat_inc(DIAG_STAT_X500
);
105 return __kvm_hypercall3(nr
, p1
, p2
, p3
);
108 static inline long __kvm_hypercall4(unsigned long nr
, unsigned long p1
,
109 unsigned long p2
, unsigned long p3
,
112 register unsigned long __nr
asm("1") = nr
;
113 register unsigned long __p1
asm("2") = p1
;
114 register unsigned long __p2
asm("3") = p2
;
115 register unsigned long __p3
asm("4") = p3
;
116 register unsigned long __p4
asm("5") = p4
;
117 register long __rc
asm("2");
119 asm volatile ("diag 2,4,0x500\n"
120 : "=d" (__rc
) : "d" (__nr
), "0" (__p1
), "d" (__p2
),
121 "d" (__p3
), "d" (__p4
) : "memory", "cc");
125 static inline long kvm_hypercall4(unsigned long nr
, unsigned long p1
,
126 unsigned long p2
, unsigned long p3
,
129 diag_stat_inc(DIAG_STAT_X500
);
130 return __kvm_hypercall4(nr
, p1
, p2
, p3
, p4
);
133 static inline long __kvm_hypercall5(unsigned long nr
, unsigned long p1
,
134 unsigned long p2
, unsigned long p3
,
135 unsigned long p4
, unsigned long p5
)
137 register unsigned long __nr
asm("1") = nr
;
138 register unsigned long __p1
asm("2") = p1
;
139 register unsigned long __p2
asm("3") = p2
;
140 register unsigned long __p3
asm("4") = p3
;
141 register unsigned long __p4
asm("5") = p4
;
142 register unsigned long __p5
asm("6") = p5
;
143 register long __rc
asm("2");
145 asm volatile ("diag 2,4,0x500\n"
146 : "=d" (__rc
) : "d" (__nr
), "0" (__p1
), "d" (__p2
),
147 "d" (__p3
), "d" (__p4
), "d" (__p5
) : "memory", "cc");
151 static inline long kvm_hypercall5(unsigned long nr
, unsigned long p1
,
152 unsigned long p2
, unsigned long p3
,
153 unsigned long p4
, unsigned long p5
)
155 diag_stat_inc(DIAG_STAT_X500
);
156 return __kvm_hypercall5(nr
, p1
, p2
, p3
, p4
, p5
);
159 static inline long __kvm_hypercall6(unsigned long nr
, unsigned long p1
,
160 unsigned long p2
, unsigned long p3
,
161 unsigned long p4
, unsigned long p5
,
164 register unsigned long __nr
asm("1") = nr
;
165 register unsigned long __p1
asm("2") = p1
;
166 register unsigned long __p2
asm("3") = p2
;
167 register unsigned long __p3
asm("4") = p3
;
168 register unsigned long __p4
asm("5") = p4
;
169 register unsigned long __p5
asm("6") = p5
;
170 register unsigned long __p6
asm("7") = p6
;
171 register long __rc
asm("2");
173 asm volatile ("diag 2,4,0x500\n"
174 : "=d" (__rc
) : "d" (__nr
), "0" (__p1
), "d" (__p2
),
175 "d" (__p3
), "d" (__p4
), "d" (__p5
), "d" (__p6
)
180 static inline long kvm_hypercall6(unsigned long nr
, unsigned long p1
,
181 unsigned long p2
, unsigned long p3
,
182 unsigned long p4
, unsigned long p5
,
185 diag_stat_inc(DIAG_STAT_X500
);
186 return __kvm_hypercall6(nr
, p1
, p2
, p3
, p4
, p5
, p6
);
189 /* kvm on s390 is always paravirtualization enabled */
190 static inline int kvm_para_available(void)
195 /* No feature bits are currently assigned for kvm on s390 */
196 static inline unsigned int kvm_arch_para_features(void)
201 static inline bool kvm_check_and_clear_guest_paused(void)
206 #endif /* __S390_KVM_PARA_H */