From patchwork Tue Sep 27 18:05:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 77058 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp16382qgf; Tue, 27 Sep 2016 11:06:58 -0700 (PDT) X-Received: by 10.98.3.67 with SMTP id 64mr49995620pfd.14.1474999618211; Tue, 27 Sep 2016 11:06:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x24si3699974pfj.64.2016.09.27.11.06.57; Tue, 27 Sep 2016 11:06:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935750AbcI0SGr (ORCPT + 3 others); Tue, 27 Sep 2016 14:06:47 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:36018 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935827AbcI0SGi (ORCPT ); Tue, 27 Sep 2016 14:06:38 -0400 Received: by mail-wm0-f42.google.com with SMTP id w84so190380736wmg.1 for ; Tue, 27 Sep 2016 11:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0JnTUwYuawhAFPNzyXLakvLbj2yy6ljrAPyxKiALyJA=; b=RMTzJIp3ozr1ODDRRrDw4Z+wxWF2kfGlmeUoZwTF+h+K45HzOWx27gwf8+xthyVSCf BxkCMWmtbToqslXlkId9sDcuCXdrQmQhn3ZpqdeR0ZQXKmjx1skqlAoma84sS0mDdIwQ A1Nk+nbr3BUU8AaUsEX0Z7Eb/erAi5QYXaVpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0JnTUwYuawhAFPNzyXLakvLbj2yy6ljrAPyxKiALyJA=; b=gk9S8qLCEY1ubVSZ/ejizHpjMhliBQzsHpN6Pl8OcdVn/JoxvKwTTqUj8S/I8XrlQT Kt73upkaJ/0ZOhi8KlkrQUycGHmyCsf6kwk19/TgAXpCPgRBgde8fAWxoOI9I6dweywD GXdM+7YTd+yjsk0WyYzJxGbXMkwQiimDm0H816/uiyylRxahjWZtkGkmArxWMbZpAmqE c9cfzA9pDpYOZ04nef5dHzeZUrENpQTxMR+LWbpqLafs35C8ywbjkKNVBCIn1imwMfIc ry5rRWkJ6mI9FR9QEFArGyBn7CkaUeSaTSNkdxOzioFS7CKfIEOSFYOO8scTsYnrtxs4 sU4w== X-Gm-Message-State: AE9vXwOqsqTwoHlc9jbdoyglzMEeUv0CKQoebD/owkX7QLwdebD27bvrfYx+3x5AKNHx2mtL X-Received: by 10.194.122.137 with SMTP id ls9mr29302961wjb.29.1474999596960; Tue, 27 Sep 2016 11:06:36 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id k2sm17932539wmg.23.2016.09.27.11.06.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 11:06:36 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall , stable@vger.kernel.org Subject: [PULL 50/50] KVM: arm/arm64: vgic: Don't flush/sync without a working vgic Date: Tue, 27 Sep 2016 20:05:58 +0200 Message-Id: <20160927180558.14699-51-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160927180558.14699-1-christoffer.dall@linaro.org> References: <20160927180558.14699-1-christoffer.dall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org If the vgic hasn't been created and initialized, we shouldn't attempt to look at its data structures or flush/sync anything to the GIC hardware. This fixes an issue reported by Alexander Graf when using a userspace irqchip. Fixes: 0919e84c0fc1 ("KVM: arm/arm64: vgic-new: Add IRQ sync/flush framework") Cc: stable@vger.kernel.org Reported-by: Alexander Graf Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Note that this is rework of a patch submitted by Alexander Graf, but slightly reworked to use vgic_initialized instead of vgic_enabled, as discussed on the list. virt/kvm/arm/vgic/vgic.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 8a529a7..2893d5b 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -645,6 +645,9 @@ next: /* Sync back the hardware VGIC state into our emulation after a guest's run. */ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) { + if (unlikely(!vgic_initialized(vcpu->kvm))) + return; + vgic_process_maintenance_interrupt(vcpu); vgic_fold_lr_state(vcpu); vgic_prune_ap_list(vcpu); @@ -653,6 +656,9 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) /* Flush our emulation state into the GIC hardware before entering the guest. */ void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) { + if (unlikely(!vgic_initialized(vcpu->kvm))) + return; + spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock); vgic_flush_lr_state(vcpu); spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock);