From patchwork Mon Dec 15 11:41:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42257 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA19821772 for ; Mon, 15 Dec 2014 12:14:29 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id u10sf7140947lbd.6 for ; Mon, 15 Dec 2014 04:14:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=vS30ietFknkBYh/rJeQCaN3DyezI93eoCZS4mlLlozk=; b=Ogvv0vRqQ6c6hSC6Fg+ak+d7fJMUFvT/Bo5W1P1GxniHxnVCA0x73Jp429e9kjD0N6 QnRnNscHlEKA/urnvvCnnb8U/p5BbPT+AIR1o5m6bxRR0tM8maY67/bzG3ZT9/HXIGXW cJouLBfAsPFfVODf4XOQZv97931h6ARxYVJSg8cgWw++m66MZMd24RBCdXqUQdde/Ota wwXDJgvi+VsQ057hdchQtiIJodlj8/+GOvqRWK5HHlTMPWIXBKNxvURdSoKNTVJu56Cf pB0BGy2Tj0ODwBFQehyIuYpahU/prbBNA+xO2XS2bVAvfk9ZALfnqWkpQdhE2ytkmA20 XwPg== X-Gm-Message-State: ALoCoQn/JMxOHdaXHVH73DCX7Kg//sxikhh8gpvmFmhlqr4Y9a/kZdfRRzUj7AEfBI76ghBPKcjA X-Received: by 10.180.8.9 with SMTP id n9mr2775691wia.6.1418645668859; Mon, 15 Dec 2014 04:14:28 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.97 with SMTP id r1ls805496lar.0.gmail; Mon, 15 Dec 2014 04:14:28 -0800 (PST) X-Received: by 10.152.2.74 with SMTP id 10mr29303783las.38.1418645668406; Mon, 15 Dec 2014 04:14:28 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id b8si10268092lbv.37.2014.12.15.04.14.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 04:14:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by mail-lb0-f174.google.com with SMTP id 10so9164269lbg.33 for ; Mon, 15 Dec 2014 04:14:28 -0800 (PST) X-Received: by 10.152.87.12 with SMTP id t12mr17679339laz.31.1418645668249; Mon, 15 Dec 2014 04:14:28 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp695885lbb; Mon, 15 Dec 2014 04:14:27 -0800 (PST) X-Received: by 10.68.139.1 with SMTP id qu1mr50398114pbb.51.1418645666386; Mon, 15 Dec 2014 04:14:26 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 16si13501836pdf.254.2014.12.15.04.14.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2014 04:14:26 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0UVx-0005Kk-1O; Mon, 15 Dec 2014 12:12:37 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0UK2-0001sD-D9 for linux-arm-kernel@bombadil.infradead.org; Mon, 15 Dec 2014 12:00:18 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0U2w-00045i-KM for linux-arm-kernel@lists.infradead.org; Mon, 15 Dec 2014 11:42:40 +0000 Received: by mail-la0-f41.google.com with SMTP id hv19so9322137lab.28 for ; Mon, 15 Dec 2014 03:42:13 -0800 (PST) X-Received: by 10.112.234.201 with SMTP id ug9mr29569167lbc.79.1418643733554; Mon, 15 Dec 2014 03:42:13 -0800 (PST) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id ug5sm2616126lac.38.2014.12.15.03.42.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 03:42:12 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [GIT PULL 10/12] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Mon, 15 Dec 2014 12:41:57 +0100 Message-Id: <1418643719-25966-11-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418643719-25966-1-git-send-email-christoffer.dall@linaro.org> References: <1418643719-25966-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141215_114238_714837_4A522D2F X-CRM114-Status: GOOD ( 11.73 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on casper.infradead.org summary: Content analysis details: (-2.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.41 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.41 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Marc Zyngier , Christoffer Dall , kvm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When the vgic initializes its internal state it does so based on the number of VCPUs available at the time. If we allow KVM to create more VCPUs after the VGIC has been initialized, we are likely to error out in unfortunate ways later, perform buffer overflows etc. Acked-by: Marc Zyngier Reviewed-by: Eric Auger Signed-off-by: Christoffer Dall --- arch/arm/kvm/arm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index c5a05f2..66f37c4 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -213,6 +213,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) int err; struct kvm_vcpu *vcpu; + if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) { + err = -EBUSY; + goto out; + } + vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL); if (!vcpu) { err = -ENOMEM;