All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf/arm-ccn: Set up the DT base before requesting the IRQ
@ 2026-11-13  8:34 hu.shengming
  2026-11-13  8:44 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: hu.shengming @ 2026-11-13  8:34 UTC (permalink / raw)
  To: will, mark.rutland
  Cc: pawel.moll, arnd, linux-arm-kernel, linux-perf-users,
	linux-kernel, zhang.run, he.qifeng1

From: Qifeng He <he.qifeng1@zte.com.cn>

arm_ccn_probe() requests the CCN interrupt before arm_ccn_pmu_init()
has initialised ccn->dt.base.  The interrupt is level-triggered, so a
pending overflow (for example one left behind by a previous kernel
across kexec) is delivered as soon as devm_request_irq() unmasks it.
arm_ccn_pmu_overflow_handler() then dereferences the NULL dt->base:

  NULL pointer dereference at virtual address 0x198
  pc : arm_ccn_pmu_overflow_handler+0x20
  lr : arm_ccn_irq_handler+0x13c

Set up dt->base as soon as the CCN MN block is mapped, before the
interrupt can be requested.  The rest of the DT/PMU setup stays in
arm_ccn_pmu_init(); before the PMU is registered the handler only
needs dt->base and the zero-initialised pmu_counters array, so it is
safe to take the interrupt during that window.

Fixes: a33b0daab73a ("bus: ARM CCN PMU driver")
Cc: stable@vger.kernel.org
Signed-off-by: Qifeng He <he.qifeng1@zte.com.cn>
Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
---
 drivers/perf/arm-ccn.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/perf/arm-ccn.c b/drivers/perf/arm-ccn.c
index 0c69165e0041..3cbdda843b59 100644
--- a/drivers/perf/arm-ccn.c
+++ b/drivers/perf/arm-ccn.c
@@ -1213,8 +1213,10 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
 	char *name;
 	int err;

-	/* Initialize DT subsystem */
-	ccn->dt.base = ccn->base + CCN_REGION_SIZE;
+	/*
+	 * Initialize the DT subsystem; dt.base was set up in
+	 * arm_ccn_probe() before the IRQ was requested.
+	 */
 	spin_lock_init(&ccn->dt.config_lock);
 	writel(CCN_DT_PMOVSR_CLR__MASK, ccn->dt.base + CCN_DT_PMOVSR_CLR);
 	writel(CCN_DT_CTL__DT_EN, ccn->dt.base + CCN_DT_CTL);
@@ -1463,6 +1465,14 @@ static int arm_ccn_probe(struct platform_device *pdev)
 	if (IS_ERR(ccn->base))
 		return PTR_ERR(ccn->base);

+	/*
+	 * The CCN interrupt is level-triggered and may already be pending,
+	 * e.g. an overflow left by a previous kernel across kexec.  The
+	 * handler can run as soon as devm_request_irq() below installs it,
+	 * and it dereferences dt->base, so set it up before that.
+	 */
+	ccn->dt.base = ccn->base + CCN_REGION_SIZE;
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-13  8:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  8:34 [PATCH] perf/arm-ccn: Set up the DT base before requesting the IRQ hu.shengming
2026-11-13  8:44 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.