From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
qemu-arm@nongnu.org, kvm@vger.kernel.org
Subject: [RFC PATCH v2 06/10] target/arm: Replace kvm_arm_pmu_supported by host_cpu_feature_supported
Date: Tue, 12 Aug 2025 19:31:30 +0200 [thread overview]
Message-ID: <20250812173131.86888-2-philmd@linaro.org> (raw)
In-Reply-To: <20250812173131.86888-1-philmd@linaro.org>
Use the generic host_cpu_feature_supported() helper to
check for the PMU feature support. This will allow to
expand to non-KVM accelerators such HVF.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/kvm_arm.h | 13 -------------
target/arm/cpu.c | 6 ++++--
target/arm/kvm-stub.c | 5 -----
target/arm/kvm.c | 9 ++-------
4 files changed, 6 insertions(+), 27 deletions(-)
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
index 6a9b6374a6d..364578c50d6 100644
--- a/target/arm/kvm_arm.h
+++ b/target/arm/kvm_arm.h
@@ -177,14 +177,6 @@ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp);
*/
bool kvm_arm_aarch32_supported(void);
-/**
- * kvm_arm_pmu_supported:
- *
- * Returns: true if KVM can enable the PMU
- * and false otherwise.
- */
-bool kvm_arm_pmu_supported(void);
-
/**
* kvm_arm_sve_supported:
*
@@ -212,11 +204,6 @@ static inline bool kvm_arm_aarch32_supported(void)
return false;
}
-static inline bool kvm_arm_pmu_supported(void)
-{
- return false;
-}
-
static inline bool kvm_arm_sve_supported(void)
{
return false;
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 1dc2a8330d8..ace8e73b532 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -24,6 +24,7 @@
#include "qemu/log.h"
#include "exec/page-vary.h"
#include "target/arm/idau.h"
+#include "qemu/accel.h"
#include "qemu/module.h"
#include "qapi/error.h"
#include "cpu.h"
@@ -1564,8 +1565,9 @@ static void arm_set_pmu(Object *obj, bool value, Error **errp)
ARMCPU *cpu = ARM_CPU(obj);
if (value) {
- if (kvm_enabled() && !kvm_arm_pmu_supported()) {
- error_setg(errp, "'pmu' feature not supported by KVM on this host");
+ if (host_cpu_feature_supported(ARM_FEATURE_PMU)) {
+ error_setg(errp, "'pmu' feature not supported by %s on this host",
+ current_accel_name());
return;
}
set_feature(&cpu->env, ARM_FEATURE_PMU);
diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c
index c93462c5b9b..3beb336416d 100644
--- a/target/arm/kvm-stub.c
+++ b/target/arm/kvm-stub.c
@@ -32,11 +32,6 @@ bool kvm_arm_aarch32_supported(void)
return false;
}
-bool kvm_arm_pmu_supported(void)
-{
- return false;
-}
-
bool kvm_arm_sve_supported(void)
{
return false;
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 93da9d67806..0aa2680a8e6 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -288,7 +288,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
}
- if (kvm_arm_pmu_supported()) {
+ if (host_cpu_feature_supported(ARM_FEATURE_PMU)) {
init.features[0] |= 1 << KVM_ARM_VCPU_PMU_V3;
pmu_supported = true;
features |= 1ULL << ARM_FEATURE_PMU;
@@ -506,11 +506,6 @@ void kvm_arm_add_vcpu_properties(ARMCPU *cpu)
"Set off to disable KVM steal time.");
}
-bool kvm_arm_pmu_supported(void)
-{
- return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3);
-}
-
int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
{
KVMState *s = KVM_STATE(ms->accelerator);
@@ -1783,7 +1778,7 @@ bool host_cpu_feature_supported(enum arm_features feature)
case ARM_FEATURE_GENERIC_TIMER:
return true;
case ARM_FEATURE_PMU:
- return kvm_arm_pmu_supported();
+ return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3);
case ARM_FEATURE_EL2:
return kvm_arm_el2_supported();
case ARM_FEATURE_EL3:
--
2.49.0
next prev parent reply other threads:[~2025-08-12 17:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 17:28 [RFC PATCH v2 00/10] target/arm: Introduce host_cpu_feature_supported() API Philippe Mathieu-Daudé
2025-08-12 17:28 ` [PATCH v2 01/10] accel/system: Introduce hwaccel_enabled() helper Philippe Mathieu-Daudé
2025-08-12 17:28 ` [PATCH v2 02/10] target/arm: Use generic hwaccel_enabled() to check 'host' cpu type Philippe Mathieu-Daudé
2025-08-12 17:28 ` [PATCH v2 03/10] target/arm: Restrict PMU to system mode Philippe Mathieu-Daudé
2025-08-12 17:28 ` [PATCH v2 04/10] target/arm: Factor hvf_psci_get_target_el() out Philippe Mathieu-Daudé
2025-08-12 17:31 ` [RFC PATCH v2 05/10] target/arm: Introduce host_cpu_feature_supported() Philippe Mathieu-Daudé
2025-08-12 17:31 ` Philippe Mathieu-Daudé [this message]
2025-08-12 22:23 ` [RFC PATCH v2 06/10] target/arm: Replace kvm_arm_pmu_supported by host_cpu_feature_supported Richard Henderson
2025-08-12 17:31 ` [RFC PATCH v2 07/10] target/arm: Replace kvm_arm_el2_supported " Philippe Mathieu-Daudé
2025-08-12 22:27 ` Richard Henderson
2025-08-12 22:22 ` [RFC PATCH v2 05/10] target/arm: Introduce host_cpu_feature_supported() Richard Henderson
2025-08-12 17:31 ` [RFC PATCH v2 08/10] target/arm/hvf: Sync registers used at EL2 Philippe Mathieu-Daudé
2025-08-12 17:31 ` [RFC PATCH v2 09/10] target/arm/hvf: Consider EL2 acceleration for Silicon M3+ chipsets Philippe Mathieu-Daudé
2025-08-12 22:32 ` Richard Henderson
2025-08-12 22:31 ` [RFC PATCH v2 08/10] target/arm/hvf: Sync registers used at EL2 Richard Henderson
2025-08-13 7:20 ` Philippe Mathieu-Daudé
2025-08-13 7:35 ` Richard Henderson
2025-08-12 17:32 ` [RFC PATCH v2 10/10] target/arm/hvf: Allow EL2/EL3 emulation on Silicon M1 / M2 Philippe Mathieu-Daudé
2025-08-12 22:34 ` Richard Henderson
2025-08-13 6:08 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250812173131.86888-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).