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>
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");
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_hypercall2(unsigned long nr
, unsigned long p1
,
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
)
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");
84 static inline long kvm_hypercall4(unsigned long nr
, unsigned long p1
,
85 unsigned long p2
, unsigned long p3
,
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");
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");
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
,
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
)
140 /* kvm on s390 is always paravirtualization enabled */
141 static inline int kvm_para_available(void)
146 /* No feature bits are currently assigned for kvm on s390 */
147 static inline unsigned int kvm_arch_para_features(void)
152 static inline bool kvm_check_and_clear_guest_paused(void)
157 #endif /* __S390_KVM_PARA_H */