From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795114340; b=cMpMWCHZQOezkiDHE3WCRQfZK9JIquSF7tzb0skrIOiIkKkIIX5/TuyYhjt1a8yaozrn xHdDc20mwfLnJR4uVF2F+/OQSLOCgfMOION2KVraMTfBHq5h1Ei4laR4/9F0r8GMtNVDC /7ueWtM96DAxgcLFuXCk2cI0ghr2MOml0Q0/fHxFCay7RxIE3AJmtjbIA2wF9Wu+yOkJF /yRN8OSO+UZ8W8C5XFGo5T7hIm34Yodk2RAUBjoUhJmUA5d8HJGcfG4qcIGxfWU2OoLD4 UAt70w72aurOklL4Gz8+c9XEoM1otAgQhSPenXWH6nM9RmUqWzrOSXwjy++dTGnPX2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795114340; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=4mbmiczFFpidgrYK+TVGYqzAKnw9jrEy+vGtBPKYYRo=; b=BE3vceIj6I1u5qqQBGxNbGb4Wu3NAMkgROQpE5SRPDhIBu41Aaz2QXgc9UVDvc8dhdU/ j+h+Rel+By5jb1dBYsCZpB1439S7z6dqNsZcQVkwMmYbqwKwghrSgp3LkmUd3DZHhoP74 DCXatH+VzPEUFIApdAkXVmoX3Zy/DWe/0AT9c3uUW2BetwVihECiq132+vUE6Zhyj4ds4 sWMZEkss/Ks8vdtB/XkElf3YGhNANLIvadQSxurQmLIxhrDkqfV6zWW3HMBl/laQN1EXu xgsWOQk679qsQ2VVuHS99CgnIN+awlrFN02/fQJVPqbFABF70h55rt+96FWW2B3zh5A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=HiqIaiA6; arc=none smtp.remote-ip=209.85.167.198 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55DFA606A33B for ; Thu, 19 Nov 2026 18:52:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 55DFA606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=HiqIaiA6 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-4db3db8687fso211535b6e.0 for ; Thu, 19 Nov 2026 10:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795114338; x=1795719138; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4mbmiczFFpidgrYK+TVGYqzAKnw9jrEy+vGtBPKYYRo=; b=HiqIaiA6v4cF1tVA8UhuIQv1jh8S+CbUtkWvyNGuQcEWCFHL3RqgIUClWV/WWzfvya qXeDZX38jW7FGHI5aH/HW/RIVZgxV9elNofEhYHjz3pSZjE5Hrbygm5hkhNL9MSUKrQ7 hw3sfi47NWsbsiwzkA5ibbxNLSCg5EwSseKyOmcusC83l85SR3Gdb0zwD+prTH4qfo0E p0jxonsHIND/cWO4Sd3fxkrZKbiHlZsFzKMFXwhTv/KVRZ8xGt1yyKHVAqbsRP93lTHJ DSBBgogcWfxurruxGHu6D4ct3NAgn4gzyQHQp+Q4pXC2xw967g9tN4nybwtZ6zuIdMvE z4vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795114338; x=1795719138; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4mbmiczFFpidgrYK+TVGYqzAKnw9jrEy+vGtBPKYYRo=; b=TPuuooT1aRA4l7sbs6XgtnxcNTO2Nq6PnJm+E+bJlW0bdMM/9ttZAc1cDNMXOmdYVo aUiKY7ryh/XDfjZegEABmRCqV3zwc5ip+7fv6ZrYUH2aIBwrjJjfwATYt6lHeDaxM/6i BA3LhwREmqQr0ClplgzKZrLjV94B2RNbPKJwjSY8UE1NtExRLRrb/E/uj5wOD1M+vh+a 0P6YsVuoskfmh2SQ0JjNpg+Rn6XZJ3Dk+fI0lgHRRXnxXVOE+uNQjfcomaiUKZLw9dlw ua7S+bVBpCwVmACCsm8nbmCtRmQ6N4mhmpCYkZQNZUMdtn6+BQddHNN6to/xw5wGFXwy A74Q== X-Forwarded-Encrypted: i=1; AL+hErH/Jo53W80mBY1pao/9y3G25BrzyN6l4YVA+ikuWpc3lQ83uYICIY1FiVF6syUYMZtXjHjCUE51ez7FTDQ=@vger.kernel.org X-Gm-Message-State: APuU4Z8rw8lvRPXRlphh8eBSxIZ7+5RsqGaIyFWd6LlRvmhK/4y1HOo4 Gswd7frduqi/SFG2en2dG0kTh9DqmQRPkGbtS1RD1ZlLOGwd5eK/GKQEinyMvWu72oWlQMJobJX bkeT3FhKGKokbXT3sitMH/wO7VA== X-Received: from iocow20-n2.prod.google.com ([2002:a05:6602:c5d4:20b0:9c3:a521:d29a]) (user=coltonlewis job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:1394:b0:4f3:68d6:f131 with SMTP id 5614622812f47-57a077147a3mr938738b6e.2.1795114337968; Thu, 19 Nov 2026 10:52:17 -0800 (PST) Date: Thu, 19 Nov 2026 18:51:44 +0000 In-Reply-To: <20261119185215.632334-1-coltonlewis@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261119185215.632334-1-coltonlewis@google.com> X-Mailer: git-send-email 2.56.1.809.ga0b61035b5-goog Message-ID: <20261119185215.632334-3-coltonlewis@google.com> Subject: [PATCH v10 02/33] KVM: arm64: Reorganize PMU includes From: Colton Lewis To: Marc Zyngier , Oliver Upton Cc: Catalin Marinas , Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , Paolo Bonzini , Russell King , Jonathan Corbet , Fuad Tabba , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Shuah Khan , James Clark , Alexandru Elisei , Mingwei Zhang , Ganapatrao Kulkarni , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" From: Marc Zyngier Including *all* of asm/kvm_host.h in asm/arm_pmuv3.h is a bad idea because that is much more than arm_pmuv3.h logically needs and creates a circular dependency that makes it easy to introduce compiler errors when editing this code. asm/kvm_host.h includes kvm/arm_pmu.h includes perf/arm_pmuv3.h includes asm/arm_pmuv3.h includes asm/kvm_host.h Reorganize the PMU includes to be more sane. In particular: - Remove the circular dependency by removing the kvm_host.h include from asm/arm_pmuv3.h since 99% of it isn't needed. - Move the remaining tiny bit of KVM/PMU interface from kvm_host.h into arm_pmu.h - Conditionally on ARM64, include the more targeted arm_pmu.h directly in the arm_pmuv3.c driver. Signed-off-by: Marc Zyngier Tested-by: James Clark Signed-off-by: Colton Lewis --- arch/arm64/include/asm/arm_pmuv3.h | 2 -- arch/arm64/include/asm/kvm_host.h | 14 -------------- drivers/perf/arm_pmuv3.c | 5 +++++ include/kvm/arm_pmu.h | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/arm_pmuv3.h b/arch/arm64/include/asm/arm_pmuv3.h index 8a777dec8d88a..cf2b2212e00a2 100644 --- a/arch/arm64/include/asm/arm_pmuv3.h +++ b/arch/arm64/include/asm/arm_pmuv3.h @@ -6,8 +6,6 @@ #ifndef __ASM_PMUV3_H #define __ASM_PMUV3_H -#include - #include #include diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 97332ffcb1300..4683281fcc5d4 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1534,25 +1534,11 @@ void kvm_arch_vcpu_ctxflush_fp(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu); -static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr) -{ - return (!has_vhe() && attr->exclude_host); -} - #ifdef CONFIG_KVM -void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr); -void kvm_clr_pmu_events(u64 clr); -bool kvm_set_pmuserenr(u64 val); void kvm_enable_trbe(void); void kvm_disable_trbe(void); void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest); #else -static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr) {} -static inline void kvm_clr_pmu_events(u64 clr) {} -static inline bool kvm_set_pmuserenr(u64 val) -{ - return false; -} static inline void kvm_enable_trbe(void) {} static inline void kvm_disable_trbe(void) {} static inline void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest) {} diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 03359e078301f..fbd631ec71a65 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -10,6 +10,11 @@ #include #include + +#if defined(CONFIG_ARM64) +#include +#endif + #include #include diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h index 6b4a118d17ca9..93f41ac77c25f 100644 --- a/include/kvm/arm_pmu.h +++ b/include/kvm/arm_pmu.h @@ -9,12 +9,22 @@ #include #include +#include #define KVM_ARMV8_PMU_MAX_COUNTERS 32 /* PPI #23 - architecturally specified for GICv5 */ #define KVM_ARMV8_PMU_GICV5_IRQ 0x20000017 +#define kvm_pmu_counter_deferred(attr) \ + ({ \ + !has_vhe() && (attr)->exclude_host; \ + }) + +struct kvm; +struct kvm_device_attr; +struct kvm_vcpu; + #if IS_ENABLED(CONFIG_HW_PERF_EVENTS) && IS_ENABLED(CONFIG_KVM) struct kvm_pmc { u8 idx; /* index into the pmu->pmc array */ @@ -68,6 +78,9 @@ int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu, int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu); struct kvm_pmu_events *kvm_get_pmu_events(void); +void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr); +void kvm_clr_pmu_events(u64 clr); +bool kvm_set_pmuserenr(u64 val); void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu); void kvm_vcpu_pmu_restore_host(struct kvm_vcpu *vcpu); void kvm_vcpu_pmu_resync_el0(void); @@ -165,6 +178,12 @@ static inline u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1) #define kvm_vcpu_has_pmu(vcpu) ({ false; }) #define kvm_vcpu_has_pmuv3_strict(vcpu) ({ false; }) static inline void kvm_pmu_update_vcpu_events(struct kvm_vcpu *vcpu) {} +static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr) {} +static inline void kvm_clr_pmu_events(u64 clr) {} +static inline bool kvm_set_pmuserenr(u64 val) +{ + return false; +} static inline void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu) {} static inline void kvm_vcpu_pmu_restore_host(struct kvm_vcpu *vcpu) {} static inline void kvm_vcpu_reload_pmu(struct kvm_vcpu *vcpu) {} -- 2.56.1.708.g77570a6a1d-goog