From patchwork Tue Sep 15 03:11:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 11775425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72B8592C for ; Tue, 15 Sep 2020 03:19:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23A8220936 for ; Tue, 15 Sep 2020 03:19:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UbhBHfdH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23A8220936 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI1V4-0003vd-5W for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 Sep 2020 23:19:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI1OD-0000Td-Hk for qemu-devel@nongnu.org; Mon, 14 Sep 2020 23:12:17 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:33476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kI1OB-0001jM-Gn for qemu-devel@nongnu.org; Mon, 14 Sep 2020 23:12:17 -0400 Received: by mail-pj1-x1042.google.com with SMTP id md22so6011936pjb.0 for ; Mon, 14 Sep 2020 20:12:15 -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 :mime-version:content-transfer-encoding; bh=aCZKhsO2QByw5JkTztWmspLBY6hhifDHq83bnO4MirI=; b=UbhBHfdHE5lGvQcilmgrKiB9r+0yqiUTOTX/9IqRFtJwYgSutwh77YzdkFqi3wnbOW AIkmAs8iQrWPIpwHdgELqfmXannsoSSn7cQFPsShV4n7WFTDyY39oC/D8rPaf534KJ10 xkylBqBXc9wvEH63hpfUjGU575y0nkYGFPo8NivUVwleeokU5546zhFNMRVi74/TwE8/ glgla5NaE2ByPMIDDa2lmqD5AK06T0gmQnV3cGGptL2iS9FhtowXbRQwBN4QaIs8eu87 pj3Y9/gQMs2QazTxXGySKQoshhkLPtudlVW8MMMssbZsZYYUmLh1FbxXbA4oM9tjedB2 PrCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aCZKhsO2QByw5JkTztWmspLBY6hhifDHq83bnO4MirI=; b=bs8e/Ovruaa3Q24vrotoW307+zb0KvJV54XZt/et4340XGAoEV0jLehs6vgoJ6FjgR c0MPeyLHh80bVGIMHKqPPiAcij0coRC7G/wsSDEIVu8NOiDETTz7b6elEeWtHsowwyEA Z5e6Qt0XrQo4l4YXqErAbQF9qLhoXdA1OdMuXPlDjYi+CsRdld+asW/fqFjZugd6eWCb HkxQLuGCYibJAusI1m+PFaBJE5iHnZ1Iogw50nA4YItvFBnR45lgAWmCCi0vH+shkDX4 GbWMLOCibheWqQqysM1RZ4BjXjfFa4m6xlPN3n3VNl8ky2Jw8GOWrXOG7ksR7egSr5tJ Cjnw== X-Gm-Message-State: AOAM533k09ZX++15tC0h7RJ4pHGyMaMX+Rmt0Hp2bhvG6/Ut7j6sRz8B 6Ghun6/tBIzne60dWqhcOXfj X-Google-Smtp-Source: ABdhPJz3OIFYOtx0gyTilkVsWVTWSYN7sRCAaQXOdXo690sP2UqQCuQlCDbhASNkcniMopZzxhvLMA== X-Received: by 2002:a17:90b:80f:: with SMTP id bk15mr2274019pjb.36.1600139534178; Mon, 14 Sep 2020 20:12:14 -0700 (PDT) Received: from localhost.localdomain ([147.75.106.138]) by smtp.gmail.com with ESMTPSA id g23sm11551776pfh.133.2020.09.14.20.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 20:12:13 -0700 (PDT) From: Haibo Xu To: drjones@redhat.com, richard.henderson@linaro.org Subject: [PATCH v3 08/12] hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init Date: Tue, 15 Sep 2020 03:11:44 +0000 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=haibo.xu@linaro.org; helo=mail-pj1-x1042.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, philmd@redhat.com, qemu-devel@nongnu.org, Haibo Xu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Move the KVM PMU setup part of fdt_add_pmu_nodes() to virt_cpu_post_init(), which is a more appropriate location. Now fdt_add_pmu_nodes() is also named more appropriately, because it no longer does anything but fdt node creation. No functional change intended. Signed-off-by: Andrew Jones Reviewed-by: Peter Maydell --- hw/arm/virt.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 2ffcb073af..6bacfb668d 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -521,21 +521,12 @@ static void fdt_add_gic_node(VirtMachineState *vms) static void fdt_add_pmu_nodes(const VirtMachineState *vms) { - CPUState *cpu; - ARMCPU *armcpu; + ARMCPU *armcpu = ARM_CPU(first_cpu); uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI; - CPU_FOREACH(cpu) { - armcpu = ARM_CPU(cpu); - if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { - return; - } - if (kvm_enabled()) { - if (kvm_irqchip_in_kernel()) { - kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); - } - kvm_arm_pmu_init(cpu); - } + if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { + assert(!object_property_get_bool(OBJECT(armcpu), "pmu", NULL)); + return; } if (vms->gic_version == VIRT_GIC_VERSION_2) { @@ -544,7 +535,6 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) (1 << vms->smp_cpus) - 1); } - armcpu = ARM_CPU(qemu_get_cpu(0)); qemu_fdt_add_subnode(vms->fdt, "/pmu"); if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) { const char compat[] = "arm,armv8-pmuv3"; @@ -1674,11 +1664,23 @@ static void finalize_gic_version(VirtMachineState *vms) static void virt_cpu_post_init(VirtMachineState *vms) { - bool aarch64; + bool aarch64, pmu; + CPUState *cpu; aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL); + pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL); - if (!kvm_enabled()) { + if (kvm_enabled()) { + CPU_FOREACH(cpu) { + if (pmu) { + assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU)); + if (kvm_irqchip_in_kernel()) { + kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); + } + kvm_arm_pmu_init(cpu); + } + } + } else { if (aarch64 && vms->highmem) { int requested_pa_size = 64 - clz64(vms->highest_gpa); int pamax = arm_pamax(ARM_CPU(first_cpu));