kvm-steal-time and sve properties are added for KVM even if the corresponding features are not available. Always add pmu property for "host".
Note that we still don't add the property for other CPUs that lack PMU. This is because we do not know what a PMU version should be enabled when the user sets the property to true while it is defined as an an error for the "host" CPU when the host doesn't have a PMU. This fixes qtest-aarch64/arm-cpu-features on the hosts that supports KVM but doesn't support PMU emulation. Signed-off-by: Akihiko Odaki <od...@rsg.ci.i.u-tokyo.ac.jp> --- kvm-steal-time and sve properties are added for KVM even if the corresponding features are not available. Always add pmu property for "host". Note that we still don't add the property for other CPUs that lack PMU. This is because we do not know what a PMU version should be enabled when the user sets the property to true while it is defined as an an error for the "host" CPU when the host doesn't have a PMU. --- Changes in v6: - Limited the scope of the change to the "host" CPU. - Link to v5: https://lore.kernel.org/r/20250104-pmu-v5-1-be9c8777c...@daynix.com Changes in v5: - Rebased. - Link to v4: https://lore.kernel.org/r/20240720-pmu-v4-0-2a2b28f6b...@daynix.com Changes in v4: - Split patch "target/arm/kvm: Fix PMU feature bit early" into "target/arm/kvm: Set PMU for host only when available" and "target/arm/kvm: Do not silently remove PMU". - Changed to define PMU also for Armv7. - Changed not to define PMU for M. - Extracted patch "hvf: arm: Raise an exception for sysreg by default" from "hvf: arm: Properly disable PMU". - Rebased. - Link to v3: https://lore.kernel.org/r/20240716-pmu-v3-0-8c7c1858a...@daynix.com Changes in v3: - Dropped patch "target/arm: Do not allow setting 'pmu' for hvf". - Dropped patch "target/arm: Allow setting 'pmu' only for host and max". - Dropped patch "target/arm/kvm: Report PMU unavailability". - Added patch "target/arm/kvm: Fix PMU feature bit early". - Added patch "hvf: arm: Do not advance PC when raising an exception". - Added patch "hvf: arm: Properly disable PMU". - Changed to check for Armv8 before adding PMU property. - Link to v2: https://lore.kernel.org/r/20240716-pmu-v2-0-f3e3e4b2d...@daynix.com Changes in v2: - Restricted writes to 'pmu' to host and max. - Prohibited writes to 'pmu' for hvf. - Link to v1: https://lore.kernel.org/r/20240629-pmu-v1-0-7269123b8...@daynix.com --- target/arm/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ca5ed7892e4e..c99d65e9bf05 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1716,6 +1716,7 @@ static void arm_cpu_propagate_feature_implications(ARMCPU *cpu) void arm_cpu_post_init(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); + ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj); /* * Some features imply others. Figure this out now, because we @@ -1767,6 +1768,9 @@ void arm_cpu_post_init(Object *obj) if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { cpu->has_pmu = true; + } + + if (cpu->has_pmu || !strcmp(acc->info->name, "host")) { object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } --- base-commit: f0737158b483e7ec2b2512145aeab888b85cc1f7 change-id: 20240629-pmu-ad5f67e2c5d0 Best regards, -- Akihiko Odaki <od...@rsg.ci.i.u-tokyo.ac.jp>