From patchwork Mon Sep 4 12:25:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111577 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1480720qge; Mon, 4 Sep 2017 05:45:26 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5g/+q3OspXx7Ni/mRVYy7lC529KiWVIePb+NPiFSuuSfW5hYnGywqrslU1tfUht648rAok X-Received: by 10.55.201.155 with SMTP id m27mr627821qkl.57.1504529126080; Mon, 04 Sep 2017 05:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529126; cv=none; d=google.com; s=arc-20160816; b=1EVS4aeGwPDeYBz8XGEm8YLCe1SNYVyyO1nYPPkIA4TTurHOYAKFljXjN4Z+870d6D MlQlrDJReeJ4ZLnryk3dTuX2jeoQKZYZHy+0KIkpBTcDsWqrrh3cfsAw1jQ/1I65wiza YdABMoZlMXjk2tmVVd1ssU1uTCIio9BJxqvCoGF7JarBvJTwT+z4ajH73jL/xBONhgfi Sb6X9Q3cM4hE0O7HHJnyaA/Lz581y4ENdSWP/LI4CHkLAhc7U4OGH6xGTCo6MC/lw2JT 5k2FjeUG6k9RKwCLtLpH32WTQwGIdWrlzn9AVjItpmWLVhkFyW3TsbjsBFj7CqQkBHaP Xwyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=/FGxQCT9QvaCiwY2Tb9zbWvh1T0a+ptkHvr9E4ChVss=; b=XScMJiHsk7X7JRCN9inXo+S6IeCxAuFa0+Jh02K+LnMaUaUrC5Nv02YrEj0GXfvgZ0 /ahah6+Ck5IlbUxGDWuxT3noXEld3PtMkThGO778vpgXnXA96MjmA21Z67vwRz8E6pdd 3J+6gNG/vSl6LCSJzUZROEli1jmblvJs3QnUTNApJWCK36IAqWCSaudMUczuT4PZX7Ky wdbwEVFhGPont/4W3R6wNXEcjC2BROfdFjCi7Gc8vBjo2+xh9tcZrp8w+h0b+zlI/lnq IUCecLOJSJooIng45QBTMIMNQD6dZIj6Q5ALQbmG9NT7EAxyncHzxDEUf2KGU8CrD83M LtLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t38si6970131qtj.42.2017.09.04.05.45.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqkm-0002KV-1V for patch@linaro.org; Mon, 04 Sep 2017 08:45:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSX-00056l-VL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSJ-0004qq-DA for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:33 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSJ-0004pl-5m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSI-0005YG-1F for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:18 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:52 +0100 Message-Id: <1504527967-29248-22-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 21/36] hw/arm/virt: allow pmu instantiation with userspace irqchip X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Move the in-kernel-irqchip test to only guard the set-irq stage, not the init stage of the PMU. Also add the PMU to the KVM device irq line synchronization to enable its use. Signed-off-by: Andrew Jones Reviewed-by: Christoffer Dall Message-id: 1500471597-2517-4-git-send-email-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/virt.c | 3 ++- target/arm/kvm.c | 6 +++++- target/arm/kvm64.c | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d6e2486..999f448 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -496,7 +496,8 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) return; } if (kvm_enabled()) { - if (!kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ))) { + if (kvm_irqchip_in_kernel() && + !kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ))) { return; } if (!kvm_arm_pmu_init(cpu)) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7c17f0d..211a7bf 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -567,7 +567,11 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) switched_level &= ~KVM_ARM_DEV_EL1_PTIMER; } - /* XXX PMU IRQ is missing */ + if (switched_level & KVM_ARM_DEV_PMU) { + qemu_set_irq(cpu->pmu_interrupt, + !!(run->s.regs.device_irq_level & KVM_ARM_DEV_PMU)); + switched_level &= ~KVM_ARM_DEV_PMU; + } if (switched_level) { qemu_log_mask(LOG_UNIMP, "%s: unhandled in-kernel device IRQ %x\n", diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index e26638a..ec7d853 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -506,8 +506,7 @@ int kvm_arch_init_vcpu(CPUState *cs) if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; } - if (!kvm_irqchip_in_kernel() || - !kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { cpu->has_pmu = false; } if (cpu->has_pmu) {