From nobody Fri Jun 12 18:34:03 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 38A203D9DC0 for ; Wed, 13 May 2026 08:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660075; cv=none; b=spRich9SMtXquaGvTRXg+1h0c+gc32P7Mf0KQ/UrUHFdbtuyfoUlxEr5jYWmeShf5iZqz/Wo4FoDGPHNs8x0Ore4OQeaxQpYXvZntorCbb8M98VBBS0fOR7RM5Zpn9ZTAm8DRB7g2mgwA2eR5xE9GpywXd5zM9i4lKTpVJx4pUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660075; c=relaxed/simple; bh=eaoZHd9dIRnpGsh6kdn4bOatoQqkq9plpvjAhNC5lDk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rre9lvtiqHdbcu4cwghVmqd386yzAf8w5esyhoiiYbiqr5RvpogghZeuE2Qck+egSbJpgn+NsUBfVZ+NCCuJBmfcOc3b/IxEosqM98Z03aZGeUE3qJpHKCezVD++oJQ563zIA6ZDFmujH8rVUqPIK+fmTCV6X0Mt3sdEWkimzlY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=tAC5oq/N; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="tAC5oq/N" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64D2K3nv2611655; Wed, 13 May 2026 08:14:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=5Sa3ADqpLBhgK6Pz8oYquXRH4ULvlnTgyvk6V0MBO vA=; b=tAC5oq/NGkhHDa+1JgyKJR763dD97wfcFtVVH+ndiIjMqbpS5QZl0aZ7h 84KNWnq0xYfK0xVnN/X49ES/AiWIAtL2SHZBMvYsfmNtGpsAJGLR1K4xIEVTPBk+ vnSmdvSzS4w88jG437s1WnVRxLzU3xrW5laKwfdL4YmVAQIga1Z272ffRTEXzJD5 cEku10lLjFaQiw1kV0LeT6Y3Lav7iFYv7oLeurll07KBgmqiUpcj+QO0QczfgcjD iKBV0FLaNsjjq1hdepu+ZAJSMI/TaBQglEc2d+blElQPSeW+Jf1hvNwjDeFUhse3 ZQWfJOyf73OlP4EGcV+k6OSNgii4A== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nvdxrr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 08:14:23 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64D89MrY012526; Wed, 13 May 2026 08:14:22 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgxwfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 08:14:21 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64D8EIEZ57540952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 08:14:18 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D3692004E; Wed, 13 May 2026 08:14:18 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E42DD2004B; Wed, 13 May 2026 08:14:15 +0000 (GMT) Received: from li-3f69264c-2ce6-11b2-a85c-c3f414d24014.ibm.com.com (unknown [9.39.28.204]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 08:14:15 +0000 (GMT) From: Sayali Patil To: linuxppc-dev@lists.ozlabs.org, maddy@linux.ibm.com Cc: linux-kernel@vger.kernel.org, Ritesh Harjani , Mahesh Salgaonkar , sshegde@linux.ibm.com, chleroy@kernel.org Subject: [PATCH v2] powerpc/time: Remove redundant preempt_disable|enable() calls from arch_irq_work_raise() - part1 Date: Wed, 13 May 2026 13:44:13 +0530 Message-ID: <20260513081413.222490-1-sayalip@linux.ibm.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=Y/XIdBeN c=1 sm=1 tr=0 ts=6a0432df cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=pGLkceISAAAA:8 a=Q_qF-8Ot7ODvqRfjXTAA:9 X-Proofpoint-GUID: aURig4lEGn4YcoKFGKmUmGdbxv6g4VDc X-Proofpoint-ORIG-GUID: fWF2nkRwUBo--9j4nEBZrSExff7CEs3N X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDA4MiBTYWx0ZWRfX/AqQEB5w+HyM tBHfDw82+nvfmYh5zgxqQb40gdUNZBh6jZsZ1SI0iAd9PHflN4WeBaMXYatfXhdm0/61NWzbKHL vAGbbpYwVEZBFOtPaut/MRjQruqvrZ/DjBpPHpuyBTvxwDRfip7BMsZGUGxVT29LPcgGnE4GRkg Sn7uxgXkSBvwJqin3nEyCHz8+TMTXsUpcVKii24VktU26nxatkUbT6AHZvYuDl+nuatX0xT3yLK nZy+wWa4bktB645P2nH0j7HOO7S7hMpeWK7mNHnrZDOXNxrU3MIoVPntKxfdXv5XtDUQwUiM5Sr niHBCvoenfo38kawx1ohkgS7E/hWMshoB5wtQiR048W2weDItDadjRe5R2dYLzRmrxjYmxPBKSe V0CsFXoHcoKclx8UUygqMwY+CLGxFiA0YsEfBl58JxanHzU0mWMuhzLNrpDIfOgJ1O2fHiXiqW6 3P55XqYKf1AkbViNDUQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-11_05,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130082 Content-Type: text/plain; charset="utf-8" A kernel panic is observed when handling machine check exceptions from real mode. BUG: Unable to handle kernel data access on read at 0xc00000006be21300 Oops: Kernel access of bad area, sig: 11 [#1] MSR: 8000000000001003 CR: 88222248 XER: 00000005 CFAR: c00000000003ffc4 DAR: c00000006be21300 DSISR: 40000000 IRQMASK: 0 NIP [c000000000029e40] arch_irq_work_raise+0x10/0x70 LR [c00000000003ffc8] machine_check_queue_event+0xa8/0x150 Call Trace: [c0000000179d3c70] [c00000000003ff64] machine_check_queue_event+0x44/0x150 [c0000000179d3d30] [c0000000000084e0] machine_check_early_common+0x1f0/0x= 2c0 The crash occurs because arch_irq_work_raise() calls preempt_disable() from machine check exception (MCE) handlers running in real mode. In this context, accessing the preempt_count can fault, leading to the panic. The preempt_disable()/preempt_enable() pair in arch_irq_work_raise() was originally added by commit 0fe1ac48bef0 ("powerpc/perf_event: Fix oops due to perf_event_do_pending call") to avoid races while raising irq work from exception context. Later, commit 471ba0e686cb ("irq_work: Do not raise an IPI when queueing work on the local CPU") added preemption protection in irq_work_queue() path, while commit 20b876918c06 ("irq_work: Use per cpu atomics instead of regular atomics") added equivalent protection in irq_work_queue_on() before reaching arch_irq_work_raise(): irq_work_queue() / irq_work_queue_on() -> preempt_disable() -> __irq_work_queue_local() -> irq_work_raise() -> arch_irq_work_raise() As a result, callers other than mce_irq_work_raise() already execute with preemption disabled, making the additional preempt_disable()/preempt_enable() pair in arch_irq_work_raise() redundant. The arch_irq_work_raise() function executes in NMI context when called from MCE handler. Hence we will not be preempted or scheduled out since we are in NMI context with MSR[EE]=3D0. Therefore, it is safe to remove the preempt_disable()/preempt_enable() calls from here. Remove it to avoid accessing preempt_count from real mode context. Fixes: cc15ff327569 ("powerpc/mce: Avoid using irq_work_queue() in realmode= ") Suggested-by: Mahesh Salgaonkar Acked-by: Shrikanth Hegde Reviewed-by: Ritesh Harjani (IBM) Signed-off-by: Sayali Patil --- v1->v2 - Split the patch series into two parts; v2 part 2 of remaining two patches will be sent later due to changes required in=20 "lkdtm/powerpc: add PPC_RADIX_TLBIEL test for radix MCE validation". - Updated commit message as per review feedback. - Added comment for arch_irq_work_raise() to indicate it must be called with preemption disabled, as per review feedback. - Added Acked-By from Shrikanth and Reviewed-by tag from Ritesh. v1: https://lore.kernel.org/all/cover.1778057685.git.sayalip@linux.ibm.com/ --- arch/powerpc/kernel/time.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 4bbeb8644d3d..b4472288e0d4 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c @@ -458,6 +458,10 @@ DEFINE_PER_CPU(u8, irq_work_pending); =20 #endif /* 32 vs 64 bit */ =20 +/* + * Must be called with preemption disabled since it updates + * per-CPU irq_work state and programs the local CPU decrementer. + */ void arch_irq_work_raise(void) { /* @@ -471,10 +475,8 @@ void arch_irq_work_raise(void) * which could get tangled up if we're messing with the same state * here. */ - preempt_disable(); set_irq_work_pending_flag(); set_dec(1); - preempt_enable(); } =20 static void set_dec_or_work(u64 val) --=20 2.52.0