• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_MIPS_KVM_PARA_H
3 #define _ASM_MIPS_KVM_PARA_H
4 
5 #include <uapi/asm/kvm_para.h>
6 
7 #define KVM_HYPERCALL ".word 0x42000028"
8 
9 /*
10  * Hypercalls for KVM.
11  *
12  * Hypercall number is passed in v0.
13  * Return value will be placed in v0.
14  * Up to 3 arguments are passed in a0, a1, and a2.
15  */
kvm_hypercall0(unsigned long num)16 static inline unsigned long kvm_hypercall0(unsigned long num)
17 {
18 	register unsigned long n asm("v0");
19 	register unsigned long r asm("v0");
20 
21 	n = num;
22 	__asm__ __volatile__(
23 		KVM_HYPERCALL
24 		: "=r" (r) : "r" (n) : "memory"
25 		);
26 
27 	return r;
28 }
29 
kvm_hypercall1(unsigned long num,unsigned long arg0)30 static inline unsigned long kvm_hypercall1(unsigned long num,
31 					unsigned long arg0)
32 {
33 	register unsigned long n asm("v0");
34 	register unsigned long r asm("v0");
35 	register unsigned long a0 asm("a0");
36 
37 	n = num;
38 	a0 = arg0;
39 	__asm__ __volatile__(
40 		KVM_HYPERCALL
41 		: "=r" (r) : "r" (n), "r" (a0) : "memory"
42 		);
43 
44 	return r;
45 }
46 
kvm_hypercall2(unsigned long num,unsigned long arg0,unsigned long arg1)47 static inline unsigned long kvm_hypercall2(unsigned long num,
48 					unsigned long arg0, unsigned long arg1)
49 {
50 	register unsigned long n asm("v0");
51 	register unsigned long r asm("v0");
52 	register unsigned long a0 asm("a0");
53 	register unsigned long a1 asm("a1");
54 
55 	n = num;
56 	a0 = arg0;
57 	a1 = arg1;
58 	__asm__ __volatile__(
59 		KVM_HYPERCALL
60 		: "=r" (r) : "r" (n), "r" (a0), "r" (a1) : "memory"
61 		);
62 
63 	return r;
64 }
65 
kvm_hypercall3(unsigned long num,unsigned long arg0,unsigned long arg1,unsigned long arg2)66 static inline unsigned long kvm_hypercall3(unsigned long num,
67 	unsigned long arg0, unsigned long arg1, unsigned long arg2)
68 {
69 	register unsigned long n asm("v0");
70 	register unsigned long r asm("v0");
71 	register unsigned long a0 asm("a0");
72 	register unsigned long a1 asm("a1");
73 	register unsigned long a2 asm("a2");
74 
75 	n = num;
76 	a0 = arg0;
77 	a1 = arg1;
78 	a2 = arg2;
79 	__asm__ __volatile__(
80 		KVM_HYPERCALL
81 		: "=r" (r) : "r" (n), "r" (a0), "r" (a1), "r" (a2) : "memory"
82 		);
83 
84 	return r;
85 }
86 
kvm_check_and_clear_guest_paused(void)87 static inline bool kvm_check_and_clear_guest_paused(void)
88 {
89 	return false;
90 }
91 
kvm_arch_para_features(void)92 static inline unsigned int kvm_arch_para_features(void)
93 {
94 	return 0;
95 }
96 
kvm_arch_para_hints(void)97 static inline unsigned int kvm_arch_para_hints(void)
98 {
99 	return 0;
100 }
101 
102 #ifdef CONFIG_MIPS_PARAVIRT
kvm_para_available(void)103 static inline bool kvm_para_available(void)
104 {
105 	return true;
106 }
107 #else
kvm_para_available(void)108 static inline bool kvm_para_available(void)
109 {
110 	return false;
111 }
112 #endif
113 
114 
115 #endif /* _ASM_MIPS_KVM_PARA_H */
116