treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / s390 / include / asm / kvm_para.h
blobcbc7c3a68e4dfdec0bdd76a767f0843afa1cd6f6
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * definition for paravirtual devices on s390
5 * Copyright IBM Corp. 2008
7 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
8 */
9 /*
10 * Hypercalls for KVM on s390. The calling convention is similar to the
11 * s390 ABI, so we use R2-R6 for parameters 1-5. In addition we use R1
12 * as hypercall number and R7 as parameter 6. The return value is
13 * written to R2. We use the diagnose instruction as hypercall. To avoid
14 * conflicts with existing diagnoses for LPAR and z/VM, we do not use
15 * the instruction encoded number, but specify the number in R1 and
16 * use 0x500 as KVM hypercall
18 * Copyright IBM Corp. 2007,2008
19 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
21 #ifndef __S390_KVM_PARA_H
22 #define __S390_KVM_PARA_H
24 #include <uapi/asm/kvm_para.h>
25 #include <asm/diag.h>
27 static inline long __kvm_hypercall0(unsigned long nr)
29 register unsigned long __nr asm("1") = nr;
30 register long __rc asm("2");
32 asm volatile ("diag 2,4,0x500\n"
33 : "=d" (__rc) : "d" (__nr): "memory", "cc");
34 return __rc;
37 static inline long kvm_hypercall0(unsigned long nr)
39 diag_stat_inc(DIAG_STAT_X500);
40 return __kvm_hypercall0(nr);
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_hypercall1(unsigned long nr, unsigned long p1)
56 diag_stat_inc(DIAG_STAT_X500);
57 return __kvm_hypercall1(nr, p1);
60 static inline long __kvm_hypercall2(unsigned long nr, unsigned long p1,
61 unsigned long p2)
63 register unsigned long __nr asm("1") = nr;
64 register unsigned long __p1 asm("2") = p1;
65 register unsigned long __p2 asm("3") = p2;
66 register long __rc asm("2");
68 asm volatile ("diag 2,4,0x500\n"
69 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2)
70 : "memory", "cc");
71 return __rc;
74 static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
75 unsigned long p2)
77 diag_stat_inc(DIAG_STAT_X500);
78 return __kvm_hypercall2(nr, p1, p2);
81 static inline long __kvm_hypercall3(unsigned long nr, unsigned long p1,
82 unsigned long p2, unsigned long p3)
84 register unsigned long __nr asm("1") = nr;
85 register unsigned long __p1 asm("2") = p1;
86 register unsigned long __p2 asm("3") = p2;
87 register unsigned long __p3 asm("4") = p3;
88 register long __rc asm("2");
90 asm volatile ("diag 2,4,0x500\n"
91 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
92 "d" (__p3) : "memory", "cc");
93 return __rc;
96 static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
97 unsigned long p2, unsigned long p3)
99 diag_stat_inc(DIAG_STAT_X500);
100 return __kvm_hypercall3(nr, p1, p2, p3);
103 static inline long __kvm_hypercall4(unsigned long nr, unsigned long p1,
104 unsigned long p2, unsigned long p3,
105 unsigned long p4)
107 register unsigned long __nr asm("1") = nr;
108 register unsigned long __p1 asm("2") = p1;
109 register unsigned long __p2 asm("3") = p2;
110 register unsigned long __p3 asm("4") = p3;
111 register unsigned long __p4 asm("5") = p4;
112 register long __rc asm("2");
114 asm volatile ("diag 2,4,0x500\n"
115 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
116 "d" (__p3), "d" (__p4) : "memory", "cc");
117 return __rc;
120 static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
121 unsigned long p2, unsigned long p3,
122 unsigned long p4)
124 diag_stat_inc(DIAG_STAT_X500);
125 return __kvm_hypercall4(nr, p1, p2, p3, p4);
128 static inline long __kvm_hypercall5(unsigned long nr, unsigned long p1,
129 unsigned long p2, unsigned long p3,
130 unsigned long p4, unsigned long p5)
132 register unsigned long __nr asm("1") = nr;
133 register unsigned long __p1 asm("2") = p1;
134 register unsigned long __p2 asm("3") = p2;
135 register unsigned long __p3 asm("4") = p3;
136 register unsigned long __p4 asm("5") = p4;
137 register unsigned long __p5 asm("6") = p5;
138 register long __rc asm("2");
140 asm volatile ("diag 2,4,0x500\n"
141 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
142 "d" (__p3), "d" (__p4), "d" (__p5) : "memory", "cc");
143 return __rc;
146 static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
147 unsigned long p2, unsigned long p3,
148 unsigned long p4, unsigned long p5)
150 diag_stat_inc(DIAG_STAT_X500);
151 return __kvm_hypercall5(nr, p1, p2, p3, p4, p5);
154 static inline long __kvm_hypercall6(unsigned long nr, unsigned long p1,
155 unsigned long p2, unsigned long p3,
156 unsigned long p4, unsigned long p5,
157 unsigned long p6)
159 register unsigned long __nr asm("1") = nr;
160 register unsigned long __p1 asm("2") = p1;
161 register unsigned long __p2 asm("3") = p2;
162 register unsigned long __p3 asm("4") = p3;
163 register unsigned long __p4 asm("5") = p4;
164 register unsigned long __p5 asm("6") = p5;
165 register unsigned long __p6 asm("7") = p6;
166 register long __rc asm("2");
168 asm volatile ("diag 2,4,0x500\n"
169 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2),
170 "d" (__p3), "d" (__p4), "d" (__p5), "d" (__p6)
171 : "memory", "cc");
172 return __rc;
175 static inline long kvm_hypercall6(unsigned long nr, unsigned long p1,
176 unsigned long p2, unsigned long p3,
177 unsigned long p4, unsigned long p5,
178 unsigned long p6)
180 diag_stat_inc(DIAG_STAT_X500);
181 return __kvm_hypercall6(nr, p1, p2, p3, p4, p5, p6);
184 /* kvm on s390 is always paravirtualization enabled */
185 static inline int kvm_para_available(void)
187 return 1;
190 /* No feature bits are currently assigned for kvm on s390 */
191 static inline unsigned int kvm_arch_para_features(void)
193 return 0;
196 static inline unsigned int kvm_arch_para_hints(void)
198 return 0;
201 static inline bool kvm_check_and_clear_guest_paused(void)
203 return false;
206 #endif /* __S390_KVM_PARA_H */