diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2014-12-18 03:39:55 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2014-12-18 03:39:55 -0500 |
commit | 2c4aa55a6af070262cca425745e8e54310e96b8d (patch) | |
tree | 6914c74c305ccffc6603d1e984f6f616e0720d5d | |
parent | cb5281a57214581902ac06fb83f0d6ea2d440318 (diff) | |
parent | 476ce5ef09b21a76e74d07ff9d723ba0de49b53b (diff) |
Merge tag 'signed-kvm-ppc-next' of git://github.com/agraf/linux-2.6 into HEAD
Patch queue for ppc - 2014-12-18
Highights this time around:
- Removal of HV support for 970. It became a maintenance burden and received
practically no testing. POWER8 with HV is available now, so just grab one
of those boxes if PR isn't enough for you.
- Some bug fixes and performance improvements
- Tracepoints for book3s_hv
26 files changed, 870 insertions, 1093 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h index 6acf0c2a0f99..942c7b1678e3 100644 --- a/arch/powerpc/include/asm/kvm_book3s.h +++ b/arch/powerpc/include/asm/kvm_book3s.h | |||
@@ -170,8 +170,6 @@ extern void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long addr, | |||
170 | unsigned long *nb_ret); | 170 | unsigned long *nb_ret); |
171 | extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr, | 171 | extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr, |
172 | unsigned long gpa, bool dirty); | 172 | unsigned long gpa, bool dirty); |
173 | extern long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, | ||
174 | long pte_index, unsigned long pteh, unsigned long ptel); | ||
175 | extern long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | 173 | extern long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, |
176 | long pte_index, unsigned long pteh, unsigned long ptel, | 174 | long pte_index, unsigned long pteh, unsigned long ptel, |
177 | pgd_t *pgdir, bool realmode, unsigned long *idx_ret); | 175 | pgd_t *pgdir, bool realmode, unsigned long *idx_ret); |
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h index 0aa817933e6a..2d81e202bdcc 100644 --- a/arch/powerpc/include/asm/kvm_book3s_64.h +++ b/arch/powerpc/include/asm/kvm_book3s_64.h | |||
@@ -37,7 +37,6 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu) | |||
37 | 37 | ||
38 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | 38 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
39 | #define KVM_DEFAULT_HPT_ORDER 24 /* 16MB HPT by default */ | 39 | #define KVM_DEFAULT_HPT_ORDER 24 /* 16MB HPT by default */ |
40 | extern unsigned long kvm_rma_pages; | ||
41 | #endif | 40 | #endif |
42 | 41 | ||
43 | #define VRMA_VSID 0x1ffffffUL /* 1TB VSID reserved for VRMA */ | 42 | #define VRMA_VSID 0x1ffffffUL /* 1TB VSID reserved for VRMA */ |
@@ -148,7 +147,7 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, | |||
148 | /* This covers 14..54 bits of va*/ | 147 | /* This covers 14..54 bits of va*/ |
149 | rb = (v & ~0x7fUL) << 16; /* AVA field */ | 148 | rb = (v & ~0x7fUL) << 16; /* AVA field */ |
150 | 149 | ||
151 | rb |= v >> (62 - 8); /* B field */ | 150 | rb |= (v >> HPTE_V_SSIZE_SHIFT) << 8; /* B field */ |
152 | /* | 151 | /* |
153 | * AVA in v had cleared lower 23 bits. We need to derive | 152 | * AVA in v had cleared lower 23 bits. We need to derive |
154 | * that from pteg index | 153 | * that from pteg index |
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 047855619cc4..7efd666a3fa7 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h | |||
@@ -180,11 +180,6 @@ struct kvmppc_spapr_tce_table { | |||
180 | struct page *pages[0]; | 180 | struct page *pages[0]; |
181 | }; | 181 | }; |
182 | 182 | ||
183 | struct kvm_rma_info { | ||
184 | atomic_t use_count; | ||
185 | unsigned long base_pfn; | ||
186 | }; | ||
187 | |||
188 | /* XICS components, defined in book3s_xics.c */ | 183 | /* XICS components, defined in book3s_xics.c */ |
189 | struct kvmppc_xics; | 184 | struct kvmppc_xics; |
190 | struct kvmppc_icp; | 185 | struct kvmppc_icp; |
@@ -214,16 +209,9 @@ struct revmap_entry { | |||
214 | #define KVMPPC_RMAP_PRESENT 0x100000000ul | 209 | #define KVMPPC_RMAP_PRESENT 0x100000000ul |
215 | #define KVMPPC_RMAP_INDEX 0xfffffffful | 210 | #define KVMPPC_RMAP_INDEX 0xfffffffful |
216 | 211 | ||
217 | /* Low-order bits in memslot->arch.slot_phys[] */ | ||
218 | #define KVMPPC_PAGE_ORDER_MASK 0x1f | ||
219 | #define KVMPPC_PAGE_NO_CACHE HPTE_R_I /* 0x20 */ | ||
220 | #define KVMPPC_PAGE_WRITETHRU HPTE_R_W /* 0x40 */ | ||
221 | #define KVMPPC_GOT_PAGE 0x80 | ||
222 | |||
223 | struct kvm_arch_memory_slot { | 212 | struct kvm_arch_memory_slot { |
224 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | 213 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
225 | unsigned long *rmap; | 214 | unsigned long *rmap; |
226 | unsigned long *slot_phys; | ||
227 | #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ | 215 | #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ |
228 | }; | 216 | }; |
229 | 217 | ||
@@ -242,14 +230,12 @@ struct kvm_arch { | |||
242 | struct kvm_rma_info *rma; | 230 | struct kvm_rma_info *rma; |
243 | unsigned long vrma_slb_v; | 231 | unsigned long vrma_slb_v; |
244 | int rma_setup_done; | 232 | int rma_setup_done; |
245 | int using_mmu_notifiers; | ||
246 | u32 hpt_order; | 233 | u32 hpt_order; |
247 | atomic_t vcpus_running; | 234 | atomic_t vcpus_running; |
248 | u32 online_vcores; | 235 | u32 online_vcores; |
249 | unsigned long hpt_npte; | 236 | unsigned long hpt_npte; |
250 | unsigned long hpt_mask; | 237 | unsigned long hpt_mask; |
251 | atomic_t hpte_mod_interest; | 238 | atomic_t hpte_mod_interest; |
252 | spinlock_t slot_phys_lock; | ||
253 | cpumask_t need_tlb_flush; | 239 | cpumask_t need_tlb_flush; |
254 | int hpt_cma_alloc; | 240 | int hpt_cma_alloc; |
255 | #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ | 241 | #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ |
@@ -297,6 +283,7 @@ struct kvmppc_vcore { | |||
297 | struct list_head runnable_threads; | 283 | struct list_head runnable_threads; |
298 | spinlock_t lock; | 284 | spinlock_t lock; |
299 | wait_queue_head_t wq; | 285 | wait_queue_head_t wq; |
286 | spinlock_t stoltb_lock; /* protects stolen_tb and preempt_tb */ | ||
300 | u64 stolen_tb; | 287 | u64 stolen_tb; |
301 | u64 preempt_tb; | 288 | u64 preempt_tb; |
302 | struct kvm_vcpu *runner; | 289 | struct kvm_vcpu *runner; |
@@ -308,6 +295,7 @@ struct kvmppc_vcore { | |||
308 | ulong dpdes; /* doorbell state (POWER8) */ | 295 | ulong dpdes; /* doorbell state (POWER8) */ |
309 | void *mpp_buffer; /* Micro Partition Prefetch buffer */ | 296 | void *mpp_buffer; /* Micro Partition Prefetch buffer */ |
310 | bool mpp_buffer_is_valid; | 297 | bool mpp_buffer_is_valid; |
298 | ulong conferring_threads; | ||
311 | }; | 299 | }; |
312 | 300 | ||
313 | #define VCORE_ENTRY_COUNT(vc) ((vc)->entry_exit_count & 0xff) | 301 | #define VCORE_ENTRY_COUNT(vc) ((vc)->entry_exit_count & 0xff) |
@@ -664,6 +652,8 @@ struct kvm_vcpu_arch { | |||
664 | spinlock_t tbacct_lock; | 652 | spinlock_t tbacct_lock; |
665 | u64 busy_stolen; | 653 | u64 busy_stolen; |
666 | u64 busy_preempt; | 654 | u64 busy_preempt; |
655 | |||
656 | u32 emul_inst; | ||
667 | #endif | 657 | #endif |
668 | }; | 658 | }; |
669 | 659 | ||
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index a6dcdb6d13c1..46bf652c9169 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h | |||
@@ -170,8 +170,6 @@ extern long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn, | |||
170 | unsigned long ioba, unsigned long tce); | 170 | unsigned long ioba, unsigned long tce); |
171 | extern long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn, | 171 | extern long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn, |
172 | unsigned long ioba); | 172 | unsigned long ioba); |
173 | extern struct kvm_rma_info *kvm_alloc_rma(void); | ||
174 | extern void kvm_release_rma(struct kvm_rma_info *ri); | ||
175 | extern struct page *kvm_alloc_hpt(unsigned long nr_pages); | 173 | extern struct page *kvm_alloc_hpt(unsigned long nr_pages); |
176 | extern void kvm_release_hpt(struct page *page, unsigned long nr_pages); | 174 | extern void kvm_release_hpt(struct page *page, unsigned long nr_pages); |
177 | extern int kvmppc_core_init_vm(struct kvm *kvm); | 175 | extern int kvmppc_core_init_vm(struct kvm *kvm); |
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index 9d7dede2847c..b14716bbb7b5 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c | |||
@@ -489,7 +489,6 @@ int main(void) | |||
489 | DEFINE(KVM_HOST_LPID, offsetof(struct kvm, arch.host_lpid)); | 489 | DEFINE(KVM_HOST_LPID, offsetof(struct kvm, arch.host_lpid)); |
490 | DEFINE(KVM_HOST_LPCR, offsetof(struct kvm, arch.host_lpcr)); | 490 | DEFINE(KVM_HOST_LPCR, offsetof(struct kvm, arch.host_lpcr)); |
491 | DEFINE(KVM_HOST_SDR1, offsetof(struct kvm, arch.host_sdr1)); | 491 | DEFINE(KVM_HOST_SDR1, offsetof(struct kvm, arch.host_sdr1)); |
492 | DEFINE(KVM_TLBIE_LOCK, offsetof(struct kvm, arch.tlbie_lock)); | ||
493 | DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits)); | 492 | DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits)); |
494 | DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls)); | 493 | DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls)); |
495 | DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); | 494 | DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); |
@@ -499,6 +498,7 @@ int main(void) | |||
499 | DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); | 498 | DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); |
500 | DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa.pinned_addr)); | 499 | DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa.pinned_addr)); |
501 | DEFINE(VCPU_VPA_DIRTY, offsetof(struct kvm_vcpu, arch.vpa.dirty)); | 500 | DEFINE(VCPU_VPA_DIRTY, offsetof(struct kvm_vcpu, arch.vpa.dirty)); |
501 | DEFINE(VCPU_HEIR, offsetof(struct kvm_vcpu, arch.emul_inst)); | ||
502 | #endif | 502 | #endif |
503 | #ifdef CONFIG_PPC_BOOK3S | 503 | #ifdef CONFIG_PPC_BOOK3S |
504 | DEFINE(VCPU_VCPUID, offsetof(struct kvm_vcpu, vcpu_id)); | 504 | DEFINE(VCPU_VCPUID, offsetof(struct kvm_vcpu, vcpu_id)); |
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig index 602eb51d20bc..f5769f19ae25 100644 --- a/arch/powerpc/kvm/Kconfig +++ b/arch/powerpc/kvm/Kconfig | |||
@@ -172,6 +172,7 @@ config KVM_XICS | |||
172 | depends on KVM_BOOK3S_64 && !KVM_MPIC | 172 | depends on KVM_BOOK3S_64 && !KVM_MPIC |
173 | select HAVE_KVM_IRQCHIP | 173 | select HAVE_KVM_IRQCHIP |
174 | select HAVE_KVM_IRQFD | 174 | select HAVE_KVM_IRQFD |
175 | default y | ||
175 | ---help--- | 176 | ---help--- |
176 | Include support for the XICS (eXternal Interrupt Controller | 177 | Include support for the XICS (eXternal Interrupt Controller |
177 | Specification) interrupt controller architecture used on | 178 | Specification) interrupt controller architecture used on |
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index b32db4b95361..888bf466d8c6 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -64,14 +64,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { | |||
64 | { NULL } | 64 | { NULL } |
65 | }; | 65 | }; |
66 | 66 | ||
67 | void kvmppc_core_load_host_debugstate(struct kvm_vcpu *vcpu) | ||
68 | { | ||
69 | } | ||
70 | |||
71 | void kvmppc_core_load_guest_debugstate(struct kvm_vcpu *vcpu) | ||
72 | { | ||
73 | } | ||
74 | |||
75 | void kvmppc_unfixup_split_real(struct kvm_vcpu *vcpu) | 67 | void kvmppc_unfixup_split_real(struct kvm_vcpu *vcpu) |
76 | { | 68 | { |
77 | if (vcpu->arch.hflags & BOOK3S_HFLAG_SPLIT_HACK) { | 69 | if (vcpu->arch.hflags & BOOK3S_HFLAG_SPLIT_HACK) { |
diff --git a/arch/powerpc/kvm/book3s_32_mmu.c b/arch/powerpc/kvm/book3s_32_mmu.c index cd0b0730e29e..a2eb6d354a57 100644 --- a/arch/powerpc/kvm/book3s_32_mmu.c +++ b/arch/powerpc/kvm/book3s_32_mmu.c | |||
@@ -78,11 +78,6 @@ static inline bool sr_kp(u32 sr_raw) | |||
78 | return (sr_raw & 0x20000000) ? true: false; | 78 | return (sr_raw & 0x20000000) ? true: false; |
79 | } | 79 | } |
80 | 80 | ||
81 | static inline bool sr_nx(u32 sr_raw) | ||
82 | { | ||
83 | return (sr_raw & 0x10000000) ? true: false; | ||
84 | } | ||
85 | |||
86 | static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr, | 81 | static int kvmppc_mmu_book3s_32_xlate_bat(struct kvm_vcpu *vcpu, gva_t eaddr, |
87 | struct kvmppc_pte *pte, bool data, | 82 | struct kvmppc_pte *pte, bool data, |
88 | bool iswrite); | 83 | bool iswrite); |
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index d40770248b6a..534acb3c6c3d 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c | |||
@@ -37,8 +37,7 @@ | |||
37 | #include <asm/ppc-opcode.h> | 37 | #include <asm/ppc-opcode.h> |
38 | #include <asm/cputable.h> | 38 | #include <asm/cputable.h> |
39 | 39 | ||
40 | /* POWER7 has 10-bit LPIDs, PPC970 has 6-bit LPIDs */ | 40 | #include "trace_hv.h" |
41 | #define MAX_LPID_970 63 | ||
42 | 41 | ||
43 | /* Power architecture requires HPT is at least 256kB */ | 42 | /* Power architecture requires HPT is at least 256kB */ |
44 | #define PPC_MIN_HPT_ORDER 18 | 43 | #define PPC_MIN_HPT_ORDER 18 |
@@ -229,14 +228,9 @@ int kvmppc_mmu_hv_init(void) | |||
229 | if (!cpu_has_feature(CPU_FTR_HVMODE)) | 228 | if (!cpu_has_feature(CPU_FTR_HVMODE)) |
230 | return -EINVAL; | 229 | return -EINVAL; |
231 | 230 | ||
232 | /* POWER7 has 10-bit LPIDs, PPC970 and e500mc have 6-bit LPIDs */ | 231 | /* POWER7 has 10-bit LPIDs (12-bit in POWER8) */ |
233 | if (cpu_has_feature(CPU_FTR_ARCH_206)) { | 232 | host_lpid = mfspr(SPRN_LPID); |
234 | host_lpid = mfspr(SPRN_LPID); /* POWER7 */ | 233 | rsvd_lpid = LPID_RSVD; |
235 | rsvd_lpid = LPID_RSVD; | ||
236 | } else { | ||
237 | host_lpid = 0; /* PPC970 */ | ||
238 | rsvd_lpid = MAX_LPID_970; | ||
239 | } | ||
240 | 234 | ||
241 | kvmppc_init_lpid(rsvd_lpid + 1); | 235 | kvmppc_init_lpid(rsvd_lpid + 1); |
242 | 236 | ||
@@ -259,130 +253,12 @@ static void kvmppc_mmu_book3s_64_hv_reset_msr(struct kvm_vcpu *vcpu) | |||
259 | kvmppc_set_msr(vcpu, msr); | 253 | kvmppc_set_msr(vcpu, msr); |
260 | } | 254 | } |
261 | 255 | ||
262 | /* | ||
263 | * This is called to get a reference to a guest page if there isn't | ||
264 | * one already in the memslot->arch.slot_phys[] array. | ||
265 | */ | ||
266 | static long kvmppc_get_guest_page(struct kvm *kvm, unsigned long gfn, | ||
267 | struct kvm_memory_slot *memslot, | ||
268 | unsigned long psize) | ||
269 | { | ||
270 | unsigned long start; | ||
271 | long np, err; | ||
272 | struct page *page, *hpage, *pages[1]; | ||
273 | unsigned long s, pgsize; | ||
274 | unsigned long *physp; | ||
275 | unsigned int is_io, got, pgorder; | ||
276 | struct vm_area_struct *vma; | ||
277 | unsigned long pfn, i, npages; | ||
278 | |||
279 | physp = memslot->arch.slot_phys; | ||
280 | if (!physp) | ||
281 | return -EINVAL; | ||
282 | if (physp[gfn - memslot->base_gfn]) | ||
283 | return 0; | ||
284 | |||
285 | is_io = 0; | ||
286 | got = 0; | ||
287 | page = NULL; | ||
288 | pgsize = psize; | ||
289 | err = -EINVAL; | ||
290 | start = gfn_to_hva_memslot(memslot, gfn); | ||
291 | |||
292 | /* Instantiate and get the page we want access to */ | ||
293 | np = get_user_pages_fast(start, 1, 1, pages); | ||
294 | if (np != 1) { | ||
295 | /* Look up the vma for the page */ | ||
296 | down_read(¤t->mm->mmap_sem); | ||
297 | vma = find_vma(current->mm, start); | ||
298 | if (!vma || vma->vm_start > start || | ||
299 | start + psize > vma->vm_end || | ||
300 | !(vma->vm_flags & VM_PFNMAP)) | ||
301 | goto up_err; | ||
302 | is_io = hpte_cache_bits(pgprot_val(vma->vm_page_prot)); | ||
303 | pfn = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT); | ||
304 | /* check alignment of pfn vs. requested page size */ | ||
305 | if (psize > PAGE_SIZE && (pfn & ((psize >> PAGE_SHIFT) - 1))) | ||
306 | goto up_err; | ||
307 | up_read(¤t->mm->mmap_sem); | ||
308 | |||
309 | } else { | ||
310 | page = pages[0]; | ||
311 | got = KVMPPC_GOT_PAGE; | ||
312 | |||
313 | /* See if this is a large page */ | ||
314 | s = PAGE_SIZE; | ||
315 | if (PageHuge(page)) { | ||
316 | hpage = compound_head(page); | ||
317 | s <<= compound_order(hpage); | ||
318 | /* Get the whole large page if slot alignment is ok */ | ||
319 | if (s > psize && slot_is_aligned(memslot, s) && | ||
320 | !(memslot->userspace_addr & (s - 1))) { | ||
321 | start &= ~(s - 1); | ||
322 | pgsize = s; | ||
323 | get_page(hpage); | ||
324 | put_page(page); | ||
325 | page = hpage; | ||
326 | } | ||
327 | } | ||
328 | if (s < psize) | ||
329 | goto out; | ||
330 | pfn = page_to_pfn(page); | ||
331 | } | ||
332 | |||
333 | npages = pgsize >> PAGE_SHIFT; | ||
334 | pgorder = __ilog2(npages); | ||
335 | physp += (gfn - memslot->base_gfn) & ~(npages - 1); | ||
336 | spin_lock(&kvm->arch.slot_phys_lock); | ||
337 | for (i = 0; i < npages; ++i) { | ||
338 | if (!physp[i]) { | ||
339 | physp[i] = ((pfn + i) << PAGE_SHIFT) + | ||
340 | got + is_io + pgorder; | ||
341 | got = 0; | ||
342 | } | ||
343 | } | ||
344 | spin_unlock(&kvm->arch.slot_phys_lock); | ||
345 | err = 0; | ||
346 | |||
347 | out: | ||
348 | if (got) | ||
349 | put_page(page); | ||
350 | return err; | ||
351 | |||
352 | up_err: | ||
353 | up_read(¤t->mm->mmap_sem); | ||
354 | return err; | ||
355 | } | ||
356 | |||
357 | long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags, | 256 | long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags, |
358 | long pte_index, unsigned long pteh, | 257 | long pte_index, unsigned long pteh, |
359 | unsigned long ptel, unsigned long *pte_idx_ret) | 258 | unsigned long ptel, unsigned long *pte_idx_ret) |
360 | { | 259 | { |
361 | unsigned long psize, gpa, gfn; | ||
362 | struct kvm_memory_slot *memslot; | ||
363 | long ret; | 260 | long ret; |
364 | 261 | ||
365 | if (kvm->arch.using_mmu_notifiers) | ||
366 | goto do_insert; | ||
367 | |||
368 | psize = hpte_page_size(pteh, ptel); | ||
369 | if (!psize) | ||
370 | return H_PARAMETER; | ||
371 | |||
372 | pteh &= ~(HPTE_V_HVLOCK | HPTE_V_ABSENT | HPTE_V_VALID); | ||
373 | |||
374 | /* Find the memslot (if any) for this address */ | ||
375 | gpa = (ptel & HPTE_R_RPN) & ~(psize - 1); | ||
376 | gfn = gpa >> PAGE_SHIFT; | ||
377 | memslot = gfn_to_memslot(kvm, gfn); | ||
378 | if (memslot && !(memslot->flags & KVM_MEMSLOT_INVALID)) { | ||
379 | if (!slot_is_aligned(memslot, psize)) | ||
380 | return H_PARAMETER; | ||
381 | if (kvmppc_get_guest_page(kvm, gfn, memslot, psize) < 0) | ||
382 | return H_PARAMETER; | ||
383 | } | ||
384 | |||
385 | do_insert: | ||
386 | /* Protect linux PTE lookup from page table destruction */ | 262 | /* Protect linux PTE lookup from page table destruction */ |
387 | rcu_read_lock_sched(); /* this disables preemption too */ | 263 | rcu_read_lock_sched(); /* this disables preemption too */ |
388 | ret = kvmppc_do_h_enter(kvm, flags, pte_index, pteh, ptel, | 264 | ret = kvmppc_do_h_enter(kvm, flags, pte_index, pteh, ptel, |
@@ -397,19 +273,6 @@ long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
397 | 273 | ||
398 | } | 274 | } |
399 | 275 | ||
400 | /* | ||
401 | * We come here on a H_ENTER call from the guest when we are not | ||
402 | * using mmu notifiers and we don't have the requested page pinned | ||
403 | * already. | ||
404 | */ | ||
405 | long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, | ||
406 | long pte_index, unsigned long pteh, | ||
407 | unsigned long ptel) | ||
408 | { | ||
409 | return kvmppc_virtmode_do_h_enter(vcpu->kvm, flags, pte_index, | ||
410 | pteh, ptel, &vcpu->arch.gpr[4]); | ||
411 | } | ||
412 | |||
413 | static struct kvmppc_slb *kvmppc_mmu_book3s_hv_find_slbe(struct kvm_vcpu *vcpu, | 276 | static struct kvmppc_slb *kvmppc_mmu_book3s_hv_find_slbe(struct kvm_vcpu *vcpu, |
414 | gva_t eaddr) | 277 | gva_t eaddr) |
415 | { | 278 | { |
@@ -494,7 +357,7 @@ static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr, | |||
494 | gpte->may_execute = gpte->may_read && !(gr & (HPTE_R_N | HPTE_R_G)); | 357 | gpte->may_execute = gpte->may_read && !(gr & (HPTE_R_N | HPTE_R_G)); |
495 | 358 | ||
496 | /* Storage key permission check for POWER7 */ | 359 | /* Storage key permission check for POWER7 */ |
497 | if (data && virtmode && cpu_has_feature(CPU_FTR_ARCH_206)) { | 360 | if (data && virtmode) { |
498 | int amrfield = hpte_get_skey_perm(gr, vcpu->arch.amr); | 361 | int amrfield = hpte_get_skey_perm(gr, vcpu->arch.amr); |
499 | if (amrfield & 1) | 362 | if (amrfield & 1) |
500 | gpte->may_read = 0; | 363 | gpte->may_read = 0; |
@@ -622,14 +485,13 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
622 | gfn = gpa >> PAGE_SHIFT; | 485 | gfn = gpa >> PAGE_SHIFT; |
623 | memslot = gfn_to_memslot(kvm, gfn); | 486 | memslot = gfn_to_memslot(kvm, gfn); |
624 | 487 | ||
488 | trace_kvm_page_fault_enter(vcpu, hpte, memslot, ea, dsisr); | ||
489 | |||
625 | /* No memslot means it's an emulated MMIO region */ | 490 | /* No memslot means it's an emulated MMIO region */ |
626 | if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) | 491 | if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) |
627 | return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea, | 492 | return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea, |
628 | dsisr & DSISR_ISSTORE); | 493 | dsisr & DSISR_ISSTORE); |
629 | 494 | ||
630 | if (!kvm->arch.using_mmu_notifiers) | ||
631 | return -EFAULT; /* should never get here */ | ||
632 | |||
633 | /* | 495 | /* |
634 | * This should never happen, because of the slot_is_aligned() | 496 | * This should never happen, because of the slot_is_aligned() |
635 | * check in kvmppc_do_h_enter(). | 497 | * check in kvmppc_do_h_enter(). |
@@ -641,6 +503,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
641 | mmu_seq = kvm->mmu_notifier_seq; | 503 | mmu_seq = kvm->mmu_notifier_seq; |
642 | smp_rmb(); | 504 | smp_rmb(); |
643 | 505 | ||
506 | ret = -EFAULT; | ||
644 | is_io = 0; | 507 | is_io = 0; |
645 | pfn = 0; | 508 | pfn = 0; |
646 | page = NULL; | 509 | page = NULL; |
@@ -664,7 +527,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
664 | } | 527 | } |
665 | up_read(¤t->mm->mmap_sem); | 528 | up_read(¤t->mm->mmap_sem); |
666 | if (!pfn) | 529 | if (!pfn) |
667 | return -EFAULT; | 530 | goto out_put; |
668 | } else { | 531 | } else { |
669 | page = pages[0]; | 532 | page = pages[0]; |
670 | pfn = page_to_pfn(page); | 533 | pfn = page_to_pfn(page); |
@@ -694,14 +557,14 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
694 | } | 557 | } |
695 | } | 558 | } |
696 | 559 | ||
697 | ret = -EFAULT; | ||
698 | if (psize > pte_size) | 560 | if (psize > pte_size) |
699 | goto out_put; | 561 | goto out_put; |
700 | 562 | ||
701 | /* Check WIMG vs. the actual page we're accessing */ | 563 | /* Check WIMG vs. the actual page we're accessing */ |
702 | if (!hpte_cache_flags_ok(r, is_io)) { | 564 | if (!hpte_cache_flags_ok(r, is_io)) { |
703 | if (is_io) | 565 | if (is_io) |
704 | return -EFAULT; | 566 | goto out_put; |
567 | |||
705 | /* | 568 | /* |
706 | * Allow guest to map emulated device memory as | 569 | * Allow guest to map emulated device memory as |
707 | * uncacheable, but actually make it cacheable. | 570 | * uncacheable, but actually make it cacheable. |
@@ -765,6 +628,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
765 | SetPageDirty(page); | 628 | SetPageDirty(page); |
766 | 629 | ||
767 | out_put: | 630 | out_put: |
631 | trace_kvm_page_fault_exit(vcpu, hpte, ret); | ||
632 | |||
768 | if (page) { | 633 | if (page) { |
769 | /* | 634 | /* |
770 | * We drop pages[0] here, not page because page might | 635 | * We drop pages[0] here, not page because page might |
@@ -895,8 +760,7 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, | |||
895 | psize = hpte_page_size(be64_to_cpu(hptep[0]), ptel); | 760 | psize = hpte_page_size(be64_to_cpu(hptep[0]), ptel); |
896 | if ((be64_to_cpu(hptep[0]) & HPTE_V_VALID) && | 761 | if ((be64_to_cpu(hptep[0]) & HPTE_V_VALID) && |
897 | hpte_rpn(ptel, psize) == gfn) { | 762 | hpte_rpn(ptel, psize) == gfn) { |
898 | if (kvm->arch.using_mmu_notifiers) | 763 | hptep[0] |= cpu_to_be64(HPTE_V_ABSENT); |
899 | hptep[0] |= cpu_to_be64(HPTE_V_ABSENT); | ||
900 | kvmppc_invalidate_hpte(kvm, hptep, i); | 764 | kvmppc_invalidate_hpte(kvm, hptep, i); |
901 | /* Harvest R and C */ | 765 | /* Harvest R and C */ |
902 | rcbits = be64_to_cpu(hptep[1]) & (HPTE_R_R | HPTE_R_C); | 766 | rcbits = be64_to_cpu(hptep[1]) & (HPTE_R_R | HPTE_R_C); |
@@ -914,15 +778,13 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, | |||
914 | 778 | ||
915 | int kvm_unmap_hva_hv(struct kvm *kvm, unsigned long hva) | 779 | int kvm_unmap_hva_hv(struct kvm *kvm, unsigned long hva) |
916 | { | 780 | { |
917 | if (kvm->arch.using_mmu_notifiers) | 781 | kvm_handle_hva(kvm, hva, kvm_unmap_rmapp); |
918 | kvm_handle_hva(kvm, hva, kvm_unmap_rmapp); | ||
919 | return 0; | 782 | return 0; |
920 | } | 783 | } |
921 | 784 | ||
922 | int kvm_unmap_hva_range_hv(struct kvm *kvm, unsigned long start, unsigned long end) | 785 | int kvm_unmap_hva_range_hv(struct kvm *kvm, unsigned long start, unsigned long end) |
923 | { | 786 | { |
924 | if (kvm->arch.using_mmu_notifiers) | 787 | kvm_handle_hva_range(kvm, start, end, kvm_unmap_rmapp); |
925 | kvm_handle_hva_range(kvm, start, end, kvm_unmap_rmapp); | ||
926 | return 0; | 788 | return 0; |
927 | } | 789 | } |
928 | 790 | ||
@@ -1004,8 +866,6 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, | |||
1004 | 866 | ||
1005 | int kvm_age_hva_hv(struct kvm *kvm, unsigned long start, unsigned long end) | 867 | int kvm_age_hva_hv(struct kvm *kvm, unsigned long start, unsigned long end) |
1006 | { | 868 | { |
1007 | if (!kvm->arch.using_mmu_notifiers) | ||
1008 | return 0; | ||
1009 | return kvm_handle_hva_range(kvm, start, end, kvm_age_rmapp); | 869 | return kvm_handle_hva_range(kvm, start, end, kvm_age_rmapp); |
1010 | } | 870 | } |
1011 | 871 | ||
@@ -1042,15 +902,11 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp, | |||
1042 | 902 | ||
1043 | int kvm_test_age_hva_hv(struct kvm *kvm, unsigned long hva) | 903 | int kvm_test_age_hva_hv(struct kvm *kvm, unsigned long hva) |
1044 | { | 904 | { |
1045 | if (!kvm->arch.using_mmu_notifiers) | ||
1046 | return 0; | ||
1047 | return kvm_handle_hva(kvm, hva, kvm_test_age_rmapp); | 905 | return kvm_handle_hva(kvm, hva, kvm_test_age_rmapp); |
1048 | } | 906 | } |
1049 | 907 | ||
1050 | void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte) | 908 | void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte) |
1051 | { | 909 | { |
1052 | if (!kvm->arch.using_mmu_notifiers) | ||
1053 | return; | ||
1054 | kvm_handle_hva(kvm, hva, kvm_unmap_rmapp); | 910 | kvm_handle_hva(kvm, hva, kvm_unmap_rmapp); |
1055 | } | 911 | } |
1056 | 912 | ||
@@ -1117,8 +973,11 @@ static int kvm_test_clear_dirty_npages(struct kvm *kvm, unsigned long *rmapp) | |||
1117 | } | 973 | } |
1118 | 974 | ||
1119 | /* Now check and modify the HPTE */ | 975 | /* Now check and modify the HPTE */ |
1120 | if (!(hptep[0] & cpu_to_be64(HPTE_V_VALID))) | 976 | if (!(hptep[0] & cpu_to_be64(HPTE_V_VALID))) { |
977 | /* unlock and continue */ | ||
978 | hptep[0] &= ~cpu_to_be64(HPTE_V_HVLOCK); | ||
1121 | continue; | 979 | continue; |
980 | } | ||
1122 | 981 | ||
1123 | /* need to make it temporarily absent so C is stable */ | 982 | /* need to make it temporarily absent so C is stable */ |
1124 | hptep[0] |= cpu_to_be64(HPTE_V_ABSENT); | 983 | hptep[0] |= cpu_to_be64(HPTE_V_ABSENT); |
@@ -1206,35 +1065,17 @@ void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long gpa, | |||
1206 | struct page *page, *pages[1]; | 1065 | struct page *page, *pages[1]; |
1207 | int npages; | 1066 | int npages; |
1208 | unsigned long hva, offset; | 1067 | unsigned long hva, offset; |
1209 | unsigned long pa; | ||
1210 | unsigned long *physp; | ||
1211 | int srcu_idx; | 1068 | int srcu_idx; |
1212 | 1069 | ||
1213 | srcu_idx = srcu_read_lock(&kvm->srcu); | 1070 | srcu_idx = srcu_read_lock(&kvm->srcu); |
1214 | memslot = gfn_to_memslot(kvm, gfn); | 1071 | memslot = gfn_to_memslot(kvm, gfn); |
1215 | if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) | 1072 | if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) |
1216 | goto err; | 1073 | goto err; |
1217 | if (!kvm->arch.using_mmu_notifiers) { | 1074 | hva = gfn_to_hva_memslot(memslot, gfn); |
1218 | physp = memslot->arch.slot_phys; | 1075 | npages = get_user_pages_fast(hva, 1, 1, pages); |
1219 | if (!physp) | 1076 | if (npages < 1) |
1220 | goto err; | 1077 | goto err; |
1221 | physp += gfn - memslot->base_gfn; | 1078 | page = pages[0]; |
1222 | pa = *physp; | ||
1223 | if (!pa) { | ||
1224 | if (kvmppc_get_guest_page(kvm, gfn, memslot, | ||
1225 | PAGE_SIZE) < 0) | ||
1226 | goto err; | ||
1227 | pa = *physp; | ||
1228 | } | ||
1229 | page = pfn_to_page(pa >> PAGE_SHIFT); | ||
1230 | get_page(page); | ||
1231 | } else { | ||
1232 | hva = gfn_to_hva_memslot(memslot, gfn); | ||
1233 | npages = get_user_pages_fast(hva, 1, 1, pages); | ||
1234 | if (npages < 1) | ||
1235 | goto err; | ||
1236 | page = pages[0]; | ||
1237 | } | ||
1238 | srcu_read_unlock(&kvm->srcu, srcu_idx); | 1079 | srcu_read_unlock(&kvm->srcu, srcu_idx); |
1239 | 1080 | ||
1240 | offset = gpa & (PAGE_SIZE - 1); | 1081 | offset = gpa & (PAGE_SIZE - 1); |
@@ -1258,7 +1099,7 @@ void kvmppc_unpin_guest_page(struct kvm *kvm, void *va, unsigned long gpa, | |||
1258 | 1099 | ||
1259 | put_page(page); | 1100 | put_page(page); |
1260 | 1101 | ||
1261 | if (!dirty || !kvm->arch.using_mmu_notifiers) | 1102 | if (!dirty) |
1262 | return; | 1103 | return; |
1263 | 1104 | ||
1264 | /* We need to mark this page dirty in the rmap chain */ | 1105 | /* We need to mark this page dirty in the rmap chain */ |
@@ -1539,9 +1380,15 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf, | |||
1539 | hptp = (__be64 *)(kvm->arch.hpt_virt + (i * HPTE_SIZE)); | 1380 | hptp = (__be64 *)(kvm->arch.hpt_virt + (i * HPTE_SIZE)); |
1540 | lbuf = (unsigned long __user *)buf; | 1381 | lbuf = (unsigned long __user *)buf; |
1541 | for (j = 0; j < hdr.n_valid; ++j) { | 1382 | for (j = 0; j < hdr.n_valid; ++j) { |
1383 | __be64 hpte_v; | ||
1384 | __be64 hpte_r; | ||
1385 | |||
1542 | err = -EFAULT; | 1386 | err = -EFAULT; |
1543 | if (__get_user(v, lbuf) || __get_user(r, lbuf + 1)) | 1387 | if (__get_user(hpte_v, lbuf) || |
1388 | __get_user(hpte_r, lbuf + 1)) | ||
1544 | goto out; | 1389 | goto out; |
1390 | v = be64_to_cpu(hpte_v); | ||
1391 | r = be64_to_cpu(hpte_r); | ||
1545 | err = -EINVAL; | 1392 | err = -EINVAL; |
1546 | if (!(v & HPTE_V_VALID)) | 1393 | if (!(v & HPTE_V_VALID)) |
1547 | goto out; | 1394 | goto out; |
@@ -1652,10 +1499,7 @@ void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu) | |||
1652 | { | 1499 | { |
1653 | struct kvmppc_mmu *mmu = &vcpu->arch.mmu; | 1500 | struct kvmppc_mmu *mmu = &vcpu->arch.mmu; |
1654 | 1501 | ||
1655 | if (cpu_has_feature(CPU_FTR_ARCH_206)) | 1502 | vcpu->arch.slb_nr = 32; /* POWER7/POWER8 */ |
1656 | vcpu->arch.slb_nr = 32; /* POWER7 */ | ||
1657 | else | ||
1658 | vcpu->arch.slb_nr = 64; | ||
1659 | 1503 | ||
1660 | mmu->xlate = kvmppc_mmu_book3s_64_hv_xlate; | 1504 | mmu->xlate = kvmppc_mmu_book3s_64_hv_xlate; |
1661 | mmu->reset_msr = kvmppc_mmu_book3s_64_hv_reset_msr; | 1505 | mmu->reset_msr = kvmppc_mmu_book3s_64_hv_reset_msr; |
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index e63587d30b70..de4018a1bc4b 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
@@ -58,6 +58,9 @@ | |||
58 | 58 | ||
59 | #include "book3s.h" | 59 | #include "book3s.h" |
60 | 60 | ||
61 | #define CREATE_TRACE_POINTS | ||
62 | #include "trace_hv.h" | ||
63 | |||
61 | /* #define EXIT_DEBUG */ | 64 | /* #define EXIT_DEBUG */ |
62 | /* #define EXIT_DEBUG_SIMPLE */ | 65 | /* #define EXIT_DEBUG_SIMPLE */ |
63 | /* #define EXIT_DEBUG_INT */ | 66 | /* #define EXIT_DEBUG_INT */ |
@@ -135,11 +138,10 @@ static void kvmppc_fast_vcpu_kick_hv(struct kvm_vcpu *vcpu) | |||
135 | * stolen. | 138 | * stolen. |
136 | * | 139 | * |
137 | * Updates to busy_stolen are protected by arch.tbacct_lock; | 140 | * Updates to busy_stolen are protected by arch.tbacct_lock; |
138 | * updates to vc->stolen_tb are protected by the arch.tbacct_lock | 141 | * updates to vc->stolen_tb are protected by the vcore->stoltb_lock |
139 | * of the vcpu that has taken responsibility for running the vcore | 142 | * lock. The stolen times are measured in units of timebase ticks. |
140 | * (i.e. vc->runner). The stolen times are measured in units of | 143 | * (Note that the != TB_NIL checks below are purely defensive; |
141 | * timebase ticks. (Note that the != TB_NIL checks below are | 144 | * they should never fail.) |
142 | * purely defensive; they should never fail.) | ||
143 | */ | 145 | */ |
144 | 146 | ||
145 | static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) | 147 | static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) |
@@ -147,12 +149,21 @@ static void kvmppc_core_vcpu_load_hv(struct kvm_vcpu *vcpu, int cpu) | |||
147 | struct kvmppc_vcore *vc = vcpu->arch.vcore; | 149 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
148 | unsigned long flags; | 150 | unsigned long flags; |
149 | 151 | ||
150 | spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); | 152 | /* |
151 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE && | 153 | * We can test vc->runner without taking the vcore lock, |
152 | vc->preempt_tb != TB_NIL) { | 154 | * because only this task ever sets vc->runner to this |
153 | vc->stolen_tb += mftb() - vc->preempt_tb; | 155 | * vcpu, and once it is set to this vcpu, only this task |
154 | vc->preempt_tb = TB_NIL; | 156 | * ever sets it to NULL. |
157 | */ | ||
158 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE) { | ||
159 | spin_lock_irqsave(&vc->stoltb_lock, flags); | ||
160 | if (vc->preempt_tb != TB_NIL) { | ||
161 | vc->stolen_tb += mftb() - vc->preempt_tb; | ||
162 | vc->preempt_tb = TB_NIL; | ||
163 | } | ||
164 | spin_unlock_irqrestore(&vc->stoltb_lock, flags); | ||
155 | } | 165 | } |
166 | spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); | ||
156 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST && | 167 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST && |
157 | vcpu->arch.busy_preempt != TB_NIL) { | 168 | vcpu->arch.busy_preempt != TB_NIL) { |
158 | vcpu->arch.busy_stolen += mftb() - vcpu->arch.busy_preempt; | 169 | vcpu->arch.busy_stolen += mftb() - vcpu->arch.busy_preempt; |
@@ -166,9 +177,12 @@ static void kvmppc_core_vcpu_put_hv(struct kvm_vcpu *vcpu) | |||
166 | struct kvmppc_vcore *vc = vcpu->arch.vcore; | 177 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
167 | unsigned long flags; | 178 | unsigned long flags; |
168 | 179 | ||
169 | spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); | 180 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE) { |
170 | if (vc->runner == vcpu && vc->vcore_state != VCORE_INACTIVE) | 181 | spin_lock_irqsave(&vc->stoltb_lock, flags); |
171 | vc->preempt_tb = mftb(); | 182 | vc->preempt_tb = mftb(); |
183 | spin_unlock_irqrestore(&vc->stoltb_lock, flags); | ||
184 | } | ||
185 | spin_lock_irqsave(&vcpu->arch.tbacct_lock, flags); | ||
172 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) | 186 | if (vcpu->arch.state == KVMPPC_VCPU_BUSY_IN_HOST) |
173 | vcpu->arch.busy_preempt = mftb(); | 187 | vcpu->arch.busy_preempt = mftb(); |
174 | spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); | 188 | spin_unlock_irqrestore(&vcpu->arch.tbacct_lock, flags); |
@@ -191,9 +205,6 @@ int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat) | |||
191 | struct kvmppc_vcore *vc = vcpu->arch.vcore; | 205 | struct kvmppc_vcore *vc = vcpu->arch.vcore; |
192 | 206 | ||
193 | if (arch_compat) { | 207 | if (arch_compat) { |
194 | if (!cpu_has_feature(CPU_FTR_ARCH_206)) | ||
195 | return -EINVAL; /* 970 has no compat mode support */ | ||
196 | |||
197 | switch (arch_compat) { | 208 | switch (arch_compat) { |
198 | case PVR_ARCH_205: | 209 | case PVR_ARCH_205: |
199 | /* | 210 | /* |
@@ -505,25 +516,14 @@ static void kvmppc_update_vpas(struct kvm_vcpu *vcpu) | |||
505 | static u64 vcore_stolen_time(struct kvmppc_vcore *vc, u64 now) | 516 | static u64 vcore_stolen_time(struct kvmppc_vcore *vc, u64 now) |
506 | { | 517 | { |
507 | u64 p; | 518 | u64 p; |
519 | unsigned long flags; | ||
508 | 520 | ||
509 | /* | 521 | spin_lock_irqsave(&vc->stoltb_lock, flags); |
510 | * If we are the task running the vcore, then since we hold | 522 | p = vc->stolen_tb; |
511 | * the vcore lock, we can't be preempted, so stolen_tb/preempt_tb | ||
512 | * can't be updated, so we don't need the tbacct_lock. | ||
513 | * If the vcore is inactive, it can't become active (since we | ||
514 | * hold the vcore lock), so the vcpu load/put functions won't | ||
515 | * update stolen_tb/preempt_tb, and we don't need tbacct_lock. | ||
516 | */ | ||
517 | if (vc->vcore_state != VCORE_INACTIVE && | 523 | if (vc->vcore_state != VCORE_INACTIVE && |
518 | vc->runner->arch.run_task != current) { | 524 | vc->preempt_tb != TB_NIL) |
519 | spin_lock_irq(&vc->runner->arch.tbacct_lock); | 525 | p += now - vc->preempt_tb; |
520 | p = vc->stolen_tb; | 526 | spin_unlock_irqrestore(&vc->stoltb_lock, flags); |
521 | if (vc->preempt_tb != TB_NIL) | ||
522 | p += now - vc->preempt_tb; | ||
523 | spin_unlock_irq(&vc->runner->arch.tbacct_lock); | ||
524 | } else { | ||
525 | p = vc->stolen_tb; | ||
526 | } | ||
527 | return p; | 527 | return p; |
528 | } | 528 | } |
529 | 529 | ||
@@ -607,10 +607,45 @@ static int kvmppc_h_set_mode(struct kvm_vcpu *vcpu, unsigned long mflags, | |||
607 | } | 607 | } |
608 | } | 608 | } |
609 | 609 | ||
610 | static int kvm_arch_vcpu_yield_to(struct kvm_vcpu *target) | ||
611 | { | ||
612 | struct kvmppc_vcore *vcore = target->arch.vcore; | ||
613 | |||
614 | /* | ||
615 | * We expect to have been called by the real mode handler | ||
616 | * (kvmppc_rm_h_confer()) which would have directly returned | ||
617 | * H_SUCCESS if the source vcore wasn't idle (e.g. if it may | ||
618 | * have useful work to do and should not confer) so we don't | ||
619 | * recheck that here. | ||
620 | */ | ||
621 | |||
622 | spin_lock(&vcore->lock); | ||
623 | if (target->arch.state == KVMPPC_VCPU_RUNNABLE && | ||
624 | vcore->vcore_state != VCORE_INACTIVE) | ||
625 | target = vcore->runner; | ||
626 | spin_unlock(&vcore->lock); | ||
627 | |||
628 | return kvm_vcpu_yield_to(target); | ||
629 | } | ||
630 | |||
631 | static int kvmppc_get_yield_count(struct kvm_vcpu *vcpu) | ||
632 | { | ||
633 | int yield_count = 0; | ||
634 | struct lppaca *lppaca; | ||
635 | |||
636 | spin_lock(&vcpu->arch.vpa_update_lock); | ||
637 | lppaca = (struct lppaca *)vcpu->arch.vpa.pinned_addr; | ||
638 | if (lppaca) | ||
639 | yield_count = lppaca->yield_count; | ||
640 | spin_unlock(&vcpu->arch.vpa_update_lock); | ||
641 | return yield_count; | ||
642 | } | ||
643 | |||
610 | int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) | 644 | int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) |
611 | { | 645 | { |
612 | unsigned long req = kvmppc_get_gpr(vcpu, 3); | 646 | unsigned long req = kvmppc_get_gpr(vcpu, 3); |
613 | unsigned long target, ret = H_SUCCESS; | 647 | unsigned long target, ret = H_SUCCESS; |
648 | int yield_count; | ||
614 | struct kvm_vcpu *tvcpu; | 649 | struct kvm_vcpu *tvcpu; |
615 | int idx, rc; | 650 | int idx, rc; |
616 | 651 | ||
@@ -619,14 +654,6 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) | |||
619 | return RESUME_HOST; | 654 | return RESUME_HOST; |
620 | 655 | ||
621 | switch (req) { | 656 | switch (req) { |
622 | case H_ENTER: | ||
623 | idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
624 | ret = kvmppc_virtmode_h_enter(vcpu, kvmppc_get_gpr(vcpu, 4), | ||
625 | kvmppc_get_gpr(vcpu, 5), | ||
626 | kvmppc_get_gpr(vcpu, 6), | ||
627 | kvmppc_get_gpr(vcpu, 7)); | ||
628 | srcu_read_unlock(&vcpu->kvm->srcu, idx); | ||
629 | break; | ||
630 | case H_CEDE: | 657 | case H_CEDE: |
631 | break; | 658 | break; |
632 | case H_PROD: | 659 | case H_PROD: |
@@ -654,7 +681,10 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) | |||
654 | ret = H_PARAMETER; | 681 | ret = H_PARAMETER; |
655 | break; | 682 | break; |
656 | } | 683 | } |
657 | kvm_vcpu_yield_to(tvcpu); | 684 | yield_count = kvmppc_get_gpr(vcpu, 5); |
685 | if (kvmppc_get_yield_count(tvcpu) != yield_count) | ||
686 | break; | ||
687 | kvm_arch_vcpu_yield_to(tvcpu); | ||
658 | break; | 688 | break; |
659 | case H_REGISTER_VPA: | 689 | case H_REGISTER_VPA: |
660 | ret = do_h_register_vpa(vcpu, kvmppc_get_gpr(vcpu, 4), | 690 | ret = do_h_register_vpa(vcpu, kvmppc_get_gpr(vcpu, 4), |
@@ -769,6 +799,8 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
769 | vcpu->stat.ext_intr_exits++; | 799 | vcpu->stat.ext_intr_exits++; |
770 | r = RESUME_GUEST; | 800 | r = RESUME_GUEST; |
771 | break; | 801 | break; |
802 | /* HMI is hypervisor interrupt and host has handled it. Resume guest.*/ | ||
803 | case BOOK3S_INTERRUPT_HMI: | ||
772 | case BOOK3S_INTERRUPT_PERFMON: | 804 | case BOOK3S_INTERRUPT_PERFMON: |
773 | r = RESUME_GUEST; | 805 | r = RESUME_GUEST; |
774 | break; | 806 | break; |
@@ -837,6 +869,10 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
837 | * Accordingly return to Guest or Host. | 869 | * Accordingly return to Guest or Host. |
838 | */ | 870 | */ |
839 | case BOOK3S_INTERRUPT_H_EMUL_ASSIST: | 871 | case BOOK3S_INTERRUPT_H_EMUL_ASSIST: |
872 | if (vcpu->arch.emul_inst != KVM_INST_FETCH_FAILED) | ||
873 | vcpu->arch.last_inst = kvmppc_need_byteswap(vcpu) ? | ||
874 | swab32(vcpu->arch.emul_inst) : | ||
875 | vcpu->arch.emul_inst; | ||
840 | if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) { | 876 | if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) { |
841 | r = kvmppc_emulate_debug_inst(run, vcpu); | 877 | r = kvmppc_emulate_debug_inst(run, vcpu); |
842 | } else { | 878 | } else { |
@@ -1357,6 +1393,7 @@ static struct kvmppc_vcore *kvmppc_vcore_create(struct kvm *kvm, int core) | |||
1357 | 1393 | ||
1358 | INIT_LIST_HEAD(&vcore->runnable_threads); | 1394 | INIT_LIST_HEAD(&vcore->runnable_threads); |
1359 | spin_lock_init(&vcore->lock); | 1395 | spin_lock_init(&vcore->lock); |
1396 | spin_lock_init(&vcore->stoltb_lock); | ||
1360 | init_waitqueue_head(&vcore->wq); | 1397 | init_waitqueue_head(&vcore->wq); |
1361 | vcore->preempt_tb = TB_NIL; | 1398 | vcore->preempt_tb = TB_NIL; |
1362 | vcore->lpcr = kvm->arch.lpcr; | 1399 | vcore->lpcr = kvm->arch.lpcr; |
@@ -1694,9 +1731,11 @@ static void kvmppc_run_core(struct kvmppc_vcore *vc) | |||
1694 | vc->n_woken = 0; | 1731 | vc->n_woken = 0; |
1695 | vc->nap_count = 0; | 1732 | vc->nap_count = 0; |
1696 | vc->entry_exit_count = 0; | 1733 | vc->entry_exit_count = 0; |
1734 | vc->preempt_tb = TB_NIL; | ||
1697 | vc->vcore_state = VCORE_STARTING; | 1735 | vc->vcore_state = VCORE_STARTING; |
1698 | vc->in_guest = 0; | 1736 | vc->in_guest = 0; |
1699 | vc->napping_threads = 0; | 1737 | vc->napping_threads = 0; |
1738 | vc->conferring_threads = 0; | ||
1700 | 1739 | ||
1701 | /* | 1740 | /* |
1702 | * Updating any of the vpas requires calling kvmppc_pin_guest_page, | 1741 | * Updating any of the vpas requires calling kvmppc_pin_guest_page, |
@@ -1726,6 +1765,7 @@ static void kvmppc_run_core(struct kvmppc_vcore *vc) | |||
1726 | list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list) { | 1765 | list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list) { |
1727 | kvmppc_start_thread(vcpu); | 1766 | kvmppc_start_thread(vcpu); |
1728 | kvmppc_create_dtl_entry(vcpu, vc); | 1767 | kvmppc_create_dtl_entry(vcpu, vc); |
1768 | trace_kvm_guest_enter(vcpu); | ||
1729 | } | 1769 | } |
1730 | 1770 | ||
1731 | /* Set this explicitly in case thread 0 doesn't have a vcpu */ | 1771 | /* Set this explicitly in case thread 0 doesn't have a vcpu */ |
@@ -1734,6 +1774,9 @@ static void kvmppc_run_core(struct kvmppc_vcore *vc) | |||
1734 | 1774 | ||
1735 | vc->vcore_state = VCORE_RUNNING; | 1775 | vc->vcore_state = VCORE_RUNNING; |
1736 | preempt_disable(); | 1776 | preempt_disable(); |
1777 | |||
1778 | trace_kvmppc_run_core(vc, 0); | ||
1779 | |||
1737 | spin_unlock(&vc->lock); | 1780 | spin_unlock(&vc->lock); |
1738 | 1781 | ||
1739 | kvm_guest_enter(); | 1782 | kvm_guest_enter(); |
@@ -1779,6 +1822,8 @@ static void kvmppc_run_core(struct kvmppc_vcore *vc) | |||
1779 | kvmppc_core_pending_dec(vcpu)) | 1822 | kvmppc_core_pending_dec(vcpu)) |
1780 | kvmppc_core_dequeue_dec(vcpu); | 1823 | kvmppc_core_dequeue_dec(vcpu); |
1781 | 1824 | ||
1825 | trace_kvm_guest_exit(vcpu); | ||
1826 | |||
1782 | ret = RESUME_GUEST; | 1827 | ret = RESUME_GUEST; |
1783 | if (vcpu->arch.trap) | 1828 | if (vcpu->arch.trap) |
1784 | ret = kvmppc_handle_exit_hv(vcpu->arch.kvm_run, vcpu, | 1829 | ret = kvmppc_handle_exit_hv(vcpu->arch.kvm_run, vcpu, |
@@ -1804,6 +1849,8 @@ static void kvmppc_run_core(struct kvmppc_vcore *vc) | |||
1804 | wake_up(&vcpu->arch.cpu_run); | 1849 | wake_up(&vcpu->arch.cpu_run); |
1805 | } | 1850 | } |
1806 | } | 1851 | } |
1852 | |||
1853 | trace_kvmppc_run_core(vc, 1); | ||
1807 | } | 1854 | } |
1808 | 1855 | ||
1809 | /* | 1856 | /* |
@@ -1826,15 +1873,37 @@ static void kvmppc_wait_for_exec(struct kvm_vcpu *vcpu, int wait_state) | |||
1826 | */ | 1873 | */ |
1827 | static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) | 1874 | static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc) |
1828 | { | 1875 | { |
1876 | struct kvm_vcpu *vcpu; | ||
1877 | int do_sleep = 1; | ||
1878 | |||
1829 | DEFINE_WAIT(wait); | 1879 | DEFINE_WAIT(wait); |
1830 | 1880 | ||
1831 | prepare_to_wait(&vc->wq, &wait, TASK_INTERRUPTIBLE); | 1881 | prepare_to_wait(&vc->wq, &wait, TASK_INTERRUPTIBLE); |
1882 | |||
1883 | /* | ||
1884 | * Check one last time for pending exceptions and ceded state after | ||
1885 | * we put ourselves on the wait queue | ||
1886 | */ | ||
1887 | list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list) { | ||
1888 | if (vcpu->arch.pending_exceptions || !vcpu->arch.ceded) { | ||
1889 | do_sleep = 0; | ||
1890 | break; | ||
1891 | } | ||
1892 | } | ||
1893 | |||
1894 | if (!do_sleep) { | ||
1895 | finish_wait(&vc->wq, &wait); | ||
1896 | return; | ||
1897 | } | ||
1898 | |||
1832 | vc->vcore_state = VCORE_SLEEPING; | 1899 | vc->vcore_state = VCORE_SLEEPING; |
1900 | trace_kvmppc_vcore_blocked(vc, 0); | ||
1833 | spin_unlock(&vc->lock); | 1901 | spin_unlock(&vc->lock); |
1834 | schedule(); | 1902 | schedule(); |
1835 | finish_wait(&vc->wq, &wait); | 1903 | finish_wait(&vc->wq, &wait); |
1836 | spin_lock(&vc->lock); | 1904 | spin_lock(&vc->lock); |
1837 | vc->vcore_state = VCORE_INACTIVE; | 1905 | vc->vcore_state = VCORE_INACTIVE; |
1906 | trace_kvmppc_vcore_blocked(vc, 1); | ||
1838 | } | 1907 | } |
1839 | 1908 | ||
1840 | static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | 1909 | static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) |
@@ -1843,6 +1912,8 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
1843 | struct kvmppc_vcore *vc; | 1912 | struct kvmppc_vcore *vc; |
1844 | struct kvm_vcpu *v, *vn; | 1913 | struct kvm_vcpu *v, *vn; |
1845 | 1914 | ||
1915 | trace_kvmppc_run_vcpu_enter(vcpu); | ||
1916 | |||
1846 | kvm_run->exit_reason = 0; | 1917 | kvm_run->exit_reason = 0; |
1847 | vcpu->arch.ret = RESUME_GUEST; | 1918 | vcpu->arch.ret = RESUME_GUEST; |
1848 | vcpu->arch.trap = 0; | 1919 | vcpu->arch.trap = 0; |
@@ -1872,6 +1943,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
1872 | VCORE_EXIT_COUNT(vc) == 0) { | 1943 | VCORE_EXIT_COUNT(vc) == 0) { |
1873 | kvmppc_create_dtl_entry(vcpu, vc); | 1944 | kvmppc_create_dtl_entry(vcpu, vc); |
1874 | kvmppc_start_thread(vcpu); | 1945 | kvmppc_start_thread(vcpu); |
1946 | trace_kvm_guest_enter(vcpu); | ||
1875 | } else if (vc->vcore_state == VCORE_SLEEPING) { | 1947 | } else if (vc->vcore_state == VCORE_SLEEPING) { |
1876 | wake_up(&vc->wq); | 1948 | wake_up(&vc->wq); |
1877 | } | 1949 | } |
@@ -1936,6 +2008,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) | |||
1936 | wake_up(&v->arch.cpu_run); | 2008 | wake_up(&v->arch.cpu_run); |
1937 | } | 2009 | } |
1938 | 2010 | ||
2011 | trace_kvmppc_run_vcpu_exit(vcpu, kvm_run); | ||
1939 | spin_unlock(&vc->lock); | 2012 | spin_unlock(&vc->lock); |
1940 | return vcpu->arch.ret; | 2013 | return vcpu->arch.ret; |
1941 | } | 2014 | } |
@@ -1962,7 +2035,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) | |||
1962 | /* Order vcpus_running vs. rma_setup_done, see kvmppc_alloc_reset_hpt */ | 2035 | /* Order vcpus_running vs. rma_setup_done, see kvmppc_alloc_reset_hpt */ |
1963 | smp_mb(); | 2036 | smp_mb(); |
1964 | 2037 | ||
1965 | /* On the first time here, set up HTAB and VRMA or RMA */ | 2038 | /* On the first time here, set up HTAB and VRMA */ |
1966 | if (!vcpu->kvm->arch.rma_setup_done) { | 2039 | if (!vcpu->kvm->arch.rma_setup_done) { |
1967 | r = kvmppc_hv_setup_htab_rma(vcpu); | 2040 | r = kvmppc_hv_setup_htab_rma(vcpu); |
1968 | if (r) | 2041 | if (r) |
@@ -1981,7 +2054,9 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) | |||
1981 | 2054 | ||
1982 | if (run->exit_reason == KVM_EXIT_PAPR_HCALL && | 2055 | if (run->exit_reason == KVM_EXIT_PAPR_HCALL && |
1983 | !(vcpu->arch.shregs.msr & MSR_PR)) { | 2056 | !(vcpu->arch.shregs.msr & MSR_PR)) { |
2057 | trace_kvm_hcall_enter(vcpu); | ||
1984 | r = kvmppc_pseries_do_hcall(vcpu); | 2058 | r = kvmppc_pseries_do_hcall(vcpu); |
2059 | trace_kvm_hcall_exit(vcpu, r); | ||
1985 | kvmppc_core_prepare_to_enter(vcpu); | 2060 | kvmppc_core_prepare_to_enter(vcpu); |
1986 | } else if (r == RESUME_PAGE_FAULT) { | 2061 | } else if (r == RESUME_PAGE_FAULT) { |
1987 | srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); | 2062 | srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); |
@@ -1997,98 +2072,6 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu) | |||
1997 | return r; | 2072 | return r; |
1998 | } | 2073 | } |
1999 | 2074 | ||
2000 | |||
2001 | /* Work out RMLS (real mode limit selector) field value for a given RMA size. | ||
2002 | Assumes POWER7 or PPC970. */ | ||
2003 | static inline int lpcr_rmls(unsigned long rma_size) | ||
2004 | { | ||
2005 | switch (rma_size) { | ||
2006 | case 32ul << 20: /* 32 MB */ | ||
2007 | if (cpu_has_feature(CPU_FTR_ARCH_206)) | ||
2008 | return 8; /* only supported on POWER7 */ | ||
2009 | return -1; | ||
2010 | case 64ul << 20: /* 64 MB */ | ||
2011 | return 3; | ||
2012 | case 128ul << 20: /* 128 MB */ | ||
2013 | return 7; | ||
2014 | case 256ul << 20: /* 256 MB */ | ||
2015 | return 4; | ||
2016 | case 1ul << 30: /* 1 GB */ | ||
2017 | return 2; | ||
2018 | case 16ul << 30: /* 16 GB */ | ||
2019 | return 1; | ||
2020 | case 256ul << 30: /* 256 GB */ | ||
2021 | return 0; | ||
2022 | default: | ||
2023 | return -1; | ||
2024 | } | ||
2025 | } | ||
2026 | |||
2027 | static int kvm_rma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | ||
2028 | { | ||
2029 | struct page *page; | ||
2030 | struct kvm_rma_info *ri = vma->vm_file->private_data; | ||
2031 | |||
2032 | if (vmf->pgoff >= kvm_rma_pages) | ||
2033 | return VM_FAULT_SIGBUS; | ||
2034 | |||
2035 | page = pfn_to_page(ri->base_pfn + vmf->pgoff); | ||
2036 | get_page(page); | ||
2037 | vmf->page = page; | ||
2038 | return 0; | ||
2039 | } | ||
2040 | |||
2041 | static const struct vm_operations_struct kvm_rma_vm_ops = { | ||
2042 | .fault = kvm_rma_fault, | ||
2043 | }; | ||
2044 | |||
2045 | static int kvm_rma_mmap(struct file *file, struct vm_area_struct *vma) | ||
2046 | { | ||
2047 | vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | ||
2048 | vma->vm_ops = &kvm_rma_vm_ops; | ||
2049 | return 0; | ||
2050 | } | ||
2051 | |||
2052 | static int kvm_rma_release(struct inode *inode, struct file *filp) | ||
2053 | { | ||
2054 | struct kvm_rma_info *ri = filp->private_data; | ||
2055 | |||
2056 | kvm_release_rma(ri); | ||
2057 | return 0; | ||
2058 | } | ||
2059 | |||
2060 | static const struct file_operations kvm_rma_fops = { | ||
2061 | .mmap = kvm_rma_mmap, | ||
2062 | .release = kvm_rma_release, | ||
2063 | }; | ||
2064 | |||
2065 | static long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, | ||
2066 | struct kvm_allocate_rma *ret) | ||
2067 | { | ||
2068 | long fd; | ||
2069 | struct kvm_rma_info *ri; | ||
2070 | /* | ||
2071 | * Only do this on PPC970 in HV mode | ||
2072 | */ | ||
2073 | if (!cpu_has_feature(CPU_FTR_HVMODE) || | ||
2074 | !cpu_has_feature(CPU_FTR_ARCH_201)) | ||
2075 | return -EINVAL; | ||
2076 | |||
2077 | if (!kvm_rma_pages) | ||
2078 | return -EINVAL; | ||
2079 | |||
2080 | ri = kvm_alloc_rma(); | ||
2081 | if (!ri) | ||
2082 | return -ENOMEM; | ||
2083 | |||
2084 | fd = anon_inode_getfd("kvm-rma", &kvm_rma_fops, ri, O_RDWR | O_CLOEXEC); | ||
2085 | if (fd < 0) | ||
2086 | kvm_release_rma(ri); | ||
2087 | |||
2088 | ret->rma_size = kvm_rma_pages << PAGE_SHIFT; | ||
2089 | return fd; | ||
2090 | } | ||
2091 | |||
2092 | static void kvmppc_add_seg_page_size(struct kvm_ppc_one_seg_page_size **sps, | 2075 | static void kvmppc_add_seg_page_size(struct kvm_ppc_one_seg_page_size **sps, |
2093 | int linux_psize) | 2076 | int linux_psize) |
2094 | { | 2077 | { |
@@ -2167,26 +2150,6 @@ out: | |||
2167 | return r; | 2150 | return r; |
2168 | } | 2151 | } |
2169 | 2152 | ||
2170 | static void unpin_slot(struct kvm_memory_slot *memslot) | ||
2171 | { | ||
2172 | unsigned long *physp; | ||
2173 | unsigned long j, npages, pfn; | ||
2174 | struct page *page; | ||
2175 | |||
2176 | physp = memslot->arch.slot_phys; | ||
2177 | npages = memslot->npages; | ||
2178 | if (!physp) | ||
2179 | return; | ||
2180 | for (j = 0; j < npages; j++) { | ||
2181 | if (!(physp[j] & KVMPPC_GOT_PAGE)) | ||
2182 | continue; | ||
2183 | pfn = physp[j] >> PAGE_SHIFT; | ||
2184 | page = pfn_to_page(pfn); | ||
2185 | SetPageDirty(page); | ||
2186 | put_page(page); | ||
2187 | } | ||
2188 | } | ||
2189 | |||
2190 | static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free, | 2153 | static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free, |
2191 | struct kvm_memory_slot *dont) | 2154 | struct kvm_memory_slot *dont) |
2192 | { | 2155 | { |
@@ -2194,11 +2157,6 @@ static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free, | |||
2194 | vfree(free->arch.rmap); | 2157 | vfree(free->arch.rmap); |
2195 | free->arch.rmap = NULL; | 2158 | free->arch.rmap = NULL; |
2196 | } | 2159 | } |
2197 | if (!dont || free->arch.slot_phys != dont->arch.slot_phys) { | ||
2198 | unpin_slot(free); | ||
2199 | vfree(free->arch.slot_phys); | ||
2200 | free->arch.slot_phys = NULL; | ||
2201 | } | ||
2202 | } | 2160 | } |
2203 | 2161 | ||
2204 | static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot, | 2162 | static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot, |
@@ -2207,7 +2165,6 @@ static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot, | |||
2207 | slot->arch.rmap = vzalloc(npages * sizeof(*slot->arch.rmap)); | 2165 | slot->arch.rmap = vzalloc(npages * sizeof(*slot->arch.rmap)); |
2208 | if (!slot->arch.rmap) | 2166 | if (!slot->arch.rmap) |
2209 | return -ENOMEM; | 2167 | return -ENOMEM; |
2210 | slot->arch.slot_phys = NULL; | ||
2211 | 2168 | ||
2212 | return 0; | 2169 | return 0; |
2213 | } | 2170 | } |
@@ -2216,17 +2173,6 @@ static int kvmppc_core_prepare_memory_region_hv(struct kvm *kvm, | |||
2216 | struct kvm_memory_slot *memslot, | 2173 | struct kvm_memory_slot *memslot, |
2217 | struct kvm_userspace_memory_region *mem) | 2174 | struct kvm_userspace_memory_region *mem) |
2218 | { | 2175 | { |
2219 | unsigned long *phys; | ||
2220 | |||
2221 | /* Allocate a slot_phys array if needed */ | ||
2222 | phys = memslot->arch.slot_phys; | ||
2223 | if (!kvm->arch.using_mmu_notifiers && !phys && memslot->npages) { | ||
2224 | phys = vzalloc(memslot->npages * sizeof(unsigned long)); | ||
2225 | if (!phys) | ||
2226 | return -ENOMEM; | ||
2227 | memslot->arch.slot_phys = phys; | ||
2228 | } | ||
2229 | |||
2230 | return 0; | 2176 | return 0; |
2231 | } | 2177 | } |
2232 | 2178 | ||
@@ -2284,17 +2230,11 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu) | |||
2284 | { | 2230 | { |
2285 | int err = 0; | 2231 | int err = 0; |
2286 | struct kvm *kvm = vcpu->kvm; | 2232 | struct kvm *kvm = vcpu->kvm; |
2287 | struct kvm_rma_info *ri = NULL; | ||
2288 | unsigned long hva; | 2233 | unsigned long hva; |
2289 | struct kvm_memory_slot *memslot; | 2234 | struct kvm_memory_slot *memslot; |
2290 | struct vm_area_struct *vma; | 2235 | struct vm_area_struct *vma; |
2291 | unsigned long lpcr = 0, senc; | 2236 | unsigned long lpcr = 0, senc; |
2292 | unsigned long lpcr_mask = 0; | ||
2293 | unsigned long psize, porder; | 2237 | unsigned long psize, porder; |
2294 | unsigned long rma_size; | ||
2295 | unsigned long rmls; | ||
2296 | unsigned long *physp; | ||
2297 | unsigned long i, npages; | ||
2298 | int srcu_idx; | 2238 | int srcu_idx; |
2299 | 2239 | ||
2300 | mutex_lock(&kvm->lock); | 2240 | mutex_lock(&kvm->lock); |
@@ -2329,88 +2269,25 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu) | |||
2329 | psize = vma_kernel_pagesize(vma); | 2269 | psize = vma_kernel_pagesize(vma); |
2330 | porder = __ilog2(psize); | 2270 | porder = __ilog2(psize); |
2331 | 2271 | ||
2332 | /* Is this one of our preallocated RMAs? */ | ||
2333 | if (vma->vm_file && vma->vm_file->f_op == &kvm_rma_fops && | ||
2334 | hva == vma->vm_start) | ||
2335 | ri = vma->vm_file->private_data; | ||
2336 | |||
2337 | up_read(¤t->mm->mmap_sem); | 2272 | up_read(¤t->mm->mmap_sem); |
2338 | 2273 | ||
2339 | if (!ri) { | 2274 | /* We can handle 4k, 64k or 16M pages in the VRMA */ |
2340 | /* On POWER7, use VRMA; on PPC970, give up */ | 2275 | err = -EINVAL; |
2341 | err = -EPERM; | 2276 | if (!(psize == 0x1000 || psize == 0x10000 || |
2342 | if (cpu_has_feature(CPU_FTR_ARCH_201)) { | 2277 | psize == 0x1000000)) |
2343 | pr_err("KVM: CPU requires an RMO\n"); | 2278 | goto out_srcu; |
2344 | goto out_srcu; | ||
2345 | } | ||
2346 | 2279 | ||
2347 | /* We can handle 4k, 64k or 16M pages in the VRMA */ | 2280 | /* Update VRMASD field in the LPCR */ |
2348 | err = -EINVAL; | 2281 | senc = slb_pgsize_encoding(psize); |
2349 | if (!(psize == 0x1000 || psize == 0x10000 || | 2282 | kvm->arch.vrma_slb_v = senc | SLB_VSID_B_1T | |
2350 | psize == 0x1000000)) | 2283 | (VRMA_VSID << SLB_VSID_SHIFT_1T); |
2351 | goto out_srcu; | 2284 | /* the -4 is to account for senc values starting at 0x10 */ |
2285 | lpcr = senc << (LPCR_VRMASD_SH - 4); | ||
2352 | 2286 | ||
2353 | /* Update VRMASD field in the LPCR */ | 2287 | /* Create HPTEs in the hash page table for the VRMA */ |
2354 | senc = slb_pgsize_encoding(psize); | 2288 | kvmppc_map_vrma(vcpu, memslot, porder); |
2355 | kvm->arch.vrma_slb_v = senc | SLB_VSID_B_1T | | ||
2356 | (VRMA_VSID << SLB_VSID_SHIFT_1T); | ||
2357 | lpcr_mask = LPCR_VRMASD; | ||
2358 | /* the -4 is to account for senc values starting at 0x10 */ | ||
2359 | lpcr = senc << (LPCR_VRMASD_SH - 4); | ||
2360 | 2289 | ||
2361 | /* Create HPTEs in the hash page table for the VRMA */ | 2290 | kvmppc_update_lpcr(kvm, lpcr, LPCR_VRMASD); |
2362 | kvmppc_map_vrma(vcpu, memslot, porder); | ||
2363 | |||
2364 | } else { | ||
2365 | /* Set up to use an RMO region */ | ||
2366 | rma_size = kvm_rma_pages; | ||
2367 | if (rma_size > memslot->npages) | ||
2368 | rma_size = memslot->npages; | ||
2369 | rma_size <<= PAGE_SHIFT; | ||
2370 | rmls = lpcr_rmls(rma_size); | ||
2371 | err = -EINVAL; | ||
2372 | if ((long)rmls < 0) { | ||
2373 | pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size); | ||
2374 | goto out_srcu; | ||
2375 | } | ||
2376 | atomic_inc(&ri->use_count); | ||
2377 | kvm->arch.rma = ri; | ||
2378 | |||
2379 | /* Update LPCR and RMOR */ | ||
2380 | if (cpu_has_feature(CPU_FTR_ARCH_201)) { | ||
2381 | /* PPC970; insert RMLS value (split field) in HID4 */ | ||
2382 | lpcr_mask = (1ul << HID4_RMLS0_SH) | | ||
2383 | (3ul << HID4_RMLS2_SH) | HID4_RMOR; | ||
2384 | lpcr = ((rmls >> 2) << HID4_RMLS0_SH) | | ||
2385 | ((rmls & 3) << HID4_RMLS2_SH); | ||
2386 | /* RMOR is also in HID4 */ | ||
2387 | lpcr |= ((ri->base_pfn >> (26 - PAGE_SHIFT)) & 0xffff) | ||
2388 | << HID4_RMOR_SH; | ||
2389 | } else { | ||
2390 | /* POWER7 */ | ||
2391 | lpcr_mask = LPCR_VPM0 | LPCR_VRMA_L | LPCR_RMLS; | ||
2392 | lpcr = rmls << LPCR_RMLS_SH; | ||
2393 | kvm->arch.rmor = ri->base_pfn << PAGE_SHIFT; | ||
2394 | } | ||
2395 | pr_info("KVM: Using RMO at %lx size %lx (LPCR = %lx)\n", | ||
2396 | ri->base_pfn << PAGE_SHIFT, rma_size, lpcr); | ||
2397 | |||
2398 | /* Initialize phys addrs of pages in RMO */ | ||
2399 | npages = kvm_rma_pages; | ||
2400 | porder = __ilog2(npages); | ||
2401 | physp = memslot->arch.slot_phys; | ||
2402 | if (physp) { | ||
2403 | if (npages > memslot->npages) | ||
2404 | npages = memslot->npages; | ||
2405 | spin_lock(&kvm->arch.slot_phys_lock); | ||
2406 | for (i = 0; i < npages; ++i) | ||
2407 | physp[i] = ((ri->base_pfn + i) << PAGE_SHIFT) + | ||
2408 | porder; | ||
2409 | spin_unlock(&kvm->arch.slot_phys_lock); | ||
2410 | } | ||
2411 | } | ||
2412 | |||
2413 | kvmppc_update_lpcr(kvm, lpcr, lpcr_mask); | ||
2414 | 2291 | ||
2415 | /* Order updates to kvm->arch.lpcr etc. vs. rma_setup_done */ | 2292 | /* Order updates to kvm->arch.lpcr etc. vs. rma_setup_done */ |
2416 | smp_wmb(); | 2293 | smp_wmb(); |
@@ -2449,35 +2326,21 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm) | |||
2449 | memcpy(kvm->arch.enabled_hcalls, default_enabled_hcalls, | 2326 | memcpy(kvm->arch.enabled_hcalls, default_enabled_hcalls, |
2450 | sizeof(kvm->arch.enabled_hcalls)); | 2327 | sizeof(kvm->arch.enabled_hcalls)); |
2451 | 2328 | ||
2452 | kvm->arch.rma = NULL; | ||
2453 | |||
2454 | kvm->arch.host_sdr1 = mfspr(SPRN_SDR1); | 2329 | kvm->arch.host_sdr1 = mfspr(SPRN_SDR1); |
2455 | 2330 | ||
2456 | if (cpu_has_feature(CPU_FTR_ARCH_201)) { | 2331 | /* Init LPCR for virtual RMA mode */ |
2457 | /* PPC970; HID4 is effectively the LPCR */ | 2332 | kvm->arch.host_lpid = mfspr(SPRN_LPID); |
2458 | kvm->arch.host_lpid = 0; | 2333 | kvm->arch.host_lpcr = lpcr = mfspr(SPRN_LPCR); |
2459 | kvm->arch.host_lpcr = lpcr = mfspr(SPRN_HID4); | 2334 | lpcr &= LPCR_PECE | LPCR_LPES; |
2460 | lpcr &= ~((3 << HID4_LPID1_SH) | (0xful << HID4_LPID5_SH)); | 2335 | lpcr |= (4UL << LPCR_DPFD_SH) | LPCR_HDICE | |
2461 | lpcr |= ((lpid >> 4) << HID4_LPID1_SH) | | 2336 | LPCR_VPM0 | LPCR_VPM1; |
2462 | ((lpid & 0xf) << HID4_LPID5_SH); | 2337 | kvm->arch.vrma_slb_v = SLB_VSID_B_1T | |
2463 | } else { | 2338 | (VRMA_VSID << SLB_VSID_SHIFT_1T); |
2464 | /* POWER7; init LPCR for virtual RMA mode */ | 2339 | /* On POWER8 turn on online bit to enable PURR/SPURR */ |
2465 | kvm->arch.host_lpid = mfspr(SPRN_LPID); | 2340 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) |
2466 | kvm->arch.host_lpcr = lpcr = mfspr(SPRN_LPCR); | 2341 | lpcr |= LPCR_ONL; |
2467 | lpcr &= LPCR_PECE | LPCR_LPES; | ||
2468 | lpcr |= (4UL << LPCR_DPFD_SH) | LPCR_HDICE | | ||
2469 | LPCR_VPM0 | LPCR_VPM1; | ||
2470 | kvm->arch.vrma_slb_v = SLB_VSID_B_1T | | ||
2471 | (VRMA_VSID << SLB_VSID_SHIFT_1T); | ||
2472 | /* On POWER8 turn on online bit to enable PURR/SPURR */ | ||
2473 | if (cpu_has_feature(CPU_FTR_ARCH_207S)) | ||
2474 | lpcr |= LPCR_ONL; | ||
2475 | } | ||
2476 | kvm->arch.lpcr = lpcr; | 2342 | kvm->arch.lpcr = lpcr; |
2477 | 2343 | ||
2478 | kvm->arch.using_mmu_notifiers = !!cpu_has_feature(CPU_FTR_ARCH_206); | ||
2479 | spin_lock_init(&kvm->arch.slot_phys_lock); | ||
2480 | |||
2481 | /* | 2344 | /* |
2482 | * Track that we now have a HV mode VM active. This blocks secondary | 2345 | * Track that we now have a HV mode VM active. This blocks secondary |
2483 | * CPU threads from coming online. | 2346 | * CPU threads from coming online. |
@@ -2507,10 +2370,6 @@ static void kvmppc_core_destroy_vm_hv(struct kvm *kvm) | |||
2507 | kvm_hv_vm_deactivated(); | 2370 | kvm_hv_vm_deactivated(); |
2508 | 2371 | ||
2509 | kvmppc_free_vcores(kvm); | 2372 | kvmppc_free_vcores(kvm); |
2510 | if (kvm->arch.rma) { | ||
2511 | kvm_release_rma(kvm->arch.rma); | ||
2512 | kvm->arch.rma = NULL; | ||
2513 | } | ||
2514 | 2373 | ||
2515 | kvmppc_free_hpt(kvm); | 2374 | kvmppc_free_hpt(kvm); |
2516 | } | 2375 | } |
@@ -2536,7 +2395,8 @@ static int kvmppc_core_emulate_mfspr_hv(struct kvm_vcpu *vcpu, int sprn, | |||
2536 | 2395 | ||
2537 | static int kvmppc_core_check_processor_compat_hv(void) | 2396 | static int kvmppc_core_check_processor_compat_hv(void) |
2538 | { | 2397 | { |
2539 | if (!cpu_has_feature(CPU_FTR_HVMODE)) | 2398 | if (!cpu_has_feature(CPU_FTR_HVMODE) || |
2399 | !cpu_has_feature(CPU_FTR_ARCH_206)) | ||
2540 | return -EIO; | 2400 | return -EIO; |
2541 | return 0; | 2401 | return 0; |
2542 | } | 2402 | } |
@@ -2550,16 +2410,6 @@ static long kvm_arch_vm_ioctl_hv(struct file *filp, | |||
2550 | 2410 | ||
2551 | switch (ioctl) { | 2411 | switch (ioctl) { |
2552 | 2412 | ||
2553 | case KVM_ALLOCATE_RMA: { | ||
2554 | struct kvm_allocate_rma rma; | ||
2555 | struct kvm *kvm = filp->private_data; | ||
2556 | |||
2557 | r = kvm_vm_ioctl_allocate_rma(kvm, &rma); | ||
2558 | if (r >= 0 && copy_to_user(argp, &rma, sizeof(rma))) | ||
2559 | r = -EFAULT; | ||
2560 | break; | ||
2561 | } | ||
2562 | |||
2563 | case KVM_PPC_ALLOCATE_HTAB: { | 2413 | case KVM_PPC_ALLOCATE_HTAB: { |
2564 | u32 htab_order; | 2414 | u32 htab_order; |
2565 | 2415 | ||
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c index 4fdc27c80f4c..3e43f815ac5d 100644 --- a/arch/powerpc/kvm/book3s_hv_builtin.c +++ b/arch/powerpc/kvm/book3s_hv_builtin.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/memblock.h> | 17 | #include <linux/memblock.h> |
18 | #include <linux/sizes.h> | 18 | #include <linux/sizes.h> |
19 | #include <linux/cma.h> | 19 | #include <linux/cma.h> |
20 | #include <linux/bitops.h> | ||
20 | 21 | ||
21 | #include <asm/cputable.h> | 22 | #include <asm/cputable.h> |
22 | #include <asm/kvm_ppc.h> | 23 | #include <asm/kvm_ppc.h> |
@@ -33,95 +34,9 @@ | |||
33 | * By default we reserve 5% of memory for hash pagetable allocation. | 34 | * By default we reserve 5% of memory for hash pagetable allocation. |
34 | */ | 35 | */ |
35 | static unsigned long kvm_cma_resv_ratio = 5; | 36 | static unsigned long kvm_cma_resv_ratio = 5; |
36 | /* | ||
37 | * We allocate RMAs (real mode areas) for KVM guests from the KVM CMA area. | ||
38 | * Each RMA has to be physically contiguous and of a size that the | ||
39 | * hardware supports. PPC970 and POWER7 support 64MB, 128MB and 256MB, | ||
40 | * and other larger sizes. Since we are unlikely to be allocate that | ||
41 | * much physically contiguous memory after the system is up and running, | ||
42 | * we preallocate a set of RMAs in early boot using CMA. | ||
43 | * should be power of 2. | ||
44 | */ | ||
45 | unsigned long kvm_rma_pages = (1 << 27) >> PAGE_SHIFT; /* 128MB */ | ||
46 | EXPORT_SYMBOL_GPL(kvm_rma_pages); | ||
47 | 37 | ||
48 | static struct cma *kvm_cma; | 38 | static struct cma *kvm_cma; |
49 | 39 | ||
50 | /* Work out RMLS (real mode limit selector) field value for a given RMA size. | ||
51 | Assumes POWER7 or PPC970. */ | ||
52 | static inline int lpcr_rmls(unsigned long rma_size) | ||
53 | { | ||
54 | switch (rma_size) { | ||
55 | case 32ul << 20: /* 32 MB */ | ||
56 | if (cpu_has_feature(CPU_FTR_ARCH_206)) | ||
57 | return 8; /* only supported on POWER7 */ | ||
58 | return -1; | ||
59 | case 64ul << 20: /* 64 MB */ | ||
60 | return 3; | ||
61 | case 128ul << 20: /* 128 MB */ | ||
62 | return 7; | ||
63 | case 256ul << 20: /* 256 MB */ | ||
64 | return 4; | ||
65 | case 1ul << 30: /* 1 GB */ | ||
66 | return 2; | ||
67 | case 16ul << 30: /* 16 GB */ | ||
68 | return 1; | ||
69 | case 256ul << 30: /* 256 GB */ | ||
70 | return 0; | ||
71 | default: | ||
72 | return -1; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | static int __init early_parse_rma_size(char *p) | ||
77 | { | ||
78 | unsigned long kvm_rma_size; | ||
79 | |||
80 | pr_debug("%s(%s)\n", __func__, p); | ||
81 | if (!p) | ||
82 | return -EINVAL; | ||
83 | kvm_rma_size = memparse(p, &p); | ||
84 | /* | ||
85 | * Check that the requested size is one supported in hardware | ||
86 | */ | ||
87 | if (lpcr_rmls(kvm_rma_size) < 0) { | ||
88 | pr_err("RMA size of 0x%lx not supported\n", kvm_rma_size); | ||
89 | return -EINVAL; | ||
90 | } | ||
91 | kvm_rma_pages = kvm_rma_size >> PAGE_SHIFT; | ||
92 | return 0; | ||
93 | } | ||
94 | early_param("kvm_rma_size", early_parse_rma_size); | ||
95 | |||
96 | struct kvm_rma_info *kvm_alloc_rma() | ||
97 | { | ||
98 | struct page *page; | ||
99 | struct kvm_rma_info *ri; | ||
100 | |||
101 | ri = kmalloc(sizeof(struct kvm_rma_info), GFP_KERNEL); | ||
102 | if (!ri) | ||
103 | return NULL; | ||
104 | page = cma_alloc(kvm_cma, kvm_rma_pages, order_base_2(kvm_rma_pages)); | ||
105 | if (!page) | ||
106 | goto err_out; | ||
107 | atomic_set(&ri->use_count, 1); | ||
108 | ri->base_pfn = page_to_pfn(page); | ||
109 | return ri; | ||
110 | err_out: | ||
111 | kfree(ri); | ||
112 | return NULL; | ||
113 | } | ||
114 | EXPORT_SYMBOL_GPL(kvm_alloc_rma); | ||
115 | |||
116 | void kvm_release_rma(struct kvm_rma_info *ri) | ||
117 | { | ||
118 | if (atomic_dec_and_test(&ri->use_count)) { | ||
119 | cma_release(kvm_cma, pfn_to_page(ri->base_pfn), kvm_rma_pages); | ||
120 | kfree(ri); | ||
121 | } | ||
122 | } | ||
123 | EXPORT_SYMBOL_GPL(kvm_release_rma); | ||
124 | |||
125 | static int __init early_parse_kvm_cma_resv(char *p) | 40 | static int __init early_parse_kvm_cma_resv(char *p) |
126 | { | 41 | { |
127 | pr_debug("%s(%s)\n", __func__, p); | 42 | pr_debug("%s(%s)\n", __func__, p); |
@@ -133,14 +48,9 @@ early_param("kvm_cma_resv_ratio", early_parse_kvm_cma_resv); | |||
133 | 48 | ||
134 | struct page *kvm_alloc_hpt(unsigned long nr_pages) | 49 | struct page *kvm_alloc_hpt(unsigned long nr_pages) |
135 | { | 50 | { |
136 | unsigned long align_pages = HPT_ALIGN_PAGES; | ||
137 | |||
138 | VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT); | 51 | VM_BUG_ON(order_base_2(nr_pages) < KVM_CMA_CHUNK_ORDER - PAGE_SHIFT); |
139 | 52 | ||
140 | /* Old CPUs require HPT aligned on a multiple of its size */ | 53 | return cma_alloc(kvm_cma, nr_pages, order_base_2(HPT_ALIGN_PAGES)); |
141 | if (!cpu_has_feature(CPU_FTR_ARCH_206)) | ||
142 | align_pages = nr_pages; | ||
143 | return cma_alloc(kvm_cma, nr_pages, order_base_2(align_pages)); | ||
144 | } | 54 | } |
145 | EXPORT_SYMBOL_GPL(kvm_alloc_hpt); | 55 | EXPORT_SYMBOL_GPL(kvm_alloc_hpt); |
146 | 56 | ||
@@ -181,22 +91,44 @@ void __init kvm_cma_reserve(void) | |||
181 | if (selected_size) { | 91 | if (selected_size) { |
182 | pr_debug("%s: reserving %ld MiB for global area\n", __func__, | 92 | pr_debug("%s: reserving %ld MiB for global area\n", __func__, |
183 | (unsigned long)selected_size / SZ_1M); | 93 | (unsigned long)selected_size / SZ_1M); |
184 | /* | 94 | align_size = HPT_ALIGN_PAGES << PAGE_SHIFT; |
185 | * Old CPUs require HPT aligned on a multiple of its size. So for them | ||
186 | * make the alignment as max size we could request. | ||
187 | */ | ||
188 | if (!cpu_has_feature(CPU_FTR_ARCH_206)) | ||
189 | align_size = __rounddown_pow_of_two(selected_size); | ||
190 | else | ||
191 | align_size = HPT_ALIGN_PAGES << PAGE_SHIFT; | ||
192 | |||
193 | align_size = max(kvm_rma_pages << PAGE_SHIFT, align_size); | ||
194 | cma_declare_contiguous(0, selected_size, 0, align_size, | 95 | cma_declare_contiguous(0, selected_size, 0, align_size, |
195 | KVM_CMA_CHUNK_ORDER - PAGE_SHIFT, false, &kvm_cma); | 96 | KVM_CMA_CHUNK_ORDER - PAGE_SHIFT, false, &kvm_cma); |
196 | } | 97 | } |
197 | } | 98 | } |
198 | 99 | ||
199 | /* | 100 | /* |
101 | * Real-mode H_CONFER implementation. | ||
102 | * We check if we are the only vcpu out of this virtual core | ||
103 | * still running in the guest and not ceded. If so, we pop up | ||
104 | * to the virtual-mode implementation; if not, just return to | ||
105 | * the guest. | ||
106 | */ | ||
107 | long int kvmppc_rm_h_confer(struct kvm_vcpu *vcpu, int target, | ||
108 | unsigned int yield_count) | ||
109 | { | ||
110 | struct kvmppc_vcore *vc = vcpu->arch.vcore; | ||
111 | int threads_running; | ||
112 | int threads_ceded; | ||
113 | int threads_conferring; | ||
114 | u64 stop = get_tb() + 10 * tb_ticks_per_usec; | ||
115 | int rv = H_SUCCESS; /* => don't yield */ | ||
116 | |||
117 | set_bit(vcpu->arch.ptid, &vc->conferring_threads); | ||
118 | while ((get_tb() < stop) && (VCORE_EXIT_COUNT(vc) == 0)) { | ||
119 | threads_running = VCORE_ENTRY_COUNT(vc); | ||
120 | threads_ceded = hweight32(vc->napping_threads); | ||
121 | threads_conferring = hweight32(vc->conferring_threads); | ||
122 | if (threads_ceded + threads_conferring >= threads_running) { | ||
123 | rv = H_TOO_HARD; /* => do yield */ | ||
124 | break; | ||
125 | } | ||
126 | } | ||
127 | clear_bit(vcpu->arch.ptid, &vc->conferring_threads); | ||
128 | return rv; | ||
129 | } | ||
130 | |||
131 | /* | ||
200 | * When running HV mode KVM we need to block certain operations while KVM VMs | 132 | * When running HV mode KVM we need to block certain operations while KVM VMs |
201 | * exist in the system. We use a counter of VMs to track this. | 133 | * exist in the system. We use a counter of VMs to track this. |
202 | * | 134 | * |
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S index 731be7478b27..36540a99d178 100644 --- a/arch/powerpc/kvm/book3s_hv_interrupts.S +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S | |||
@@ -52,10 +52,8 @@ _GLOBAL(__kvmppc_vcore_entry) | |||
52 | std r3, _CCR(r1) | 52 | std r3, _CCR(r1) |
53 | 53 | ||
54 | /* Save host DSCR */ | 54 | /* Save host DSCR */ |
55 | BEGIN_FTR_SECTION | ||
56 | mfspr r3, SPRN_DSCR | 55 | mfspr r3, SPRN_DSCR |
57 | std r3, HSTATE_DSCR(r13) | 56 | std r3, HSTATE_DSCR(r13) |
58 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
59 | 57 | ||
60 | BEGIN_FTR_SECTION | 58 | BEGIN_FTR_SECTION |
61 | /* Save host DABR */ | 59 | /* Save host DABR */ |
@@ -84,11 +82,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
84 | mfspr r7, SPRN_MMCR0 /* save MMCR0 */ | 82 | mfspr r7, SPRN_MMCR0 /* save MMCR0 */ |
85 | mtspr SPRN_MMCR0, r3 /* freeze all counters, disable interrupts */ | 83 | mtspr SPRN_MMCR0, r3 /* freeze all counters, disable interrupts */ |
86 | mfspr r6, SPRN_MMCRA | 84 | mfspr r6, SPRN_MMCRA |
87 | BEGIN_FTR_SECTION | 85 | /* Clear MMCRA in order to disable SDAR updates */ |
88 | /* On P7, clear MMCRA in order to disable SDAR updates */ | ||
89 | li r5, 0 | 86 | li r5, 0 |
90 | mtspr SPRN_MMCRA, r5 | 87 | mtspr SPRN_MMCRA, r5 |
91 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
92 | isync | 88 | isync |
93 | ld r3, PACALPPACAPTR(r13) /* is the host using the PMU? */ | 89 | ld r3, PACALPPACAPTR(r13) /* is the host using the PMU? */ |
94 | lbz r5, LPPACA_PMCINUSE(r3) | 90 | lbz r5, LPPACA_PMCINUSE(r3) |
@@ -113,20 +109,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
113 | mfspr r7, SPRN_PMC4 | 109 | mfspr r7, SPRN_PMC4 |
114 | mfspr r8, SPRN_PMC5 | 110 | mfspr r8, SPRN_PMC5 |
115 | mfspr r9, SPRN_PMC6 | 111 | mfspr r9, SPRN_PMC6 |
116 | BEGIN_FTR_SECTION | ||
117 | mfspr r10, SPRN_PMC7 | ||
118 | mfspr r11, SPRN_PMC8 | ||
119 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
120 | stw r3, HSTATE_PMC(r13) | 112 | stw r3, HSTATE_PMC(r13) |
121 | stw r5, HSTATE_PMC + 4(r13) | 113 | stw r5, HSTATE_PMC + 4(r13) |
122 | stw r6, HSTATE_PMC + 8(r13) | 114 | stw r6, HSTATE_PMC + 8(r13) |
123 | stw r7, HSTATE_PMC + 12(r13) | 115 | stw r7, HSTATE_PMC + 12(r13) |
124 | stw r8, HSTATE_PMC + 16(r13) | 116 | stw r8, HSTATE_PMC + 16(r13) |
125 | stw r9, HSTATE_PMC + 20(r13) | 117 | stw r9, HSTATE_PMC + 20(r13) |
126 | BEGIN_FTR_SECTION | ||
127 | stw r10, HSTATE_PMC + 24(r13) | ||
128 | stw r11, HSTATE_PMC + 28(r13) | ||
129 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
130 | 31: | 118 | 31: |
131 | 119 | ||
132 | /* | 120 | /* |
@@ -140,31 +128,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | |||
140 | add r8,r8,r7 | 128 | add r8,r8,r7 |
141 | std r8,HSTATE_DECEXP(r13) | 129 | std r8,HSTATE_DECEXP(r13) |
142 | 130 | ||
143 | #ifdef CONFIG_SMP | ||
144 | /* | ||
145 | * On PPC970, if the guest vcpu has an external interrupt pending, | ||
146 | * send ourselves an IPI so as to interrupt the guest once it | ||
147 | * enables interrupts. (It must have interrupts disabled, | ||
148 | * otherwise we would already have delivered the interrupt.) | ||
149 | * | ||
150 | * XXX If this is a UP build, smp_send_reschedule is not available, | ||
151 | * so the interrupt will be delayed until the next time the vcpu | ||
152 | * enters the guest with interrupts enabled. | ||
153 | */ | ||
154 | BEGIN_FTR_SECTION | ||
155 | ld r4, HSTATE_KVM_VCPU(r13) | ||
156 | ld r0, VCPU_PENDING_EXC(r4) | ||
157 | li r7, (1 << BOOK3S_IRQPRIO_EXTERNAL) | ||
158 | oris r7, r7, (1 << BOOK3S_IRQPRIO_EXTERNAL_LEVEL)@h | ||
159 | and. r0, r0, r7 | ||
160 | beq 32f | ||
161 | lhz r3, PACAPACAINDEX(r13) | ||
162 | bl smp_send_reschedule | ||
163 | nop | ||
164 | 32: | ||
165 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
166 | #endif /* CONFIG_SMP */ | ||
167 | |||
168 | /* Jump to partition switch code */ | 131 | /* Jump to partition switch code */ |
169 | bl kvmppc_hv_entry_trampoline | 132 | bl kvmppc_hv_entry_trampoline |
170 | nop | 133 | nop |
diff --git a/arch/powerpc/kvm/book3s_hv_ras.c b/arch/powerpc/kvm/book3s_hv_ras.c index d562c8e2bc30..60081bd75847 100644 --- a/arch/powerpc/kvm/book3s_hv_ras.c +++ b/arch/powerpc/kvm/book3s_hv_ras.c | |||
@@ -138,8 +138,5 @@ out: | |||
138 | 138 | ||
139 | long kvmppc_realmode_machine_check(struct kvm_vcpu *vcpu) | 139 | long kvmppc_realmode_machine_check(struct kvm_vcpu *vcpu) |
140 | { | 140 | { |
141 | if (cpu_has_feature(CPU_FTR_ARCH_206)) | 141 | return kvmppc_realmode_mc_power7(vcpu); |
142 | return kvmppc_realmode_mc_power7(vcpu); | ||
143 | |||
144 | return 0; | ||
145 | } | 142 | } |
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index 084ad54c73cd..510bdfbc4073 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c | |||
@@ -45,16 +45,12 @@ static int global_invalidates(struct kvm *kvm, unsigned long flags) | |||
45 | * as indicated by local_paca->kvm_hstate.kvm_vcpu being set, | 45 | * as indicated by local_paca->kvm_hstate.kvm_vcpu being set, |
46 | * we can use tlbiel as long as we mark all other physical | 46 | * we can use tlbiel as long as we mark all other physical |
47 | * cores as potentially having stale TLB entries for this lpid. | 47 | * cores as potentially having stale TLB entries for this lpid. |
48 | * If we're not using MMU notifiers, we never take pages away | ||
49 | * from the guest, so we can use tlbiel if requested. | ||
50 | * Otherwise, don't use tlbiel. | 48 | * Otherwise, don't use tlbiel. |
51 | */ | 49 | */ |
52 | if (kvm->arch.online_vcores == 1 && local_paca->kvm_hstate.kvm_vcpu) | 50 | if (kvm->arch.online_vcores == 1 && local_paca->kvm_hstate.kvm_vcpu) |
53 | global = 0; | 51 | global = 0; |
54 | else if (kvm->arch.using_mmu_notifiers) | ||
55 | global = 1; | ||
56 | else | 52 | else |
57 | global = !(flags & H_LOCAL); | 53 | global = 1; |
58 | 54 | ||
59 | if (!global) { | 55 | if (!global) { |
60 | /* any other core might now have stale TLB entries... */ | 56 | /* any other core might now have stale TLB entries... */ |
@@ -170,7 +166,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
170 | struct revmap_entry *rev; | 166 | struct revmap_entry *rev; |
171 | unsigned long g_ptel; | 167 | unsigned long g_ptel; |
172 | struct kvm_memory_slot *memslot; | 168 | struct kvm_memory_slot *memslot; |
173 | unsigned long *physp, pte_size; | 169 | unsigned long pte_size; |
174 | unsigned long is_io; | 170 | unsigned long is_io; |
175 | unsigned long *rmap; | 171 | unsigned long *rmap; |
176 | pte_t pte; | 172 | pte_t pte; |
@@ -198,9 +194,6 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
198 | is_io = ~0ul; | 194 | is_io = ~0ul; |
199 | rmap = NULL; | 195 | rmap = NULL; |
200 | if (!(memslot && !(memslot->flags & KVM_MEMSLOT_INVALID))) { | 196 | if (!(memslot && !(memslot->flags & KVM_MEMSLOT_INVALID))) { |
201 | /* PPC970 can't do emulated MMIO */ | ||
202 | if (!cpu_has_feature(CPU_FTR_ARCH_206)) | ||
203 | return H_PARAMETER; | ||
204 | /* Emulated MMIO - mark this with key=31 */ | 197 | /* Emulated MMIO - mark this with key=31 */ |
205 | pteh |= HPTE_V_ABSENT; | 198 | pteh |= HPTE_V_ABSENT; |
206 | ptel |= HPTE_R_KEY_HI | HPTE_R_KEY_LO; | 199 | ptel |= HPTE_R_KEY_HI | HPTE_R_KEY_LO; |
@@ -213,37 +206,20 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
213 | slot_fn = gfn - memslot->base_gfn; | 206 | slot_fn = gfn - memslot->base_gfn; |
214 | rmap = &memslot->arch.rmap[slot_fn]; | 207 | rmap = &memslot->arch.rmap[slot_fn]; |
215 | 208 | ||
216 | if (!kvm->arch.using_mmu_notifiers) { | 209 | /* Translate to host virtual address */ |
217 | physp = memslot->arch.slot_phys; | 210 | hva = __gfn_to_hva_memslot(memslot, gfn); |
218 | if (!physp) | 211 | |
219 | return H_PARAMETER; | 212 | /* Look up the Linux PTE for the backing page */ |
220 | physp += slot_fn; | 213 | pte_size = psize; |
221 | if (realmode) | 214 | pte = lookup_linux_pte_and_update(pgdir, hva, writing, &pte_size); |
222 | physp = real_vmalloc_addr(physp); | 215 | if (pte_present(pte) && !pte_numa(pte)) { |
223 | pa = *physp; | 216 | if (writing && !pte_write(pte)) |
224 | if (!pa) | 217 | /* make the actual HPTE be read-only */ |
225 | return H_TOO_HARD; | 218 | ptel = hpte_make_readonly(ptel); |
226 | is_io = pa & (HPTE_R_I | HPTE_R_W); | 219 | is_io = hpte_cache_bits(pte_val(pte)); |
227 | pte_size = PAGE_SIZE << (pa & KVMPPC_PAGE_ORDER_MASK); | 220 | pa = pte_pfn(pte) << PAGE_SHIFT; |
228 | pa &= PAGE_MASK; | 221 | pa |= hva & (pte_size - 1); |
229 | pa |= gpa & ~PAGE_MASK; | 222 | pa |= gpa & ~PAGE_MASK; |
230 | } else { | ||
231 | /* Translate to host virtual address */ | ||
232 | hva = __gfn_to_hva_memslot(memslot, gfn); | ||
233 | |||
234 | /* Look up the Linux PTE for the backing page */ | ||
235 | pte_size = psize; | ||
236 | pte = lookup_linux_pte_and_update(pgdir, hva, writing, | ||
237 | &pte_size); | ||
238 | if (pte_present(pte) && !pte_numa(pte)) { | ||
239 | if (writing && !pte_write(pte)) | ||
240 | /* make the actual HPTE be read-only */ | ||
241 | ptel = hpte_make_readonly(ptel); | ||
242 | is_io = hpte_cache_bits(pte_val(pte)); | ||
243 | pa = pte_pfn(pte) << PAGE_SHIFT; | ||
244 | pa |= hva & (pte_size - 1); | ||
245 | pa |= gpa & ~PAGE_MASK; | ||
246 | } | ||
247 | } | 223 | } |
248 | 224 | ||
249 | if (pte_size < psize) | 225 | if (pte_size < psize) |
@@ -337,8 +313,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags, | |||
337 | rmap = real_vmalloc_addr(rmap); | 313 | rmap = real_vmalloc_addr(rmap); |
338 | lock_rmap(rmap); | 314 | lock_rmap(rmap); |
339 | /* Check for pending invalidations under the rmap chain lock */ | 315 | /* Check for pending invalidations under the rmap chain lock */ |
340 | if (kvm->arch.using_mmu_notifiers && | 316 | if (mmu_notifier_retry(kvm, mmu_seq)) { |
341 | mmu_notifier_retry(kvm, mmu_seq)) { | ||
342 | /* inval in progress, write a non-present HPTE */ | 317 | /* inval in progress, write a non-present HPTE */ |
343 | pteh |= HPTE_V_ABSENT; | 318 | pteh |= HPTE_V_ABSENT; |
344 | pteh &= ~HPTE_V_VALID; | 319 | pteh &= ~HPTE_V_VALID; |
@@ -395,61 +370,11 @@ static inline int try_lock_tlbie(unsigned int *lock) | |||
395 | return old == 0; | 370 | return old == 0; |
396 | } | 371 | } |
397 | 372 | ||
398 | /* | ||
399 | * tlbie/tlbiel is a bit different on the PPC970 compared to later | ||
400 | * processors such as POWER7; the large page bit is in the instruction | ||
401 | * not RB, and the top 16 bits and the bottom 12 bits of the VA | ||
402 | * in RB must be 0. | ||
403 | */ | ||
404 | static void do_tlbies_970(struct kvm *kvm, unsigned long *rbvalues, | ||
405 | long npages, int global, bool need_sync) | ||
406 | { | ||
407 | long i; | ||
408 | |||
409 | if (global) { | ||
410 | while (!try_lock_tlbie(&kvm->arch.tlbie_lock)) | ||
411 | cpu_relax(); | ||
412 | if (need_sync) | ||
413 | asm volatile("ptesync" : : : "memory"); | ||
414 | for (i = 0; i < npages; ++i) { | ||
415 | unsigned long rb = rbvalues[i]; | ||
416 | |||
417 | if (rb & 1) /* large page */ | ||
418 | asm volatile("tlbie %0,1" : : | ||
419 | "r" (rb & 0x0000fffffffff000ul)); | ||
420 | else | ||
421 | asm volatile("tlbie %0,0" : : | ||
422 | "r" (rb & 0x0000fffffffff000ul)); | ||
423 | } | ||
424 | asm volatile("eieio; tlbsync; ptesync" : : : "memory"); | ||
425 | kvm->arch.tlbie_lock = 0; | ||
426 | } else { | ||
427 | if (need_sync) | ||
428 | asm volatile("ptesync" : : : "memory"); | ||
429 | for (i = 0; i < npages; ++i) { | ||
430 | unsigned long rb = rbvalues[i]; | ||
431 | |||
432 | if (rb & 1) /* large page */ | ||
433 | asm volatile("tlbiel %0,1" : : | ||
434 | "r" (rb & 0x0000fffffffff000ul)); | ||
435 | else | ||
436 | asm volatile("tlbiel %0,0" : : | ||
437 | "r" (rb & 0x0000fffffffff000ul)); | ||
438 | } | ||
439 | asm volatile("ptesync" : : : "memory"); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues, | 373 | static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues, |
444 | long npages, int global, bool need_sync) | 374 | long npages, int global, bool need_sync) |
445 | { | 375 | { |
446 | long i; | 376 | long i; |
447 | 377 | ||
448 | if (cpu_has_feature(CPU_FTR_ARCH_201)) { | ||
449 | /* PPC970 tlbie instruction is a bit different */ | ||
450 | do_tlbies_970(kvm, rbvalues, npages, global, need_sync); | ||
451 | return; | ||
452 | } | ||
453 | if (global) { | 378 | if (global) { |
454 | while (!try_lock_tlbie(&kvm->arch.tlbie_lock)) | 379 | while (!try_lock_tlbie(&kvm->arch.tlbie_lock)) |
455 | cpu_relax(); | 380 | cpu_relax(); |
@@ -667,40 +592,29 @@ long kvmppc_h_protect(struct kvm_vcpu *vcpu, unsigned long flags, | |||
667 | rev->guest_rpte = r; | 592 | rev->guest_rpte = r; |
668 | note_hpte_modification(kvm, rev); | 593 | note_hpte_modification(kvm, rev); |
669 | } | 594 | } |
670 | r = (be64_to_cpu(hpte[1]) & ~mask) | bits; | ||
671 | 595 | ||
672 | /* Update HPTE */ | 596 | /* Update HPTE */ |
673 | if (v & HPTE_V_VALID) { | 597 | if (v & HPTE_V_VALID) { |
674 | rb = compute_tlbie_rb(v, r, pte_index); | ||
675 | hpte[0] = cpu_to_be64(v & ~HPTE_V_VALID); | ||
676 | do_tlbies(kvm, &rb, 1, global_invalidates(kvm, flags), true); | ||
677 | /* | 598 | /* |
678 | * If the host has this page as readonly but the guest | 599 | * If the page is valid, don't let it transition from |
679 | * wants to make it read/write, reduce the permissions. | 600 | * readonly to writable. If it should be writable, we'll |
680 | * Checking the host permissions involves finding the | 601 | * take a trap and let the page fault code sort it out. |
681 | * memslot and then the Linux PTE for the page. | ||
682 | */ | 602 | */ |
683 | if (hpte_is_writable(r) && kvm->arch.using_mmu_notifiers) { | 603 | pte = be64_to_cpu(hpte[1]); |
684 | unsigned long psize, gfn, hva; | 604 | r = (pte & ~mask) | bits; |
685 | struct kvm_memory_slot *memslot; | 605 | if (hpte_is_writable(r) && !hpte_is_writable(pte)) |
686 | pgd_t *pgdir = vcpu->arch.pgdir; | 606 | r = hpte_make_readonly(r); |
687 | pte_t pte; | 607 | /* If the PTE is changing, invalidate it first */ |
688 | 608 | if (r != pte) { | |
689 | psize = hpte_page_size(v, r); | 609 | rb = compute_tlbie_rb(v, r, pte_index); |
690 | gfn = ((r & HPTE_R_RPN) & ~(psize - 1)) >> PAGE_SHIFT; | 610 | hpte[0] = cpu_to_be64((v & ~HPTE_V_VALID) | |
691 | memslot = __gfn_to_memslot(kvm_memslots_raw(kvm), gfn); | 611 | HPTE_V_ABSENT); |
692 | if (memslot) { | 612 | do_tlbies(kvm, &rb, 1, global_invalidates(kvm, flags), |
693 | hva = __gfn_to_hva_memslot(memslot, gfn); | 613 | true); |
694 | pte = lookup_linux_pte_and_update(pgdir, hva, | 614 | hpte[1] = cpu_to_be64(r); |
695 | 1, &psize); | ||
696 | if (pte_present(pte) && !pte_write(pte)) | ||
697 | r = hpte_make_readonly(r); | ||
698 | } | ||
699 | } | 615 | } |
700 | } | 616 | } |
701 | hpte[1] = cpu_to_be64(r); | 617 | unlock_hpte(hpte, v & ~HPTE_V_HVLOCK); |
702 | eieio(); | ||
703 | hpte[0] = cpu_to_be64(v & ~HPTE_V_HVLOCK); | ||
704 | asm volatile("ptesync" : : : "memory"); | 618 | asm volatile("ptesync" : : : "memory"); |
705 | return H_SUCCESS; | 619 | return H_SUCCESS; |
706 | } | 620 | } |
diff --git a/arch/powerpc/kvm/book3s_hv_rm_xics.c b/arch/powerpc/kvm/book3s_hv_rm_xics.c index 3ee38e6e884f..7b066f6b02ad 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_xics.c +++ b/arch/powerpc/kvm/book3s_hv_rm_xics.c | |||
@@ -183,8 +183,10 @@ static void icp_rm_down_cppr(struct kvmppc_xics *xics, struct kvmppc_icp *icp, | |||
183 | * state update in HW (ie bus transactions) so we can handle them | 183 | * state update in HW (ie bus transactions) so we can handle them |
184 | * separately here as well. | 184 | * separately here as well. |
185 | */ | 185 | */ |
186 | if (resend) | 186 | if (resend) { |
187 | icp->rm_action |= XICS_RM_CHECK_RESEND; | 187 | icp->rm_action |= XICS_RM_CHECK_RESEND; |
188 | icp->rm_resend_icp = icp; | ||
189 | } | ||
188 | } | 190 | } |
189 | 191 | ||
190 | 192 | ||
@@ -254,10 +256,25 @@ int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, | |||
254 | * nothing needs to be done as there can be no XISR to | 256 | * nothing needs to be done as there can be no XISR to |
255 | * reject. | 257 | * reject. |
256 | * | 258 | * |
259 | * ICP state: Check_IPI | ||
260 | * | ||
257 | * If the CPPR is less favored, then we might be replacing | 261 | * If the CPPR is less favored, then we might be replacing |
258 | * an interrupt, and thus need to possibly reject it as in | 262 | * an interrupt, and thus need to possibly reject it. |
259 | * | 263 | * |
260 | * ICP state: Check_IPI | 264 | * ICP State: IPI |
265 | * | ||
266 | * Besides rejecting any pending interrupts, we also | ||
267 | * update XISR and pending_pri to mark IPI as pending. | ||
268 | * | ||
269 | * PAPR does not describe this state, but if the MFRR is being | ||
270 | * made less favored than its earlier value, there might be | ||
271 | * a previously-rejected interrupt needing to be resent. | ||
272 | * Ideally, we would want to resend only if | ||
273 | * prio(pending_interrupt) < mfrr && | ||
274 | * prio(pending_interrupt) < cppr | ||
275 | * where pending interrupt is the one that was rejected. But | ||
276 | * we don't have that state, so we simply trigger a resend | ||
277 | * whenever the MFRR is made less favored. | ||
261 | */ | 278 | */ |
262 | do { | 279 | do { |
263 | old_state = new_state = ACCESS_ONCE(icp->state); | 280 | old_state = new_state = ACCESS_ONCE(icp->state); |
@@ -270,13 +287,14 @@ int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, | |||
270 | resend = false; | 287 | resend = false; |
271 | if (mfrr < new_state.cppr) { | 288 | if (mfrr < new_state.cppr) { |
272 | /* Reject a pending interrupt if not an IPI */ | 289 | /* Reject a pending interrupt if not an IPI */ |
273 | if (mfrr <= new_state.pending_pri) | 290 | if (mfrr <= new_state.pending_pri) { |
274 | reject = new_state.xisr; | 291 | reject = new_state.xisr; |
275 | new_state.pending_pri = mfrr; | 292 | new_state.pending_pri = mfrr; |
276 | new_state.xisr = XICS_IPI; | 293 | new_state.xisr = XICS_IPI; |
294 | } | ||
277 | } | 295 | } |
278 | 296 | ||
279 | if (mfrr > old_state.mfrr && mfrr > new_state.cppr) { | 297 | if (mfrr > old_state.mfrr) { |
280 | resend = new_state.need_resend; | 298 | resend = new_state.need_resend; |
281 | new_state.need_resend = 0; | 299 | new_state.need_resend = 0; |
282 | } | 300 | } |
@@ -289,8 +307,10 @@ int kvmppc_rm_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, | |||
289 | } | 307 | } |
290 | 308 | ||
291 | /* Pass resends to virtual mode */ | 309 | /* Pass resends to virtual mode */ |
292 | if (resend) | 310 | if (resend) { |
293 | this_icp->rm_action |= XICS_RM_CHECK_RESEND; | 311 | this_icp->rm_action |= XICS_RM_CHECK_RESEND; |
312 | this_icp->rm_resend_icp = icp; | ||
313 | } | ||
294 | 314 | ||
295 | return check_too_hard(xics, this_icp); | 315 | return check_too_hard(xics, this_icp); |
296 | } | 316 | } |
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index edb2ccdbb2ba..0a2d64fb5de8 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S | |||
@@ -94,20 +94,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_PMAO_BUG) | |||
94 | lwz r6, HSTATE_PMC + 12(r13) | 94 | lwz r6, HSTATE_PMC + 12(r13) |
95 | lwz r8, HSTATE_PMC + 16(r13) | 95 | lwz r8, HSTATE_PMC + 16(r13) |
96 | lwz r9, HSTATE_PMC + 20(r13) | 96 | lwz r9, HSTATE_PMC + 20(r13) |
97 | BEGIN_FTR_SECTION | ||
98 | lwz r10, HSTATE_PMC + 24(r13) | ||
99 | lwz r11, HSTATE_PMC + 28(r13) | ||
100 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
101 | mtspr SPRN_PMC1, r3 | 97 | mtspr SPRN_PMC1, r3 |
102 | mtspr SPRN_PMC2, r4 | 98 | mtspr SPRN_PMC2, r4 |
103 | mtspr SPRN_PMC3, r5 | 99 | mtspr SPRN_PMC3, r5 |
104 | mtspr SPRN_PMC4, r6 | 100 | mtspr SPRN_PMC4, r6 |
105 | mtspr SPRN_PMC5, r8 | 101 | mtspr SPRN_PMC5, r8 |
106 | mtspr SPRN_PMC6, r9 | 102 | mtspr SPRN_PMC6, r9 |
107 | BEGIN_FTR_SECTION | ||
108 | mtspr SPRN_PMC7, r10 | ||
109 | mtspr SPRN_PMC8, r11 | ||
110 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
111 | ld r3, HSTATE_MMCR(r13) | 103 | ld r3, HSTATE_MMCR(r13) |
112 | ld r4, HSTATE_MMCR + 8(r13) | 104 | ld r4, HSTATE_MMCR + 8(r13) |
113 | ld r5, HSTATE_MMCR + 16(r13) | 105 | ld r5, HSTATE_MMCR + 16(r13) |
@@ -153,11 +145,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
153 | 145 | ||
154 | cmpwi cr1, r12, BOOK3S_INTERRUPT_MACHINE_CHECK | 146 | cmpwi cr1, r12, BOOK3S_INTERRUPT_MACHINE_CHECK |
155 | cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL | 147 | cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL |
156 | BEGIN_FTR_SECTION | ||
157 | beq 11f | 148 | beq 11f |
158 | cmpwi cr2, r12, BOOK3S_INTERRUPT_HMI | 149 | cmpwi cr2, r12, BOOK3S_INTERRUPT_HMI |
159 | beq cr2, 14f /* HMI check */ | 150 | beq cr2, 14f /* HMI check */ |
160 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
161 | 151 | ||
162 | /* RFI into the highmem handler, or branch to interrupt handler */ | 152 | /* RFI into the highmem handler, or branch to interrupt handler */ |
163 | mfmsr r6 | 153 | mfmsr r6 |
@@ -166,7 +156,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | |||
166 | mtmsrd r6, 1 /* Clear RI in MSR */ | 156 | mtmsrd r6, 1 /* Clear RI in MSR */ |
167 | mtsrr0 r8 | 157 | mtsrr0 r8 |
168 | mtsrr1 r7 | 158 | mtsrr1 r7 |
169 | beqa 0x500 /* external interrupt (PPC970) */ | ||
170 | beq cr1, 13f /* machine check */ | 159 | beq cr1, 13f /* machine check */ |
171 | RFI | 160 | RFI |
172 | 161 | ||
@@ -374,11 +363,8 @@ kvmppc_hv_entry: | |||
374 | slbia | 363 | slbia |
375 | ptesync | 364 | ptesync |
376 | 365 | ||
377 | BEGIN_FTR_SECTION | ||
378 | b 30f | ||
379 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
380 | /* | 366 | /* |
381 | * POWER7 host -> guest partition switch code. | 367 | * POWER7/POWER8 host -> guest partition switch code. |
382 | * We don't have to lock against concurrent tlbies, | 368 | * We don't have to lock against concurrent tlbies, |
383 | * but we do have to coordinate across hardware threads. | 369 | * but we do have to coordinate across hardware threads. |
384 | */ | 370 | */ |
@@ -486,97 +472,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
486 | cmpwi r3,512 /* 1 microsecond */ | 472 | cmpwi r3,512 /* 1 microsecond */ |
487 | li r12,BOOK3S_INTERRUPT_HV_DECREMENTER | 473 | li r12,BOOK3S_INTERRUPT_HV_DECREMENTER |
488 | blt hdec_soon | 474 | blt hdec_soon |
489 | b 31f | ||
490 | |||
491 | /* | ||
492 | * PPC970 host -> guest partition switch code. | ||
493 | * We have to lock against concurrent tlbies, | ||
494 | * using native_tlbie_lock to lock against host tlbies | ||
495 | * and kvm->arch.tlbie_lock to lock against guest tlbies. | ||
496 | * We also have to invalidate the TLB since its | ||
497 | * entries aren't tagged with the LPID. | ||
498 | */ | ||
499 | 30: ld r5,HSTATE_KVM_VCORE(r13) | ||
500 | ld r9,VCORE_KVM(r5) /* pointer to struct kvm */ | ||
501 | |||
502 | /* first take native_tlbie_lock */ | ||
503 | .section ".toc","aw" | ||
504 | toc_tlbie_lock: | ||
505 | .tc native_tlbie_lock[TC],native_tlbie_lock | ||
506 | .previous | ||
507 | ld r3,toc_tlbie_lock@toc(r2) | ||
508 | #ifdef __BIG_ENDIAN__ | ||
509 | lwz r8,PACA_LOCK_TOKEN(r13) | ||
510 | #else | ||
511 | lwz r8,PACAPACAINDEX(r13) | ||
512 | #endif | ||
513 | 24: lwarx r0,0,r3 | ||
514 | cmpwi r0,0 | ||
515 | bne 24b | ||
516 | stwcx. r8,0,r3 | ||
517 | bne 24b | ||
518 | isync | ||
519 | |||
520 | ld r5,HSTATE_KVM_VCORE(r13) | ||
521 | ld r7,VCORE_LPCR(r5) /* use vcore->lpcr to store HID4 */ | ||
522 | li r0,0x18f | ||
523 | rotldi r0,r0,HID4_LPID5_SH /* all lpid bits in HID4 = 1 */ | ||
524 | or r0,r7,r0 | ||
525 | ptesync | ||
526 | sync | ||
527 | mtspr SPRN_HID4,r0 /* switch to reserved LPID */ | ||
528 | isync | ||
529 | li r0,0 | ||
530 | stw r0,0(r3) /* drop native_tlbie_lock */ | ||
531 | |||
532 | /* invalidate the whole TLB */ | ||
533 | li r0,256 | ||
534 | mtctr r0 | ||
535 | li r6,0 | ||
536 | 25: tlbiel r6 | ||
537 | addi r6,r6,0x1000 | ||
538 | bdnz 25b | ||
539 | ptesync | ||
540 | 475 | ||
541 | /* Take the guest's tlbie_lock */ | ||
542 | addi r3,r9,KVM_TLBIE_LOCK | ||
543 | 24: lwarx r0,0,r3 | ||
544 | cmpwi r0,0 | ||
545 | bne 24b | ||
546 | stwcx. r8,0,r3 | ||
547 | bne 24b | ||
548 | isync | ||
549 | ld r6,KVM_SDR1(r9) | ||
550 | mtspr SPRN_SDR1,r6 /* switch to partition page table */ | ||
551 | |||
552 | /* Set up HID4 with the guest's LPID etc. */ | ||
553 | sync | ||
554 | mtspr SPRN_HID4,r7 | ||
555 | isync | ||
556 | |||
557 | /* drop the guest's tlbie_lock */ | ||
558 | li r0,0 | ||
559 | stw r0,0(r3) | ||
560 | |||
561 | /* Check if HDEC expires soon */ | ||
562 | mfspr r3,SPRN_HDEC | ||
563 | cmpwi r3,10 | ||
564 | li r12,BOOK3S_INTERRUPT_HV_DECREMENTER | ||
565 | blt hdec_soon | ||
566 | |||
567 | /* Enable HDEC interrupts */ | ||
568 | mfspr r0,SPRN_HID0 | ||
569 | li r3,1 | ||
570 | rldimi r0,r3, HID0_HDICE_SH, 64-HID0_HDICE_SH-1 | ||
571 | sync | ||
572 | mtspr SPRN_HID0,r0 | ||
573 | mfspr r0,SPRN_HID0 | ||
574 | mfspr r0,SPRN_HID0 | ||
575 | mfspr r0,SPRN_HID0 | ||
576 | mfspr r0,SPRN_HID0 | ||
577 | mfspr r0,SPRN_HID0 | ||
578 | mfspr r0,SPRN_HID0 | ||
579 | 31: | ||
580 | /* Do we have a guest vcpu to run? */ | 476 | /* Do we have a guest vcpu to run? */ |
581 | cmpdi r4, 0 | 477 | cmpdi r4, 0 |
582 | beq kvmppc_primary_no_guest | 478 | beq kvmppc_primary_no_guest |
@@ -606,7 +502,6 @@ kvmppc_got_guest: | |||
606 | stb r6, VCPU_VPA_DIRTY(r4) | 502 | stb r6, VCPU_VPA_DIRTY(r4) |
607 | 25: | 503 | 25: |
608 | 504 | ||
609 | BEGIN_FTR_SECTION | ||
610 | /* Save purr/spurr */ | 505 | /* Save purr/spurr */ |
611 | mfspr r5,SPRN_PURR | 506 | mfspr r5,SPRN_PURR |
612 | mfspr r6,SPRN_SPURR | 507 | mfspr r6,SPRN_SPURR |
@@ -616,7 +511,6 @@ BEGIN_FTR_SECTION | |||
616 | ld r8,VCPU_SPURR(r4) | 511 | ld r8,VCPU_SPURR(r4) |
617 | mtspr SPRN_PURR,r7 | 512 | mtspr SPRN_PURR,r7 |
618 | mtspr SPRN_SPURR,r8 | 513 | mtspr SPRN_SPURR,r8 |
619 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
620 | 514 | ||
621 | BEGIN_FTR_SECTION | 515 | BEGIN_FTR_SECTION |
622 | /* Set partition DABR */ | 516 | /* Set partition DABR */ |
@@ -625,9 +519,7 @@ BEGIN_FTR_SECTION | |||
625 | ld r6,VCPU_DABR(r4) | 519 | ld r6,VCPU_DABR(r4) |
626 | mtspr SPRN_DABRX,r5 | 520 | mtspr SPRN_DABRX,r5 |
627 | mtspr SPRN_DABR,r6 | 521 | mtspr SPRN_DABR,r6 |
628 | BEGIN_FTR_SECTION_NESTED(89) | ||
629 | isync | 522 | isync |
630 | END_FTR_SECTION_NESTED(CPU_FTR_ARCH_206, CPU_FTR_ARCH_206, 89) | ||
631 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | 523 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) |
632 | 524 | ||
633 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | 525 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM |
@@ -758,20 +650,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_PMAO_BUG) | |||
758 | lwz r7, VCPU_PMC + 12(r4) | 650 | lwz r7, VCPU_PMC + 12(r4) |
759 | lwz r8, VCPU_PMC + 16(r4) | 651 | lwz r8, VCPU_PMC + 16(r4) |
760 | lwz r9, VCPU_PMC + 20(r4) | 652 | lwz r9, VCPU_PMC + 20(r4) |
761 | BEGIN_FTR_SECTION | ||
762 | lwz r10, VCPU_PMC + 24(r4) | ||
763 | lwz r11, VCPU_PMC + 28(r4) | ||
764 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
765 | mtspr SPRN_PMC1, r3 | 653 | mtspr SPRN_PMC1, r3 |
766 | mtspr SPRN_PMC2, r5 | 654 | mtspr SPRN_PMC2, r5 |
767 | mtspr SPRN_PMC3, r6 | 655 | mtspr SPRN_PMC3, r6 |
768 | mtspr SPRN_PMC4, r7 | 656 | mtspr SPRN_PMC4, r7 |
769 | mtspr SPRN_PMC5, r8 | 657 | mtspr SPRN_PMC5, r8 |
770 | mtspr SPRN_PMC6, r9 | 658 | mtspr SPRN_PMC6, r9 |
771 | BEGIN_FTR_SECTION | ||
772 | mtspr SPRN_PMC7, r10 | ||
773 | mtspr SPRN_PMC8, r11 | ||
774 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
775 | ld r3, VCPU_MMCR(r4) | 659 | ld r3, VCPU_MMCR(r4) |
776 | ld r5, VCPU_MMCR + 8(r4) | 660 | ld r5, VCPU_MMCR + 8(r4) |
777 | ld r6, VCPU_MMCR + 16(r4) | 661 | ld r6, VCPU_MMCR + 16(r4) |
@@ -818,14 +702,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
818 | ld r30, VCPU_GPR(R30)(r4) | 702 | ld r30, VCPU_GPR(R30)(r4) |
819 | ld r31, VCPU_GPR(R31)(r4) | 703 | ld r31, VCPU_GPR(R31)(r4) |
820 | 704 | ||
821 | BEGIN_FTR_SECTION | ||
822 | /* Switch DSCR to guest value */ | 705 | /* Switch DSCR to guest value */ |
823 | ld r5, VCPU_DSCR(r4) | 706 | ld r5, VCPU_DSCR(r4) |
824 | mtspr SPRN_DSCR, r5 | 707 | mtspr SPRN_DSCR, r5 |
825 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
826 | 708 | ||
827 | BEGIN_FTR_SECTION | 709 | BEGIN_FTR_SECTION |
828 | /* Skip next section on POWER7 or PPC970 */ | 710 | /* Skip next section on POWER7 */ |
829 | b 8f | 711 | b 8f |
830 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | 712 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) |
831 | /* Turn on TM so we can access TFHAR/TFIAR/TEXASR */ | 713 | /* Turn on TM so we can access TFHAR/TFIAR/TEXASR */ |
@@ -901,7 +783,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |||
901 | mtspr SPRN_DAR, r5 | 783 | mtspr SPRN_DAR, r5 |
902 | mtspr SPRN_DSISR, r6 | 784 | mtspr SPRN_DSISR, r6 |
903 | 785 | ||
904 | BEGIN_FTR_SECTION | ||
905 | /* Restore AMR and UAMOR, set AMOR to all 1s */ | 786 | /* Restore AMR and UAMOR, set AMOR to all 1s */ |
906 | ld r5,VCPU_AMR(r4) | 787 | ld r5,VCPU_AMR(r4) |
907 | ld r6,VCPU_UAMOR(r4) | 788 | ld r6,VCPU_UAMOR(r4) |
@@ -909,7 +790,6 @@ BEGIN_FTR_SECTION | |||
909 | mtspr SPRN_AMR,r5 | 790 | mtspr SPRN_AMR,r5 |
910 | mtspr SPRN_UAMOR,r6 | 791 | mtspr SPRN_UAMOR,r6 |
911 | mtspr SPRN_AMOR,r7 | 792 | mtspr SPRN_AMOR,r7 |
912 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
913 | 793 | ||
914 | /* Restore state of CTRL run bit; assume 1 on entry */ | 794 | /* Restore state of CTRL run bit; assume 1 on entry */ |
915 | lwz r5,VCPU_CTRL(r4) | 795 | lwz r5,VCPU_CTRL(r4) |
@@ -944,13 +824,11 @@ deliver_guest_interrupt: | |||
944 | rldicl r0, r0, 64 - BOOK3S_IRQPRIO_EXTERNAL_LEVEL, 63 | 824 | rldicl r0, r0, 64 - BOOK3S_IRQPRIO_EXTERNAL_LEVEL, 63 |
945 | cmpdi cr1, r0, 0 | 825 | cmpdi cr1, r0, 0 |
946 | andi. r8, r11, MSR_EE | 826 | andi. r8, r11, MSR_EE |
947 | BEGIN_FTR_SECTION | ||
948 | mfspr r8, SPRN_LPCR | 827 | mfspr r8, SPRN_LPCR |
949 | /* Insert EXTERNAL_LEVEL bit into LPCR at the MER bit position */ | 828 | /* Insert EXTERNAL_LEVEL bit into LPCR at the MER bit position */ |
950 | rldimi r8, r0, LPCR_MER_SH, 63 - LPCR_MER_SH | 829 | rldimi r8, r0, LPCR_MER_SH, 63 - LPCR_MER_SH |
951 | mtspr SPRN_LPCR, r8 | 830 | mtspr SPRN_LPCR, r8 |
952 | isync | 831 | isync |
953 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
954 | beq 5f | 832 | beq 5f |
955 | li r0, BOOK3S_INTERRUPT_EXTERNAL | 833 | li r0, BOOK3S_INTERRUPT_EXTERNAL |
956 | bne cr1, 12f | 834 | bne cr1, 12f |
@@ -1105,15 +983,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) | |||
1105 | 983 | ||
1106 | stw r12,VCPU_TRAP(r9) | 984 | stw r12,VCPU_TRAP(r9) |
1107 | 985 | ||
1108 | /* Save HEIR (HV emulation assist reg) in last_inst | 986 | /* Save HEIR (HV emulation assist reg) in emul_inst |
1109 | if this is an HEI (HV emulation interrupt, e40) */ | 987 | if this is an HEI (HV emulation interrupt, e40) */ |
1110 | li r3,KVM_INST_FETCH_FAILED | 988 | li r3,KVM_INST_FETCH_FAILED |
1111 | BEGIN_FTR_SECTION | ||
1112 | cmpwi r12,BOOK3S_INTERRUPT_H_EMUL_ASSIST | 989 | cmpwi r12,BOOK3S_INTERRUPT_H_EMUL_ASSIST |
1113 | bne 11f | 990 | bne 11f |
1114 | mfspr r3,SPRN_HEIR | 991 | mfspr r3,SPRN_HEIR |
1115 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | 992 | 11: stw r3,VCPU_HEIR(r9) |
1116 | 11: stw r3,VCPU_LAST_INST(r9) | ||
1117 | 993 | ||
1118 | /* these are volatile across C function calls */ | 994 | /* these are volatile across C function calls */ |
1119 | mfctr r3 | 995 | mfctr r3 |
@@ -1121,13 +997,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | |||
1121 | std r3, VCPU_CTR(r9) | 997 | std r3, VCPU_CTR(r9) |
1122 | stw r4, VCPU_XER(r9) | 998 | stw r4, VCPU_XER(r9) |
1123 | 999 | ||
1124 | BEGIN_FTR_SECTION | ||
1125 | /* If this is a page table miss then see if it's theirs or ours */ | 1000 | /* If this is a page table miss then see if it's theirs or ours */ |
1126 | cmpwi r12, BOOK3S_INTERRUPT_H_DATA_STORAGE | 1001 | cmpwi r12, BOOK3S_INTERRUPT_H_DATA_STORAGE |
1127 | beq kvmppc_hdsi | 1002 | beq kvmppc_hdsi |
1128 | cmpwi r12, BOOK3S_INTERRUPT_H_INST_STORAGE | 1003 | cmpwi r12, BOOK3S_INTERRUPT_H_INST_STORAGE |
1129 | beq kvmppc_hisi | 1004 | beq kvmppc_hisi |
1130 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
1131 | 1005 | ||
1132 | /* See if this is a leftover HDEC interrupt */ | 1006 | /* See if this is a leftover HDEC interrupt */ |
1133 | cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER | 1007 | cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER |
@@ -1140,11 +1014,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | |||
1140 | cmpwi r12,BOOK3S_INTERRUPT_SYSCALL | 1014 | cmpwi r12,BOOK3S_INTERRUPT_SYSCALL |
1141 | beq hcall_try_real_mode | 1015 | beq hcall_try_real_mode |
1142 | 1016 | ||
1143 | /* Only handle external interrupts here on arch 206 and later */ | ||
1144 | BEGIN_FTR_SECTION | ||
1145 | b ext_interrupt_to_host | ||
1146 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) | ||
1147 | |||
1148 | /* External interrupt ? */ | 1017 | /* External interrupt ? */ |
1149 | cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL | 1018 | cmpwi r12, BOOK3S_INTERRUPT_EXTERNAL |
1150 | bne+ ext_interrupt_to_host | 1019 | bne+ ext_interrupt_to_host |
@@ -1174,11 +1043,9 @@ guest_exit_cont: /* r9 = vcpu, r12 = trap, r13 = paca */ | |||
1174 | mfdsisr r7 | 1043 | mfdsisr r7 |
1175 | std r6, VCPU_DAR(r9) | 1044 | std r6, VCPU_DAR(r9) |
1176 | stw r7, VCPU_DSISR(r9) | 1045 | stw r7, VCPU_DSISR(r9) |
1177 | BEGIN_FTR_SECTION | ||
1178 | /* don't overwrite fault_dar/fault_dsisr if HDSI */ | 1046 | /* don't overwrite fault_dar/fault_dsisr if HDSI */ |
1179 | cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE | 1047 | cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE |
1180 | beq 6f | 1048 | beq 6f |
1181 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
1182 | std r6, VCPU_FAULT_DAR(r9) | 1049 | std r6, VCPU_FAULT_DAR(r9) |
1183 | stw r7, VCPU_FAULT_DSISR(r9) | 1050 | stw r7, VCPU_FAULT_DSISR(r9) |
1184 | 1051 | ||
@@ -1217,7 +1084,6 @@ mc_cont: | |||
1217 | /* | 1084 | /* |
1218 | * Save the guest PURR/SPURR | 1085 | * Save the guest PURR/SPURR |
1219 | */ | 1086 | */ |
1220 | BEGIN_FTR_SECTION | ||
1221 | mfspr r5,SPRN_PURR | 1087 | mfspr r5,SPRN_PURR |
1222 | mfspr r6,SPRN_SPURR | 1088 | mfspr r6,SPRN_SPURR |
1223 | ld r7,VCPU_PURR(r9) | 1089 | ld r7,VCPU_PURR(r9) |
@@ -1237,7 +1103,6 @@ BEGIN_FTR_SECTION | |||
1237 | add r4,r4,r6 | 1103 | add r4,r4,r6 |
1238 | mtspr SPRN_PURR,r3 | 1104 | mtspr SPRN_PURR,r3 |
1239 | mtspr SPRN_SPURR,r4 | 1105 | mtspr SPRN_SPURR,r4 |
1240 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_201) | ||
1241 | 1106 | ||
1242 | /* Save DEC */ | 1107 | /* Save DEC */ |
1243 | mfspr r5,SPRN_DEC | 1108 | mfspr r5,SPRN_DEC |
@@ -1287,22 +1152,18 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S) | |||
1287 | 8: | 1152 | 8: |
1288 | 1153 | ||
1289 | /* Save and reset AMR and UAMOR before turning on the MMU */ | 1154 | /* Save and reset AMR and UAMOR before turning on the MMU */ |
1290 | BEGIN_FTR_SECTION | ||
1291 | mfspr r5,SPRN_AMR | 1155 | mfspr r5,SPRN_AMR |
1292 | mfspr r6,SPRN_UAMOR | 1156 | mfspr r6,SPRN_UAMOR |
1293 | std r5,VCPU_AMR(r9) | 1157 | std r5,VCPU_AMR(r9) |
1294 | std r6,VCPU_UAMOR(r9) | 1158 | std r6,VCPU_UAMOR(r9) |
1295 | li r6,0 | 1159 | li r6,0 |
1296 | mtspr SPRN_AMR,r6 | 1160 | mtspr SPRN_AMR,r6 |
1297 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
1298 | 1161 | ||
1299 | /* Switch DSCR back to host value */ | 1162 | /* Switch DSCR back to host value */ |
1300 | BEGIN_FTR_SECTION | ||
1301 | mfspr r8, SPRN_DSCR | 1163 | mfspr r8, SPRN_DSCR |
1302 | ld r7, HSTATE_DSCR(r13) | 1164 | ld r7, HSTATE_DSCR(r13) |
1303 | std r8, VCPU_DSCR(r9) | 1165 | std r8, VCPU_DSCR(r9) |
1304 | mtspr SPRN_DSCR, r7 | 1166 | mtspr SPRN_DSCR, r7 |
1305 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
1306 | 1167 | ||
1307 | /* Save non-volatile GPRs */ | 1168 | /* Save non-volatile GPRs */ |
1308 | std r14, VCPU_GPR(R14)(r9) | 1169 | std r14, VCPU_GPR(R14)(r9) |
@@ -1484,11 +1345,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
1484 | mfspr r4, SPRN_MMCR0 /* save MMCR0 */ | 1345 | mfspr r4, SPRN_MMCR0 /* save MMCR0 */ |
1485 | mtspr SPRN_MMCR0, r3 /* freeze all counters, disable ints */ | 1346 | mtspr SPRN_MMCR0, r3 /* freeze all counters, disable ints */ |
1486 | mfspr r6, SPRN_MMCRA | 1347 | mfspr r6, SPRN_MMCRA |
1487 | BEGIN_FTR_SECTION | 1348 | /* Clear MMCRA in order to disable SDAR updates */ |
1488 | /* On P7, clear MMCRA in order to disable SDAR updates */ | ||
1489 | li r7, 0 | 1349 | li r7, 0 |
1490 | mtspr SPRN_MMCRA, r7 | 1350 | mtspr SPRN_MMCRA, r7 |
1491 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) | ||
1492 | isync | 1351 | isync |
1493 | beq 21f /* if no VPA, save PMU stuff anyway */ | 1352 | beq 21f /* if no VPA, save PMU stuff anyway */ |
1494 | lbz r7, LPPACA_PMCINUSE(r8) | 1353 | lbz r7, LPPACA_PMCINUSE(r8) |
@@ -1513,10 +1372,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
1513 | mfspr r6, SPRN_PMC4 | 1372 | mfspr r6, SPRN_PMC4 |
1514 | mfspr r7, SPRN_PMC5 | 1373 | mfspr r7, SPRN_PMC5 |
1515 | mfspr r8, SPRN_PMC6 | 1374 | mfspr r8, SPRN_PMC6 |
1516 | BEGIN_FTR_SECTION | ||
1517 | mfspr r10, SPRN_PMC7 | ||
1518 | mfspr r11, SPRN_PMC8 | ||
1519 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
1520 | stw r3, VCPU_PMC(r9) | 1375 | stw r3, VCPU_PMC(r9) |
1521 | stw r4, VCPU_PMC + 4(r9) | 1376 | stw r4, VCPU_PMC + 4(r9) |
1522 | stw r5, VCPU_PMC + 8(r9) | 1377 | stw r5, VCPU_PMC + 8(r9) |
@@ -1524,10 +1379,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | |||
1524 | stw r7, VCPU_PMC + 16(r9) | 1379 | stw r7, VCPU_PMC + 16(r9) |
1525 | stw r8, VCPU_PMC + 20(r9) | 1380 | stw r8, VCPU_PMC + 20(r9) |
1526 | BEGIN_FTR_SECTION | 1381 | BEGIN_FTR_SECTION |
1527 | stw r10, VCPU_PMC + 24(r9) | ||
1528 | stw r11, VCPU_PMC + 28(r9) | ||
1529 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
1530 | BEGIN_FTR_SECTION | ||
1531 | mfspr r5, SPRN_SIER | 1382 | mfspr r5, SPRN_SIER |
1532 | mfspr r6, SPRN_SPMC1 | 1383 | mfspr r6, SPRN_SPMC1 |
1533 | mfspr r7, SPRN_SPMC2 | 1384 | mfspr r7, SPRN_SPMC2 |
@@ -1547,11 +1398,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
1547 | ptesync | 1398 | ptesync |
1548 | 1399 | ||
1549 | hdec_soon: /* r12 = trap, r13 = paca */ | 1400 | hdec_soon: /* r12 = trap, r13 = paca */ |
1550 | BEGIN_FTR_SECTION | ||
1551 | b 32f | ||
1552 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | ||
1553 | /* | 1401 | /* |
1554 | * POWER7 guest -> host partition switch code. | 1402 | * POWER7/POWER8 guest -> host partition switch code. |
1555 | * We don't have to lock against tlbies but we do | 1403 | * We don't have to lock against tlbies but we do |
1556 | * have to coordinate the hardware threads. | 1404 | * have to coordinate the hardware threads. |
1557 | */ | 1405 | */ |
@@ -1679,87 +1527,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | |||
1679 | 16: ld r8,KVM_HOST_LPCR(r4) | 1527 | 16: ld r8,KVM_HOST_LPCR(r4) |
1680 | mtspr SPRN_LPCR,r8 | 1528 | mtspr SPRN_LPCR,r8 |
1681 | isync | 1529 | isync |
1682 | b 33f | ||
1683 | |||
1684 | /* | ||
1685 | * PPC970 guest -> host partition switch code. | ||
1686 | * We have to lock against concurrent tlbies, and | ||
1687 | * we have to flush the whole TLB. | ||
1688 | */ | ||
1689 | 32: ld r5,HSTATE_KVM_VCORE(r13) | ||
1690 | ld r4,VCORE_KVM(r5) /* pointer to struct kvm */ | ||
1691 | |||
1692 | /* Take the guest's tlbie_lock */ | ||
1693 | #ifdef __BIG_ENDIAN__ | ||
1694 | lwz r8,PACA_LOCK_TOKEN(r13) | ||
1695 | #else | ||
1696 | lwz r8,PACAPACAINDEX(r13) | ||
1697 | #endif | ||
1698 | addi r3,r4,KVM_TLBIE_LOCK | ||
1699 | 24: lwarx r0,0,r3 | ||
1700 | cmpwi r0,0 | ||
1701 | bne 24b | ||
1702 | stwcx. r8,0,r3 | ||
1703 | bne 24b | ||
1704 | isync | ||
1705 | |||
1706 | ld r7,KVM_HOST_LPCR(r4) /* use kvm->arch.host_lpcr for HID4 */ | ||
1707 | li r0,0x18f | ||
1708 | rotldi r0,r0,HID4_LPID5_SH /* all lpid bits in HID4 = 1 */ | ||
1709 | or r0,r7,r0 | ||
1710 | ptesync | ||
1711 | sync | ||
1712 | mtspr SPRN_HID4,r0 /* switch to reserved LPID */ | ||
1713 | isync | ||
1714 | li r0,0 | ||
1715 | stw r0,0(r3) /* drop guest tlbie_lock */ | ||
1716 | |||
1717 | /* invalidate the whole TLB */ | ||
1718 | li r0,256 | ||
1719 | mtctr r0 | ||
1720 | li r6,0 | ||
1721 | 25: tlbiel r6 | ||
1722 | addi r6,r6,0x1000 | ||
1723 | bdnz 25b | ||
1724 | ptesync | ||
1725 | |||
1726 | /* take native_tlbie_lock */ | ||
1727 | ld r3,toc_tlbie_lock@toc(2) | ||
1728 | 24: lwarx r0,0,r3 | ||
1729 | cmpwi r0,0 | ||
1730 | bne 24b | ||
1731 | stwcx. r8,0,r3 | ||
1732 | bne 24b | ||
1733 | isync | ||
1734 | |||
1735 | ld r6,KVM_HOST_SDR1(r4) | ||
1736 | mtspr SPRN_SDR1,r6 /* switch to host page table */ | ||
1737 | |||
1738 | /* Set up host HID4 value */ | ||
1739 | sync | ||
1740 | mtspr SPRN_HID4,r7 | ||
1741 | isync | ||
1742 | li r0,0 | ||
1743 | stw r0,0(r3) /* drop native_tlbie_lock */ | ||
1744 | |||
1745 | lis r8,0x7fff /* MAX_INT@h */ | ||
1746 | mtspr SPRN_HDEC,r8 | ||
1747 | |||
1748 | /* Disable HDEC interrupts */ | ||
1749 | mfspr r0,SPRN_HID0 | ||
1750 | li r3,0 | ||
1751 | rldimi r0,r3, HID0_HDICE_SH, 64-HID0_HDICE_SH-1 | ||
1752 | sync | ||
1753 | mtspr SPRN_HID0,r0 | ||
1754 | mfspr r0,SPRN_HID0 | ||
1755 | mfspr r0,SPRN_HID0 | ||
1756 | mfspr r0,SPRN_HID0 | ||
1757 | mfspr r0,SPRN_HID0 | ||
1758 | mfspr r0,SPRN_HID0 | ||
1759 | mfspr r0,SPRN_HID0 | ||
1760 | 1530 | ||
1761 | /* load host SLB entries */ | 1531 | /* load host SLB entries */ |
1762 | 33: ld r8,PACA_SLBSHADOWPTR(r13) | 1532 | ld r8,PACA_SLBSHADOWPTR(r13) |
1763 | 1533 | ||
1764 | .rept SLB_NUM_BOLTED | 1534 | .rept SLB_NUM_BOLTED |
1765 | li r3, SLBSHADOW_SAVEAREA | 1535 | li r3, SLBSHADOW_SAVEAREA |
@@ -2028,7 +1798,7 @@ hcall_real_table: | |||
2028 | .long 0 /* 0xd8 */ | 1798 | .long 0 /* 0xd8 */ |
2029 | .long 0 /* 0xdc */ | 1799 | .long 0 /* 0xdc */ |
2030 | .long DOTSYM(kvmppc_h_cede) - hcall_real_table | 1800 | .long DOTSYM(kvmppc_h_cede) - hcall_real_table |
2031 | .long 0 /* 0xe4 */ | 1801 | .long DOTSYM(kvmppc_rm_h_confer) - hcall_real_table |
2032 | .long 0 /* 0xe8 */ | 1802 | .long 0 /* 0xe8 */ |
2033 | .long 0 /* 0xec */ | 1803 | .long 0 /* 0xec */ |
2034 | .long 0 /* 0xf0 */ | 1804 | .long 0 /* 0xf0 */ |
@@ -2107,9 +1877,6 @@ _GLOBAL(kvmppc_h_cede) | |||
2107 | stw r0,VCPU_TRAP(r3) | 1877 | stw r0,VCPU_TRAP(r3) |
2108 | li r0,H_SUCCESS | 1878 | li r0,H_SUCCESS |
2109 | std r0,VCPU_GPR(R3)(r3) | 1879 | std r0,VCPU_GPR(R3)(r3) |
2110 | BEGIN_FTR_SECTION | ||
2111 | b kvm_cede_exit /* just send it up to host on 970 */ | ||
2112 | END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) | ||
2113 | 1880 | ||
2114 | /* | 1881 | /* |
2115 | * Set our bit in the bitmask of napping threads unless all the | 1882 | * Set our bit in the bitmask of napping threads unless all the |
@@ -2435,7 +2202,6 @@ BEGIN_FTR_SECTION | |||
2435 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) | 2202 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) |
2436 | #endif | 2203 | #endif |
2437 | mtmsrd r8 | 2204 | mtmsrd r8 |
2438 | isync | ||
2439 | addi r3,r3,VCPU_FPRS | 2205 | addi r3,r3,VCPU_FPRS |
2440 | bl store_fp_state | 2206 | bl store_fp_state |
2441 | #ifdef CONFIG_ALTIVEC | 2207 | #ifdef CONFIG_ALTIVEC |
@@ -2471,7 +2237,6 @@ BEGIN_FTR_SECTION | |||
2471 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) | 2237 | END_FTR_SECTION_IFSET(CPU_FTR_VSX) |
2472 | #endif | 2238 | #endif |
2473 | mtmsrd r8 | 2239 | mtmsrd r8 |
2474 | isync | ||
2475 | addi r3,r4,VCPU_FPRS | 2240 | addi r3,r4,VCPU_FPRS |
2476 | bl load_fp_state | 2241 | bl load_fp_state |
2477 | #ifdef CONFIG_ALTIVEC | 2242 | #ifdef CONFIG_ALTIVEC |
diff --git a/arch/powerpc/kvm/book3s_paired_singles.c b/arch/powerpc/kvm/book3s_paired_singles.c index bfb8035314e3..bd6ab1672ae6 100644 --- a/arch/powerpc/kvm/book3s_paired_singles.c +++ b/arch/powerpc/kvm/book3s_paired_singles.c | |||
@@ -352,14 +352,6 @@ static inline u32 inst_get_field(u32 inst, int msb, int lsb) | |||
352 | return kvmppc_get_field(inst, msb + 32, lsb + 32); | 352 | return kvmppc_get_field(inst, msb + 32, lsb + 32); |
353 | } | 353 | } |
354 | 354 | ||
355 | /* | ||
356 | * Replaces inst bits with ordering according to spec. | ||
357 | */ | ||
358 | static inline u32 inst_set_field(u32 inst, int msb, int lsb, int value) | ||
359 | { | ||
360 | return kvmppc_set_field(inst, msb + 32, lsb + 32, value); | ||
361 | } | ||
362 | |||
363 | bool kvmppc_inst_is_paired_single(struct kvm_vcpu *vcpu, u32 inst) | 355 | bool kvmppc_inst_is_paired_single(struct kvm_vcpu *vcpu, u32 inst) |
364 | { | 356 | { |
365 | if (!(vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE)) | 357 | if (!(vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE)) |
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c index cf2eb16846d1..f57383941d03 100644 --- a/arch/powerpc/kvm/book3s_pr.c +++ b/arch/powerpc/kvm/book3s_pr.c | |||
@@ -644,11 +644,6 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
644 | return r; | 644 | return r; |
645 | } | 645 | } |
646 | 646 | ||
647 | static inline int get_fpr_index(int i) | ||
648 | { | ||
649 | return i * TS_FPRWIDTH; | ||
650 | } | ||
651 | |||
652 | /* Give up external provider (FPU, Altivec, VSX) */ | 647 | /* Give up external provider (FPU, Altivec, VSX) */ |
653 | void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr) | 648 | void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr) |
654 | { | 649 | { |
diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c index eaeb78047fb8..807351f76f84 100644 --- a/arch/powerpc/kvm/book3s_xics.c +++ b/arch/powerpc/kvm/book3s_xics.c | |||
@@ -613,10 +613,25 @@ static noinline int kvmppc_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, | |||
613 | * there might be a previously-rejected interrupt needing | 613 | * there might be a previously-rejected interrupt needing |
614 | * to be resent. | 614 | * to be resent. |
615 | * | 615 | * |
616 | * ICP state: Check_IPI | ||
617 | * | ||
616 | * If the CPPR is less favored, then we might be replacing | 618 | * If the CPPR is less favored, then we might be replacing |
617 | * an interrupt, and thus need to possibly reject it as in | 619 | * an interrupt, and thus need to possibly reject it. |
618 | * | 620 | * |
619 | * ICP state: Check_IPI | 621 | * ICP State: IPI |
622 | * | ||
623 | * Besides rejecting any pending interrupts, we also | ||
624 | * update XISR and pending_pri to mark IPI as pending. | ||
625 | * | ||
626 | * PAPR does not describe this state, but if the MFRR is being | ||
627 | * made less favored than its earlier value, there might be | ||
628 | * a previously-rejected interrupt needing to be resent. | ||
629 | * Ideally, we would want to resend only if | ||
630 | * prio(pending_interrupt) < mfrr && | ||
631 | * prio(pending_interrupt) < cppr | ||
632 | * where pending interrupt is the one that was rejected. But | ||
633 | * we don't have that state, so we simply trigger a resend | ||
634 | * whenever the MFRR is made less favored. | ||
620 | */ | 635 | */ |
621 | do { | 636 | do { |
622 | old_state = new_state = ACCESS_ONCE(icp->state); | 637 | old_state = new_state = ACCESS_ONCE(icp->state); |
@@ -629,13 +644,14 @@ static noinline int kvmppc_h_ipi(struct kvm_vcpu *vcpu, unsigned long server, | |||
629 | resend = false; | 644 | resend = false; |
630 | if (mfrr < new_state.cppr) { | 645 | if (mfrr < new_state.cppr) { |
631 | /* Reject a pending interrupt if not an IPI */ | 646 | /* Reject a pending interrupt if not an IPI */ |
632 | if (mfrr <= new_state.pending_pri) | 647 | if (mfrr <= new_state.pending_pri) { |
633 | reject = new_state.xisr; | 648 | reject = new_state.xisr; |
634 | new_state.pending_pri = mfrr; | 649 | new_state.pending_pri = mfrr; |
635 | new_state.xisr = XICS_IPI; | 650 | new_state.xisr = XICS_IPI; |
651 | } | ||
636 | } | 652 | } |
637 | 653 | ||
638 | if (mfrr > old_state.mfrr && mfrr > new_state.cppr) { | 654 | if (mfrr > old_state.mfrr) { |
639 | resend = new_state.need_resend; | 655 | resend = new_state.need_resend; |
640 | new_state.need_resend = 0; | 656 | new_state.need_resend = 0; |
641 | } | 657 | } |
@@ -789,7 +805,7 @@ static noinline int kvmppc_xics_rm_complete(struct kvm_vcpu *vcpu, u32 hcall) | |||
789 | if (icp->rm_action & XICS_RM_KICK_VCPU) | 805 | if (icp->rm_action & XICS_RM_KICK_VCPU) |
790 | kvmppc_fast_vcpu_kick(icp->rm_kick_target); | 806 | kvmppc_fast_vcpu_kick(icp->rm_kick_target); |
791 | if (icp->rm_action & XICS_RM_CHECK_RESEND) | 807 | if (icp->rm_action & XICS_RM_CHECK_RESEND) |
792 | icp_check_resend(xics, icp); | 808 | icp_check_resend(xics, icp->rm_resend_icp); |
793 | if (icp->rm_action & XICS_RM_REJECT) | 809 | if (icp->rm_action & XICS_RM_REJECT) |
794 | icp_deliver_irq(xics, icp, icp->rm_reject); | 810 | icp_deliver_irq(xics, icp, icp->rm_reject); |
795 | if (icp->rm_action & XICS_RM_NOTIFY_EOI) | 811 | if (icp->rm_action & XICS_RM_NOTIFY_EOI) |
diff --git a/arch/powerpc/kvm/book3s_xics.h b/arch/powerpc/kvm/book3s_xics.h index e8aaa7a3f209..73f0f2723c07 100644 --- a/arch/powerpc/kvm/book3s_xics.h +++ b/arch/powerpc/kvm/book3s_xics.h | |||
@@ -74,6 +74,7 @@ struct kvmppc_icp { | |||
74 | #define XICS_RM_NOTIFY_EOI 0x8 | 74 | #define XICS_RM_NOTIFY_EOI 0x8 |
75 | u32 rm_action; | 75 | u32 rm_action; |
76 | struct kvm_vcpu *rm_kick_target; | 76 | struct kvm_vcpu *rm_kick_target; |
77 | struct kvmppc_icp *rm_resend_icp; | ||
77 | u32 rm_reject; | 78 | u32 rm_reject; |
78 | u32 rm_eoied_irq; | 79 | u32 rm_eoied_irq; |
79 | 80 | ||
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c index 2e02ed849f36..be4f3fd460a9 100644 --- a/arch/powerpc/kvm/e500.c +++ b/arch/powerpc/kvm/e500.c | |||
@@ -299,14 +299,6 @@ void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr) | |||
299 | kvmppc_e500_recalc_shadow_pid(to_e500(vcpu)); | 299 | kvmppc_e500_recalc_shadow_pid(to_e500(vcpu)); |
300 | } | 300 | } |
301 | 301 | ||
302 | void kvmppc_core_load_host_debugstate(struct kvm_vcpu *vcpu) | ||
303 | { | ||
304 | } | ||
305 | |||
306 | void kvmppc_core_load_guest_debugstate(struct kvm_vcpu *vcpu) | ||
307 | { | ||
308 | } | ||
309 | |||
310 | static void kvmppc_core_vcpu_load_e500(struct kvm_vcpu *vcpu, int cpu) | 302 | static void kvmppc_core_vcpu_load_e500(struct kvm_vcpu *vcpu, int cpu) |
311 | { | 303 | { |
312 | kvmppc_booke_vcpu_load(vcpu, cpu); | 304 | kvmppc_booke_vcpu_load(vcpu, cpu); |
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c index c1f8f53cd312..c45eaab752b0 100644 --- a/arch/powerpc/kvm/powerpc.c +++ b/arch/powerpc/kvm/powerpc.c | |||
@@ -527,18 +527,12 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) | |||
527 | r = 0; | 527 | r = 0; |
528 | break; | 528 | break; |
529 | case KVM_CAP_PPC_RMA: | 529 | case KVM_CAP_PPC_RMA: |
530 | r = hv_enabled; | 530 | r = 0; |
531 | /* PPC970 requires an RMA */ | ||
532 | if (r && cpu_has_feature(CPU_FTR_ARCH_201)) | ||
533 | r = 2; | ||
534 | break; | 531 | break; |
535 | #endif | 532 | #endif |
536 | case KVM_CAP_SYNC_MMU: | 533 | case KVM_CAP_SYNC_MMU: |
537 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE | 534 | #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE |
538 | if (hv_enabled) | 535 | r = hv_enabled; |
539 | r = cpu_has_feature(CPU_FTR_ARCH_206) ? 1 : 0; | ||
540 | else | ||
541 | r = 0; | ||
542 | #elif defined(KVM_ARCH_WANT_MMU_NOTIFIER) | 536 | #elif defined(KVM_ARCH_WANT_MMU_NOTIFIER) |
543 | r = 1; | 537 | r = 1; |
544 | #else | 538 | #else |
diff --git a/arch/powerpc/kvm/trace_book3s.h b/arch/powerpc/kvm/trace_book3s.h new file mode 100644 index 000000000000..f647ce0f428b --- /dev/null +++ b/arch/powerpc/kvm/trace_book3s.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #if !defined(_TRACE_KVM_BOOK3S_H) | ||
2 | #define _TRACE_KVM_BOOK3S_H | ||
3 | |||
4 | /* | ||
5 | * Common defines used by the trace macros in trace_pr.h and trace_hv.h | ||
6 | */ | ||
7 | |||
8 | #define kvm_trace_symbol_exit \ | ||
9 | {0x100, "SYSTEM_RESET"}, \ | ||
10 | {0x200, "MACHINE_CHECK"}, \ | ||
11 | {0x300, "DATA_STORAGE"}, \ | ||
12 | {0x380, "DATA_SEGMENT"}, \ | ||
13 | {0x400, "INST_STORAGE"}, \ | ||
14 | {0x480, "INST_SEGMENT"}, \ | ||
15 | {0x500, "EXTERNAL"}, \ | ||
16 | {0x501, "EXTERNAL_LEVEL"}, \ | ||
17 | {0x502, "EXTERNAL_HV"}, \ | ||
18 | {0x600, "ALIGNMENT"}, \ | ||
19 | {0x700, "PROGRAM"}, \ | ||
20 | {0x800, "FP_UNAVAIL"}, \ | ||
21 | {0x900, "DECREMENTER"}, \ | ||
22 | {0x980, "HV_DECREMENTER"}, \ | ||
23 | {0xc00, "SYSCALL"}, \ | ||
24 | {0xd00, "TRACE"}, \ | ||
25 | {0xe00, "H_DATA_STORAGE"}, \ | ||
26 | {0xe20, "H_INST_STORAGE"}, \ | ||
27 | {0xe40, "H_EMUL_ASSIST"}, \ | ||
28 | {0xf00, "PERFMON"}, \ | ||
29 | {0xf20, "ALTIVEC"}, \ | ||
30 | {0xf40, "VSX"} | ||
31 | |||
32 | #endif | ||
diff --git a/arch/powerpc/kvm/trace_booke.h b/arch/powerpc/kvm/trace_booke.h index f7537cf26ce7..7ec534d1db9f 100644 --- a/arch/powerpc/kvm/trace_booke.h +++ b/arch/powerpc/kvm/trace_booke.h | |||
@@ -151,6 +151,47 @@ TRACE_EVENT(kvm_booke206_ref_release, | |||
151 | __entry->pfn, __entry->flags) | 151 | __entry->pfn, __entry->flags) |
152 | ); | 152 | ); |
153 | 153 | ||
154 | #ifdef CONFIG_SPE_POSSIBLE | ||
155 | #define kvm_trace_symbol_irqprio_spe \ | ||
156 | {BOOKE_IRQPRIO_SPE_UNAVAIL, "SPE_UNAVAIL"}, \ | ||
157 | {BOOKE_IRQPRIO_SPE_FP_DATA, "SPE_FP_DATA"}, \ | ||
158 | {BOOKE_IRQPRIO_SPE_FP_ROUND, "SPE_FP_ROUND"}, | ||
159 | #else | ||
160 | #define kvm_trace_symbol_irqprio_spe | ||
161 | #endif | ||
162 | |||
163 | #ifdef CONFIG_PPC_E500MC | ||
164 | #define kvm_trace_symbol_irqprio_e500mc \ | ||
165 | {BOOKE_IRQPRIO_ALTIVEC_UNAVAIL, "ALTIVEC_UNAVAIL"}, \ | ||
166 | {BOOKE_IRQPRIO_ALTIVEC_ASSIST, "ALTIVEC_ASSIST"}, | ||
167 | #else | ||
168 | #define kvm_trace_symbol_irqprio_e500mc | ||
169 | #endif | ||
170 | |||
171 | #define kvm_trace_symbol_irqprio \ | ||
172 | kvm_trace_symbol_irqprio_spe \ | ||
173 | kvm_trace_symbol_irqprio_e500mc \ | ||
174 | {BOOKE_IRQPRIO_DATA_STORAGE, "DATA_STORAGE"}, \ | ||
175 | {BOOKE_IRQPRIO_INST_STORAGE, "INST_STORAGE"}, \ | ||
176 | {BOOKE_IRQPRIO_ALIGNMENT, "ALIGNMENT"}, \ | ||
177 | {BOOKE_IRQPRIO_PROGRAM, "PROGRAM"}, \ | ||
178 | {BOOKE_IRQPRIO_FP_UNAVAIL, "FP_UNAVAIL"}, \ | ||
179 | {BOOKE_IRQPRIO_SYSCALL, "SYSCALL"}, \ | ||
180 | {BOOKE_IRQPRIO_AP_UNAVAIL, "AP_UNAVAIL"}, \ | ||
181 | {BOOKE_IRQPRIO_DTLB_MISS, "DTLB_MISS"}, \ | ||
182 | {BOOKE_IRQPRIO_ITLB_MISS, "ITLB_MISS"}, \ | ||
183 | {BOOKE_IRQPRIO_MACHINE_CHECK, "MACHINE_CHECK"}, \ | ||
184 | {BOOKE_IRQPRIO_DEBUG, "DEBUG"}, \ | ||
185 | {BOOKE_IRQPRIO_CRITICAL, "CRITICAL"}, \ | ||
186 | {BOOKE_IRQPRIO_WATCHDOG, "WATCHDOG"}, \ | ||
187 | {BOOKE_IRQPRIO_EXTERNAL, "EXTERNAL"}, \ | ||
188 | {BOOKE_IRQPRIO_FIT, "FIT"}, \ | ||
189 | {BOOKE_IRQPRIO_DECREMENTER, "DECREMENTER"}, \ | ||
190 | {BOOKE_IRQPRIO_PERFORMANCE_MONITOR, "PERFORMANCE_MONITOR"}, \ | ||
191 | {BOOKE_IRQPRIO_EXTERNAL_LEVEL, "EXTERNAL_LEVEL"}, \ | ||
192 | {BOOKE_IRQPRIO_DBELL, "DBELL"}, \ | ||
193 | {BOOKE_IRQPRIO_DBELL_CRIT, "DBELL_CRIT"} \ | ||
194 | |||
154 | TRACE_EVENT(kvm_booke_queue_irqprio, | 195 | TRACE_EVENT(kvm_booke_queue_irqprio, |
155 | TP_PROTO(struct kvm_vcpu *vcpu, unsigned int priority), | 196 | TP_PROTO(struct kvm_vcpu *vcpu, unsigned int priority), |
156 | TP_ARGS(vcpu, priority), | 197 | TP_ARGS(vcpu, priority), |
@@ -167,8 +208,10 @@ TRACE_EVENT(kvm_booke_queue_irqprio, | |||
167 | __entry->pending = vcpu->arch.pending_exceptions; | 208 | __entry->pending = vcpu->arch.pending_exceptions; |
168 | ), | 209 | ), |
169 | 210 | ||
170 | TP_printk("vcpu=%x prio=%x pending=%lx", | 211 | TP_printk("vcpu=%x prio=%s pending=%lx", |
171 | __entry->cpu_nr, __entry->priority, __entry->pending) | 212 | __entry->cpu_nr, |
213 | __print_symbolic(__entry->priority, kvm_trace_symbol_irqprio), | ||
214 | __entry->pending) | ||
172 | ); | 215 | ); |
173 | 216 | ||
174 | #endif | 217 | #endif |
diff --git a/arch/powerpc/kvm/trace_hv.h b/arch/powerpc/kvm/trace_hv.h new file mode 100644 index 000000000000..33d9daff5783 --- /dev/null +++ b/arch/powerpc/kvm/trace_hv.h | |||
@@ -0,0 +1,477 @@ | |||
1 | #if !defined(_TRACE_KVM_HV_H) || defined(TRACE_HEADER_MULTI_READ) | ||
2 | #define _TRACE_KVM_HV_H | ||
3 | |||
4 | #include <linux/tracepoint.h> | ||
5 | #include "trace_book3s.h" | ||
6 | #include <asm/hvcall.h> | ||
7 | #include <asm/kvm_asm.h> | ||
8 | |||
9 | #undef TRACE_SYSTEM | ||
10 | #define TRACE_SYSTEM kvm_hv | ||
11 | #define TRACE_INCLUDE_PATH . | ||
12 | #define TRACE_INCLUDE_FILE trace_hv | ||
13 | |||
14 | #define kvm_trace_symbol_hcall \ | ||
15 | {H_REMOVE, "H_REMOVE"}, \ | ||
16 | {H_ENTER, "H_ENTER"}, \ | ||
17 | {H_READ, "H_READ"}, \ | ||
18 | {H_CLEAR_MOD, "H_CLEAR_MOD"}, \ | ||
19 | {H_CLEAR_REF, "H_CLEAR_REF"}, \ | ||
20 | {H_PROTECT, "H_PROTECT"}, \ | ||
21 | {H_GET_TCE, "H_GET_TCE"}, \ | ||
22 | {H_PUT_TCE, "H_PUT_TCE"}, \ | ||
23 | {H_SET_SPRG0, "H_SET_SPRG0"}, \ | ||
24 | {H_SET_DABR, "H_SET_DABR"}, \ | ||
25 | {H_PAGE_INIT, "H_PAGE_INIT"}, \ | ||
26 | {H_SET_ASR, "H_SET_ASR"}, \ | ||
27 | {H_ASR_ON, "H_ASR_ON"}, \ | ||
28 | {H_ASR_OFF, "H_ASR_OFF"}, \ | ||
29 | {H_LOGICAL_CI_LOAD, "H_LOGICAL_CI_LOAD"}, \ | ||
30 | {H_LOGICAL_CI_STORE, "H_LOGICAL_CI_STORE"}, \ | ||
31 | {H_LOGICAL_CACHE_LOAD, "H_LOGICAL_CACHE_LOAD"}, \ | ||
32 | {H_LOGICAL_CACHE_STORE, "H_LOGICAL_CACHE_STORE"}, \ | ||
33 | {H_LOGICAL_ICBI, "H_LOGICAL_ICBI"}, \ | ||
34 | {H_LOGICAL_DCBF, "H_LOGICAL_DCBF"}, \ | ||
35 | {H_GET_TERM_CHAR, "H_GET_TERM_CHAR"}, \ | ||
36 | {H_PUT_TERM_CHAR, "H_PUT_TERM_CHAR"}, \ | ||
37 | {H_REAL_TO_LOGICAL, "H_REAL_TO_LOGICAL"}, \ | ||
38 | {H_HYPERVISOR_DATA, "H_HYPERVISOR_DATA"}, \ | ||
39 | {H_EOI, "H_EOI"}, \ | ||
40 | {H_CPPR, "H_CPPR"}, \ | ||
41 | {H_IPI, "H_IPI"}, \ | ||
42 | {H_IPOLL, "H_IPOLL"}, \ | ||
43 | {H_XIRR, "H_XIRR"}, \ | ||
44 | {H_PERFMON, "H_PERFMON"}, \ | ||
45 | {H_MIGRATE_DMA, "H_MIGRATE_DMA"}, \ | ||
46 | {H_REGISTER_VPA, "H_REGISTER_VPA"}, \ | ||
47 | {H_CEDE, "H_CEDE"}, \ | ||
48 | {H_CONFER, "H_CONFER"}, \ | ||
49 | {H_PROD, "H_PROD"}, \ | ||
50 | {H_GET_PPP, "H_GET_PPP"}, \ | ||
51 | {H_SET_PPP, "H_SET_PPP"}, \ | ||
52 | {H_PURR, "H_PURR"}, \ | ||
53 | {H_PIC, "H_PIC"}, \ | ||
54 | {H_REG_CRQ, "H_REG_CRQ"}, \ | ||
55 | {H_FREE_CRQ, "H_FREE_CRQ"}, \ | ||
56 | {H_VIO_SIGNAL, "H_VIO_SIGNAL"}, \ | ||
57 | {H_SEND_CRQ, "H_SEND_CRQ"}, \ | ||
58 | {H_COPY_RDMA, "H_COPY_RDMA"}, \ | ||
59 | {H_REGISTER_LOGICAL_LAN, "H_REGISTER_LOGICAL_LAN"}, \ | ||
60 | {H_FREE_LOGICAL_LAN, "H_FREE_LOGICAL_LAN"}, \ | ||
61 | {H_ADD_LOGICAL_LAN_BUFFER, "H_ADD_LOGICAL_LAN_BUFFER"}, \ | ||
62 | {H_SEND_LOGICAL_LAN, "H_SEND_LOGICAL_LAN"}, \ | ||
63 | {H_BULK_REMOVE, "H_BULK_REMOVE"}, \ | ||
64 | {H_MULTICAST_CTRL, "H_MULTICAST_CTRL"}, \ | ||
65 | {H_SET_XDABR, "H_SET_XDABR"}, \ | ||
66 | {H_STUFF_TCE, "H_STUFF_TCE"}, \ | ||
67 | {H_PUT_TCE_INDIRECT, "H_PUT_TCE_INDIRECT"}, \ | ||
68 | {H_CHANGE_LOGICAL_LAN_MAC, "H_CHANGE_LOGICAL_LAN_MAC"}, \ | ||
69 | {H_VTERM_PARTNER_INFO, "H_VTERM_PARTNER_INFO"}, \ | ||
70 | {H_REGISTER_VTERM, "H_REGISTER_VTERM"}, \ | ||
71 | {H_FREE_VTERM, "H_FREE_VTERM"}, \ | ||
72 | {H_RESET_EVENTS, "H_RESET_EVENTS"}, \ | ||
73 | {H_ALLOC_RESOURCE, "H_ALLOC_RESOURCE"}, \ | ||
74 | {H_FREE_RESOURCE, "H_FREE_RESOURCE"}, \ | ||
75 | {H_MODIFY_QP, "H_MODIFY_QP"}, \ | ||
76 | {H_QUERY_QP, "H_QUERY_QP"}, \ | ||
77 | {H_REREGISTER_PMR, "H_REREGISTER_PMR"}, \ | ||
78 | {H_REGISTER_SMR, "H_REGISTER_SMR"}, \ | ||
79 | {H_QUERY_MR, "H_QUERY_MR"}, \ | ||
80 | {H_QUERY_MW, "H_QUERY_MW"}, \ | ||
81 | {H_QUERY_HCA, "H_QUERY_HCA"}, \ | ||
82 | {H_QUERY_PORT, "H_QUERY_PORT"}, \ | ||
83 | {H_MODIFY_PORT, "H_MODIFY_PORT"}, \ | ||
84 | {H_DEFINE_AQP1, "H_DEFINE_AQP1"}, \ | ||
85 | {H_GET_TRACE_BUFFER, "H_GET_TRACE_BUFFER"}, \ | ||
86 | {H_DEFINE_AQP0, "H_DEFINE_AQP0"}, \ | ||
87 | {H_RESIZE_MR, "H_RESIZE_MR"}, \ | ||
88 | {H_ATTACH_MCQP, "H_ATTACH_MCQP"}, \ | ||
89 | {H_DETACH_MCQP, "H_DETACH_MCQP"}, \ | ||
90 | {H_CREATE_RPT, "H_CREATE_RPT"}, \ | ||
91 | {H_REMOVE_RPT, "H_REMOVE_RPT"}, \ | ||
92 | {H_REGISTER_RPAGES, "H_REGISTER_RPAGES"}, \ | ||
93 | {H_DISABLE_AND_GETC, "H_DISABLE_AND_GETC"}, \ | ||
94 | {H_ERROR_DATA, "H_ERROR_DATA"}, \ | ||
95 | {H_GET_HCA_INFO, "H_GET_HCA_INFO"}, \ | ||
96 | {H_GET_PERF_COUNT, "H_GET_PERF_COUNT"}, \ | ||
97 | {H_MANAGE_TRACE, "H_MANAGE_TRACE"}, \ | ||
98 | {H_FREE_LOGICAL_LAN_BUFFER, "H_FREE_LOGICAL_LAN_BUFFER"}, \ | ||
99 | {H_QUERY_INT_STATE, "H_QUERY_INT_STATE"}, \ | ||
100 | {H_POLL_PENDING, "H_POLL_PENDING"}, \ | ||
101 | {H_ILLAN_ATTRIBUTES, "H_ILLAN_ATTRIBUTES"}, \ | ||
102 | {H_MODIFY_HEA_QP, "H_MODIFY_HEA_QP"}, \ | ||
103 | {H_QUERY_HEA_QP, "H_QUERY_HEA_QP"}, \ | ||
104 | {H_QUERY_HEA, "H_QUERY_HEA"}, \ | ||
105 | {H_QUERY_HEA_PORT, "H_QUERY_HEA_PORT"}, \ | ||
106 | {H_MODIFY_HEA_PORT, "H_MODIFY_HEA_PORT"}, \ | ||
107 | {H_REG_BCMC, "H_REG_BCMC"}, \ | ||
108 | {H_DEREG_BCMC, "H_DEREG_BCMC"}, \ | ||
109 | {H_REGISTER_HEA_RPAGES, "H_REGISTER_HEA_RPAGES"}, \ | ||
110 | {H_DISABLE_AND_GET_HEA, "H_DISABLE_AND_GET_HEA"}, \ | ||
111 | {H_GET_HEA_INFO, "H_GET_HEA_INFO"}, \ | ||
112 | {H_ALLOC_HEA_RESOURCE, "H_ALLOC_HEA_RESOURCE"}, \ | ||
113 | {H_ADD_CONN, "H_ADD_CONN"}, \ | ||
114 | {H_DEL_CONN, "H_DEL_CONN"}, \ | ||
115 | {H_JOIN, "H_JOIN"}, \ | ||
116 | {H_VASI_STATE, "H_VASI_STATE"}, \ | ||
117 | {H_ENABLE_CRQ, "H_ENABLE_CRQ"}, \ | ||
118 | {H_GET_EM_PARMS, "H_GET_EM_PARMS"}, \ | ||
119 | {H_SET_MPP, "H_SET_MPP"}, \ | ||
120 | {H_GET_MPP, "H_GET_MPP"}, \ | ||
121 | {H_HOME_NODE_ASSOCIATIVITY, "H_HOME_NODE_ASSOCIATIVITY"}, \ | ||
122 | {H_BEST_ENERGY, "H_BEST_ENERGY"}, \ | ||
123 | {H_XIRR_X, "H_XIRR_X"}, \ | ||
124 | {H_RANDOM, "H_RANDOM"}, \ | ||
125 | {H_COP, "H_COP"}, \ | ||
126 | {H_GET_MPP_X, "H_GET_MPP_X"}, \ | ||
127 | {H_SET_MODE, "H_SET_MODE"}, \ | ||
128 | {H_RTAS, "H_RTAS"} | ||
129 | |||
130 | #define kvm_trace_symbol_kvmret \ | ||
131 | {RESUME_GUEST, "RESUME_GUEST"}, \ | ||
132 | {RESUME_GUEST_NV, "RESUME_GUEST_NV"}, \ | ||
133 | {RESUME_HOST, "RESUME_HOST"}, \ | ||
134 | {RESUME_HOST_NV, "RESUME_HOST_NV"} | ||
135 | |||
136 | #define kvm_trace_symbol_hcall_rc \ | ||
137 | {H_SUCCESS, "H_SUCCESS"}, \ | ||
138 | {H_BUSY, "H_BUSY"}, \ | ||
139 | {H_CLOSED, "H_CLOSED"}, \ | ||
140 | {H_NOT_AVAILABLE, "H_NOT_AVAILABLE"}, \ | ||
141 | {H_CONSTRAINED, "H_CONSTRAINED"}, \ | ||
142 | {H_PARTIAL, "H_PARTIAL"}, \ | ||
143 | {H_IN_PROGRESS, "H_IN_PROGRESS"}, \ | ||
144 | {H_PAGE_REGISTERED, "H_PAGE_REGISTERED"}, \ | ||
145 | {H_PARTIAL_STORE, "H_PARTIAL_STORE"}, \ | ||
146 | {H_PENDING, "H_PENDING"}, \ | ||
147 | {H_CONTINUE, "H_CONTINUE"}, \ | ||
148 | {H_LONG_BUSY_START_RANGE, "H_LONG_BUSY_START_RANGE"}, \ | ||
149 | {H_LONG_BUSY_ORDER_1_MSEC, "H_LONG_BUSY_ORDER_1_MSEC"}, \ | ||
150 | {H_LONG_BUSY_ORDER_10_MSEC, "H_LONG_BUSY_ORDER_10_MSEC"}, \ | ||
151 | {H_LONG_BUSY_ORDER_100_MSEC, "H_LONG_BUSY_ORDER_100_MSEC"}, \ | ||
152 | {H_LONG_BUSY_ORDER_1_SEC, "H_LONG_BUSY_ORDER_1_SEC"}, \ | ||
153 | {H_LONG_BUSY_ORDER_10_SEC, "H_LONG_BUSY_ORDER_10_SEC"}, \ | ||
154 | {H_LONG_BUSY_ORDER_100_SEC, "H_LONG_BUSY_ORDER_100_SEC"}, \ | ||
155 | {H_LONG_BUSY_END_RANGE, "H_LONG_BUSY_END_RANGE"}, \ | ||
156 | {H_TOO_HARD, "H_TOO_HARD"}, \ | ||
157 | {H_HARDWARE, "H_HARDWARE"}, \ | ||
158 | {H_FUNCTION, "H_FUNCTION"}, \ | ||
159 | {H_PRIVILEGE, "H_PRIVILEGE"}, \ | ||
160 | {H_PARAMETER, "H_PARAMETER"}, \ | ||
161 | {H_BAD_MODE, "H_BAD_MODE"}, \ | ||
162 | {H_PTEG_FULL, "H_PTEG_FULL"}, \ | ||
163 | {H_NOT_FOUND, "H_NOT_FOUND"}, \ | ||
164 | {H_RESERVED_DABR, "H_RESERVED_DABR"}, \ | ||
165 | {H_NO_MEM, "H_NO_MEM"}, \ | ||
166 | {H_AUTHORITY, "H_AUTHORITY"}, \ | ||
167 | {H_PERMISSION, "H_PERMISSION"}, \ | ||
168 | {H_DROPPED, "H_DROPPED"}, \ | ||
169 | {H_SOURCE_PARM, "H_SOURCE_PARM"}, \ | ||
170 | {H_DEST_PARM, "H_DEST_PARM"}, \ | ||
171 | {H_REMOTE_PARM, "H_REMOTE_PARM"}, \ | ||
172 | {H_RESOURCE, "H_RESOURCE"}, \ | ||
173 | {H_ADAPTER_PARM, "H_ADAPTER_PARM"}, \ | ||
174 | {H_RH_PARM, "H_RH_PARM"}, \ | ||
175 | {H_RCQ_PARM, "H_RCQ_PARM"}, \ | ||
176 | {H_SCQ_PARM, "H_SCQ_PARM"}, \ | ||
177 | {H_EQ_PARM, "H_EQ_PARM"}, \ | ||
178 | {H_RT_PARM, "H_RT_PARM"}, \ | ||
179 | {H_ST_PARM, "H_ST_PARM"}, \ | ||
180 | {H_SIGT_PARM, "H_SIGT_PARM"}, \ | ||
181 | {H_TOKEN_PARM, "H_TOKEN_PARM"}, \ | ||
182 | {H_MLENGTH_PARM, "H_MLENGTH_PARM"}, \ | ||
183 | {H_MEM_PARM, "H_MEM_PARM"}, \ | ||
184 | {H_MEM_ACCESS_PARM, "H_MEM_ACCESS_PARM"}, \ | ||
185 | {H_ATTR_PARM, "H_ATTR_PARM"}, \ | ||
186 | {H_PORT_PARM, "H_PORT_PARM"}, \ | ||
187 | {H_MCG_PARM, "H_MCG_PARM"}, \ | ||
188 | {H_VL_PARM, "H_VL_PARM"}, \ | ||
189 | {H_TSIZE_PARM, "H_TSIZE_PARM"}, \ | ||
190 | {H_TRACE_PARM, "H_TRACE_PARM"}, \ | ||
191 | {H_MASK_PARM, "H_MASK_PARM"}, \ | ||
192 | {H_MCG_FULL, "H_MCG_FULL"}, \ | ||
193 | {H_ALIAS_EXIST, "H_ALIAS_EXIST"}, \ | ||
194 | {H_P_COUNTER, "H_P_COUNTER"}, \ | ||
195 | {H_TABLE_FULL, "H_TABLE_FULL"}, \ | ||
196 | {H_ALT_TABLE, "H_ALT_TABLE"}, \ | ||
197 | {H_MR_CONDITION, "H_MR_CONDITION"}, \ | ||
198 | {H_NOT_ENOUGH_RESOURCES, "H_NOT_ENOUGH_RESOURCES"}, \ | ||
199 | {H_R_STATE, "H_R_STATE"}, \ | ||
200 | {H_RESCINDED, "H_RESCINDED"}, \ | ||
201 | {H_P2, "H_P2"}, \ | ||
202 | {H_P3, "H_P3"}, \ | ||
203 | {H_P4, "H_P4"}, \ | ||
204 | {H_P5, "H_P5"}, \ | ||
205 | {H_P6, "H_P6"}, \ | ||
206 | {H_P7, "H_P7"}, \ | ||
207 | {H_P8, "H_P8"}, \ | ||
208 | {H_P9, "H_P9"}, \ | ||
209 | {H_TOO_BIG, "H_TOO_BIG"}, \ | ||
210 | {H_OVERLAP, "H_OVERLAP"}, \ | ||
211 | {H_INTERRUPT, "H_INTERRUPT"}, \ | ||
212 | {H_BAD_DATA, "H_BAD_DATA"}, \ | ||
213 | {H_NOT_ACTIVE, "H_NOT_ACTIVE"}, \ | ||
214 | {H_SG_LIST, "H_SG_LIST"}, \ | ||
215 | {H_OP_MODE, "H_OP_MODE"}, \ | ||
216 | {H_COP_HW, "H_COP_HW"}, \ | ||
217 | {H_UNSUPPORTED_FLAG_START, "H_UNSUPPORTED_FLAG_START"}, \ | ||
218 | {H_UNSUPPORTED_FLAG_END, "H_UNSUPPORTED_FLAG_END"}, \ | ||
219 | {H_MULTI_THREADS_ACTIVE, "H_MULTI_THREADS_ACTIVE"}, \ | ||
220 | {H_OUTSTANDING_COP_OPS, "H_OUTSTANDING_COP_OPS"} | ||
221 | |||
222 | TRACE_EVENT(kvm_guest_enter, | ||
223 | TP_PROTO(struct kvm_vcpu *vcpu), | ||
224 | TP_ARGS(vcpu), | ||
225 | |||
226 | TP_STRUCT__entry( | ||
227 | __field(int, vcpu_id) | ||
228 | __field(unsigned long, pc) | ||
229 | __field(unsigned long, pending_exceptions) | ||
230 | __field(u8, ceded) | ||
231 | ), | ||
232 | |||
233 | TP_fast_assign( | ||
234 | __entry->vcpu_id = vcpu->vcpu_id; | ||
235 | __entry->pc = kvmppc_get_pc(vcpu); | ||
236 | __entry->ceded = vcpu->arch.ceded; | ||
237 | __entry->pending_exceptions = vcpu->arch.pending_exceptions; | ||
238 | ), | ||
239 | |||
240 | TP_printk("VCPU %d: pc=0x%lx pexcp=0x%lx ceded=%d", | ||
241 | __entry->vcpu_id, | ||
242 | __entry->pc, | ||
243 | __entry->pending_exceptions, __entry->ceded) | ||
244 | ); | ||
245 | |||
246 | TRACE_EVENT(kvm_guest_exit, | ||
247 | TP_PROTO(struct kvm_vcpu *vcpu), | ||
248 | TP_ARGS(vcpu), | ||
249 | |||
250 | TP_STRUCT__entry( | ||
251 | __field(int, vcpu_id) | ||
252 | __field(int, trap) | ||
253 | __field(unsigned long, pc) | ||
254 | __field(unsigned long, msr) | ||
255 | __field(u8, ceded) | ||
256 | ), | ||
257 | |||
258 | TP_fast_assign( | ||
259 | __entry->vcpu_id = vcpu->vcpu_id; | ||
260 | __entry->trap = vcpu->arch.trap; | ||
261 | __entry->ceded = vcpu->arch.ceded; | ||
262 | __entry->pc = kvmppc_get_pc(vcpu); | ||
263 | __entry->msr = vcpu->arch.shregs.msr; | ||
264 | ), | ||
265 | |||
266 | TP_printk("VCPU %d: trap=%s pc=0x%lx msr=0x%lx, ceded=%d", | ||
267 | __entry->vcpu_id, | ||
268 | __print_symbolic(__entry->trap, kvm_trace_symbol_exit), | ||
269 | __entry->pc, __entry->msr, __entry->ceded | ||
270 | ) | ||
271 | ); | ||
272 | |||
273 | TRACE_EVENT(kvm_page_fault_enter, | ||
274 | TP_PROTO(struct kvm_vcpu *vcpu, unsigned long *hptep, | ||
275 | struct kvm_memory_slot *memslot, unsigned long ea, | ||
276 | unsigned long dsisr), | ||
277 | |||
278 | TP_ARGS(vcpu, hptep, memslot, ea, dsisr), | ||
279 | |||
280 | TP_STRUCT__entry( | ||
281 | __field(int, vcpu_id) | ||
282 | __field(unsigned long, hpte_v) | ||
283 | __field(unsigned long, hpte_r) | ||
284 | __field(unsigned long, gpte_r) | ||
285 | __field(unsigned long, ea) | ||
286 | __field(u64, base_gfn) | ||
287 | __field(u32, slot_flags) | ||
288 | __field(u32, dsisr) | ||
289 | ), | ||
290 | |||
291 | TP_fast_assign( | ||
292 | __entry->vcpu_id = vcpu->vcpu_id; | ||
293 | __entry->hpte_v = hptep[0]; | ||
294 | __entry->hpte_r = hptep[1]; | ||
295 | __entry->gpte_r = hptep[2]; | ||
296 | __entry->ea = ea; | ||
297 | __entry->dsisr = dsisr; | ||
298 | __entry->base_gfn = memslot ? memslot->base_gfn : -1UL; | ||
299 | __entry->slot_flags = memslot ? memslot->flags : 0; | ||
300 | ), | ||
301 | |||
302 | TP_printk("VCPU %d: hpte=0x%lx:0x%lx guest=0x%lx ea=0x%lx,%x slot=0x%llx,0x%x", | ||
303 | __entry->vcpu_id, | ||
304 | __entry->hpte_v, __entry->hpte_r, __entry->gpte_r, | ||
305 | __entry->ea, __entry->dsisr, | ||
306 | __entry->base_gfn, __entry->slot_flags) | ||
307 | ); | ||
308 | |||
309 | TRACE_EVENT(kvm_page_fault_exit, | ||
310 | TP_PROTO(struct kvm_vcpu *vcpu, unsigned long *hptep, long ret), | ||
311 | |||
312 | TP_ARGS(vcpu, hptep, ret), | ||
313 | |||
314 | TP_STRUCT__entry( | ||
315 | __field(int, vcpu_id) | ||
316 | __field(unsigned long, hpte_v) | ||
317 | __field(unsigned long, hpte_r) | ||
318 | __field(long, ret) | ||
319 | ), | ||
320 | |||
321 | TP_fast_assign( | ||
322 | __entry->vcpu_id = vcpu->vcpu_id; | ||
323 | __entry->hpte_v = hptep[0]; | ||
324 | __entry->hpte_r = hptep[1]; | ||
325 | __entry->ret = ret; | ||
326 | ), | ||
327 | |||
328 | TP_printk("VCPU %d: hpte=0x%lx:0x%lx ret=0x%lx", | ||
329 | __entry->vcpu_id, | ||
330 | __entry->hpte_v, __entry->hpte_r, __entry->ret) | ||
331 | ); | ||
332 | |||
333 | TRACE_EVENT(kvm_hcall_enter, | ||
334 | TP_PROTO(struct kvm_vcpu *vcpu), | ||
335 | |||
336 | TP_ARGS(vcpu), | ||
337 | |||
338 | TP_STRUCT__entry( | ||
339 | __field(int, vcpu_id) | ||
340 | __field(unsigned long, req) | ||
341 | __field(unsigned long, gpr4) | ||
342 | __field(unsigned long, gpr5) | ||
343 | __field(unsigned long, gpr6) | ||
344 | __field(unsigned long, gpr7) | ||
345 | ), | ||
346 | |||
347 | TP_fast_assign( | ||
348 | __entry->vcpu_id = vcpu->vcpu_id; | ||
349 | __entry->req = kvmppc_get_gpr(vcpu, 3); | ||
350 | __entry->gpr4 = kvmppc_get_gpr(vcpu, 4); | ||
351 | __entry->gpr5 = kvmppc_get_gpr(vcpu, 5); | ||
352 | __entry->gpr6 = kvmppc_get_gpr(vcpu, 6); | ||
353 | __entry->gpr7 = kvmppc_get_gpr(vcpu, 7); | ||
354 | ), | ||
355 | |||
356 | TP_printk("VCPU %d: hcall=%s GPR4-7=0x%lx,0x%lx,0x%lx,0x%lx", | ||
357 | __entry->vcpu_id, | ||
358 | __print_symbolic(__entry->req, kvm_trace_symbol_hcall), | ||
359 | __entry->gpr4, __entry->gpr5, __entry->gpr6, __entry->gpr7) | ||
360 | ); | ||
361 | |||
362 | TRACE_EVENT(kvm_hcall_exit, | ||
363 | TP_PROTO(struct kvm_vcpu *vcpu, int ret), | ||
364 | |||
365 | TP_ARGS(vcpu, ret), | ||
366 | |||
367 | TP_STRUCT__entry( | ||
368 | __field(int, vcpu_id) | ||
369 | __field(unsigned long, ret) | ||
370 | __field(unsigned long, hcall_rc) | ||
371 | ), | ||
372 | |||
373 | TP_fast_assign( | ||
374 | __entry->vcpu_id = vcpu->vcpu_id; | ||
375 | __entry->ret = ret; | ||
376 | __entry->hcall_rc = kvmppc_get_gpr(vcpu, 3); | ||
377 | ), | ||
378 | |||
379 | TP_printk("VCPU %d: ret=%s hcall_rc=%s", | ||
380 | __entry->vcpu_id, | ||
381 | __print_symbolic(__entry->ret, kvm_trace_symbol_kvmret), | ||
382 | __print_symbolic(__entry->ret & RESUME_FLAG_HOST ? | ||
383 | H_TOO_HARD : __entry->hcall_rc, | ||
384 | kvm_trace_symbol_hcall_rc)) | ||
385 | ); | ||
386 | |||
387 | TRACE_EVENT(kvmppc_run_core, | ||
388 | TP_PROTO(struct kvmppc_vcore *vc, int where), | ||
389 | |||
390 | TP_ARGS(vc, where), | ||
391 | |||
392 | TP_STRUCT__entry( | ||
393 | __field(int, n_runnable) | ||
394 | __field(int, runner_vcpu) | ||
395 | __field(int, where) | ||
396 | __field(pid_t, tgid) | ||
397 | ), | ||
398 | |||
399 | TP_fast_assign( | ||
400 | __entry->runner_vcpu = vc->runner->vcpu_id; | ||
401 | __entry->n_runnable = vc->n_runnable; | ||
402 | __entry->where = where; | ||
403 | __entry->tgid = current->tgid; | ||
404 | ), | ||
405 | |||
406 | TP_printk("%s runner_vcpu==%d runnable=%d tgid=%d", | ||
407 | __entry->where ? "Exit" : "Enter", | ||
408 | __entry->runner_vcpu, __entry->n_runnable, __entry->tgid) | ||
409 | ); | ||
410 | |||
411 | TRACE_EVENT(kvmppc_vcore_blocked, | ||
412 | TP_PROTO(struct kvmppc_vcore *vc, int where), | ||
413 | |||
414 | TP_ARGS(vc, where), | ||
415 | |||
416 | TP_STRUCT__entry( | ||
417 | __field(int, n_runnable) | ||
418 | __field(int, runner_vcpu) | ||
419 | __field(int, where) | ||
420 | __field(pid_t, tgid) | ||
421 | ), | ||
422 | |||
423 | TP_fast_assign( | ||
424 | __entry->runner_vcpu = vc->runner->vcpu_id; | ||
425 | __entry->n_runnable = vc->n_runnable; | ||
426 | __entry->where = where; | ||
427 | __entry->tgid = current->tgid; | ||
428 | ), | ||
429 | |||
430 | TP_printk("%s runner_vcpu=%d runnable=%d tgid=%d", | ||
431 | __entry->where ? "Exit" : "Enter", | ||
432 | __entry->runner_vcpu, __entry->n_runnable, __entry->tgid) | ||
433 | ); | ||
434 | |||
435 | TRACE_EVENT(kvmppc_run_vcpu_enter, | ||
436 | TP_PROTO(struct kvm_vcpu *vcpu), | ||
437 | |||
438 | TP_ARGS(vcpu), | ||
439 | |||
440 | TP_STRUCT__entry( | ||
441 | __field(int, vcpu_id) | ||
442 | __field(pid_t, tgid) | ||
443 | ), | ||
444 | |||
445 | TP_fast_assign( | ||
446 | __entry->vcpu_id = vcpu->vcpu_id; | ||
447 | __entry->tgid = current->tgid; | ||
448 | ), | ||
449 | |||
450 | TP_printk("VCPU %d: tgid=%d", __entry->vcpu_id, __entry->tgid) | ||
451 | ); | ||
452 | |||
453 | TRACE_EVENT(kvmppc_run_vcpu_exit, | ||
454 | TP_PROTO(struct kvm_vcpu *vcpu, struct kvm_run *run), | ||
455 | |||
456 | TP_ARGS(vcpu, run), | ||
457 | |||
458 | TP_STRUCT__entry( | ||
459 | __field(int, vcpu_id) | ||
460 | __field(int, exit) | ||
461 | __field(int, ret) | ||
462 | ), | ||
463 | |||
464 | TP_fast_assign( | ||
465 | __entry->vcpu_id = vcpu->vcpu_id; | ||
466 | __entry->exit = run->exit_reason; | ||
467 | __entry->ret = vcpu->arch.ret; | ||
468 | ), | ||
469 | |||
470 | TP_printk("VCPU %d: exit=%d, ret=%d", | ||
471 | __entry->vcpu_id, __entry->exit, __entry->ret) | ||
472 | ); | ||
473 | |||
474 | #endif /* _TRACE_KVM_HV_H */ | ||
475 | |||
476 | /* This part must be outside protection */ | ||
477 | #include <trace/define_trace.h> | ||
diff --git a/arch/powerpc/kvm/trace_pr.h b/arch/powerpc/kvm/trace_pr.h index e1357cd8dc1f..810507cb688a 100644 --- a/arch/powerpc/kvm/trace_pr.h +++ b/arch/powerpc/kvm/trace_pr.h | |||
@@ -3,36 +3,13 @@ | |||
3 | #define _TRACE_KVM_PR_H | 3 | #define _TRACE_KVM_PR_H |
4 | 4 | ||
5 | #include <linux/tracepoint.h> | 5 | #include <linux/tracepoint.h> |
6 | #include "trace_book3s.h" | ||
6 | 7 | ||
7 | #undef TRACE_SYSTEM | 8 | #undef TRACE_SYSTEM |
8 | #define TRACE_SYSTEM kvm_pr | 9 | #define TRACE_SYSTEM kvm_pr |
9 | #define TRACE_INCLUDE_PATH . | 10 | #define TRACE_INCLUDE_PATH . |
10 | #define TRACE_INCLUDE_FILE trace_pr | 11 | #define TRACE_INCLUDE_FILE trace_pr |
11 | 12 | ||
12 | #define kvm_trace_symbol_exit \ | ||
13 | {0x100, "SYSTEM_RESET"}, \ | ||
14 | {0x200, "MACHINE_CHECK"}, \ | ||
15 | {0x300, "DATA_STORAGE"}, \ | ||
16 | {0x380, "DATA_SEGMENT"}, \ | ||
17 | {0x400, "INST_STORAGE"}, \ | ||
18 | {0x480, "INST_SEGMENT"}, \ | ||
19 | {0x500, "EXTERNAL"}, \ | ||
20 | {0x501, "EXTERNAL_LEVEL"}, \ | ||
21 | {0x502, "EXTERNAL_HV"}, \ | ||
22 | {0x600, "ALIGNMENT"}, \ | ||
23 | {0x700, "PROGRAM"}, \ | ||
24 | {0x800, "FP_UNAVAIL"}, \ | ||
25 | {0x900, "DECREMENTER"}, \ | ||
26 | {0x980, "HV_DECREMENTER"}, \ | ||
27 | {0xc00, "SYSCALL"}, \ | ||
28 | {0xd00, "TRACE"}, \ | ||
29 | {0xe00, "H_DATA_STORAGE"}, \ | ||
30 | {0xe20, "H_INST_STORAGE"}, \ | ||
31 | {0xe40, "H_EMUL_ASSIST"}, \ | ||
32 | {0xf00, "PERFMON"}, \ | ||
33 | {0xf20, "ALTIVEC"}, \ | ||
34 | {0xf40, "VSX"} | ||
35 | |||
36 | TRACE_EVENT(kvm_book3s_reenter, | 13 | TRACE_EVENT(kvm_book3s_reenter, |
37 | TP_PROTO(int r, struct kvm_vcpu *vcpu), | 14 | TP_PROTO(int r, struct kvm_vcpu *vcpu), |
38 | TP_ARGS(r, vcpu), | 15 | TP_ARGS(r, vcpu), |