aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/book3s_pr.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2011-12-14 21:03:22 -0500
committerAvi Kivity <avi@redhat.com>2012-03-05 07:52:39 -0500
commit82ed36164c8a8ee685ea3fb3c4f741214ac070ca (patch)
tree259f2e7a839d7506d7fbb9a3be6763ad2f5e9fd2 /arch/powerpc/kvm/book3s_pr.c
parent55514893739d28f095f19b012133eea4cb4a9390 (diff)
KVM: PPC: Book3s HV: Implement get_dirty_log using hardware changed bit
This changes the implementation of kvm_vm_ioctl_get_dirty_log() for Book3s HV guests to use the hardware C (changed) bits in the guest hashed page table. Since this makes the implementation quite different from the Book3s PR case, this moves the existing implementation from book3s.c to book3s_pr.c and creates a new implementation in book3s_hv.c. That implementation calls kvmppc_hv_get_dirty_log() to do the actual work by calling kvm_test_clear_dirty on each page. It iterates over the HPTEs, clearing the C bit if set, and returns 1 if any C bit was set (including the saved C bit in the rmap entry). Signed-off-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm/book3s_pr.c')
-rw-r--r--arch/powerpc/kvm/book3s_pr.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 2da670405727..c193625d5289 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -1056,6 +1056,45 @@ out:
1056 return ret; 1056 return ret;
1057} 1057}
1058 1058
1059/*
1060 * Get (and clear) the dirty memory log for a memory slot.
1061 */
1062int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1063 struct kvm_dirty_log *log)
1064{
1065 struct kvm_memory_slot *memslot;
1066 struct kvm_vcpu *vcpu;
1067 ulong ga, ga_end;
1068 int is_dirty = 0;
1069 int r;
1070 unsigned long n;
1071
1072 mutex_lock(&kvm->slots_lock);
1073
1074 r = kvm_get_dirty_log(kvm, log, &is_dirty);
1075 if (r)
1076 goto out;
1077
1078 /* If nothing is dirty, don't bother messing with page tables. */
1079 if (is_dirty) {
1080 memslot = id_to_memslot(kvm->memslots, log->slot);
1081
1082 ga = memslot->base_gfn << PAGE_SHIFT;
1083 ga_end = ga + (memslot->npages << PAGE_SHIFT);
1084
1085 kvm_for_each_vcpu(n, vcpu, kvm)
1086 kvmppc_mmu_pte_pflush(vcpu, ga, ga_end);
1087
1088 n = kvm_dirty_bitmap_bytes(memslot);
1089 memset(memslot->dirty_bitmap, 0, n);
1090 }
1091
1092 r = 0;
1093out:
1094 mutex_unlock(&kvm->slots_lock);
1095 return r;
1096}
1097
1059int kvmppc_core_prepare_memory_region(struct kvm *kvm, 1098int kvmppc_core_prepare_memory_region(struct kvm *kvm,
1060 struct kvm_userspace_memory_region *mem) 1099 struct kvm_userspace_memory_region *mem)
1061{ 1100{