From patchwork Fri Sep 26 13:16:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 37984 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB4CB202DB for ; Fri, 26 Sep 2014 13:24:36 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y10sf5744661wgg.2 for ; Fri, 26 Sep 2014 06:24:36 -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=w4gyrVa6Ir6NcsHe7AqXWXXeSR85m0FzrLxlLydNenY=; b=h/q3sJnvKUdaVxnZZCe0OKini+agnlZ7Y3dX7ybjFu1FSSHdW4UCr1AMYsaERIyHoF y4j8X0l1fFYOmSAjG2NrqJgz5+g5JeGf2YxY9Z0GEWFbFB4GPG9Fpey64Uv8CA24eIhq OVg1o0s5O+oFVlZubWOifuS9TQhxukk4MhCa6lw74Us4e4JBkYOJnzY8lIHc464TbpAS hvhrhfKcwDeIELyUCTbRVADHIIoGremnvl2Q8fNc0FXXtvLWMgkQoflnKen1lSShVJlc iGKvVE59KwsEHx89rrGq1gP/VZ6WiCfTHti+hmvjWUXV2Sjts+gwvir31YevKZs0mF1m watQ== X-Gm-Message-State: ALoCoQl/Vi5+1f1jaorhEPRs3IeQgwBIaF8n4gSsGqWdzhKwM+hlulnCJSXp5uSJ7M3gjS72C8c4 X-Received: by 10.180.24.225 with SMTP id x1mr3581057wif.2.1411737876190; Fri, 26 Sep 2014 06:24:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.141 with SMTP id j13ls394940laa.5.gmail; Fri, 26 Sep 2014 06:24:36 -0700 (PDT) X-Received: by 10.152.197.35 with SMTP id ir3mr20810431lac.82.1411737876035; Fri, 26 Sep 2014 06:24:36 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by mx.google.com with ESMTPS id u1si7233541lae.37.2014.09.26.06.24.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 06:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id q1so2776834lam.7 for ; Fri, 26 Sep 2014 06:24:35 -0700 (PDT) X-Received: by 10.112.76.6 with SMTP id g6mr19429859lbw.22.1411737875775; Fri, 26 Sep 2014 06:24:35 -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.112.130.169 with SMTP id of9csp59920lbb; Fri, 26 Sep 2014 06:24:35 -0700 (PDT) X-Received: by 10.66.249.135 with SMTP id yu7mr31332606pac.103.1411737874297; Fri, 26 Sep 2014 06:24:34 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id tk9si9213184pbc.159.2014.09.26.06.24.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Sep 2014 06:24:34 -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 1XXVUB-00012h-Ko; Fri, 26 Sep 2014 13:22:59 +0000 Received: from mail-la0-f47.google.com ([209.85.215.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XXVPp-0002r2-8f for linux-arm-kernel@lists.infradead.org; Fri, 26 Sep 2014 13:18:29 +0000 Received: by mail-la0-f47.google.com with SMTP id mc6so14270027lab.20 for ; Fri, 26 Sep 2014 06:18:05 -0700 (PDT) X-Received: by 10.112.201.42 with SMTP id jx10mr2910041lbc.101.1411737485306; Fri, 26 Sep 2014 06:18:05 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id z4sm1876657laz.39.2014.09.26.06.18.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Sep 2014 06:18:04 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , Gleb Natapov Subject: [PATCH 17/27] KVM: ARM: vgic: plug irq injection race Date: Fri, 26 Sep 2014 15:16:50 +0200 Message-Id: <1411737420-9063-18-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1411737420-9063-1-git-send-email-christoffer.dall@linaro.org> References: <1411737420-9063-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140926_061829_505795_6090CD5D X-CRM114-Status: GOOD ( 10.20 ) 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.47 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.47 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , kvmarm@lists.cs.columbia.edu, 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.215.48 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 From: Marc Zyngier 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 37fd20d..9bdf181 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1585,7 +1585,8 @@ out: int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, bool level) { - if (vgic_update_irq_pending(kvm, cpuid, irq_num, level)) + if (likely(vgic_initialized(kvm)) && + vgic_update_irq_pending(kvm, cpuid, irq_num, level)) vgic_kick_vcpus(kvm); return 0;