From patchwork Tue Jul 8 11:09:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 33190 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8FBE720969 for ; Tue, 8 Jul 2014 11:11:44 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id jx11sf2943681veb.0 for ; Tue, 08 Jul 2014 04:11:44 -0700 (PDT) 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:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=vcjZvDvHkoZ9xruS3Ft5vzlyOq+lk3jcf04ZQThUTUo=; b=dTYr3TttJtwxc1j59b+mZeE3CbayTsYoxcsm7ZhMcG+G+6OdTjFNhYhzVnAzsfN7cQ RLW1j4V8eg6UfSreFMioT3cab9JO2OIe4QdREmY+3Fg812z8t+E9PrH7JjKASaPusxPp HJAPSpDmCNeI63Oz3DszIt28rdpkxxlTgEfe81rsyqQM11wmJS2aGAj+teByZokBXGPY 8CnHZeATs9pbqxxXLpgQwoRNCst/pb6J6BLUnmAWe8hpzHMBuCiQezG5/yZHIHiK4r1E WV6vIeIaDQ2UUxNjbFP8zzF/jnAIRS9kS56U9N5e6/lPq4VzTo/+hti8MOzyVkVDc++x 4WjQ== X-Gm-Message-State: ALoCoQmutZpfpR8lZwXg3QBwlaMhxweF4bBZL+bUnAP9bwOQRZevFTz8oC7DfvB80drEvPzXhill X-Received: by 10.58.114.41 with SMTP id jd9mr17741646veb.9.1404817904329; Tue, 08 Jul 2014 04:11:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.178 with SMTP id w47ls2132547qge.55.gmail; Tue, 08 Jul 2014 04:11:44 -0700 (PDT) X-Received: by 10.52.184.199 with SMTP id ew7mr38933vdc.44.1404817904215; Tue, 08 Jul 2014 04:11:44 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id ig16si16607543vec.99.2014.07.08.04.11.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Jul 2014 04:11:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 as permitted sender) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so5445277veb.14 for ; Tue, 08 Jul 2014 04:11:44 -0700 (PDT) X-Received: by 10.220.80.142 with SMTP id t14mr17861vck.55.1404817904140; Tue, 08 Jul 2014 04:11:44 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp760868vcb; Tue, 8 Jul 2014 04:11:43 -0700 (PDT) X-Received: by 10.66.220.169 with SMTP id px9mr6472587pac.79.1404817902902; Tue, 08 Jul 2014 04:11:42 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 1si5929868pdf.24.2014.07.08.04.11.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jul 2014 04:11:42 -0700 (PDT) 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 1X4TI5-0002HI-Ga; Tue, 08 Jul 2014 11:10:29 +0000 Received: from inca-roads.misterjones.org ([213.251.177.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4THS-0000fb-Kg for linux-arm-kernel@lists.infradead.org; Tue, 08 Jul 2014 11:09:52 +0000 Received: from [176.25.195.83] (helo=why.wild-wind.fr.eu.org) by cheepnis.misterjones.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.80) (envelope-from ) id 1X4TGz-0003VB-0O; Tue, 08 Jul 2014 13:09:21 +0200 From: Marc Zyngier To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/9] KVM: ARM: vgic: plug irq injection race Date: Tue, 8 Jul 2014 12:09:00 +0100 Message-Id: <1404817748-31302-2-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1404817748-31302-1-git-send-email-marc.zyngier@arm.com> References: <1404817748-31302-1-git-send-email-marc.zyngier@arm.com> X-SA-Exim-Connect-IP: 176.25.195.83 X-SA-Exim-Rcpt-To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, christoffer.dall@linaro.org, andre.przywara@arm.com X-SA-Exim-Mail-From: marc.zyngier@arm.com X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140708_040950_846752_5B53B947 X-CRM114-Status: GOOD ( 10.06 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) Cc: andre.przywara@arm.com, Christoffer Dall 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: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.169 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 As it stands, nothing prevents userspace from injecting an interrupt before the guest's GIC is actually initialized. This goes unnoticed so far (as everything is pretty much statically allocated), but ends up exploding in a spectacular way once we switch to a more dynamic allocation (the GIC data structure isn't there yet). The fix is to test for the "ready" flag in the VGIC distributor before trying to inject the interrupt. Note that in order to avoid breaking userspace, we have to ignore what is essentially an error. Signed-off-by: Marc Zyngier Acked-by: Christoffer Dall --- virt/kvm/arm/vgic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index ede8f64..eebaf54 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1466,7 +1466,8 @@ out: int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, bool level) { - if (vgic_update_irq_state(kvm, cpuid, irq_num, level)) + if (likely(vgic_initialized(kvm)) && + vgic_update_irq_state(kvm, cpuid, irq_num, level)) vgic_kick_vcpus(kvm); return 0;