Message ID | 1418469449-13277-6-git-send-email-christoffer.dall@linaro.org |
---|---|
State | New |
Headers | show
Return-Path: <patchwork-forward+bncBCAJ5U7H64CRBTWBWCSAKGQERG5ACNY@linaro.org> X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9058026C75 for <linaro@patches.linaro.org>; Sat, 13 Dec 2014 11:19:43 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf2085867wiv.5 for <linaro@patches.linaro.org>; Sat, 13 Dec 2014 03:19:42 -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=2QNlRvVQVlO3dDe1WchEaX7Guyt1cskNaMXisbN9WT4=; b=RycnHB7SmbrGbrSl7Lh6z3N7o+vSlyilRGtcki6RnSgzcR2f9G1l9hHkriflJ//k5/ FOKACcHG54T/UW76a+aqBEJX1UJv922Rt4b+EmQ00PO2jcdEJz5BfptOJ/uVE6so18KP 0Zt1QrgMHhsyLV53mScP9G4gN+f02L6Qr6JEZ7GGjY1IFIeT0F85T51rPNcxdtrjqs5p TXr2rAoLI4Ji9VA/qN9+pxL65vBV+2egcPYHwmOitoF+nCI9HtR0PPaxAQ8iIeM4eJmi 5SwQx34mkyt3ERa3V5Z1q/bo115LcTl+rVwNBh+O8nq7eBZfzxO+AbBN7FG9XXP3lPT+ 73GQ== X-Gm-Message-State: ALoCoQk+23KMny32nCWc20N1BP4v9LVn0cclYEUJQ3/raMLxPIUaSKaHLSgEKL80CajRigCaOgKz X-Received: by 10.112.219.199 with SMTP id pq7mr195816lbc.9.1418469582820; Sat, 13 Dec 2014 03:19:42 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.133 with SMTP id o5ls15514lal.78.gmail; Sat, 13 Dec 2014 03:19:42 -0800 (PST) X-Received: by 10.112.173.202 with SMTP id bm10mr19632142lbc.74.1418469582337; Sat, 13 Dec 2014 03:19:42 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id ks1si4214392lac.22.2014.12.13.03.19.42 for <patchwork-forward@linaro.org> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Dec 2014 03:19:42 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id w7so2793262lbi.2 for <patchwork-forward@linaro.org>; Sat, 13 Dec 2014 03:19:42 -0800 (PST) X-Received: by 10.112.219.37 with SMTP id pl5mr17161034lbc.25.1418469582253; Sat, 13 Dec 2014 03:19:42 -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 ru5csp231975lbb; Sat, 13 Dec 2014 03:19:41 -0800 (PST) X-Received: by 10.70.101.97 with SMTP id ff1mr34104924pdb.142.1418469580892; Sat, 13 Dec 2014 03:19:40 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ut3si5634188pab.193.2014.12.13.03.19.40 for <patch@linaro.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Dec 2014 03:19:40 -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 1XzkiJ-0006wM-Pt; Sat, 13 Dec 2014 11:18:19 +0000 Received: from mail-lb0-f171.google.com ([209.85.217.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xzkh1-0006HF-AR for linux-arm-kernel@lists.infradead.org; Sat, 13 Dec 2014 11:17:00 +0000 Received: by mail-lb0-f171.google.com with SMTP id w7so2845738lbi.16 for <linux-arm-kernel@lists.infradead.org>; Sat, 13 Dec 2014 03:16:37 -0800 (PST) X-Received: by 10.152.26.201 with SMTP id n9mr13548864lag.50.1418469397022; Sat, 13 Dec 2014 03:16:37 -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.35 for <multiple recipients> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Dec 2014 03:16:36 -0800 (PST) From: Christoffer Dall <christoffer.dall@linaro.org> To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/6] arm/arm64: KVM: Initialize the vgic on-demand when injecting IRQs Date: Sat, 13 Dec 2014 12:17:28 +0100 Message-Id: <1418469449-13277-6-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_031659_572156_C6F8988F X-CRM114-Status: GOOD ( 12.15 ) 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.171 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.217.171 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record Cc: Christoffer Dall <christoffer.dall@linaro.org>, kvm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: <patchwork-forward.linaro.org> List-Unsubscribe: <mailto:googlegroups-manage+836684582541+unsubscribe@googlegroups.com>, <http://groups.google.com/a/linaro.org/group/patchwork-forward/subscribe> List-Archive: <http://groups.google.com/a/linaro.org/group/patchwork-forward/> List-Post: <http://groups.google.com/a/linaro.org/group/patchwork-forward/post>, <mailto:patchwork-forward@linaro.org> List-Help: <http://support.google.com/a/linaro.org/bin/topic.py?topic=25838>, <mailto:patchwork-forward+help@linaro.org> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> 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.171 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 |
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index e1bef68..330445c 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1693,11 +1693,22 @@ out: int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, bool level) { - if (likely(vgic_ready(kvm)) && - vgic_update_irq_pending(kvm, cpuid, irq_num, level)) + int ret = 0; + + if (unlikely(!vgic_initialized(kvm))) { + mutex_lock(&kvm->lock); + ret = vgic_init(kvm); + mutex_unlock(&kvm->lock); + + if (ret) + goto out; + } + + if (vgic_update_irq_pending(kvm, cpuid, irq_num, level)) vgic_kick_vcpus(kvm); - return 0; +out: + return ret; } static irqreturn_t vgic_maintenance_handler(int irq, void *data)
Userspace assumes that it can wire up IRQ injections after having created all VCPUs and after having created the VGIC, but potentially before starting the first VCPU. This can currently lead to lost IRQs because the state of that IRQ injection is not stored anywhere and we don't return an error to userspace. We haven't seen this problem manifest itself yet, presumably because guests reset the devices on boot, but this could cause issues with migration and other non-standard startup configurations. Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org> --- virt/kvm/arm/vgic.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)