From patchwork Thu Oct 29 15:44:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 56483 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 n9TFmRYQ015812 for ; Thu, 29 Oct 2009 15:48:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755431AbZJ2PsL (ORCPT ); Thu, 29 Oct 2009 11:48:11 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755381AbZJ2PsK (ORCPT ); Thu, 29 Oct 2009 11:48:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34097 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755392AbZJ2PsG (ORCPT ); Thu, 29 Oct 2009 11:48:06 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9TFmBjp030265 for ; Thu, 29 Oct 2009 11:48:11 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9TFmAnw023208; Thu, 29 Oct 2009 11:48:10 -0400 Received: from amt.cnet (vpn-10-38.str.redhat.com [10.32.10.38]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n9TFm8xp003285; Thu, 29 Oct 2009 11:48:09 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 3D9AC67419B; Thu, 29 Oct 2009 13:46:48 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n9TFkfca008792; Thu, 29 Oct 2009 13:46:41 -0200 Message-Id: <20091029154553.814210695@amt.cnet> User-Agent: quilt/0.47-1 Date: Thu, 29 Oct 2009 13:44:16 -0200 From: Marcelo Tosatti To: avi@redhat.com Cc: kvm@vger.kernel.org, mst@redhat.com, gleb@redhat.com, Marcelo Tosatti Subject: [patch 2/3] KVM: x86: disallow KVM_{SET, GET}_LAPIC without allocated in-kernel lapic References: <20091029154414.686484229@amt.cnet> Content-Disposition: inline; filename=get-set-lapic X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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 @@ -1893,6 +1893,9 @@ long kvm_arch_vcpu_ioctl(struct file *fi switch (ioctl) { case KVM_GET_LAPIC: { + r = -EINVAL; + if (!vcpu->arch.apic) + goto out; lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL); r = -ENOMEM; @@ -1908,6 +1911,9 @@ long kvm_arch_vcpu_ioctl(struct file *fi break; } case KVM_SET_LAPIC: { + r = -EINVAL; + if (!vcpu->arch.apic) + goto out; lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL); r = -ENOMEM; if (!lapic)