blob: aa795ccef2942feb73f8cf7e85bda5f7b1f47ad1 [file] [log] [blame]
Alexander Graf4e3420252009-10-30 05:47:05 +00001/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License, version 2, as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 *
15 * Copyright SUSE Linux Products GmbH 2009
16 *
17 * Authors: Alexander Graf <agraf@suse.de>
18 */
19
20#ifndef __ASM_KVM_BOOK3S_H__
21#define __ASM_KVM_BOOK3S_H__
22
23#include <linux/types.h>
24#include <linux/kvm_host.h>
Alexander Graf2191d652010-04-16 00:11:32 +020025#include <asm/kvm_book3s_asm.h>
Alexander Graf4e3420252009-10-30 05:47:05 +000026
Alexander Graf4e3420252009-10-30 05:47:05 +000027struct kvmppc_bat {
Alexander Grafe15a1132009-11-30 03:02:02 +000028 u64 raw;
Alexander Graf4e3420252009-10-30 05:47:05 +000029 u32 bepi;
30 u32 bepi_mask;
Alexander Graf4e3420252009-10-30 05:47:05 +000031 u32 brpn;
32 u8 wimg;
33 u8 pp;
Alexander Graf3ed9c6d2010-03-24 21:48:36 +010034 bool vs : 1;
35 bool vp : 1;
Alexander Graf4e3420252009-10-30 05:47:05 +000036};
37
38struct kvmppc_sid_map {
39 u64 guest_vsid;
40 u64 guest_esid;
41 u64 host_vsid;
Alexander Graf3ed9c6d2010-03-24 21:48:36 +010042 bool valid : 1;
Alexander Graf4e3420252009-10-30 05:47:05 +000043};
44
45#define SID_MAP_BITS 9
46#define SID_MAP_NUM (1 << SID_MAP_BITS)
47#define SID_MAP_MASK (SID_MAP_NUM - 1)
48
Alexander Graf8b6db3b2010-08-15 08:04:24 +020049#ifdef CONFIG_PPC_BOOK3S_64
50#define SID_CONTEXTS 1
51#else
52#define SID_CONTEXTS 128
53#define VSID_POOL_SIZE (SID_CONTEXTS * 16)
54#endif
55
Paul Mackerrasc4befc52011-06-29 00:17:33 +000056struct hpte_cache {
57 struct hlist_node list_pte;
58 struct hlist_node list_pte_long;
59 struct hlist_node list_vpte;
60 struct hlist_node list_vpte_long;
61 struct rcu_head rcu_head;
62 u64 host_va;
63 u64 pfn;
64 ulong slot;
65 struct kvmppc_pte pte;
66};
67
Alexander Graf4e3420252009-10-30 05:47:05 +000068struct kvmppc_vcpu_book3s {
69 struct kvm_vcpu vcpu;
Alexander Grafc7f38f42010-04-16 00:11:40 +020070 struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
Alexander Graf4e3420252009-10-30 05:47:05 +000071 struct kvmppc_sid_map sid_map[SID_MAP_NUM];
Alexander Graf4e3420252009-10-30 05:47:05 +000072 struct {
73 u64 esid;
74 u64 vsid;
75 } slb_shadow[64];
76 u8 slb_shadow_max;
Alexander Graf4e3420252009-10-30 05:47:05 +000077 struct kvmppc_bat ibat[8];
78 struct kvmppc_bat dbat[8];
79 u64 hid[6];
Alexander Grafd6d549b2010-02-19 11:00:33 +010080 u64 gqr[8];
Alexander Graf4e3420252009-10-30 05:47:05 +000081 u64 sdr1;
Alexander Graf4e3420252009-10-30 05:47:05 +000082 u64 hior;
83 u64 msr_mask;
Alexander Graf4e3420252009-10-30 05:47:05 +000084 u64 vsid_next;
Alexander Graf8b6db3b2010-08-15 08:04:24 +020085#ifdef CONFIG_PPC_BOOK3S_32
86 u32 vsid_pool[VSID_POOL_SIZE];
87#else
88 u64 vsid_first;
Alexander Graf4e3420252009-10-30 05:47:05 +000089 u64 vsid_max;
Alexander Graf8b6db3b2010-08-15 08:04:24 +020090#endif
91 int context_id[SID_CONTEXTS];
Paul Mackerrasc4befc52011-06-29 00:17:33 +000092
Alexander Graf1022fc32011-09-14 21:45:23 +020093 bool hior_explicit; /* HIOR is set by ioctl, not PVR */
94
Paul Mackerrasc4befc52011-06-29 00:17:33 +000095 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
96 struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
97 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
98 struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG];
99 int hpte_cache_count;
100 spinlock_t mmu_lock;
Alexander Graf4e3420252009-10-30 05:47:05 +0000101};
102
103#define CONTEXT_HOST 0
104#define CONTEXT_GUEST 1
105#define CONTEXT_GUEST_END 2
106
Alexander Graff7bc74e2010-04-20 02:49:48 +0200107#define VSID_REAL 0x1fffffffffc00000ULL
108#define VSID_BAT 0x1fffffffffb00000ULL
109#define VSID_REAL_DR 0x2000000000000000ULL
110#define VSID_REAL_IR 0x4000000000000000ULL
Alexander Graf5a1b4192010-03-24 21:48:35 +0100111#define VSID_PR 0x8000000000000000ULL
Alexander Graf4e3420252009-10-30 05:47:05 +0000112
Alexander Grafaf7b4d12010-04-20 02:49:46 +0200113extern void kvmppc_mmu_pte_flush(struct kvm_vcpu *vcpu, ulong ea, ulong ea_mask);
Alexander Graf4e3420252009-10-30 05:47:05 +0000114extern void kvmppc_mmu_pte_vflush(struct kvm_vcpu *vcpu, u64 vp, u64 vp_mask);
Alexander Grafaf7b4d12010-04-20 02:49:46 +0200115extern void kvmppc_mmu_pte_pflush(struct kvm_vcpu *vcpu, ulong pa_start, ulong pa_end);
Alexander Graf4e3420252009-10-30 05:47:05 +0000116extern void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 new_msr);
Paul Mackerrasf05ed4d2011-06-29 00:17:58 +0000117extern void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr);
Alexander Graf4e3420252009-10-30 05:47:05 +0000118extern void kvmppc_mmu_book3s_64_init(struct kvm_vcpu *vcpu);
119extern void kvmppc_mmu_book3s_32_init(struct kvm_vcpu *vcpu);
Paul Mackerrasde56a942011-06-29 00:21:34 +0000120extern void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu);
Alexander Graf4e3420252009-10-30 05:47:05 +0000121extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte);
122extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr);
123extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu);
Paul Mackerras697d3892011-12-12 12:36:37 +0000124extern int kvmppc_book3s_hv_page_fault(struct kvm_run *run,
125 struct kvm_vcpu *vcpu, unsigned long addr,
126 unsigned long status);
127extern long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr,
128 unsigned long slb_v, unsigned long valid);
Alexander Graffef093be2010-06-30 15:18:46 +0200129
130extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte);
131extern struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu);
132extern void kvmppc_mmu_hpte_destroy(struct kvm_vcpu *vcpu);
133extern int kvmppc_mmu_hpte_init(struct kvm_vcpu *vcpu);
134extern void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte);
135extern int kvmppc_mmu_hpte_sysinit(void);
136extern void kvmppc_mmu_hpte_sysexit(void);
Paul Mackerrasde56a942011-06-29 00:21:34 +0000137extern int kvmppc_mmu_hv_init(void);
Alexander Graffef093be2010-06-30 15:18:46 +0200138
Alexander Graf5467a972010-02-19 11:00:38 +0100139extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data);
140extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr, bool data);
Alexander Graf4e3420252009-10-30 05:47:05 +0000141extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec);
Paul Mackerrasde56a942011-06-29 00:21:34 +0000142extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags);
Alexander Grafe15a1132009-11-30 03:02:02 +0000143extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
144 bool upper, u32 val);
Alexander Grafaba3bd72010-02-19 11:00:39 +0100145extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
Alexander Graf831317b2010-02-19 11:00:44 +0100146extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu);
Alexander Grafe8508942010-07-29 14:47:54 +0200147extern pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn);
Paul Mackerras342d3db2011-12-12 12:38:05 +0000148extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
149 unsigned long *rmap, long pte_index, int realmode);
150extern void kvmppc_invalidate_hpte(struct kvm *kvm, unsigned long *hptep,
151 unsigned long pte_index);
Paul Mackerras55514892011-12-15 02:02:47 +0000152void kvmppc_clear_ref_hpte(struct kvm *kvm, unsigned long *hptep,
153 unsigned long pte_index);
Paul Mackerras93e60242011-12-12 12:28:55 +0000154extern void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long addr,
155 unsigned long *nb_ret);
156extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr);
Paul Mackerrasc77162d2011-12-12 12:31:00 +0000157extern long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
158 long pte_index, unsigned long pteh, unsigned long ptel);
159extern long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
160 long pte_index, unsigned long pteh, unsigned long ptel);
Paul Mackerras82ed3612011-12-15 02:03:22 +0000161extern long kvmppc_hv_get_dirty_log(struct kvm *kvm,
162 struct kvm_memory_slot *memslot);
Alexander Graf4e3420252009-10-30 05:47:05 +0000163
Paul Mackerras02143942011-07-23 17:41:44 +1000164extern void kvmppc_entry_trampoline(void);
Paul Mackerrasde56a942011-06-29 00:21:34 +0000165extern void kvmppc_hv_entry_trampoline(void);
Alexander Grafd5e52812010-01-15 14:49:10 +0100166extern void kvmppc_load_up_fpu(void);
167extern void kvmppc_load_up_altivec(void);
168extern void kvmppc_load_up_vsx(void);
Alexander Grafca7f4202010-03-24 21:48:28 +0100169extern u32 kvmppc_alignment_dsisr(struct kvm_vcpu *vcpu, unsigned int inst);
170extern ulong kvmppc_alignment_dar(struct kvm_vcpu *vcpu, unsigned int inst);
Alexander Graf0254f0742011-08-08 17:21:15 +0200171extern int kvmppc_h_pr(struct kvm_vcpu *vcpu, unsigned long cmd);
Alexander Graf4e3420252009-10-30 05:47:05 +0000172
173static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
174{
175 return container_of(vcpu, struct kvmppc_vcpu_book3s, vcpu);
176}
177
Paul Mackerrasde56a942011-06-29 00:21:34 +0000178extern void kvm_return_point(void);
179
180/* Also add subarch specific defines */
181
182#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
183#include <asm/kvm_book3s_32.h>
184#endif
185#ifdef CONFIG_KVM_BOOK3S_64_HANDLER
186#include <asm/kvm_book3s_64.h>
187#endif
188
189#ifdef CONFIG_KVM_BOOK3S_PR
190
Paul Mackerrasf05ed4d2011-06-29 00:17:58 +0000191static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu)
192{
193 return to_book3s(vcpu)->hior;
194}
195
196static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu,
197 unsigned long pending_now, unsigned long old_pending)
198{
199 if (pending_now)
200 vcpu->arch.shared->int_pending = 1;
201 else if (old_pending)
202 vcpu->arch.shared->int_pending = 0;
203}
204
Alexander Grafc7f38f42010-04-16 00:11:40 +0200205static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
206{
207 if ( num < 14 ) {
Alexander Graf468a12c2011-12-09 14:44:13 +0100208 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
209 svcpu->gpr[num] = val;
210 svcpu_put(svcpu);
Alexander Grafc7f38f42010-04-16 00:11:40 +0200211 to_book3s(vcpu)->shadow_vcpu->gpr[num] = val;
212 } else
213 vcpu->arch.gpr[num] = val;
214}
215
216static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
217{
Alexander Graf468a12c2011-12-09 14:44:13 +0100218 if ( num < 14 ) {
219 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
220 ulong r = svcpu->gpr[num];
221 svcpu_put(svcpu);
222 return r;
223 } else
Alexander Grafc7f38f42010-04-16 00:11:40 +0200224 return vcpu->arch.gpr[num];
225}
226
227static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
228{
Alexander Graf468a12c2011-12-09 14:44:13 +0100229 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
230 svcpu->cr = val;
231 svcpu_put(svcpu);
Alexander Grafc7f38f42010-04-16 00:11:40 +0200232 to_book3s(vcpu)->shadow_vcpu->cr = val;
233}
234
235static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
236{
Alexander Graf468a12c2011-12-09 14:44:13 +0100237 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
238 u32 r;
239 r = svcpu->cr;
240 svcpu_put(svcpu);
241 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200242}
243
244static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
245{
Alexander Graf468a12c2011-12-09 14:44:13 +0100246 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
247 svcpu->xer = val;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200248 to_book3s(vcpu)->shadow_vcpu->xer = val;
Alexander Graf468a12c2011-12-09 14:44:13 +0100249 svcpu_put(svcpu);
Alexander Grafc7f38f42010-04-16 00:11:40 +0200250}
251
252static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
253{
Alexander Graf468a12c2011-12-09 14:44:13 +0100254 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
255 u32 r;
256 r = svcpu->xer;
257 svcpu_put(svcpu);
258 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200259}
260
261static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
262{
Alexander Graf468a12c2011-12-09 14:44:13 +0100263 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
264 svcpu->ctr = val;
265 svcpu_put(svcpu);
Alexander Grafc7f38f42010-04-16 00:11:40 +0200266}
267
268static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
269{
Alexander Graf468a12c2011-12-09 14:44:13 +0100270 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
271 ulong r;
272 r = svcpu->ctr;
273 svcpu_put(svcpu);
274 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200275}
276
277static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
278{
Alexander Graf468a12c2011-12-09 14:44:13 +0100279 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
280 svcpu->lr = val;
281 svcpu_put(svcpu);
Alexander Grafc7f38f42010-04-16 00:11:40 +0200282}
283
284static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
285{
Alexander Graf468a12c2011-12-09 14:44:13 +0100286 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
287 ulong r;
288 r = svcpu->lr;
289 svcpu_put(svcpu);
290 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200291}
292
293static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
294{
Alexander Graf468a12c2011-12-09 14:44:13 +0100295 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
296 svcpu->pc = val;
297 svcpu_put(svcpu);
Alexander Grafc7f38f42010-04-16 00:11:40 +0200298}
299
300static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
301{
Alexander Graf468a12c2011-12-09 14:44:13 +0100302 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
303 ulong r;
304 r = svcpu->pc;
305 svcpu_put(svcpu);
306 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200307}
308
309static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
310{
311 ulong pc = kvmppc_get_pc(vcpu);
Alexander Graf468a12c2011-12-09 14:44:13 +0100312 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
313 u32 r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200314
315 /* Load the instruction manually if it failed to do so in the
316 * exit path */
317 if (svcpu->last_inst == KVM_INST_FETCH_FAILED)
318 kvmppc_ld(vcpu, &pc, sizeof(u32), &svcpu->last_inst, false);
319
Alexander Graf468a12c2011-12-09 14:44:13 +0100320 r = svcpu->last_inst;
321 svcpu_put(svcpu);
322 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200323}
324
325static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
326{
Alexander Graf468a12c2011-12-09 14:44:13 +0100327 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
328 ulong r;
329 r = svcpu->fault_dar;
330 svcpu_put(svcpu);
331 return r;
Alexander Grafc7f38f42010-04-16 00:11:40 +0200332}
Alexander Graf4e3420252009-10-30 05:47:05 +0000333
Paul Mackerrasf05ed4d2011-06-29 00:17:58 +0000334static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu)
335{
336 ulong crit_raw = vcpu->arch.shared->critical;
337 ulong crit_r1 = kvmppc_get_gpr(vcpu, 1);
338 bool crit;
339
340 /* Truncate crit indicators in 32 bit mode */
341 if (!(vcpu->arch.shared->msr & MSR_SF)) {
342 crit_raw &= 0xffffffff;
343 crit_r1 &= 0xffffffff;
344 }
345
346 /* Critical section when crit == r1 */
347 crit = (crit_raw == crit_r1);
348 /* ... and we're in supervisor mode */
349 crit = crit && !(vcpu->arch.shared->msr & MSR_PR);
350
351 return crit;
352}
Paul Mackerrasde56a942011-06-29 00:21:34 +0000353#else /* CONFIG_KVM_BOOK3S_PR */
354
355static inline unsigned long kvmppc_interrupt_offset(struct kvm_vcpu *vcpu)
356{
357 return 0;
358}
359
360static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu,
361 unsigned long pending_now, unsigned long old_pending)
362{
Paul Mackerrasde56a942011-06-29 00:21:34 +0000363}
364
365static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
366{
367 vcpu->arch.gpr[num] = val;
368}
369
370static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
371{
372 return vcpu->arch.gpr[num];
373}
374
375static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
376{
377 vcpu->arch.cr = val;
378}
379
380static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
381{
382 return vcpu->arch.cr;
383}
384
385static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
386{
387 vcpu->arch.xer = val;
388}
389
390static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
391{
392 return vcpu->arch.xer;
393}
394
395static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
396{
397 vcpu->arch.ctr = val;
398}
399
400static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
401{
402 return vcpu->arch.ctr;
403}
404
405static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
406{
407 vcpu->arch.lr = val;
408}
409
410static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
411{
412 return vcpu->arch.lr;
413}
414
415static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
416{
417 vcpu->arch.pc = val;
418}
419
420static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
421{
422 return vcpu->arch.pc;
423}
424
425static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
426{
427 ulong pc = kvmppc_get_pc(vcpu);
428
429 /* Load the instruction manually if it failed to do so in the
430 * exit path */
431 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED)
432 kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false);
433
434 return vcpu->arch.last_inst;
435}
436
437static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
438{
439 return vcpu->arch.fault_dar;
440}
441
442static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu)
443{
444 return false;
445}
446#endif
Paul Mackerrasf05ed4d2011-06-29 00:17:58 +0000447
Alexander Grafad0a0482010-03-24 21:48:30 +0100448/* Magic register values loaded into r3 and r4 before the 'sc' assembly
449 * instruction for the OSI hypercalls */
450#define OSI_SC_MAGIC_R3 0x113724FA
451#define OSI_SC_MAGIC_R4 0x77810F9B
452
Alexander Graf4e3420252009-10-30 05:47:05 +0000453#define INS_DCBZ 0x7c0007ec
454
Alexander Graf4e3420252009-10-30 05:47:05 +0000455#endif /* __ASM_KVM_BOOK3S_H__ */