From patchwork Sat Dec 13 11:17:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42208 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DD0BF21772 for ; Sat, 13 Dec 2014 11:19:42 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf5844405lab.8 for ; Sat, 13 Dec 2014 03:19:41 -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=I8LLzTLdpCKjGvp3SGMFHckDjCellH/XAOExQHX9Q6Y=; b=YzG7GRtviuFTP5EYidEf1w2G4US4g2VGtmTSoLHhWC+fJTzvhWYSH2OV7U6gtQZ+eG MJQjKqHOzj8OhJ73YJqkM2pU/tUSBU9fGM1BS4R+mu0WA+CxwLePMqcLNag3j992YSSk WvqbLYGVs7tlmwdh2ogQ956AqfDJMLrgCE4KGOIHJ9iF6WXQLn8lqzT5tTl+avubB0tN /2X7NyKyp5FzFyLFU35MTYiQfhbACvyDugpsSMATYUSI/yS2qa9KFbUH6RX0VU3/sej3 rhJAGqIzDDe9Fa6Gn3j0PrxqKMADGbkxWDz+ICi0FSVmaEOtAdcURTIXDK01QfbcTuTw je0w== X-Gm-Message-State: ALoCoQmmWi65u9owiJ0uLPkPpmlPf3qt1eOV69QerneWi+Uxn5Wmtgy3i46sUsIeoRdzIiioQiT4 X-Received: by 10.194.176.106 with SMTP id ch10mr122561wjc.6.1418469581825; Sat, 13 Dec 2014 03:19:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.201 with SMTP id x9ls117163lae.89.gmail; Sat, 13 Dec 2014 03:19:41 -0800 (PST) X-Received: by 10.152.19.71 with SMTP id c7mr20116865lae.79.1418469581340; Sat, 13 Dec 2014 03:19:41 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id k12si4212333laa.24.2014.12.13.03.19.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Dec 2014 03:19:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so7260641lbv.12 for ; Sat, 13 Dec 2014 03:19:41 -0800 (PST) X-Received: by 10.112.130.132 with SMTP id oe4mr19980611lbb.82.1418469581208; Sat, 13 Dec 2014 03:19:41 -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 ru5csp231970lbb; Sat, 13 Dec 2014 03:19:40 -0800 (PST) X-Received: by 10.70.101.97 with SMTP id ff1mr34104775pdb.142.1418469579254; Sat, 13 Dec 2014 03:19:39 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id sm2si5711759pbc.123.2014.12.13.03.19.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Dec 2014 03:19:39 -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 1Xzki3-0006k0-6L; Sat, 13 Dec 2014 11:18:03 +0000 Received: from mail-lb0-f176.google.com ([209.85.217.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xzkgz-0006Gq-FD for linux-arm-kernel@lists.infradead.org; Sat, 13 Dec 2014 11:16:58 +0000 Received: by mail-lb0-f176.google.com with SMTP id p9so6974892lbv.7 for ; Sat, 13 Dec 2014 03:16:35 -0800 (PST) X-Received: by 10.112.43.66 with SMTP id u2mr13784298lbl.35.1418469395427; Sat, 13 Dec 2014 03:16:35 -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 b4sm1096765lbp.17.2014.12.13.03.16.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Dec 2014 03:16:34 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/6] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Sat, 13 Dec 2014 12:17:27 +0100 Message-Id: <1418469449-13277-5-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418469449-13277-1-git-send-email-christoffer.dall@linaro.org> References: <1418469449-13277-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141213_031657_728304_75E15ED7 X-CRM114-Status: GOOD ( 11.84 ) 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.217.176 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.217.176 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record Cc: 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.181 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 --- 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;