From patchwork Wed Jun 23 06:02:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 107551 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5N62NdM017154 for ; Wed, 23 Jun 2010 06:02:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751367Ab0FWGCV (ORCPT ); Wed, 23 Jun 2010 02:02:21 -0400 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:56578 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873Ab0FWGCU (ORCPT ); Wed, 23 Jun 2010 02:02:20 -0400 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 86DD2248389; Wed, 23 Jun 2010 15:02:19 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 75EC4248306; Wed, 23 Jun 2010 15:02:19 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.115]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id 1786413C302; Wed, 23 Jun 2010 15:02:18 +0900 (JST) Date: Wed, 23 Jun 2010 15:02:59 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com, agraf@suse.de Cc: kvm@vger.kernel.org, kvm-ia64@vger.kernel.org, kvm-ppc@vger.kernel.org, takuya.yoshikawa@gmail.com Subject: [PATCH v2 4/4] KVM: cleanup: make kvm_vm_ioctl_get_dirty_log() arch independent Message-Id: <20100623150259.6ed2cd69.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100623145807.07a07c4c.yoshikawa.takuya@oss.ntt.co.jp> References: <20100623145807.07a07c4c.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 23 Jun 2010 06:02:25 +0000 (UTC) diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index da0c133..86b6b1d 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c @@ -1815,24 +1815,15 @@ static void kvm_ia64_sync_dirty_log(struct kvm *kvm, spin_unlock(&kvm->arch.dirty_log_lock); } -int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, - struct kvm_dirty_log *log) +int kvm_arch_vm_ioctl_get_dirty_log(struct kvm *kvm, + struct kvm_dirty_log *log) { int r, i; unsigned long n; struct kvm_memory_slot *memslot; unsigned long is_dirty = 0; - mutex_lock(&kvm->slots_lock); - - r = -EINVAL; - if (log->slot >= KVM_MEMORY_SLOTS) - goto out; - memslot = &kvm->memslots->memslots[log->slot]; - r = -ENOENT; - if (!memslot->dirty_bitmap) - goto out; kvm_ia64_sync_dirty_log(kvm, memslot); @@ -1855,7 +1846,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, } r = 0; out: - mutex_unlock(&kvm->slots_lock); return r; } diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index bea6f7c..884d4a5 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -1179,8 +1179,8 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, /* * Get (and clear) the dirty memory log for a memory slot. */ -int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, - struct kvm_dirty_log *log) +int kvm_arch_vm_ioctl_get_dirty_log(struct kvm *kvm, + struct kvm_dirty_log *log) { struct kvm_memory_slot *memslot; struct kvm_vcpu *vcpu; @@ -1189,16 +1189,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, int r, i; unsigned long n; - mutex_lock(&kvm->slots_lock); - - r = -EINVAL; - if (log->slot >= KVM_MEMORY_SLOTS) - goto out; - memslot = &kvm->memslots->memslots[log->slot]; - r = -ENOENT; - if (!memslot->dirty_bitmap) - goto out; n = kvm_dirty_bitmap_bytes(memslot); @@ -1226,7 +1217,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, r = 0; out: - mutex_unlock(&kvm->slots_lock); return r; } diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 8d4e35f..376b586 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -565,7 +565,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu, return r; } -int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) +int kvm_arch_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) { return -ENOTSUPP; } diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 47acdb1..159aec2 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -134,8 +134,8 @@ int kvm_dev_ioctl_check_extension(long ext) /* * Get (and clear) the dirty memory log for a memory slot. */ -int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, - struct kvm_dirty_log *log) +int kvm_arch_vm_ioctl_get_dirty_log(struct kvm *kvm, + struct kvm_dirty_log *log) { return 0; } diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index e18e68f..ce4c603 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2861,24 +2861,15 @@ static int kvm_vm_ioctl_reinject(struct kvm *kvm, /* * Get (and clear) the dirty memory log for a memory slot. */ -int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, - struct kvm_dirty_log *log) +int kvm_arch_vm_ioctl_get_dirty_log(struct kvm *kvm, + struct kvm_dirty_log *log) { int r, i; struct kvm_memory_slot *memslot; unsigned long n; unsigned long is_dirty = 0; - mutex_lock(&kvm->slots_lock); - - r = -EINVAL; - if (log->slot >= KVM_MEMORY_SLOTS) - goto out; - memslot = &kvm->memslots->memslots[log->slot]; - r = -ENOENT; - if (!memslot->dirty_bitmap) - goto out; n = kvm_dirty_bitmap_bytes(memslot); @@ -2929,7 +2920,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, r = 0; out: - mutex_unlock(&kvm->slots_lock); return r; } diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b51e6b2..9289d1a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -336,8 +336,8 @@ long kvm_arch_vcpu_ioctl(struct file *filp, int kvm_dev_ioctl_check_extension(long ext); -int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, - struct kvm_dirty_log *log); +int kvm_arch_vm_ioctl_get_dirty_log(struct kvm *kvm, + struct kvm_dirty_log *log); int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, struct diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 8859049..bf3d273 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -773,6 +773,30 @@ int kvm_vm_ioctl_set_memory_region(struct kvm *kvm, return kvm_set_memory_region(kvm, mem, user_alloc); } +static int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, + struct kvm_dirty_log *log) +{ + struct kvm_memory_slot *memslot; + int r; + + mutex_lock(&kvm->slots_lock); + + r = -EINVAL; + if (log->slot >= KVM_MEMORY_SLOTS) + goto out; + + memslot = &kvm->memslots->memslots[log->slot]; + r = -ENOENT; + if (!memslot->dirty_bitmap) + goto out; + + r = kvm_arch_vm_ioctl_get_dirty_log(kvm, log); + +out: + mutex_unlock(&kvm->slots_lock); + return r; +} + void kvm_disable_largepages(void) { largepages_enabled = false;