x86: events: Do not return bogus capabilities if PMU is broken
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 1 Jun 2022 09:45:17 +0000 (05:45 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Jun 2022 17:06:15 +0000 (13:06 -0400)
commit916e3a4f950eac92c28cc138c10d86514ffebf98
tree03b3058f7a16c36027dafb72fe86c69c027da3b6
parent92d80178a35b1ab04c4a8250a06399150dbf0b6a
x86: events: Do not return bogus capabilities if PMU is broken

If the PMU is broken due to firmware issues, check_hw_exists() will return
false but perf_get_x86_pmu_capability() will still return data from x86_pmu.
Likewise if some of the hotplug callbacks cannot be installed the contents
of x86_pmu will not be reverted.

Handle the failure in both cases by clearing x86_pmu if init_hw_perf_events()
or reverts to software events only.

Co-developed-by: Like Xu <likexu@tencent.com>
Signed-off-by: Like Xu <likexu@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/events/core.c