Message ID | 20240716-pmu-v2-2-f3e3e4b2d3d5@daynix.com |
---|---|
State | New |
Headers | show |
Series | target/arm/kvm: Report PMU unavailability | expand |
On Tue, 16 Jul 2024 at 09:28, Akihiko Odaki <akihiko.odaki@daynix.com> wrote: > > Setting 'pmu' does not make sense for CPU types emulating physical > CPUs. > > Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> > --- > target/arm/cpu.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index 14d4eca12740..8c180c679ce2 100644 > --- a/target/arm/cpu.c > +++ b/target/arm/cpu.c > @@ -1594,6 +1594,13 @@ static bool arm_get_pmu(Object *obj, Error **errp) > static void arm_set_pmu(Object *obj, bool value, Error **errp) > { > ARMCPU *cpu = ARM_CPU(obj); > + const char *typename = object_get_typename(obj); > + > + if (strcmp(typename, ARM_CPU_TYPE_NAME("host")) && > + strcmp(typename, ARM_CPU_TYPE_NAME("max"))) { > + error_setg(errp, "Setting 'pmu' is only supported by host and max"); > + return; > + } This doesn't seem right. In general where we provide a user-facing -cpu foo,bar=off option we allow the user to use it to disable the bar feature on named CPUs too. So you can use it to say "give me a neoverse-v1 without the PMU". thanks -- PMM
diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 14d4eca12740..8c180c679ce2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1594,6 +1594,13 @@ static bool arm_get_pmu(Object *obj, Error **errp) static void arm_set_pmu(Object *obj, bool value, Error **errp) { ARMCPU *cpu = ARM_CPU(obj); + const char *typename = object_get_typename(obj); + + if (strcmp(typename, ARM_CPU_TYPE_NAME("host")) && + strcmp(typename, ARM_CPU_TYPE_NAME("max"))) { + error_setg(errp, "Setting 'pmu' is only supported by host and max"); + return; + } if (value) { if (kvm_enabled() && !kvm_arm_pmu_supported()) {
Setting 'pmu' does not make sense for CPU types emulating physical CPUs. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> --- target/arm/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+)