From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1B7B39A7FD; Tue, 21 Jul 2026 18:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784659933; cv=none; b=D5dAFgCdN9ducDxcLyiU7Ggb4tH1L36hFULWAn+F4fEpaL92ngc8Lp3FzuvQNiaq+sg4PYZNHuUoigyNfFnHdimGoCDPVGHvap9XLpgXZSyKb11ttLLNzg3NHk6Kyrs5//pFos2r06nShwK+9NRsB0RCtXXcoLlsZ39ixfPvwRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784659933; c=relaxed/simple; bh=jBTSFo1V/Jn57vrWFMRM23QF3xNUd5yuZgz4LLKqu9k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K8lrd0BIoCD65fh5B+V/WsAWpvnMvCkgHiO/yqeAJfyN5BZwDVZcpXM6u0m+GT5mzCcPsDRv8Hh3NHOMbfkBGTKD0dYQoyAeFAlhBKA6uUVaU08oaXN1Eopk7HzEZCE55Uwp1H2L2OK5qvI2HFTB/3h0eziUe2hRBm8PvclDrvI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=j+MeztHJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="j+MeztHJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10C181F00A3E; Tue, 21 Jul 2026 18:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784659932; bh=DIuzOPXnPWnQZAaoLvgkN5jG9C27YR/D/6IQYJX8Ays=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j+MeztHJXTtESbNfTUdqneJdx+dRfnk4d1fClyLra8Rj/qMl4DlY8jKClltzgeQqd ZUQsU7e3FsmFwr/oQDsyiF3YkT6gd6sBnDgkGlXUBoc3pkkj/d4wgl1cmlBYFecIfH ebXA2AXuPJMaP07SfvITCTUBHkZhvwsGERJ7MIF8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shrikanth Hegde , Aboorva Devarajan , Madhavan Srinivasan , Sasha Levin Subject: [PATCH 7.1 0789/2077] powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del Date: Tue, 21 Jul 2026 17:07:42 +0200 Message-ID: <20260721152611.405619386@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152552.646164743@linuxfoundation.org> References: <20260721152552.646164743@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aboorva Devarajan [ Upstream commit 81e3a86030462824a67d697739cf3f387f4ba350 ] fsl_emb_pmu_del() unconditionally calls put_cpu_var(cpu_hw_events) at the 'out:' label, but only calls the matching get_cpu_var() after the 'i < 0' early-return check. When event->hw.idx is negative the function jumps to 'out:' without having taken get_cpu_var(), and the trailing put_cpu_var() then issues an unmatched preempt_enable(), underflowing preempt_count. On a CONFIG_PREEMPT=y kernel preempt_count would underflow and eventually present as a 'scheduling while atomic' BUG. Move put_cpu_var() to pair with get_cpu_var() so the percpu access is correctly bracketed and the 'out:' label only handles perf_pmu_enable. Fixes: a11106544f33 ("powerpc/perf: e500 support") Reviewed-by: Shrikanth Hegde Signed-off-by: Aboorva Devarajan Signed-off-by: Madhavan Srinivasan Link: https://patch.msgid.link/20260605082912.305100-2-aboorvad@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/perf/core-fsl-emb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/perf/core-fsl-emb.c b/arch/powerpc/perf/core-fsl-emb.c index 7120ab20cbfecb..02b5dd74c187a0 100644 --- a/arch/powerpc/perf/core-fsl-emb.c +++ b/arch/powerpc/perf/core-fsl-emb.c @@ -366,9 +366,10 @@ static void fsl_emb_pmu_del(struct perf_event *event, int flags) cpuhw->n_events--; + put_cpu_var(cpu_hw_events); + out: perf_pmu_enable(event->pmu); - put_cpu_var(cpu_hw_events); } static void fsl_emb_pmu_start(struct perf_event *event, int ef_flags) -- 2.53.0