[PATCH v2 1/1] drivers/perf: Fix kernel panic due to the invalid mon_ctx pointer
Will Deacon
will at kernel.org
Fri Oct 27 03:27:07 PDT 2023
On Thu, Oct 26, 2023 at 06:34:43PM -0500, Shanker Donthineni wrote:
> The return pointer from the resctrl_arch_mon_ctx_alloc_no_wait() function
> is saved in a 32-bit variable 'hwc->idx' which results in the loss of
> the upper 32 bits. This, in turn, triggers a kernel panic when attempting
> to access a corrupted pointer.
>
> Use 'event->pmu_private' instead of 'hwc->idx' to resolve the issue.
>
> Another reason contributing to the problem due to continuous 'error irq'
> messages. The resctrl_arch_mon_ctx_alloc_no_wait() function returns a valid
> PTR when it cannot allocate monitor resources, resulting in an incorrect
> MON_SEL configuration. To resolve this issue, return an ERR_PTR when monitor
> allocation fails
>
> dmesg:
> mpam: error irq from msc:0 'Monitor_Range', partid:228, pmg: 0, ris: 0
> mpam: error irq from msc:0 'Monitor_Range', partid:228, pmg: 0, ris: 0
> mpam: error irq from msc:0 'Monitor_Range', partid:228, pmg: 0, ris: 0
> ...
> mpam: error irq from msc:0 'Monitor_Range', partid:228, pmg: 0, ris: 0
>
> Signed-off-by: Shanker Donthineni <sdonthineni at nvidia.com>
> ---
> Changes in v2:
> -Use 'event->pmu_private' instead of 'hwc->idx' to keep monitor context
> -Return ERR_PTR if unable to allocate resource in resctrl_arch_mon_ctx_alloc_no_wait()
>
> drivers/perf/resctrl_pmu.c | 12 ++++++------
> drivers/platform/mpam/mpam_resctrl.c | 23 ++++++++++++++++-------
I can't see these files upstream or in linux-next, so please don't cc me on
changes to them until they've landed. My inbox is bad enough as it is!
Thanks,
Will
More information about the linux-arm-kernel
mailing list