From patchwork Thu Aug 1 04:58:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mingwei Zhang X-Patchwork-Id: 13749544 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 608D014388E for ; Thu, 1 Aug 2024 04:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722488391; cv=none; b=H4DIvpKH535nDtBuiRj7EQhnkpAy74JjrlDj1aZ9raZ0YIAHx8swzF+uBa6u0atx4j1occIjZb65i2NkgwoSMN0/B1HOG0Smac4j59X/SzH+NzRcVZXbQ8ZC1xr9eqKalT5qhFnLwcTrzjlcURJwxEDAZPMI5CXD30IBb6pYmm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722488391; c=relaxed/simple; bh=BaHu02UFGqjoVlKM/KF0W8Z1EcBs0bxy9IzWhYDzC2A=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Hvo7243j387XfeL7wkNJjFArtQmTTSxd7q2X5TofUUeDHilt+EC/rKlk+CU4t+qhnvrz0UrcPiMBcujRUacuzUBEXzZ/snKTm6YQ+0SyXzrdK3tscKs66Xs/FFoduooYOkJjyQohaxhxWyJA3vwzGM1NjS9Ema2GCvT6ELhl81k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--mizhang.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=PK0BQ5DH; arc=none smtp.client-ip=209.85.215.202 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--mizhang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PK0BQ5DH" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-7ad78c1a019so4320608a12.2 for ; Wed, 31 Jul 2024 21:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722488390; x=1723093190; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=RUvQCQx/WMIpOOFe9mcTTW5PZCf+TCUSSqHzyb7UegQ=; b=PK0BQ5DH9hon1toAm7uuoTbuasYKVwaq1eEvGzpK7piVVqv6R60PqoPZQlP7xrqubf 2kHO8Qe9aPc2Xs4tXeb9F0XdkvEsUdYobIbUF5xdS8sdHazjpLGfx+JT5FwsBFpyl3zG YpHF/kM2dLIOulCH38KzG4o3FkrE9BM1CcV6HZfa+EFm5NPqIPc9LTZAtbt4ZOgv6yAD 9YpTYwwQ6FbZZdy4SxM1c06jmcqV0AyQ+pitkE663x2esSlfRit8uy7K4HNqyHhxMIMH YZFr4m40pngUZwHlhPbCU8KJnCpWC2eUw4TRp12XlJLtryoWVGa2wb074Yr7Mhgd7eUf Mozw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722488390; x=1723093190; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RUvQCQx/WMIpOOFe9mcTTW5PZCf+TCUSSqHzyb7UegQ=; b=pmJtW5JljDRYuo+s5wqod/CD+/7Qs936gWK8bmrbxbrowDl/M3V34m/Npa3AJUyFny aOLfW5ZDbQYDDRn0b4h7ULayWvtW0rIJnvJxAjlxkzKDsgm92VKjao9LI/5bT6f3K0T3 RVMk65Hk6NstcnAJwXuQC503InvMFO0OCdDbaAFEDj5ES4XirYOKWDVU2dOFjK+IigZq mQ8XRE2DsUYs+Ekxa2Eg67mFRmU1dvG0Lq0WgJ2yA4SIJYbr2PKJGyahG2kC0wsBf/Wm X4xvrwtZsWq6iw7nv57Fi7EBn0BqVux4IrdjFXOIo9O78rIp+2hEdy1agRDTTvyKtLCK do8A== X-Forwarded-Encrypted: i=1; AJvYcCXMuHogrx4HWox3IjlIpS7d1sV6OvnkLNe6FY4WyytqZC/MzXccQi2/ZLm0wQxJk5FotmX5eQu1GTskh5eipT6CKnkc X-Gm-Message-State: AOJu0Yx+5epPVwh+k/iD9oNGhGoH2YdRKsJlBr11AXmjfKwBZfBwjje8 OnMiNZb0d03xUR7mf85vFUk4pIXKjXOE8imJg3ZEWvkMrKTfGwg09b3fvtSWymW3JH0Wcf2MNg6 WIAQINg== X-Google-Smtp-Source: AGHT+IHjXcgdfDuOm2S1Gi0CNX+VfGrMUYUIMcwlsSzve61nT6t1siC1nF2RVWD4E2UIzf/j4bY/WUAd3RI8 X-Received: from mizhang-super.c.googlers.com ([34.105.13.176]) (user=mizhang job=sendgmr) by 2002:a65:6813:0:b0:76c:26a8:e0dc with SMTP id 41be03b00d2f7-7b634c51fcbmr2594a12.5.1722488389288; Wed, 31 Jul 2024 21:59:49 -0700 (PDT) Reply-To: Mingwei Zhang Date: Thu, 1 Aug 2024 04:58:30 +0000 In-Reply-To: <20240801045907.4010984-1-mizhang@google.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240801045907.4010984-1-mizhang@google.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog Message-ID: <20240801045907.4010984-22-mizhang@google.com> Subject: [RFC PATCH v3 21/58] KVM: x86/pmu: Add a helper to check if passthrough PMU is enabled From: Mingwei Zhang To: Sean Christopherson , Paolo Bonzini , Xiong Zhang , Dapeng Mi , Kan Liang , Zhenyu Wang , Manali Shukla , Sandipan Das Cc: Jim Mattson , Stephane Eranian , Ian Rogers , Namhyung Kim , Mingwei Zhang , gce-passthrou-pmu-dev@google.com, Samantha Alt , Zhiyuan Lv , Yanfei Xu , Like Xu , Peter Zijlstra , Raghavendra Rao Ananta , kvm@vger.kernel.org, linux-perf-users@vger.kernel.org Add a helper to check if passthrough PMU is enabled for convenience as it is vendor neutral. Signed-off-by: Mingwei Zhang Signed-off-by: Dapeng Mi Tested-by: Yongwei Ma --- arch/x86/kvm/pmu.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h index cf93be5e7359..56ba0772568c 100644 --- a/arch/x86/kvm/pmu.h +++ b/arch/x86/kvm/pmu.h @@ -48,6 +48,11 @@ struct kvm_pmu_ops { void kvm_pmu_ops_update(const struct kvm_pmu_ops *pmu_ops); +static inline bool is_passthrough_pmu_enabled(struct kvm_vcpu *vcpu) +{ + return vcpu_to_pmu(vcpu)->passthrough; +} + static inline bool kvm_pmu_has_perf_global_ctrl(struct kvm_pmu *pmu) { /*