]> git.proxmox.com Git - mirror_qemu.git/blame - target-ppc/kvm_ppc.h
Enable H_CLEAR_MOD and H_CLEAR_REF hypercalls on KVM/PPC64.
[mirror_qemu.git] / target-ppc / kvm_ppc.h
CommitLineData
d76d1650
AJ
1/*
2 * Copyright 2008 IBM Corporation.
3 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
4 *
5 * This work is licensed under the GNU GPL license version 2 or later.
6 *
7 */
8
2a6a4076
MA
9#ifndef KVM_PPC_H
10#define KVM_PPC_H
d76d1650 11
2985b86b
AF
12#define TYPE_HOST_POWERPC_CPU "host-" TYPE_POWERPC_CPU
13
921e28db
AG
14#ifdef CONFIG_KVM
15
dc333cd6 16uint32_t kvmppc_get_tbfreq(void);
eadaada1 17uint64_t kvmppc_get_clockfreq(void);
6659394f
DG
18uint32_t kvmppc_get_vmx(void);
19uint32_t kvmppc_get_dfp(void);
ef951443
ND
20bool kvmppc_get_host_model(char **buf);
21bool kvmppc_get_host_serial(char **buf);
1a61a9ae 22int kvmppc_get_hasidle(CPUPPCState *env);
1328c2bf 23int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
1bc22652 24int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
026bfd89 25void kvmppc_enable_logical_ci_hcalls(void);
ef9971dd 26void kvmppc_enable_set_mode_hcall(void);
5145ad4f 27void kvmppc_enable_clear_ref_mod_hcalls(void);
1bc22652 28void kvmppc_set_papr(PowerPCCPU *cpu);
6db5bb0f 29int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
5b95b8b9 30void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
e97c3636 31int kvmppc_smt_threads(void);
31f2cb8f
BB
32int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
33int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
34int kvmppc_set_tcr(PowerPCCPU *cpu);
35int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
98efaf75 36#ifndef CONFIG_USER_ONLY
658fa66b 37off_t kvmppc_alloc_rma(void **rma);
da95324e 38bool kvmppc_spapr_use_multitce(void);
9bb62a07 39void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd,
6a81dd17 40 bool need_vfio);
0f5cb298 41int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
7f763a5d
DG
42int kvmppc_reset_htab(int shift_hint);
43uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift);
98efaf75 44#endif /* !CONFIG_USER_ONLY */
3b961124 45bool kvmppc_has_cap_epr(void);
feaa64c4 46int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);
7c43bca0 47bool kvmppc_has_cap_htab_fd(void);
e68cb8b4
AK
48int kvmppc_get_htab_fd(bool write);
49int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns);
50int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
51 uint16_t n_valid, uint16_t n_invalid);
7c43bca0
AK
52uint64_t kvmppc_hash64_read_pteg(PowerPCCPU *cpu, target_ulong pte_index);
53void kvmppc_hash64_free_pteg(uint64_t token);
fc87e185 54
c1385933
AK
55void kvmppc_hash64_write_pte(CPUPPCState *env, target_ulong pte_index,
56 target_ulong pte0, target_ulong pte1);
87a91de6 57bool kvmppc_has_cap_fixup_hcalls(void);
4d9392be 58int kvmppc_enable_hwrng(void);
e5c0d3ce 59int kvmppc_put_books_sregs(PowerPCCPU *cpu);
52b2519c 60PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void);
c1385933 61
921e28db
AG
62#else
63
64static inline uint32_t kvmppc_get_tbfreq(void)
65{
66 return 0;
67}
68
ef951443
ND
69static inline bool kvmppc_get_host_model(char **buf)
70{
71 return false;
72}
73
74static inline bool kvmppc_get_host_serial(char **buf)
75{
76 return false;
77}
78
921e28db
AG
79static inline uint64_t kvmppc_get_clockfreq(void)
80{
81 return 0;
82}
83
6659394f
DG
84static inline uint32_t kvmppc_get_vmx(void)
85{
86 return 0;
87}
88
89static inline uint32_t kvmppc_get_dfp(void)
90{
91 return 0;
92}
93
1a61a9ae
SY
94static inline int kvmppc_get_hasidle(CPUPPCState *env)
95{
96 return 0;
97}
98
1328c2bf 99static inline int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)
921e28db
AG
100{
101 return -1;
102}
103
1bc22652 104static inline int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level)
921e28db
AG
105{
106 return -1;
107}
108
026bfd89
DG
109static inline void kvmppc_enable_logical_ci_hcalls(void)
110{
111}
112
ef9971dd
AK
113static inline void kvmppc_enable_set_mode_hcall(void)
114{
115}
116
5145ad4f
NW
117static inline void kvmppc_enable_clear_ref_mod_hcalls(void)
118{
119}
120
1bc22652 121static inline void kvmppc_set_papr(PowerPCCPU *cpu)
f61b4bed
AG
122{
123}
124
6db5bb0f
AK
125static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
126{
127 return 0;
128}
129
5b95b8b9
AG
130static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
131{
132}
133
e97c3636
DG
134static inline int kvmppc_smt_threads(void)
135{
136 return 1;
137}
138
31f2cb8f
BB
139static inline int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
140{
141 return 0;
142}
143
144static inline int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits)
145{
146 return 0;
147}
148
149static inline int kvmppc_set_tcr(PowerPCCPU *cpu)
150{
151 return 0;
152}
153
154static inline int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
155{
156 return -1;
157}
158
98efaf75 159#ifndef CONFIG_USER_ONLY
658fa66b 160static inline off_t kvmppc_alloc_rma(void **rma)
354ac20a
DG
161{
162 return 0;
163}
164
da95324e
AK
165static inline bool kvmppc_spapr_use_multitce(void)
166{
167 return false;
168}
169
0f5cb298 170static inline void *kvmppc_create_spapr_tce(uint32_t liobn,
9bb62a07 171 uint32_t window_size, int *fd,
f94819d6 172 bool need_vfio)
0f5cb298
DG
173{
174 return NULL;
175}
176
177static inline int kvmppc_remove_spapr_tce(void *table, int pfd,
523e7b8a 178 uint32_t nb_table)
0f5cb298
DG
179{
180 return -1;
181}
7f763a5d
DG
182
183static inline int kvmppc_reset_htab(int shift_hint)
184{
a3166f8f 185 return 0;
7f763a5d
DG
186}
187
188static inline uint64_t kvmppc_rma_size(uint64_t current_size,
189 unsigned int hash_shift)
190{
191 return ram_size;
192}
193
98efaf75 194#endif /* !CONFIG_USER_ONLY */
0f5cb298 195
3b961124
SY
196static inline bool kvmppc_has_cap_epr(void)
197{
198 return false;
199}
e68cb8b4 200
feaa64c4
DG
201static inline int kvmppc_define_rtas_kernel_token(uint32_t token,
202 const char *function)
203{
204 return -1;
205}
206
7c43bca0
AK
207static inline bool kvmppc_has_cap_htab_fd(void)
208{
209 return false;
210}
211
e68cb8b4
AK
212static inline int kvmppc_get_htab_fd(bool write)
213{
214 return -1;
215}
216
217static inline int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize,
218 int64_t max_ns)
219{
220 abort();
221}
222
223static inline int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,
224 uint16_t n_valid, uint16_t n_invalid)
225{
226 abort();
227}
228
7c43bca0
AK
229static inline uint64_t kvmppc_hash64_read_pteg(PowerPCCPU *cpu,
230 target_ulong pte_index)
231{
232 abort();
233}
234
235static inline void kvmppc_hash64_free_pteg(uint64_t token)
236{
237 abort();
238}
239
c1385933
AK
240static inline void kvmppc_hash64_write_pte(CPUPPCState *env,
241 target_ulong pte_index,
242 target_ulong pte0, target_ulong pte1)
243{
244 abort();
245}
246
87a91de6
AG
247static inline bool kvmppc_has_cap_fixup_hcalls(void)
248{
249 abort();
250}
251
4d9392be
TH
252static inline int kvmppc_enable_hwrng(void)
253{
254 return -1;
255}
e5c0d3ce
DG
256
257static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu)
258{
259 abort();
260}
52b2519c
TH
261
262static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void)
263{
264 return NULL;
265}
266
921e28db
AG
267#endif
268
b45d63b6 269#ifndef CONFIG_KVM
3240dd9a 270
b45d63b6 271#define kvmppc_eieio() do { } while (0)
3240dd9a
TH
272
273static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
274{
275}
276
277static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
278{
279}
280
281#else /* CONFIG_KVM */
282
b45d63b6
BH
283#define kvmppc_eieio() \
284 do { \
285 if (kvm_enabled()) { \
286 asm volatile("eieio" : : : "memory"); \
287 } \
288 } while (0)
3240dd9a
TH
289
290/* Store data cache blocks back to memory */
291static inline void kvmppc_dcbst_range(PowerPCCPU *cpu, uint8_t *addr, int len)
292{
293 uint8_t *p;
294
295 for (p = addr; p < addr + len; p += cpu->env.dcache_line_size) {
296 asm volatile("dcbst 0,%0" : : "r"(p) : "memory");
297 }
298}
299
300/* Invalidate instruction cache blocks */
301static inline void kvmppc_icbi_range(PowerPCCPU *cpu, uint8_t *addr, int len)
302{
303 uint8_t *p;
304
305 for (p = addr; p < addr + len; p += cpu->env.icache_line_size) {
306 asm volatile("icbi 0,%0" : : "r"(p));
307 }
308}
309
310#endif /* CONFIG_KVM */
b45d63b6 311
fc87e185
AG
312#ifndef KVM_INTERRUPT_SET
313#define KVM_INTERRUPT_SET -1
314#endif
315
316#ifndef KVM_INTERRUPT_UNSET
317#define KVM_INTERRUPT_UNSET -2
318#endif
319
320#ifndef KVM_INTERRUPT_SET_LEVEL
321#define KVM_INTERRUPT_SET_LEVEL -3
322#endif
dc333cd6 323
2a6a4076 324#endif /* KVM_PPC_H */