blob: 6964db226f83ee3d27e7bde23e5269bef95d3e61 [file] [log] [blame]
Heiko Carstensb0c632d2008-03-25 18:47:20 +01001/*
2 * asm-s390/kvm_para.h - definition for paravirtual devices on s390
3 *
4 * Copyright IBM Corp. 2008
5 *
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.
9 *
10 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
11 */
12
13#ifndef __S390_KVM_PARA_H
14#define __S390_KVM_PARA_H
15
Avi Kivity27c23812009-08-16 15:31:11 +030016#ifdef __KERNEL__
17
Heiko Carstensb0c632d2008-03-25 18:47:20 +010018/*
Christian Borntraegere976a2b2008-03-25 18:47:46 +010019 * 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
26 *
27 * Copyright IBM Corp. 2007,2008
28 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
29 *
30 * This work is licensed under the terms of the GNU GPL, version 2.
Heiko Carstensb0c632d2008-03-25 18:47:20 +010031 */
32
Christian Borntraegere976a2b2008-03-25 18:47:46 +010033static inline long kvm_hypercall0(unsigned long nr)
Heiko Carstensb0c632d2008-03-25 18:47:20 +010034{
Christian Borntraegere976a2b2008-03-25 18:47:46 +010035 register unsigned long __nr asm("1") = nr;
36 register long __rc asm("2");
37
38 asm volatile ("diag 2,4,0x500\n"
39 : "=d" (__rc) : "d" (__nr): "memory", "cc");
40 return __rc;
Heiko Carstensb0c632d2008-03-25 18:47:20 +010041}
42
Christian Borntraegere976a2b2008-03-25 18:47:46 +010043static inline long kvm_hypercall1(unsigned long nr, unsigned long p1)
44{
45 register unsigned long __nr asm("1") = nr;
46 register unsigned long __p1 asm("2") = p1;
47 register long __rc asm("2");
48
49 asm volatile ("diag 2,4,0x500\n"
50 : "=d" (__rc) : "d" (__nr), "0" (__p1) : "memory", "cc");
51 return __rc;
52}
53
54static inline long kvm_hypercall2(unsigned long nr, unsigned long p1,
55 unsigned long p2)
56{
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");
61
62 asm volatile ("diag 2,4,0x500\n"
63 : "=d" (__rc) : "d" (__nr), "0" (__p1), "d" (__p2)
64 : "memory", "cc");
65 return __rc;
66}
67
68static inline long kvm_hypercall3(unsigned long nr, unsigned long p1,
69 unsigned long p2, unsigned long p3)
70{
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");
76
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;
81}
82
83
84static inline long kvm_hypercall4(unsigned long nr, unsigned long p1,
85 unsigned long p2, unsigned long p3,
86 unsigned long p4)
87{
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");
94
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;
99}
100
101static inline long kvm_hypercall5(unsigned long nr, unsigned long p1,
102 unsigned long p2, unsigned long p3,
103 unsigned long p4, unsigned long p5)
104{
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");
112
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;
117}
118
119static 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)
123{
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");
132
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;
138}
139
140/* kvm on s390 is always paravirtualization enabled */
141static inline int kvm_para_available(void)
142{
143 return 1;
144}
145
146/* No feature bits are currently assigned for kvm on s390 */
Heiko Carstensb0c632d2008-03-25 18:47:20 +0100147static inline unsigned int kvm_arch_para_features(void)
148{
149 return 0;
150}
151
Avi Kivity27c23812009-08-16 15:31:11 +0300152#endif
153
Heiko Carstensb0c632d2008-03-25 18:47:20 +0100154#endif /* __S390_KVM_PARA_H */