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 B67F8395D99; Tue, 21 Jul 2026 20:36:46 +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=1784666208; cv=none; b=YAzc43Oaq4MA/xB+YsUrXnE3bbqxI/QMrwDBjivFFeqyOiVTbbDPKCIJUAGQIIMz76tZ5Fera37JRQqi/BAyk4cxeOQSdsMgXHrNKDdL2bkrPACh7rDawFxBbTrlV2gnWfdGUJ7vJos/thv/FYaaXl8eLSeo+HtsfRZ5Ec7t6i8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784666208; c=relaxed/simple; bh=gELKMaT/PBF+X8j9sbtx6DLE1DP6wOVIZ8Fn72ULuhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QdeDWhFZOfcAv621MvgOUsBSgCGBK250k+sRgJ/gN7Zq9T96oaOZPqA4gK/p7qxDQn/gNOec5h4VKlpNsWSE4FWOFupdYPUs1JsiHI89sa9dQEXui0ncWVgCqQwqUOB81togxI3Jvj5AOZcICfsgI0nk2FUzKBiUvAdsfeAEx4w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M6mKQ0My; 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="M6mKQ0My" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C2D31F00A3F; Tue, 21 Jul 2026 20:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784666206; bh=qQP4jpWuEa5RsnZlT+54eZU0XKmjNk6wrlDY3tCkhao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M6mKQ0MycM3sFxjZZdoYxvqmP+uuGrd17PUBEitgLtoIC0eIFP0I+ww3dUbaNezOl Kn8pYhIRO7E4l+QwXXcsx5u05z1yWM8WnIP31ugEjY6VnR7XzBltNRVh5ALR7qvy0t 0+C6lD+FQSf2bNr4hYd5B1hdfA1VW/nQuGF904z4= 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 6.6 0593/1266] powerpc/perf: fix preempt count underflow in fsl_emb_pmu_del Date: Tue, 21 Jul 2026 17:17:10 +0200 Message-ID: <20260721152455.134410550@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152441.786066624@linuxfoundation.org> References: <20260721152441.786066624@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 1a53ab08447cbe..31037df4178ca2 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