KVM: PPC: Book3S HV: Tracepoints for KVM HV guest interactions
authorSuresh E. Warrier <warrier@linux.vnet.ibm.com>
Thu, 4 Dec 2014 00:48:10 +0000 (18:48 -0600)
committerAlexander Graf <agraf@suse.de>
Wed, 17 Dec 2014 12:29:27 +0000 (13:29 +0100)
This patch adds trace points in the guest entry and exit code and also
for exceptions handled by the host in kernel mode - hypercalls and page
faults. The new events are added to /sys/kernel/debug/tracing/events
under a new subsystem called kvm_hv.

Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
arch/powerpc/kvm/book3s_64_mmu_hv.c
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/trace_book3s.h [new file with mode: 0644]
arch/powerpc/kvm/trace_hv.h [new file with mode: 0644]
arch/powerpc/kvm/trace_pr.h

index 59425f1..311e4a3 100644 (file)
@@ -37,6 +37,8 @@
 #include <asm/ppc-opcode.h>
 #include <asm/cputable.h>
 
+#include "trace_hv.h"
+
 /* POWER7 has 10-bit LPIDs, PPC970 has 6-bit LPIDs */
 #define MAX_LPID_970   63
 
@@ -622,6 +624,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
        gfn = gpa >> PAGE_SHIFT;
        memslot = gfn_to_memslot(kvm, gfn);
 
+       trace_kvm_page_fault_enter(vcpu, hpte, memslot, ea, dsisr);
+
        /* No memslot means it's an emulated MMIO region */
        if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID))
                return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea,
@@ -641,6 +645,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
        mmu_seq = kvm->mmu_notifier_seq;
        smp_rmb();
 
+       ret = -EFAULT;
        is_io = 0;
        pfn = 0;
        page = NULL;
@@ -664,7 +669,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
                }
                up_read(&current->mm->mmap_sem);
                if (!pfn)
-                       return -EFAULT;
+                       goto out_put;
        } else {
                page = pages[0];
                pfn = page_to_pfn(page);
@@ -694,14 +699,14 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
                }
        }
 
-       ret = -EFAULT;
        if (psize > pte_size)
                goto out_put;
 
        /* Check WIMG vs. the actual page we're accessing */
        if (!hpte_cache_flags_ok(r, is_io)) {
                if (is_io)
-                       return -EFAULT;
+                       goto out_put;
+
                /*
                 * Allow guest to map emulated device memory as
                 * uncacheable, but actually make it cacheable.
@@ -765,6 +770,8 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
                SetPageDirty(page);
 
  out_put:
+       trace_kvm_page_fault_exit(vcpu, hpte, ret);
+
        if (page) {
                /*
                 * We drop pages[0] here, not page because page might
Simple merge
Simple merge
Simple merge
Simple merge