]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
powerpc/perf: Fix crashes with generic_compat_pmu & BHRB
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Tue, 2 Jun 2020 02:56:12 +0000 (12:56 +1000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 16 Sep 2020 09:15:01 +0000 (05:15 -0400)
commit9105859bd0536b3534c937b9ac8da0b128bc4efd
tree74cb3113d29f9ede580e9084cdcedb654923e253
parentd73dd63c354941092e2fdfa2d1de54fc05b5090c
powerpc/perf: Fix crashes with generic_compat_pmu & BHRB

BugLink: https://bugs.launchpad.net/bugs/1895174
commit b460b512417ae9c8b51a3bdcc09020cd6c60ff69 upstream.

The bhrb_filter_map ("The Branch History Rolling Buffer") callback is
only defined in raw CPUs' power_pmu structs. The "architected" CPUs
use generic_compat_pmu, which does not have this callback, and crashes
occur if a user tries to enable branch stack for an event.

This add a NULL pointer check for bhrb_filter_map() which behaves as
if the callback returned an error.

This does not add the same check for config_bhrb() as the only caller
checks for cpuhw->bhrb_users which remains zero if bhrb_filter_map==0.

Fixes: be80e758d0c2 ("powerpc/perf: Add generic compat mode pmu driver")
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200602025612.62707-1-aik@ozlabs.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/perf/core-book3s.c