From patchwork Tue Dec 9 15:44:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42060 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 5A38A25E75 for ; Tue, 9 Dec 2014 15:46:11 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf975079eek.0 for ; Tue, 09 Dec 2014 07:46:10 -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=McgJGCIqe2SKT5Ug7YdiYjQGXVHUiAuB6gFO5mUX93Y=; b=O8NH2Ia2OBXFuZYjD/qnPPWQ6CX0W/qe0L6aJFiW21YyZmWFyV6PNk5qnhIA/hgUgm 0F1DnvPq0aYy+eCv1Z55Q5twGOePHzUUs3u5ue2ydWwRYs7VTbR6+XYSb0i9M4Mka/OU nzWgQtwRjJtANEEtQJTaHRaRVpEEgC18uifLlCRmJiSGbXkpVOqIqM8lcT+K92v5be7E PI6MG+2LpIHDBUqiVaaKhVfya7nr+DJSaBd6lhQVB5U9F9bwq1hKVjEkH8ZC6YW7eOzP V6+asr7KQz5dwwqka4g5TB4EJrenz4dsbc3ojGnmrH3NvM1hbfBbaqTPw1YCfEzQQvbv rn8w== X-Gm-Message-State: ALoCoQnTXxLqFmZTowmFYP7nBydmv9qu2ViQsHBmOwyDIKx6W3aXoWwRCxfPD80AfIogHMh5BFN4 X-Received: by 10.152.43.50 with SMTP id t18mr177440lal.8.1418139970557; Tue, 09 Dec 2014 07:46:10 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.168 with SMTP id n8ls46398laf.65.gmail; Tue, 09 Dec 2014 07:46:10 -0800 (PST) X-Received: by 10.112.199.138 with SMTP id jk10mr22390238lbc.86.1418139970313; Tue, 09 Dec 2014 07:46:10 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id ml2si1752233lbc.7.2014.12.09.07.46.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 07:46:10 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so734205lab.26 for ; Tue, 09 Dec 2014 07:46:10 -0800 (PST) X-Received: by 10.112.138.137 with SMTP id qq9mr22400582lbb.80.1418139970224; Tue, 09 Dec 2014 07:46:10 -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 ew9csp769817lbc; Tue, 9 Dec 2014 07:46:09 -0800 (PST) X-Received: by 10.70.128.203 with SMTP id nq11mr31613159pdb.52.1418139968060; Tue, 09 Dec 2014 07:46:08 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e4si2506653pdk.32.2014.12.09.07.46.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2014 07:46:08 -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 1XyMxx-0005KO-O7; Tue, 09 Dec 2014 15:44:45 +0000 Received: from mail-la0-f52.google.com ([209.85.215.52]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XyMwz-0004kK-Jp for linux-arm-kernel@lists.infradead.org; Tue, 09 Dec 2014 15:43:46 +0000 Received: by mail-la0-f52.google.com with SMTP id hs14so758163lab.11 for ; Tue, 09 Dec 2014 07:43:21 -0800 (PST) X-Received: by 10.112.56.134 with SMTP id a6mr22584475lbq.25.1418139801530; Tue, 09 Dec 2014 07:43:21 -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.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 07:43:20 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/5] arm/arm64: KVM: Initialize the vgic on-demand when injecting IRQs Date: Tue, 9 Dec 2014 16:44:04 +0100 Message-Id: <1418139844-27892-6-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_074345_893283_6B5E9D0D X-CRM114-Status: GOOD ( 11.63 ) 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.52 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.52 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 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.53 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 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 --- virt/kvm/arm/vgic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index c98cc6b..feef015 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1693,8 +1693,13 @@ 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)) + if (unlikely(!vgic_initialized(kvm))) { + mutex_lock(&kvm->lock); + vgic_init(kvm); + mutex_unlock(&kvm->lock); + } + + if (vgic_update_irq_pending(kvm, cpuid, irq_num, level)) vgic_kick_vcpus(kvm); return 0;