From patchwork Tue Oct 27 15:10:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 56107 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 n9RFERxG014937 for ; Tue, 27 Oct 2009 15:14:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753872AbZJ0POV (ORCPT ); Tue, 27 Oct 2009 11:14:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753555AbZJ0POU (ORCPT ); Tue, 27 Oct 2009 11:14:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23956 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753472AbZJ0POU (ORCPT ); Tue, 27 Oct 2009 11:14:20 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9RFE3Yn007341; Tue, 27 Oct 2009 11:14:03 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9RFE2Z4022483; Tue, 27 Oct 2009 11:14:02 -0400 Received: from amt.cnet (vpn-10-14.str.redhat.com [10.32.10.14]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n9RFE0BL008907; Tue, 27 Oct 2009 11:14:01 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 0B861682A78; Tue, 27 Oct 2009 13:12:50 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n9RFClhN009433; Tue, 27 Oct 2009 13:12:47 -0200 Message-Id: <20091027151125.287873732@redhat.com> User-Agent: quilt/0.47-1 Date: Tue, 27 Oct 2009 13:10:43 -0200 From: Marcelo Tosatti To: avi@redhat.com Cc: kvm , stable@kernel.org, Marcelo Tosatti Subject: [patch 1/3] KVM: x86: disallow multiple KVM_CREATE_IRQCHIP References: <20091027151042.118902183@redhat.com> Content-Disposition: inline; filename=irqchip-create X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Index: kvm/arch/x86/kvm/x86.c =================================================================== --- kvm.orig/arch/x86/kvm/x86.c +++ kvm/arch/x86/kvm/x86.c @@ -2285,6 +2285,9 @@ long kvm_arch_vm_ioctl(struct file *filp goto out; break; case KVM_CREATE_IRQCHIP: + r = -EEXIST; + if (kvm->arch.vpic) + goto out; r = -ENOMEM; kvm->arch.vpic = kvm_create_pic(kvm); if (kvm->arch.vpic) { @@ -2300,6 +2303,8 @@ long kvm_arch_vm_ioctl(struct file *filp if (r) { kfree(kvm->arch.vpic); kfree(kvm->arch.vioapic); + kvm->arch.vpic = NULL; + kvm->arch.vioapic = NULL; goto out; } break;