From patchwork Thu May 7 21:03:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 22393 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n47LAG0m015269 for ; Thu, 7 May 2009 21:10:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754435AbZEGVKH (ORCPT ); Thu, 7 May 2009 17:10:07 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752791AbZEGVKG (ORCPT ); Thu, 7 May 2009 17:10:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45207 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753837AbZEGVJ7 (ORCPT ); Thu, 7 May 2009 17:09:59 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n47LA0X9016590 for ; Thu, 7 May 2009 17:10:00 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n47L9xbD013878 for ; Thu, 7 May 2009 17:09:59 -0400 Received: from amt.cnet (vpn-10-52.str.redhat.com [10.32.10.52]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n47L9vCj017562 for ; Thu, 7 May 2009 17:09:58 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 9BE3B5C8009 for ; Thu, 7 May 2009 18:09:27 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n47L7pse008062; Thu, 7 May 2009 18:07:51 -0300 Message-Id: <20090507210534.150690630@amt.cnet> User-Agent: quilt/0.47-1 Date: Thu, 07 May 2009 18:03:35 -0300 From: mtosatti@redhat.com To: kvm@vger.kernel.org Cc: avi@redhat.com, Marcelo Tosatti Subject: [patch 4/4] KVM: x86: disallow changing a slots size References: <20090507210331.370806285@amt.cnet> Content-Disposition: inline; filename=disallow-alias-size-change X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Support to shrinking aliases complicates kernel code unnecessarily, while userspace can do the same with two operations, delete an alias, and create a new alias. Signed-off-by: Marcelo Tosatti --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: kvm-pending/arch/x86/kvm/x86.c =================================================================== --- kvm-pending.orig/arch/x86/kvm/x86.c +++ kvm-pending/arch/x86/kvm/x86.c @@ -1669,6 +1669,7 @@ static int kvm_vm_ioctl_set_memory_alias { int r, n; struct kvm_mem_alias *p; + unsigned long npages; r = -EINVAL; /* General sanity checks */ @@ -1690,9 +1691,12 @@ static int kvm_vm_ioctl_set_memory_alias p = &kvm->arch.aliases[alias->slot]; - /* FIXME: either disallow shrinking alias slots or disable - * size changes as done with memslots - */ + /* Disallow changing an alias slot's size. */ + npages = alias->memory_size >> PAGE_SHIFT; + r = -EINVAL; + if (npages && p->npages && npages != p->npages) + goto out_unlock; + if (!alias->memory_size) { r = -EBUSY; if (kvm_root_gfn_in_range(kvm, p->base_gfn,