1 /* SPDX-License-Identifier: GPL-2.0 */
3 * definition for paravirtual devices on s390
5 * Copyright IBM Corp. 2008
7 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
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>
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");
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");
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
,
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
)
74 static inline long kvm_hypercall2(unsigned long nr
, unsigned long p1
,
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");
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
,
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");
120 static inline long kvm_hypercall4(unsigned long nr
, unsigned long p1
,
121 unsigned long p2
, unsigned long p3
,
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");
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
,
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
)
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
,
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)
190 /* No feature bits are currently assigned for kvm on s390 */
191 static inline unsigned int kvm_arch_para_features(void)
196 static inline unsigned int kvm_arch_para_hints(void)
201 static inline bool kvm_check_and_clear_guest_paused(void)
206 #endif /* __S390_KVM_PARA_H */