From patchwork Tue Dec 9 15:44:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42059 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEB8325E75 for ; Tue, 9 Dec 2014 15:45:59 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf974870eek.0 for ; Tue, 09 Dec 2014 07:45:59 -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=KAQEpN3hDaBpSIx4nt13veC8freRoKyg6g2hHSLgmpk=; b=FrDO7rOFVjlqA7MSZviFeo3lIPy7Sj+VVz+qGOEOhSO8mTq0IebrY7eVbWwmFZxx55 2PtXqw72wNI9n5sNb6c0R4I7UrGl02dF8UGGbTlTGSdcXCmt2JaPDtHKsRMfzcaw/m// 8bNtUwYujNQn4zva1TFZnfDOkZEX2aRxsHSPp+BgjtCUsRPWs1HRrdrQCsGf0WZQJGLZ MdAn3lXjzXa+z/LjaSsvPqaWnbqzE+sZ8C/jY5PHQf5HOGwCFMUk4ehUX2fDGauGIN52 5JapFzq40bQT8wKs0m8oJ9/3APh429GkZqXOR1/iAUds6HAYzNO5PNVs3s+eA8U/PSx7 0PNA== X-Gm-Message-State: ALoCoQk0Uv3g8sap/V9XoywucHy0YdcuCXm5Jl6O+Ta1ImohCIF6AeM3+tjjnEaAu4PeH2oCcDF8 X-Received: by 10.194.95.74 with SMTP id di10mr7426873wjb.0.1418139959078; Tue, 09 Dec 2014 07:45:59 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.165 with SMTP id 5ls55689lav.42.gmail; Tue, 09 Dec 2014 07:45:58 -0800 (PST) X-Received: by 10.152.234.140 with SMTP id ue12mr22134143lac.78.1418139958762; Tue, 09 Dec 2014 07:45:58 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id iz2si1679898lbc.92.2014.12.09.07.45.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 07:45:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ms9so753309lab.10 for ; Tue, 09 Dec 2014 07:45:58 -0800 (PST) X-Received: by 10.153.7.170 with SMTP id dd10mr22250577lad.44.1418139958655; Tue, 09 Dec 2014 07:45:58 -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.184.201 with SMTP id ew9csp769794lbc; Tue, 9 Dec 2014 07:45:57 -0800 (PST) X-Received: by 10.67.12.236 with SMTP id et12mr6630835pad.31.1418139956592; Tue, 09 Dec 2014 07:45:56 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id dm1si2497771pbb.32.2014.12.09.07.45.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2014 07:45:56 -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 1XyMxn-0005DR-BJ; Tue, 09 Dec 2014 15:44:35 +0000 Received: from mail-la0-f49.google.com ([209.85.215.49]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyMwy-0004kI-KN for linux-arm-kernel@lists.infradead.org; Tue, 09 Dec 2014 15:43:45 +0000 Received: by mail-la0-f49.google.com with SMTP id hs14so743455lab.36 for ; Tue, 09 Dec 2014 07:43:20 -0800 (PST) X-Received: by 10.112.155.72 with SMTP id vu8mr22768025lbb.30.1418139799956; Tue, 09 Dec 2014 07:43:19 -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 i2sm180810lae.40.2014.12.09.07.43.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 07:43:19 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Tue, 9 Dec 2014 16:44:03 +0100 Message-Id: <1418139844-27892-5-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418139844-27892-1-git-send-email-christoffer.dall@linaro.org> References: <1418139844-27892-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141209_074344_901253_4BE3A7DD X-CRM114-Status: GOOD ( 12.17 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.49 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.49 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Christoffer Dall , kvm@vger.kernel.org, Eric Auger 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.215.51 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. Cc: Eric Auger Signed-off-by: Christoffer Dall Reviewed-by: Eric Auger --- This replaces Eric Auger's previous patch (https://lists.cs.columbia.edu/pipermail/kvmarm/2014-December/012646.html), because it fits better with testing to include it in this series and I realized that we need to add a check against irqchip_in_kernel() as well. 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 a9d005f..d4da244 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;