From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32B65C433EF for ; Wed, 22 Sep 2021 00:07:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E9AA61178 for ; Wed, 22 Sep 2021 00:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232171AbhIVAJN (ORCPT ); Tue, 21 Sep 2021 20:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232156AbhIVAI3 (ORCPT ); Tue, 21 Sep 2021 20:08:29 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E829C061766 for ; Tue, 21 Sep 2021 17:06:17 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id h18-20020ad446f2000000b0037a7b48ba05so7041648qvw.19 for ; Tue, 21 Sep 2021 17:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=6Icjr/ACV1XsfVUfKjKZi9JPiJa8aiN8zAxRj7zkg58=; b=lodyKSv5s5L9FuAs5M0G0kMx/zVrl93Ee68EIaXohxy+LQ+d8m+TXXDCkue1vWSnVV ViQYh0dHzV9iJNwFB6yjTYg0JxCSrOowA0Ye/c7r2V2aOqrV/LmltE8U0Zt+k8GFxu9h 2la1t1UJWIkOSVjh2yV0uEzAZiwrdvHA0zHKk46Dq/OX6UEK0uGcCRXWfsZIO3eQTKqS ConZVcLZT+4wy0TFLTPjpjtLAOIGL9YLutbbFVl73zcBDJOID6vgd5v4Ln2GZlWHiqop o86J2gkYFymM8L2O6tTywYJkqskrpEBIkrTz73Gvpj/PmQ5jYyO0eaPS4tdU3c0It1S4 A6OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=6Icjr/ACV1XsfVUfKjKZi9JPiJa8aiN8zAxRj7zkg58=; b=VE2SONzn7y0FHc8ReGyy6hDTqr4xoDiJpWs24Vqu6k0RJ5mjcEfxRvtcw98NRLRsxr n3xtWTzb1DETgnOXXB8ALcWy4vYAk0hRqrCqM5XCRnZEwOwBbdbpGVBcim28Lb+hJbJI 915Dd3IWsy0pa34QjxcPSQKbcbBJLqBDYpkLS2CnoNO+7jcxXdc1E20gfReXIWP4y7oK u2dQ9t6aa+LAJeOgV+N4xVIiv51EqnaTRX6B0FoacRit5Bpl8Xx9f7/TAYzESM0Fk3hD WQHL5ElntcXMrZkAJFNNm/cp8Wa0ANZ308yQN9IpesZ7nMkAIiQ7PJzR1/v0XikED2ZA uyIQ== X-Gm-Message-State: AOAM533anRWRGCowZMo9L696sNaZcepsLbYO+0Fj7WH64XrR89GVtJP/ 5ydu7XrzW+OQkAv7KPM5XGmmf25ZtSY= X-Google-Smtp-Source: ABdhPJzlQAzmSdl3nY/YBM5ZcGipBomoLCiu3CqrYXxVZ0o44Jz0iqe4JnQizT8BW9SKS2QFzZIdD02YgoQ= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:90:200:b022:92d6:d37b:686c]) (user=seanjc job=sendgmr) by 2002:a25:7350:: with SMTP id o77mr39621975ybc.549.1632269176658; Tue, 21 Sep 2021 17:06:16 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 21 Sep 2021 17:05:32 -0700 In-Reply-To: <20210922000533.713300-1-seanjc@google.com> Message-Id: <20210922000533.713300-16-seanjc@google.com> Mime-Version: 1.0 References: <20210922000533.713300-1-seanjc@google.com> X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH v3 15/16] KVM: arm64: Drop perf.c and fold its tiny bits of code into arm.c / pmu.c From: Sean Christopherson To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Marc Zyngier , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Boris Ostrovsky , Juergen Gross Cc: Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Artem Kashkanov , Like Xu , Zhu Lingshan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org Call KVM's (un)register perf callbacks helpers directly from arm.c, and move the PMU bits into pmu.c and rename the related helper accordingly. Signed-off-by: Sean Christopherson --- arch/arm64/include/asm/kvm_host.h | 3 --- arch/arm64/kvm/Makefile | 2 +- arch/arm64/kvm/arm.c | 6 ++++-- arch/arm64/kvm/perf.c | 27 --------------------------- arch/arm64/kvm/pmu.c | 8 ++++++++ include/kvm/arm_pmu.h | 1 + 6 files changed, 14 insertions(+), 33 deletions(-) delete mode 100644 arch/arm64/kvm/perf.c diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 828b6eaa2c56..f141ac65f4f1 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -670,9 +670,6 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len); int kvm_handle_mmio_return(struct kvm_vcpu *vcpu); int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa); -void kvm_perf_init(void); -void kvm_perf_teardown(void); - #ifdef CONFIG_GUEST_PERF_EVENTS static inline bool kvm_arch_pmi_in_guest(struct kvm_vcpu *vcpu) { diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile index 989bb5dad2c8..0bcc378b7961 100644 --- a/arch/arm64/kvm/Makefile +++ b/arch/arm64/kvm/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_KVM) += hyp/ kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \ $(KVM)/vfio.o $(KVM)/irqchip.o $(KVM)/binary_stats.o \ - arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o \ + arm.o mmu.o mmio.o psci.o hypercalls.o pvtime.o \ inject_fault.o va_layout.o handle_exit.o \ guest.o debug.o reset.o sys_regs.o \ vgic-sys-reg-v3.o fpsimd.o pmu.o \ diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 2b542fdc237e..48f89d80f464 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1744,7 +1744,9 @@ static int init_subsystems(void) if (err) goto out; - kvm_perf_init(); + kvm_pmu_init(); + kvm_register_perf_callbacks(NULL); + kvm_sys_reg_table_init(); out: @@ -2160,7 +2162,7 @@ int kvm_arch_init(void *opaque) /* NOP: Compiling as a module not supported */ void kvm_arch_exit(void) { - kvm_perf_teardown(); + kvm_unregister_perf_callbacks(); } static int __init early_kvm_mode_cfg(char *arg) diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c deleted file mode 100644 index 0b902e0d5b5d..000000000000 --- a/arch/arm64/kvm/perf.c +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Based on the x86 implementation. - * - * Copyright (C) 2012 ARM Ltd. - * Author: Marc Zyngier - */ - -#include -#include - -#include - -DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available); - -void kvm_perf_init(void) -{ - if (kvm_pmu_probe_pmuver() != 0xf && !is_protected_kvm_enabled()) - static_branch_enable(&kvm_arm_pmu_available); - - kvm_register_perf_callbacks(NULL); -} - -void kvm_perf_teardown(void) -{ - kvm_unregister_perf_callbacks(); -} diff --git a/arch/arm64/kvm/pmu.c b/arch/arm64/kvm/pmu.c index 03a6c1f4a09a..d98b57a17043 100644 --- a/arch/arm64/kvm/pmu.c +++ b/arch/arm64/kvm/pmu.c @@ -7,6 +7,14 @@ #include #include +DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available); + +void kvm_pmu_init(void) +{ + if (kvm_pmu_probe_pmuver() != 0xf && !is_protected_kvm_enabled()) + static_branch_enable(&kvm_arm_pmu_available); +} + /* * Given the perf event attributes and system type, determine * if we are going to need to switch counters at guest entry/exit. diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h index 864b9997efb2..42270676498d 100644 --- a/include/kvm/arm_pmu.h +++ b/include/kvm/arm_pmu.h @@ -14,6 +14,7 @@ #define ARMV8_PMU_MAX_COUNTER_PAIRS ((ARMV8_PMU_MAX_COUNTERS + 1) >> 1) DECLARE_STATIC_KEY_FALSE(kvm_arm_pmu_available); +void kvm_pmu_init(void); static __always_inline bool kvm_arm_support_pmu_v3(void) { -- 2.33.0.464.g1972c5931b-goog