From patchwork Tue Sep 27 18:05:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 77057 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp16370qgf; Tue, 27 Sep 2016 11:06:57 -0700 (PDT) X-Received: by 10.66.16.74 with SMTP id e10mr50265368pad.148.1474999617626; Tue, 27 Sep 2016 11:06:57 -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:57 -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 S936227AbcI0SGo (ORCPT + 3 others); Tue, 27 Sep 2016 14:06:44 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:35212 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935750AbcI0SGh (ORCPT ); Tue, 27 Sep 2016 14:06:37 -0400 Received: by mail-wm0-f43.google.com with SMTP id l132so190667712wmf.0 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=3bRji74izhSENW2IOrEfQ2z9SqQZPI3xqnHCTJsOUD4=; b=VXR4+sf6JnSmzyvjPcSlXSscIElH8PHtydcPplqSc39qOa0nT6d4KB4v8f6zm/RltD Vjm43Rjx2QdG1m+XoOKyovWFxposCK4rr+fYiwZseCU9SIQnrGsZI84/5DVCetxnj3bT PfY4MqGnJQ14bDM5FcD1FhXdW2Y7QAPZaADxU= 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=3bRji74izhSENW2IOrEfQ2z9SqQZPI3xqnHCTJsOUD4=; b=XivKKOJyN9zIMlMWW2wGRBZv5eGy7MkXAeD+qTw9fvzSZkQAl3f2vr4QxlSk0Pgp97 n95Y/wKE557Law13cTODjfUj217uHRND8cG1zAioyaWGUTcrysOmllTPeo0Wmic8uWnN XBnfoJaBKHrWXF0IUi28jIP9KRPX3jKKbFdu4oi1c9yKWlWoPVz3yxokl3I3NcKPKi/X 2L2hClk//dFw+EUzsyiHRN+KhKEbr1HcuA7+LPWhkQ41au0LHf/fniDuyGkXI3d1T7db AOschsd+ilC4GyYXNwHGa/nCOP6e8R4fbFh6T6GZnHfr5N/l6okRrQQUrCMDKR3aHgxm LTrw== X-Gm-Message-State: AA6/9RnC3SIi27gjrm7nVGpyN3XlI/gwTJCv1IkDeLzSZyfn44FXk2uhqT8km6+MdmlWSiBj X-Received: by 10.28.5.133 with SMTP id 127mr4087842wmf.128.1474999596157; 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.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 11:06:35 -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, Shannon Zhao Subject: [PULL 49/50] KVM: arm64: Require in-kernel irqchip for PMU support Date: Tue, 27 Sep 2016 20:05:57 +0200 Message-Id: <20160927180558.14699-50-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 userspace creates a PMU for the VCPU, but doesn't create an in-kernel irqchip, then we end up in a nasty path where we try to take an uninitialized spinlock, which can lead to all sorts of breakages. Luckily, QEMU always creates the VGIC before the PMU, so we can establish this as ABI and check for the VGIC in the PMU init stage. This can be relaxed at a later time if we want to support PMU with a userspace irqchip. Cc: stable@vger.kernel.org Cc: Shannon Zhao Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- Documentation/virtual/kvm/devices/vcpu.txt | 4 +++- virt/kvm/arm/pmu.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) -- 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/Documentation/virtual/kvm/devices/vcpu.txt b/Documentation/virtual/kvm/devices/vcpu.txt index c041658..02f5068 100644 --- a/Documentation/virtual/kvm/devices/vcpu.txt +++ b/Documentation/virtual/kvm/devices/vcpu.txt @@ -30,4 +30,6 @@ Returns: -ENODEV: PMUv3 not supported attribute -EBUSY: PMUv3 already initialized -Request the initialization of the PMUv3. +Request the initialization of the PMUv3. This must be done after creating the +in-kernel irqchip. Creating a PMU with a userspace irqchip is currently not +supported. diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c index a027569..6e9c40e 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c @@ -423,6 +423,14 @@ static int kvm_arm_pmu_v3_init(struct kvm_vcpu *vcpu) if (!kvm_arm_support_pmu_v3()) return -ENODEV; + /* + * We currently require an in-kernel VGIC to use the PMU emulation, + * because we do not support forwarding PMU overflow interrupts to + * userspace yet. + */ + if (!irqchip_in_kernel(vcpu->kvm) || !vgic_initialized(vcpu->kvm)) + return -ENODEV; + if (!test_bit(KVM_ARM_VCPU_PMU_V3, vcpu->arch.features) || !kvm_arm_pmu_irq_initialized(vcpu)) return -ENXIO;