From patchwork Fri Jan 11 09:26:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 1965241 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 1FAD13FE37 for ; Fri, 11 Jan 2013 09:26:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753219Ab3AKJ0U (ORCPT ); Fri, 11 Jan 2013 04:26:20 -0500 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]:32956 "EHLO tama50.ecl.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591Ab3AKJ0T (ORCPT ); Fri, 11 Jan 2013 04:26:19 -0500 Received: from mfs6.rdh.ecl.ntt.co.jp (mfs6.rdh.ecl.ntt.co.jp [129.60.39.149]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id r0B9QGhw021516; Fri, 11 Jan 2013 18:26:16 +0900 Received: from mfs6.rdh.ecl.ntt.co.jp (localhost.localdomain [127.0.0.1]) by mfs6.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 22699E0194; Fri, 11 Jan 2013 18:26:16 +0900 (JST) Received: from imail2.m.ecl.ntt.co.jp (imail2.m.ecl.ntt.co.jp [129.60.5.247]) by mfs6.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 0DA54E018E; Fri, 11 Jan 2013 18:26:16 +0900 (JST) Received: from yshpad ([129.60.241.180]) by imail2.m.ecl.ntt.co.jp (8.13.8/8.13.8) with SMTP id r0B9QFLV025191; Fri, 11 Jan 2013 18:26:16 +0900 Date: Fri, 11 Jan 2013 18:26:55 +0900 From: Takuya Yoshikawa To: mtosatti@redhat.com, gleb@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 2/4] KVM: set_memory_region: Don't check for overlaps unless we create or move a slot Message-Id: <20130111182655.8eaddd7d.yoshikawa_takuya_b1@lab.ntt.co.jp> In-Reply-To: <20130111182518.6c5975d9.yoshikawa_takuya_b1@lab.ntt.co.jp> References: <20130111182518.6c5975d9.yoshikawa_takuya_b1@lab.ntt.co.jp> X-Mailer: Sylpheed 3.1.0 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Don't need the check for deleting an existing slot or just modifiying the flags. Signed-off-by: Takuya Yoshikawa --- virt/kvm/kvm_main.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d5e4bf9..f6c8cdc 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -782,14 +782,16 @@ int __kvm_set_memory_region(struct kvm *kvm, if (!npages && !old.npages) goto out; - /* Check for overlaps */ - r = -EEXIST; - kvm_for_each_memslot(slot, kvm->memslots) { - if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot) - continue; - if (!((base_gfn + npages <= slot->base_gfn) || - (base_gfn >= slot->base_gfn + slot->npages))) - goto out; + if ((npages && !old.npages) || (base_gfn != old.base_gfn)) { + /* Check for overlaps */ + r = -EEXIST; + kvm_for_each_memslot(slot, kvm->memslots) { + if (slot->id >= KVM_USER_MEM_SLOTS || slot == memslot) + continue; + if (!((base_gfn + npages <= slot->base_gfn) || + (base_gfn >= slot->base_gfn + slot->npages))) + goto out; + } } /* Free page dirty bitmap if unneeded */